[polari/wip/fmuellner/bg-app: 3/6] app: Factor out 'start-client' action



commit 0fd5e5f51dd658a870616c83c0523652f7a014e2
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Aug 6 04:56:14 2016 +0200

    app: Factor out 'start-client' action
    
    The telepathy client is currently started if necessary when the
    application is activated. However as there are cases for running
    the client without activating the application (read: creating a
    window), it makes sense to split out the code. While for now a
    separate function would do just fine, we'll eventually want the
    functionality available even when Polari is not running, so add
    a corresponding action.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770749

 src/application.js |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index c6d19e2..9925d67 100644
--- a/src/application.js
+++ b/src/application.js
@@ -81,6 +81,8 @@ const Application = new Lang.Class({
             parameter_type: GLib.VariantType.new('o') },
           { name: 'discard-identify-password',
             parameter_type: GLib.VariantType.new('o') },
+          { name: 'start-client',
+            activate: Lang.bind(this, this._onStartClient) },
           { name: 'help',
             activate: Lang.bind(this, this._onShowHelp),
             accels: ['F1'] },
@@ -143,14 +145,7 @@ const Application = new Lang.Class({
     },
 
     vfunc_activate: function() {
-        if (!this._telepathyClient) {
-            let params = {
-                name: 'Polari',
-                account_manager: this._accountsMonitor.accountManager,
-                uniquify_name: false
-            };
-            this._telepathyClient = new TelepathyClient.TelepathyClient(params);
-        }
+        this.activate_action('start-client', null);
 
         if (!this.active_window) {
             let window = new MainWindow.MainWindow({ application: this });
@@ -470,6 +465,18 @@ const Application = new Lang.Class({
         dialog.show();
     },
 
+    _onStartClient: function() {
+        if (this._telepathyClient)
+            return;
+
+        let params = {
+            name: 'Polari',
+            account_manager: this._accountsMonitor.accountManager,
+            uniquify_name: false
+        };
+        this._telepathyClient = new TelepathyClient.TelepathyClient(params);
+    },
+
     _onShowHelp: function() {
         Utils.openURL('help:org.gnome.Polari', Gtk.get_current_event_time());
     },


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