[gnome-shell] dbusServices/extensions: Simplify actions handling



commit 089fd315dd067b009977e7a0a64e8611631d536c
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jul 30 00:58:18 2021 +0200

    dbusServices/extensions: Simplify actions handling
    
    GTK4 has dedicated API for widget-specific actions, make use of that
    instead of explicitly managing an action group.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2012>

 js/dbusServices/extensions/extensionPrefsDialog.js | 44 +++++++++-------------
 1 file changed, 18 insertions(+), 26 deletions(-)
---
diff --git a/js/dbusServices/extensions/extensionPrefsDialog.js 
b/js/dbusServices/extensions/extensionPrefsDialog.js
index 8fa6a533b2..cdcb852151 100644
--- a/js/dbusServices/extensions/extensionPrefsDialog.js
+++ b/js/dbusServices/extensions/extensionPrefsDialog.js
@@ -44,19 +44,32 @@ const ExtensionPrefsErrorPage = GObject.registerClass({
         'errorView',
     ],
 }, class ExtensionPrefsErrorPage extends Gtk.Widget {
+    static _classInit(klass) {
+        super._classInit(klass);
+
+        klass.install_action('page.copy-error',
+            null,
+            self => {
+                const clipboard = self.get_display().get_clipboard();
+                clipboard.set(self._errorMarkdown);
+            });
+        klass.install_action('page.show-url',
+            null,
+            self => Gtk.show_uri(self.get_root(), self._url, Gdk.CURRENT_TIME));
+
+        return klass;
+    }
+
     _init(extension, error) {
         super._init({
             layout_manager: new Gtk.BinLayout(),
         });
+        this._addCustomStylesheet();
 
         this._uuid = extension.uuid;
         this._url = extension.metadata.url || '';
 
-        this._actionGroup = new Gio.SimpleActionGroup();
-        this.insert_action_group('page', this._actionGroup);
-
-        this._initActions();
-        this._addCustomStylesheet();
+        this.action_set_enabled('page.show-url', this._url !== '');
 
         this._gesture = new Gtk.GestureClick({
             button: 0,
@@ -106,27 +119,6 @@ const ExtensionPrefsErrorPage = GObject.registerClass({
             this._expander.remove_css_class('expanded');
     }
 
-    _initActions() {
-        let action;
-
-        action = new Gio.SimpleAction({ name: 'copy-error' });
-        action.connect('activate', () => {
-            const clipboard = this.get_display().get_clipboard();
-            clipboard.set(this._errorMarkdown);
-        });
-        this._actionGroup.add_action(action);
-
-        action = new Gio.SimpleAction({
-            name: 'show-url',
-            enabled: this._url !== '',
-        });
-        action.connect('activate', () => {
-            Gio.AppInfo.launch_default_for_uri(this._url,
-                this.get_display().get_app_launch_context());
-        });
-        this._actionGroup.add_action(action);
-    }
-
     _addCustomStylesheet() {
         let provider = new Gtk.CssProvider();
         let uri = 'resource:///org/gnome/Shell/Extensions/css/application.css';


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