[polari] application: don't open dialogs if already opened



commit 10d310f13248cb08ff70a8ef1d620dcd0a38153d
Author: Sebastien Lafargue <slaf66 gmail com>
Date:   Sun Nov 24 21:18:24 2013 +0100

    application: don't open dialogs if already opened
    
    When connection dialog or about dialog are open, we still can go to app
    menu and open them again. We don't want this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=715076

 src/application.js |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index bfeed82..ae418a2 100644
--- a/src/application.js
+++ b/src/application.js
@@ -386,18 +386,28 @@ const Application = new Lang.Class({
     },
 
     _onListConnections: function() {
-        let dialog = new Connections.ConnectionsDialog();
-        dialog.widget.show();
-        dialog.widget.connect('response',
-            function(widget) {
+        if (this._connectionsDialog) {
+            this._connectionsDialog.widget.present();
+            return;
+        }
+
+        this._connectionsDialog = new Connections.ConnectionsDialog();
+        this._connectionsDialog.widget.show();
+        this._connectionsDialog.widget.connect('response',
+            Lang.bind(this, function(widget) {
                 widget.destroy();
-            });
+                this._connectionsDialog = null;
+            }));
     },
 
     _onShowPreferences: function() {
     },
 
     _onShowAbout: function() {
+        if (this._aboutDialog) {
+            this._aboutDialog.present();
+            return;
+        }
         let aboutParams = {
             authors: [
                 'Florian M' + String.fromCharCode(0x00FC) // ΓΌ
@@ -419,11 +429,12 @@ const Application = new Lang.Class({
             modal: true
         };
 
-        let dialog = new Gtk.AboutDialog(aboutParams);
-        dialog.show();
-        dialog.connect('response', function() {
-            dialog.destroy();
-        });
+        this._aboutDialog = new Gtk.AboutDialog(aboutParams);
+        this._aboutDialog.show();
+        this._aboutDialog.connect('response', Lang.bind(this, function() {
+            this._aboutDialog.destroy();
+            this._aboutDialog = null;
+        }));
     },
 
     _onQuit: function() {


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