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

Proposed by Rory on 2015-02-16
Status: Merged
Approved by: Cody Garver on 2015-05-08
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 2015-02-16 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.
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
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-01-17 23:56:32 +0000
3+++ CMakeLists.txt 2015-03-26 22:27:53 +0000
4@@ -54,10 +54,17 @@
5 message ("-- Zeitgeist integration disabled")
6 endif ()
7
8-set (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};")
9+find_package (PkgConfig)
10+
11+pkg_check_modules(PLANK QUIET plank>=0.8.1.1197)
12+if (PLANK_FOUND)
13+ set (PLANK_DEPS plank)
14+ set (PLANK_OPTIONS --define=HAS_PLANK)
15+endif ()
16+
17+set (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};")
18 set (UI_DEPS "gtk+-3.0>=3.10.0;granite;${ZEITGEIST_DEPS};")
19
20-find_package (PkgConfig)
21 pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0)
22
23 find_package (Vala REQUIRED)
24@@ -98,6 +105,7 @@
25 -g
26 ${UNITY_OPTIONS}
27 ${ZEITGEIST_OPTIONS}
28+ ${PLANK_OPTIONS}
29 )
30
31 include_directories(${CMAKE_BINARY_DIR}/lib/synapse-core)
32
33=== modified file 'src/Widgets/AppEntry.vala'
34--- src/Widgets/AppEntry.vala 2015-02-16 22:09:02 +0000
35+++ src/Widgets/AppEntry.vala 2015-03-26 22:27:53 +0000
36@@ -35,6 +35,16 @@
37
38 private Backend.App application;
39
40+#if HAS_PLANK
41+ static construct {
42+ plank_client = Plank.DBus.Client.get_instance ();
43+ }
44+
45+ private static Plank.DBus.Client plank_client;
46+ private bool docked = false;
47+ private string desktop_uri;
48+#endif
49+
50 public AppEntry (Backend.App app) {
51 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
52 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},
53@@ -42,6 +52,9 @@
54
55 desktop_id = app.desktop_id;
56 desktop_path = app.desktop_path;
57+#if HAS_PLANK
58+ desktop_uri = File.new_for_path (desktop_path).get_uri ();
59+#endif
60
61 application = app;
62 app_name = app.name;
63@@ -158,7 +171,44 @@
64 }
65 });
66 }
67+
68+#if HAS_PLANK
69+ if (plank_client != null && plank_client.is_connected) {
70+ if (menu.get_children ().length () > 0)
71+ menu.add (new Gtk.SeparatorMenuItem ());
72+
73+ menu.add (get_plank_menuitem ());
74+ }
75+#endif
76+
77 menu.show_all ();
78 }
79
80+#if HAS_PLANK
81+ private Gtk.MenuItem get_plank_menuitem () {
82+ docked = (desktop_uri in plank_client.get_persistent_applications ());
83+
84+ var plank_menuitem = new Gtk.MenuItem ();
85+ plank_menuitem.set_use_underline (true);
86+
87+ if (docked)
88+ plank_menuitem.set_label (_("Remove from _Dock"));
89+ else
90+ plank_menuitem.set_label (_("Add to _Dock"));
91+
92+ plank_menuitem.activate.connect (plank_menuitem_activate);
93+
94+ return plank_menuitem;
95+ }
96+
97+ private void plank_menuitem_activate () {
98+ if (plank_client == null || !plank_client.is_connected)
99+ return;
100+
101+ if (docked)
102+ plank_client.remove_item (desktop_uri);
103+ else
104+ plank_client.add_item (desktop_uri);
105+ }
106+#endif
107 }

Subscribers

People subscribed via source and target branches