From: Kevin Wasserman Date: Sat, 4 May 2013 02:54:41 +0000 (-0400) Subject: Fix identity selector relaunch issue (LP# 1172751) X-Git-Tag: 0.7.1~84 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=moonshot-ui.git;a=commitdiff_plain;h=5496446012d9ebeb04e894067e5708d7ea4c2881 Fix identity selector relaunch issue (LP# 1172751) When identity selector is already running, but hidden a subsequent attempt to start an identity selector process now sends a dbus message to the original process telling it to show the ui. The new process then exits with an appropriate message. --- diff --git a/src/moonshot-identity-manager-app.vala b/src/moonshot-identity-manager-app.vala index 7b4389d..2897e0d 100644 --- a/src/moonshot-identity-manager-app.vala +++ b/src/moonshot-identity-manager-app.vala @@ -1,12 +1,16 @@ using Gee; using Gtk; +[DBus (name = "org.janet.Moonshot")] +interface IIdentityManager : GLib.Object { + public abstract bool show_ui() throws IOError; +} public class IdentityManagerApp { public IdentityManagerModel model; public IdCard default_id_card; public bool explicitly_launched; - private IdentityManagerView view; + public IdentityManagerView view; private MoonshotServer ipc_server; #if OS_MACOS @@ -252,7 +256,18 @@ public class IdentityManagerApp { bus_acquired_cb, (conn, name) => {}, (conn, name) => { - error ("Couldn't own name %s on DBus.", name); + bool shown=false; + try { + IIdentityManager manager = Bus.get_proxy_sync (BusType.SESSION, name, "/org/janet/moonshot"); + shown = manager.show_ui(); + } catch (IOError e) { + } + if (!shown) { + GLib.error ("Couldn't own name %s on dbus or show previously launched identity manager.", name); + } else { + stdout.printf("Showed previously launched identity manager.\n"); + GLib.Process.exit(0); + } }); } #endif diff --git a/src/moonshot-server.vala b/src/moonshot-server.vala index 539dbc3..2bff71d 100644 --- a/src/moonshot-server.vala +++ b/src/moonshot-server.vala @@ -10,6 +10,16 @@ public class MoonshotServer : Object { this.parent_app = app; } + public bool show_ui() + { + if (parent_app.view == null) { + return false; + } + parent_app.show(); + parent_app.explicitly_launched = true; + return true; + } + public async bool get_identity (string nai, string password, string service,