-
Notifications
You must be signed in to change notification settings - Fork 165
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
base: master
Are you sure you want to change the base?
Conversation
999a794
to
3983063
Compare
Ok, looks intresting. I'll see if I can define another way to get such icons though, without bothering gsettings |
Hi Finii Good idea! I tested it on my computer, but it doesn't update the list by itself. Do I have to restart Gnome when a new tray appears? best regards |
Well, you need to restart Gnome after you updated the extension (like |
I don't think there is any other (trivial) way, as the preferences cannot easily interfere with the shell or any running extension, even itself -- or at least I did not find how it could. Another option would be writing to a temporary file, but then gsettings really is cleaner, I guess? By the way, this is a great addition -- I had a very hard time finding ids for appindicators some weeks ago, it easily took me more than and hour... I guess I'm not very good at it :) I will try to update this by allowing the preferences to update automatically when a new icon is added, without needed to close the preferences. |
Here is a patch, which:
diff --git a/indicatorStatusIcon.js b/indicatorStatusIcon.js
index 9eee93a..a245f0f 100644
--- a/indicatorStatusIcon.js
+++ b/indicatorStatusIcon.js
@@ -183,13 +183,6 @@ class AppIndicatorsIndicatorStatusIcon extends BaseStatusIcon {
}
});
- 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));
- }
-
this._showIfReady();
}
@@ -243,6 +236,16 @@ 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;
@@ -250,6 +253,7 @@ class AppIndicatorsIndicatorStatusIcon extends BaseStatusIcon {
this._updateLabel();
this._updateStatus();
this._updateMenu();
+ this._addToRecentIcons();
super._showIfReady();
}
diff --git a/prefs.js b/prefs.js
index 80a94c3..919de10 100644
--- a/prefs.js
+++ b/prefs.js
@@ -290,16 +290,27 @@ class AppIndicatorPreferences extends Gtk.Box {
iconIDListStore.set_column_types([
GObject.TYPE_STRING,
]);
- const iconIDs = this._settings.get_value('recent-icons').deep_unpack();
- iconIDs.forEach(v => {
- iconIDListStore.set(iconIDListStore.append(), [0], [v]);
- });
+ const iconIDListTrack = [];
const iconIDTreeView = new Gtk.TreeView({
- model: iconIDListStore,
+ model: iconIDListStore
});
const iconIDTreeViewColumn = new Gtk.TreeViewColumn({
title: 'Recent Indicator IDs',
});
+
+ const update_recent_icons = _ => {
+ 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', update_recent_icons);
+ update_recent_icons();
+
const standardCellRenderer = new Gtk.CellRendererText();
iconIDTreeViewColumn.pack_start(standardCellRenderer, true);
iconIDTreeViewColumn.add_attribute(standardCellRenderer, 'text', 0); I can make this a proper PR if you want, however this might just add noise for nothing. |
You can add to my PR if you like - collaborator thing sent. In this way there will not be multiple PRs doing the same thing. And then one can keep the PR rebased on master and wait ;-) 3v1n0 is rather busy with more important repos I believe ;) |
Ok thanks, I will commit it to your repo then! I don't have much time to rebase it right now, but I guess this PR will wait here anyway so there is no hurry :) |
Sorry, I somehow pushed to the wrong branch, this is ok now |
[why] When someone wants to exchange an icon with a custom one the icon name is needed. That can be nontrivial to find it out. [how] Just collect all icon names that we encountered since the extension has been started and list these names below the icon replacement table in the settings dialog. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Rebase on master; force push. Works beautifully on my machine! Thank you 👍 |
Ah there is some eslint stuff, will fix that. Force push again imminent. |
2f33912
to
0df9f2d
Compare
- update the list when an indicator is added while preferences are open - fixes a bug where the icons are not added any more once the extension is started (the reason why `_addToRecentIcons` is called in `_showIfReady`)
@aunetx Had to remove your |
@Finii sorry if that caused some problem, tell me if you need anything else :) |
extension.js
Outdated
@@ -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 |
There was a problem hiding this comment.
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...
Is there any hope for this pull request to merge? |
Considering the ongoing problems with the dreaded three dots, I think it'd be a good idea to take a look at adding this again. |
I tried to merge the master branch, it works for me on GNOME 46 now, however while trying to merge it I think I changed the branch of this PR... @Finii sorry for this, honestly I am quite bad with git, tell me if I need to change something! |
@aunetx I guess I do not know what I should do. The two commits you added are ... what? ;-D |
Ah probably instead of merging the master INTO this branch (d6ca83e) you should have done a rebase of this branch ON master. I usually prefer that because then only the needed-for-this-feature changes are in the PR and nothing already in master. Otoh rebasing can be a lot of work. But the result of a merge is often incomprehensible. |
Ho sorry for this :/ at least I did not touch to your Tell me if I can help if I messed up somewhere irremediably |
Hello, this seems not to work with last versions, has I done something wrong? This seems weird as it worked some weeks ago... |
Back story:
Mattermost icon 2nd from left with
Transparent Shell
Top Bar to make it visible[why]
When someone wants to exchange an icon with a custom one the icon name
is needed. That can be nontrivial to find it out.
[how]
Just collect all icon names that we encountered since the extension has
been started and list these names below the icon replacement table in
the settings dialog.
This is how it looks on my machine:
Implementation details:
Sometimes they are purged for other reasons :-(Maybe it can be solved in a better way, this was just a Friday morning project. But I guess this improves the usability of the new custom icon functionality for ordinary users quite a bit.
I will try to improve on the spurious purges of the list.Fixed with force push.