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



commit d6e21e403aa8151f59bece2f3e1e3c345fd02e5c
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 |  2 ++
 src/accountsMonitor.js        |  6 ++++--
 src/application.js            | 18 ++++++++++++++++--
 3 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/flatpak/org.gnome.Polari.json b/flatpak/org.gnome.Polari.json
index bc10c46..e5d5002 100644
--- a/flatpak/org.gnome.Polari.json
+++ b/flatpak/org.gnome.Polari.json
@@ -4,6 +4,7 @@
     "runtime-version": "master",
     "sdk": "org.gnome.Sdk",
     "command": "polari",
+    "x-run-args": ["--debug"],
     "tags": ["nightly"],
     "desktop-file-name-prefix": "(Nightly) ",
     "finish-args": [
@@ -15,6 +16,7 @@
         "--share=network",
         /* Our client name */
         "--own-name=org.freedesktop.Telepathy.Client.Polari",
+        "--own-name=org.freedesktop.Telepathy.Client.Polari.Debug",
         /* Telepathy */
         "--talk-name=org.freedesktop.Telepathy.AccountManager",
         "--talk-name=org.freedesktop.Telepathy.ChannelDispatcher",
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index a2fb92d..3058f8b 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -18,8 +18,10 @@ class AccountsMonitor {
         this._accountSettings = new Map();
 
         this._app = Gio.Application.get_default();
-        this._app.connect('prepare-shutdown',
-                          Lang.bind(this, this._onPrepareShutdown));
+
+        if (!this._app.isDebugInstance)
+            this._app.connect('prepare-shutdown',
+                              Lang.bind(this, this._onPrepareShutdown));
 
         this._accountManager = Tp.AccountManager.dup();
 
diff --git a/src/application.js b/src/application.js
index f509061..37dd2d7 100644
--- a/src/application.js
+++ b/src/application.js
@@ -46,17 +46,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;
@@ -453,6 +462,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');
@@ -717,8 +730,9 @@ var Application = GObject.registerClass({
         if (this._telepathyClient)
             return;
 
+        let suffix = this.isDebugInstance ? '.Debug' : '';
         let params = {
-            name: 'Polari',
+            name: 'Polari' + suffix,
             account_manager: this._accountsMonitor.accountManager,
             uniquify_name: false
         };


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