Merge lp:~roryj/slingshot/add_to_plank into lp:~elementary-pantheon/slingshot/trunk

Proposed by Rory
Status: Merged
Approved by: Cody Garver
Approved revision: 518
Merged at revision: 524
Proposed branch: lp:~roryj/slingshot/add_to_plank
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 107 lines (+60/-2)
2 files modified
CMakeLists.txt (+10/-2)
src/Widgets/AppEntry.vala (+50/-0)
To merge this branch: bzr merge lp:~roryj/slingshot/add_to_plank
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+249857@code.launchpad.net

Commit message

appentry: Add 'Add to/Remove from Dock' menuitem using Plank DBusManager

Description of the change

Add 'Add to/Remove from Dock' menuitem using plank dbus api.

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Merged the plank branch. So the required version is 0.8.1.1197

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-01-17 23:56:32 +0000
+++ CMakeLists.txt 2015-03-26 22:27:53 +0000
@@ -54,10 +54,17 @@
54 message ("-- Zeitgeist integration disabled")54 message ("-- Zeitgeist integration disabled")
55endif ()55endif ()
5656
57set (CORE_DEPS "gobject-2.0;glib-2.0;gio-2.0;gio-unix-2.0;libsoup-2.4;gee-0.8;libgnome-menu-3.0;json-glib-1.0;${UNITY_DEPS};")57find_package (PkgConfig)
58
59pkg_check_modules(PLANK QUIET plank>=0.8.1.1197)
60if (PLANK_FOUND)
61 set (PLANK_DEPS plank)
62 set (PLANK_OPTIONS --define=HAS_PLANK)
63endif ()
64
65set (CORE_DEPS "gobject-2.0;glib-2.0;gio-2.0;gio-unix-2.0;libsoup-2.4;gee-0.8;libgnome-menu-3.0;json-glib-1.0;${UNITY_DEPS};${PLANK_DEPS};")
58set (UI_DEPS "gtk+-3.0>=3.10.0;granite;${ZEITGEIST_DEPS};")66set (UI_DEPS "gtk+-3.0>=3.10.0;granite;${ZEITGEIST_DEPS};")
5967
60find_package (PkgConfig)
61pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0)68pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0)
6269
63find_package (Vala REQUIRED)70find_package (Vala REQUIRED)
@@ -98,6 +105,7 @@
98 -g105 -g
99 ${UNITY_OPTIONS}106 ${UNITY_OPTIONS}
100 ${ZEITGEIST_OPTIONS}107 ${ZEITGEIST_OPTIONS}
108 ${PLANK_OPTIONS}
101)109)
102110
103include_directories(${CMAKE_BINARY_DIR}/lib/synapse-core)111include_directories(${CMAKE_BINARY_DIR}/lib/synapse-core)
104112
=== modified file 'src/Widgets/AppEntry.vala'
--- src/Widgets/AppEntry.vala 2015-02-16 22:09:02 +0000
+++ src/Widgets/AppEntry.vala 2015-03-26 22:27:53 +0000
@@ -35,6 +35,16 @@
3535
36 private Backend.App application;36 private Backend.App application;
3737
38#if HAS_PLANK
39 static construct {
40 plank_client = Plank.DBus.Client.get_instance ();
41 }
42
43 private static Plank.DBus.Client plank_client;
44 private bool docked = false;
45 private string desktop_uri;
46#endif
47
38 public AppEntry (Backend.App app) {48 public AppEntry (Backend.App app) {
39 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};49 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
40 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},50 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},
@@ -42,6 +52,9 @@
4252
43 desktop_id = app.desktop_id;53 desktop_id = app.desktop_id;
44 desktop_path = app.desktop_path;54 desktop_path = app.desktop_path;
55#if HAS_PLANK
56 desktop_uri = File.new_for_path (desktop_path).get_uri ();
57#endif
4558
46 application = app;59 application = app;
47 app_name = app.name;60 app_name = app.name;
@@ -158,7 +171,44 @@
158 }171 }
159 });172 });
160 }173 }
174
175#if HAS_PLANK
176 if (plank_client != null && plank_client.is_connected) {
177 if (menu.get_children ().length () > 0)
178 menu.add (new Gtk.SeparatorMenuItem ());
179
180 menu.add (get_plank_menuitem ());
181 }
182#endif
183
161 menu.show_all ();184 menu.show_all ();
162 }185 }
163186
187#if HAS_PLANK
188 private Gtk.MenuItem get_plank_menuitem () {
189 docked = (desktop_uri in plank_client.get_persistent_applications ());
190
191 var plank_menuitem = new Gtk.MenuItem ();
192 plank_menuitem.set_use_underline (true);
193
194 if (docked)
195 plank_menuitem.set_label (_("Remove from _Dock"));
196 else
197 plank_menuitem.set_label (_("Add to _Dock"));
198
199 plank_menuitem.activate.connect (plank_menuitem_activate);
200
201 return plank_menuitem;
202 }
203
204 private void plank_menuitem_activate () {
205 if (plank_client == null || !plank_client.is_connected)
206 return;
207
208 if (docked)
209 plank_client.remove_item (desktop_uri);
210 else
211 plank_client.add_item (desktop_uri);
212 }
213#endif
164}214}

Subscribers

People subscribed via source and target branches