[gnome-shell-extensions] workspace-indicator: Bind name to action target



commit 57f7f21ecb621fadbc595f73d8b7aaed987ea722
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Feb 13 14:53:13 2022 +0100

    workspace-indicator: Bind name to action target
    
    Since we now have an override for bind_properties_full(), we can
    use that instead of an explicit notify handler.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/218>

 extensions/workspace-indicator/prefs.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js
index bf64fed..3cffbcf 100644
--- a/extensions/workspace-indicator/prefs.js
+++ b/extensions/workspace-indicator/prefs.js
@@ -112,12 +112,17 @@ class WorkspaceRow extends Adw.PreferencesRow {
 
         const button = new Gtk.Button({
             action_name: 'workspaces.remove',
-            action_target: new GLib.Variant('s', name),
             icon_name: 'edit-delete-symbolic',
             has_frame: false,
         });
         box.append(button);
 
+        this.bind_property_full('name',
+            button, 'action-target',
+            GObject.BindingFlags.SYNC_CREATE,
+            (bind, target) => [true, new GLib.Variant('s', target)],
+            null);
+
         this._entry = new Gtk.Entry({
             max_width_chars: 25,
         });
@@ -147,10 +152,8 @@ class WorkspaceRow extends Adw.PreferencesRow {
             this._stopEdit();
         });
 
-        this.connect('notify::name', () => {
-            button.action_target = new GLib.Variant('s', this.name);
-            this.activate_action('workspaces.update', null);
-        });
+        this.connect('notify::name',
+            () => this.activate_action('workspaces.update', null);
     }
 
     edit() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]