Merge lp:~victored/slingshot/app-launcher-dbus into lp:~elementary-pantheon/slingshot/trunk

Proposed by Victor Martinez
Status: Merged
Approved by: Tom Beckmann
Approved revision: 239
Merged at revision: 317
Proposed branch: lp:~victored/slingshot/app-launcher-dbus
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 116 lines (+78/-1)
3 files modified
CMakeLists.txt (+1/-0)
src/Backend/DBusService.vala (+72/-0)
src/Slingshot.vala (+5/-1)
To merge this branch: bzr merge lp:~victored/slingshot/app-launcher-dbus
Reviewer Review Type Date Requested Status
Sergey "Shnatsel" Davidoff (community) Approve
Review via email: mp+114771@code.launchpad.net

Description of the change

Implement org.pantheon.desktop.AppLauncherService DBus service.

Currently, the API only exports the app's current state via a signal. I've based the implementation on the GtkWidget::visible property, emitting a signal whenever it changes. Clients of this service can know the current state of Slingshot by connecting a handler to the visibility_changed() signal. Wingpanel is supposed to be one of those clients. See the related implementation at lp:~victored/wingpanel/app-launcher-dbus

To post a comment you must log in.
238. By Victor Martinez

Connect to "show" and "hide" signals instead of using notify for the "visible" property.

239. By Victor Martinez

Emit initial state as soon as the dbus service name registration succeeds

Revision history for this message
Victor Martinez (victored) wrote :

Hey guys, you've got a pending review here!

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

I like the approach.
Note that it makes it impossible to run several instances of Slingshot; make sure claiming d-bus name is wrapped in try-catch or something, that it doesn't crash if the name is already claimed.

review: Approve
Revision history for this message
Removed by request (removed2115751) wrote :

Built and installed with lp:~victored/wingpanel/app-launcher-dbus, works great so far.

Revision history for this message
Andrea Basso (voluntatefaber) wrote :

I'd like to release Slingshot beta1 tomorrow and I was thinking about merging this later, so that we don't get any unexpected bug. Do you all agree or think this should make it for beta1 despite the risk of new bugs?

Revision history for this message
Victor Martinez (victored) wrote :

That sounds good to me Andrea. I'm pretty sure I've not introduced any major issue though.

Revision history for this message
Andrea Basso (voluntatefaber) wrote :

Victor, I know you probably haven't, but for example, we merged Ricotz's gmenu-3 branch more than a month ago, IIRC, and it all seemed alright. Only yesterday we found out it introduced a severe regression, for this reason I'd like to wait. I'll merge it as soon as Slingshot gets released and I have a bit of spare time (probably from Friday).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2012-07-13 11:57:20 +0000
+++ CMakeLists.txt 2012-07-18 17:46:21 +0000
@@ -42,6 +42,7 @@
42 src/Settings.vala42 src/Settings.vala
43 src/Utils.vala43 src/Utils.vala
44 src/Backend/AppSystem.vala44 src/Backend/AppSystem.vala
45 src/Backend/DBusService.vala
45 src/Backend/App.vala46 src/Backend/App.vala
46 src/Backend/RelevancyService.vala47 src/Backend/RelevancyService.vala
47 src/Widgets/AppEntry.vala48 src/Widgets/AppEntry.vala
4849
=== added file 'src/Backend/DBusService.vala'
--- src/Backend/DBusService.vala 1970-01-01 00:00:00 +0000
+++ src/Backend/DBusService.vala 2012-07-18 17:46:21 +0000
@@ -0,0 +1,72 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2//
3// Copyright (C) 2012 Slingshot Developers
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19namespace Slingshot {
20
21 public class DBusService : Object {
22
23 [DBus (name = "org.pantheon.desktop.AppLauncherService")]
24 private class Service : Object {
25 public signal void visibility_changed (bool launcher_visible);
26 private Gtk.Widget? view = null;
27
28 public Service (Gtk.Widget view) {
29 this.view = view;
30 view.show.connect (on_view_visibility_change);
31 view.hide.connect (on_view_visibility_change);
32 }
33
34 internal void on_view_visibility_change () {
35 debug ("Visibility changed. Sending visible = %s over DBus", view.visible.to_string ());
36 this.visibility_changed (view.visible);
37 }
38 }
39
40 private Service? service = null;
41
42 public DBusService (SlingshotView view) {
43 // Own bus name
44 // try to register service name in session bus
45 Bus.own_name (BusType.SESSION,
46 "org.pantheon.desktop.AppLauncherService",
47 BusNameOwnerFlags.NONE,
48 (conn) => { on_bus_aquired (conn, view); },
49 name_acquired_handler,
50 () => { critical ("Could not aquire service name"); });
51
52 }
53
54 private void on_bus_aquired (DBusConnection connection, SlingshotView view) {
55 try {
56 // start service and register it as dbus object
57 service = new Service (view);
58 connection.register_object ("/org/pantheon/desktop/AppLauncherService", service);
59 } catch (IOError e) {
60 critical ("Could not register service: %s", e.message);
61 return_if_reached ();
62 }
63 }
64
65 private void name_acquired_handler (DBusConnection connection, string name) {
66 message ("Service registration suceeded");
67 return_if_fail (service != null);
68 // Emit initial state
69 service.on_view_visibility_change ();
70 }
71 }
72}
0\ No newline at end of file73\ No newline at end of file
174
=== modified file 'src/Slingshot.vala'
--- src/Slingshot.vala 2012-06-24 10:18:48 +0000
+++ src/Slingshot.vala 2012-07-18 17:46:21 +0000
@@ -30,6 +30,7 @@
30 public static Settings settings { get; private set; default = null; }30 public static Settings settings { get; private set; default = null; }
31 //public static CssProvider style_provider { get; private set; default = null; }31 //public static CssProvider style_provider { get; private set; default = null; }
32 public static IconTheme icon_theme { get; set; default = null; }32 public static IconTheme icon_theme { get; set; default = null; }
33 private DBusService? dbus_service = null;
3334
34 construct {35 construct {
3536
@@ -82,10 +83,13 @@
82 }83 }
8384
84 protected override void activate () {85 protected override void activate () {
85
86 if (get_windows () == null) {86 if (get_windows () == null) {
87 view = new SlingshotView ();87 view = new SlingshotView ();
88 view.set_application (this);88 view.set_application (this);
89
90 if (dbus_service == null)
91 dbus_service = new DBusService (view);
92
89 if (!silent) {93 if (!silent) {
90 //view.move_to_coords (0, 0);94 //view.move_to_coords (0, 0);
91 view.show_slingshot ();95 view.show_slingshot ();

Subscribers

People subscribed via source and target branches