Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add indicator for recent icon IDs in prefs dialog #312

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default class DashToDockExtension extends Extension.Extension {
enable() {
this._isEnabled = true;
SettingsManager.initialize(this);
const settings = SettingsManager.getDefault().gsettings;
settings.reset('recent-icons'); // clear in preparation of new collection
Util.tryCleanupOldIndicators();
this._maybeEnableAfterNameAvailable();
TrayIconsManager.TrayIconsManager.initialize();
Expand Down
12 changes: 12 additions & 0 deletions indicatorStatusIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import Clutter from 'gi://Clutter';
import GLib from 'gi://GLib';
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';
import St from 'gi://St';
Expand Down Expand Up @@ -323,13 +324,24 @@ class IndicatorStatusIcon 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();
}

_updateClickCount(event) {
Expand Down
34 changes: 33 additions & 1 deletion prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AppIndicatorPreferences extends Gtk.Box {
margin_bottom: 30,
});
this.custom_icons_vbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
orientation: Gtk.Orientation.VERTICAL,
spacing: 10,
margin_start: 10,
margin_end: 10,
Expand Down Expand Up @@ -267,7 +267,39 @@ class AppIndicatorPreferences extends Gtk.Box {
customTreeView.insert_column(customAttentionIconColumn, 2);
customTreeView.set_grid_lines(Gtk.TreeViewGridLines.BOTH);

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);

this.custom_icons_vbox.append(customTreeView);
this.custom_icons_vbox.append(iconIDTreeView);

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 @@ -45,5 +45,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>