[gnome-shell] extensionPrefs: Skip main window when launched with a UUID



commit 5b3fb024be7298e803447cbd7de8bc0401830c19
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue May 27 01:36:41 2014 +0200

    extensionPrefs: Skip main window when launched with a UUID
    
    The extension-prefs tool is used by gnome-tweak-tool and the
    extensions web site to display preferences. However as those
    already implement their own extension lists, the main window
    is not useful in that context (to not say it is rather silly).
    
    Just skip the main window and only show the specified extension's
    preference dialog in those cases.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730829

 js/extensionPrefs/main.js |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js
index 3c86498..e77ac66 100644
--- a/js/extensionPrefs/main.js
+++ b/js/extensionPrefs/main.js
@@ -52,6 +52,8 @@ const Application = new Lang.Class({
         this._extensionPrefsModules = {};
 
         this._startupUuid = null;
+        this._loaded = false;
+        this._skipMainWindow = false;
     },
 
     _extensionAvailable: function(uuid) {
@@ -100,8 +102,18 @@ const Application = new Lang.Class({
 
         let dialog = new Gtk.Dialog({ use_header_bar: true,
                                       modal: true,
-                                      title: extension.metadata.name,
-                                      transient_for: this._window });
+                                      title: extension.metadata.name });
+
+        if (this._skipMainWindow) {
+            this.application.add_window(dialog);
+            if (this._window)
+                this._window.destroy();
+            this._window = dialog;
+            this._window.window_position = Gtk.WindowPosition.CENTER;
+        } else {
+            dialog.transient_for = this._window;
+        }
+
         dialog.set_default_size(600, 400);
         dialog.get_content_area().add(widget);
         dialog.show();
@@ -220,6 +232,8 @@ const Application = new Lang.Class({
         if (this._startupUuid && this._extensionAvailable(this._startupUuid))
             this._selectExtension(this._startupUuid);
         this._startupUuid = null;
+        this._skipMainWindow = false;
+        this._loaded = true;
     },
 
     _onActivate: function() {
@@ -235,16 +249,21 @@ const Application = new Lang.Class({
     _onCommandLine: function(app, commandLine) {
         app.activate();
         let args = commandLine.get_arguments();
+
         if (args.length) {
             let uuid = args[0];
 
+            this._skipMainWindow = true;
+
             // Strip off "extension:///" prefix which fakes a URI, if it exists
             uuid = stripPrefix(uuid, "extension:///");
 
             if (this._extensionAvailable(uuid))
                 this._selectExtension(uuid);
-            else
+            else if (!this._loaded)
                 this._startupUuid = uuid;
+            else
+                this._skipMainWindow = false;
         }
         return 0;
     }


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