[polari/wip/fmuellner/debug-instance: 1/3] app: Add --debug command line flag



commit 1ee76b1172e4c6a076e7823db44ade2be3c2fd7b
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 19 12:45:26 2016 +0100

    app: Add --debug command line flag
    
    It runs polari with a different application ID and doesn't disconnect
    when closed, so it allows hacking on polari while using it for chatting
    at the same time :-)
    
    Fixes https://gitlab.gnome.org/GNOME/polari/issues/24

 flatpak/org.gnome.Polari.json |  1 +
 src/accountsMonitor.js        |  6 ++++--
 src/application.js            | 17 +++++++++++++++--
 3 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/flatpak/org.gnome.Polari.json b/flatpak/org.gnome.Polari.json
index bc10c46..a045da7 100644
--- a/flatpak/org.gnome.Polari.json
+++ b/flatpak/org.gnome.Polari.json
@@ -15,6 +15,7 @@
         "--share=network",
         /* Our client name */
         "--own-name=org.freedesktop.Telepathy.Client.Polari",
+        "--own-name=org.freedesktop.Telepathy.Client.Polari.*",
         /* Telepathy */
         "--talk-name=org.freedesktop.Telepathy.AccountManager",
         "--talk-name=org.freedesktop.Telepathy.ChannelDispatcher",
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index 1ae5900..3b0c67d 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -14,8 +14,10 @@ var AccountsMonitor = class {
         this._accountSettings = new Map();
 
         this._app = Gio.Application.get_default();
-        this._app.connect('prepare-shutdown',
-                          this._onPrepareShutdown.bind(this));
+
+        if (!this._app.isDebugInstance)
+            this._app.connect('prepare-shutdown',
+                              this._onPrepareShutdown.bind(this));
 
         this._accountManager = Tp.AccountManager.dup();
 
diff --git a/src/application.js b/src/application.js
index 66aa6c0..aa1b344 100644
--- a/src/application.js
+++ b/src/application.js
@@ -45,17 +45,26 @@ var Application = GObject.registerClass({
         this.add_main_option('start-client', 0,
                              GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
                              _("Start Telepathy client"), null);
+        this.add_main_option('debug', 0,
+                             GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
+                             _("Run in debug mode"), null);
         this.add_main_option('version', 0,
                              GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
                              _("Print version and exit"), null);
         this.connect('handle-local-options', (o, dict) => {
+            let v = dict.lookup_value('debug', null);
+            if (v && v.get_boolean()) {
+                this.set_flags(this.flags | Gio.ApplicationFlags.NON_UNIQUE);
+
+            }
+
             try {
                 this.register(null);
             } catch(e) {
                 return 1;
             }
 
-            let v = dict.lookup_value('start-client', null);
+            v = dict.lookup_value('start-client', null);
             if (v && v.get_boolean()) {
                 this.activate_action('start-client', null);
                 return 0;
@@ -457,6 +466,10 @@ var Application = GObject.registerClass({
         return savedRooms.n_children() == 0;
     }
 
+    get isDebugInstance() {
+        return this.flags & Gio.ApplicationFlags.NON_UNIQUE;
+    }
+
     _updateUserListAction() {
         let room = this.active_window.active_room;
         let action = this.lookup_action('user-list');
@@ -724,7 +737,7 @@ var Application = GObject.registerClass({
         let params = {
             name: 'Polari',
             account_manager: this._accountsMonitor.accountManager,
-            uniquify_name: false
+            uniquify_name: this.isDebugInstance
         };
         this._telepathyClient = new TelepathyClient(params);
     }


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