[polari] app: Do not create window on startup



commit 375298844b477e3ad51016108fd711f8a0b40847
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Sep 9 22:12:30 2014 +0200

    app: Do not create window on startup
    
    While not clearly documented, applications are not expected to
    open windows in startup(); moving window creation to activate()
    will also prepare us for starting window-less (e.g. for a shell
    search provider) ...

 src/application.js |   34 +++++++++++-----------------------
 src/mainWindow.js  |   14 ++++++++++++++
 2 files changed, 25 insertions(+), 23 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 5681a76..b9643ce 100644
--- a/src/application.js
+++ b/src/application.js
@@ -149,32 +149,20 @@ const Application = new Lang.Class({
 
         for (let i = 1; i < 10; i++)
             this.set_accels_for_action('app.nth-room(%d)'.format(i), ['<Alt>' + i]);
-
-        this._window = new MainWindow.MainWindow(this);
-        this._window.window.connect('destroy', Lang.bind(this,
-            function() {
-                for (let id in this._pendingRequests)
-                    this._pendingRequests[id].cancellable.cancel();
-                this.emitJS('prepare-shutdown');
-            }));
-
-        let provider = new Gtk.CssProvider();
-        let uri = 'resource:///org/gnome/Polari/application.css';
-        let file = Gio.File.new_for_uri(uri);
-        try {
-            provider.load_from_file(Gio.File.new_for_uri(uri));
-        } catch(e) {
-            logError(e, "Failed to add application style");
-        }
-        Gtk.StyleContext.add_provider_for_screen(this._window.window.get_screen(),
-                                                 provider, 600);
-
-        this._window.window.show_all();
     },
 
     vfunc_activate: function() {
-        if (this._window)
-            this._window.window.present();
+        if (!this._window) {
+            this._window = new MainWindow.MainWindow(this);
+            this._window.window.connect('destroy', Lang.bind(this,
+                function() {
+                    for (let id in this._pendingRequests)
+                        this._pendingRequests[id].cancellable.cancel();
+                    this.emitJS('prepare-shutdown');
+            }));
+            this._window.window.show_all();
+        }
+        this._window.window.present();
     },
 
     _updateAccountAction: function(action) {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 699ef8d..90b0627 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -37,6 +37,20 @@ const MainWindow = new Lang.Class({
 
         this._createWidget(app);
 
+        let provider = new Gtk.CssProvider();
+        let uri = 'resource:///org/gnome/Polari/application.css';
+        let file = Gio.File.new_for_uri(uri);
+        try {
+            provider.load_from_file(Gio.File.new_for_uri(uri));
+        } catch(e) {
+            logError(e, "Failed to add application style");
+        }
+        Gtk.StyleContext.add_provider_for_screen(
+            this.window.get_screen(),
+            provider,
+            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
+        );
+
         this._accountsMonitor = AccountsMonitor.getDefault();
         this._accountsMonitor.connect('account-status-changed',
                                       Lang.bind(this, this._onAccountChanged));


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