Merge lp:~ken-vandine/gwibber/lp_923863 into lp:gwibber

Proposed by Ken VanDine
Status: Merged
Merged at revision: 1284
Proposed branch: lp:~ken-vandine/gwibber/lp_923863
Merge into: lp:gwibber
Diff against target: 38 lines (+28/-0)
1 file modified
client/gwibber-client.vala (+28/-0)
To merge this branch: bzr merge lp:~ken-vandine/gwibber/lp_923863
Reviewer Review Type Date Requested Status
David Klasinc (community) Approve
Review via email: mp+93481@code.launchpad.net

Description of the change

Shutdown the service when using Quit from the menu if the unity lens isn't running.

To post a comment you must log in.
Revision history for this message
David Klasinc (bigwhale) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/gwibber-client.vala'
2--- client/gwibber-client.vala 2012-02-16 06:06:00 +0000
3+++ client/gwibber-client.vala 2012-02-16 19:20:25 +0000
4@@ -327,6 +327,34 @@
5 private void on_quit ()
6 {
7 destroy ();
8+ var service = new Gwibber.Service();
9+
10+ /* Check if the unity lens is running and only shutdown the
11+ * service if it isn't
12+ */
13+ bool has_owner = false;
14+ try {
15+ string name = "com.canonical.Unity.Lens.Gwibber";
16+ DBusConnection bus = Bus.get_sync (BusType.SESSION);
17+ Variant result = bus.call_sync ("org.freedesktop.DBus",
18+ "/org/freedesktop/dbus",
19+ "org.freedesktop.DBus",
20+ "NameHasOwner",
21+ new Variant ("(s)", name),
22+ new VariantType ("(b)"),
23+ DBusCallFlags.NO_AUTO_START,
24+ -1);
25+ result.get ("(b)", out has_owner);
26+ } catch (Error e) {
27+ warning ("Unable to decide if '%s' is running: %s", name, e.message);
28+ }
29+
30+ if (!has_owner)
31+ {
32+ debug ("Lens isn't running");
33+ service.quit ();
34+ }
35+
36 }
37
38 bool on_configure_event (Gdk.EventConfigure event) {