Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const Extension = imports.misc.extensionUtils.getCurrentExtension();
const StatusNotifierWatcher = Extension.imports.statusNotifierWatcher;
const TrayIconsManager = Extension.imports.trayIconsManager;
const Util = Extension.imports.util;
const SettingsManager = Extension.imports.settingsManager;

let statusNotifierWatcher = null;
let isEnabled = false;
Expand All @@ -42,6 +43,8 @@ function init() {
watchDog.destroy();
};
/* eslint-enable no-undef */
const settings = SettingsManager.getDefaultGSettings();
settings.reset('recent-icons'); // clear in preparation of new collection
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said in inline comment, I'd prefer to have another way to handle this.

One method would be using a GAction for example...

}

// FIXME: when entering/leaving the lock screen, the extension might be enabled/disabled rapidly.
Expand Down
12 changes: 12 additions & 0 deletions indicatorStatusIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/* exported IndicatorStatusIcon, IndicatorStatusTrayIcon */

const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const St = imports.gi.St;

Expand Down Expand Up @@ -235,13 +236,24 @@ class AppIndicatorsIndicatorStatusIcon extends BaseStatusIcon {
}
}

_addToRecentIcons() {
const settings = SettingsManager.getDefaultGSettings();
const iconIDs = settings.get_value('recent-icons').deep_unpack();

if (this._indicator.id && !iconIDs.includes(this._indicator.id)) {
iconIDs.push(this._indicator.id);
settings.set_value('recent-icons', new GLib.Variant('as', iconIDs));
}
}

_showIfReady() {
if (!this.isReady())
return;

this._updateLabel();
this._updateStatus();
this._updateMenu();
this._addToRecentIcons();

super._showIfReady();
}
Expand Down
40 changes: 37 additions & 3 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AppIndicatorPreferences extends Gtk.Box {
margin_end: 30,
margin_top: 30,
margin_bottom: 30 });
this.custom_icons_vbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL,
this.custom_icons_vbox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL,
spacing: 10,
margin_start: 10,
margin_end: 10,
Expand Down Expand Up @@ -286,10 +286,44 @@ class AppIndicatorPreferences extends Gtk.Box {
customTreeView.insert_column(customAttentionIconColumn, 2);
customTreeView.set_grid_lines(Gtk.TreeViewGridLines.BOTH);

if (imports.gi.versions.Gtk === '4.0')
const iconIDListStore = new Gtk.ListStore();
iconIDListStore.set_column_types([
GObject.TYPE_STRING,
]);
const iconIDListTrack = [];
const iconIDTreeView = new Gtk.TreeView({
model: iconIDListStore,
});
const iconIDTreeViewColumn = new Gtk.TreeViewColumn({
title: 'Recent Indicator IDs',
});

const updateRecentIcons = () => {
const iconIDs = this._settings.get_value('recent-icons').deep_unpack();
iconIDs.forEach(v => {
if (!iconIDListTrack.includes(v)) {
iconIDListStore.set(iconIDListStore.append(), [0], [v]);
iconIDListTrack.push(v);
}
});
};

this._settings.connect('changed::recent-icons', updateRecentIcons);
updateRecentIcons();

const standardCellRenderer = new Gtk.CellRendererText();
iconIDTreeViewColumn.pack_start(standardCellRenderer, true);
iconIDTreeViewColumn.add_attribute(standardCellRenderer, 'text', 0);
iconIDTreeView.insert_column(iconIDTreeViewColumn, 0);
iconIDTreeView.set_grid_lines(Gtk.TreeViewGridLines.BOTH);

if (imports.gi.versions.Gtk === '4.0') {
this.custom_icons_vbox.append(customTreeView);
else
this.custom_icons_vbox.append(iconIDTreeView);
} else {
this.custom_icons_vbox.pack_start(customTreeView, false, false, 0);
this.custom_icons_vbox.pack_start(iconIDTreeView, true, true, 0);
}

cellrenderer.connect('edited', (w, path, text) => {
this.selection = customTreeView.get_selection();
Expand Down
5 changes: 5 additions & 0 deletions schemas/org.gnome.shell.extensions.appindicator.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,10 @@
<summary>Custom icons</summary>
<description>Replace any icons with custom icons from themes</description>
</key>
<key name="recent-icons" type="as">
<default>[]</default>
<summary>Recent icon IDs</summary>
<description>List of recently encountered icon ids</description>
</key>
</schema>
</schemalist>