[gnome-shell-extensions/wip/fmuellner/gtk4: 10/19] user-theme: Track GSettings to sync checkmark
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions/wip/fmuellner/gtk4: 10/19] user-theme: Track GSettings to sync checkmark
- Date: Thu, 14 Jan 2021 13:41:19 +0000 (UTC)
commit a246f2eb94902b91dfd41817d91fafde4f2ffd0a
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Apr 15 23:32:20 2020 +0200
user-theme: Track GSettings to sync checkmark
GTK4 removes the generic GtkWidget API for accessing an inserted
action group, so we need an alternative for tracking the currently
selected theme.
Using the underlying GSettings object looks like the easiest option,
so do that.
extensions/user-theme/prefs.js | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/extensions/user-theme/prefs.js b/extensions/user-theme/prefs.js
index 029483c..a92be0c 100644
--- a/extensions/user-theme/prefs.js
+++ b/extensions/user-theme/prefs.js
@@ -93,7 +93,7 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow {
}
_addTheme(name) {
- const row = new ThemeRow(name);
+ const row = new ThemeRow(name, this._settings);
this._rows.set(name, row);
this._list.add(row);
@@ -134,12 +134,13 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow {
const ThemeRow = GObject.registerClass(
class ThemeRow extends Gtk.ListBoxRow {
- _init(name) {
- this._name = new GLib.Variant('s', name);
+ _init(name, settings) {
+ this._name = name;
+ this._settings = settings;
super._init({
action_name: 'theme.name',
- action_target: this._name,
+ action_target: new GLib.Variant('s', name),
});
const box = new Gtk.Box({
@@ -167,20 +168,19 @@ class ThemeRow extends Gtk.ListBoxRow {
box.show_all();
- const id = this.connect('parent-set', () => {
- this.disconnect(id);
+ const id = this._settings.connect('changed::name',
+ this._syncCheckmark.bind(this));
+ this._syncCheckmark();
- const actionGroup = this.get_action_group('theme');
- actionGroup.connect('action-state-changed::name',
- this._syncCheckmark.bind(this));
- this._syncCheckmark();
+ this.connect('destroy', () => {
+ this._settings.disconnect(id);
+ this._settings = null;
});
}
_syncCheckmark() {
- const actionGroup = this.get_action_group('theme');
- const state = actionGroup.get_action_state('name');
- this._checkmark.opacity = this._name.equal(state);
+ const visible = this._name === this._settings.get_string('name');
+ this._checkmark.opacity = visible ? 1. : 0;
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]