mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 16:31:58 +02:00
prefs: Show icon in plugins with modified feature ranks
This commit is contained in:
42
src/prefs.js
42
src/prefs.js
@@ -292,11 +292,16 @@ class ClapperPrefsPluginFeature extends Adw.ActionRow
|
|||||||
_onSwitchActivate(enableSwitch)
|
_onSwitchActivate(enableSwitch)
|
||||||
{
|
{
|
||||||
const { settingsData } = this.get_ancestor(PrefsPluginRankingSubpage);
|
const { settingsData } = this.get_ancestor(PrefsPluginRankingSubpage);
|
||||||
|
const pluginExp = this.get_ancestor(PrefsPluginExpander);
|
||||||
|
|
||||||
if(enableSwitch.active)
|
if(enableSwitch.active) {
|
||||||
settingsData[this.title] = this.currentRank;
|
settingsData[this.title] = this.currentRank;
|
||||||
else if(settingsData[this.title] != null)
|
pluginExp.modCount++;
|
||||||
|
}
|
||||||
|
else if(settingsData[this.title] != null) {
|
||||||
delete settingsData[this.title];
|
delete settingsData[this.title];
|
||||||
|
pluginExp.modCount--;
|
||||||
|
}
|
||||||
|
|
||||||
this._updateRanking(settingsData);
|
this._updateRanking(settingsData);
|
||||||
}
|
}
|
||||||
@@ -393,18 +398,32 @@ let PrefsPluginExpander = GObject.registerClass({
|
|||||||
},
|
},
|
||||||
class ClapperPrefsPluginExpander extends Adw.ExpanderRow
|
class ClapperPrefsPluginExpander extends Adw.ExpanderRow
|
||||||
{
|
{
|
||||||
_init(plugin)
|
_init(plugin, modCount)
|
||||||
{
|
{
|
||||||
super._init({
|
super._init({
|
||||||
title: plugin,
|
title: plugin,
|
||||||
show_enable_switch: false,
|
show_enable_switch: false,
|
||||||
});
|
});
|
||||||
|
this.modCount = modCount;
|
||||||
|
|
||||||
this.expandSignal = this.connect(
|
this.expandSignal = this.connect(
|
||||||
'notify::expanded', this._onExpandedNotify.bind(this)
|
'notify::expanded', this._onExpandedNotify.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set modCount(value)
|
||||||
|
{
|
||||||
|
this._modCount = value;
|
||||||
|
this.icon_name = (value > 0) ? 'dialog-information-symbolic' : null;
|
||||||
|
|
||||||
|
debug(`Plugin ${this.title} has ${value} modified features`);
|
||||||
|
}
|
||||||
|
|
||||||
|
get modCount()
|
||||||
|
{
|
||||||
|
return this._modCount;
|
||||||
|
}
|
||||||
|
|
||||||
_onExpandedNotify()
|
_onExpandedNotify()
|
||||||
{
|
{
|
||||||
if(!this.expanded)
|
if(!this.expanded)
|
||||||
@@ -444,6 +463,7 @@ class ClapperPrefsPluginRankingSubpage extends Gtk.Box
|
|||||||
const decoders = gstRegistry.feature_filter(this._decodersFilterCb, false);
|
const decoders = gstRegistry.feature_filter(this._decodersFilterCb, false);
|
||||||
|
|
||||||
const plugins = {};
|
const plugins = {};
|
||||||
|
const mods = {};
|
||||||
this.settingsData = {};
|
this.settingsData = {};
|
||||||
|
|
||||||
/* In case someone messed up gsettings values */
|
/* In case someone messed up gsettings values */
|
||||||
@@ -470,12 +490,20 @@ class ClapperPrefsPluginRankingSubpage extends Gtk.Box
|
|||||||
plugins[pluginName] = [];
|
plugins[pluginName] = [];
|
||||||
|
|
||||||
const decName = decoder.get_name();
|
const decName = decoder.get_name();
|
||||||
|
const isModified = (this.settingsData[decName] != null);
|
||||||
|
|
||||||
plugins[pluginName].push({
|
plugins[pluginName].push({
|
||||||
name: decName,
|
name: decName,
|
||||||
rank: decoder.get_rank(),
|
rank: decoder.get_rank(),
|
||||||
enabled: this.settingsData[decName] != null,
|
enabled: isModified,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(isModified) {
|
||||||
|
if(!mods[pluginName])
|
||||||
|
mods[pluginName] = 0;
|
||||||
|
|
||||||
|
mods[pluginName]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pluginsNames = Object.keys(plugins);
|
const pluginsNames = Object.keys(plugins);
|
||||||
@@ -485,8 +513,10 @@ class ClapperPrefsPluginRankingSubpage extends Gtk.Box
|
|||||||
(res[key] = plugins[key], res), {}
|
(res[key] = plugins[key], res), {}
|
||||||
);
|
);
|
||||||
|
|
||||||
for(let plugin in this.pluginsData)
|
for(let plugin in this.pluginsData) {
|
||||||
this._decoders_group.add(new PrefsPluginExpander(plugin));
|
const modCount = mods[plugin] || 0;
|
||||||
|
this._decoders_group.add(new PrefsPluginExpander(plugin, modCount));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_decodersFilterCb(feature)
|
_decodersFilterCb(feature)
|
||||||
|
Reference in New Issue
Block a user