Merge lp:~3v1n0/unity/ups-empty-menu into lp:unity

Proposed by Marco Trevisan (Treviño) on 2012-11-29
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2012-12-05
Approved revision: 2924
Merged at revision: 2955
Proposed branch: lp:~3v1n0/unity/ups-empty-menu
Merge into: lp:unity
Diff against target: 263 lines (+70/-30)
8 files modified
CMakeLists.txt (+4/-1)
config.h.cmake (+2/-0)
manual-tests/PanelService.txt (+17/-0)
po/POTFILES.in (+1/-0)
services/CMakeLists.txt (+15/-9)
services/panel-main.c (+1/-0)
services/panel-service.c (+30/-18)
tests/CMakeLists.txt (+0/-2)
To merge this branch: bzr merge lp:~3v1n0/unity/ups-empty-menu
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2012-12-04
Andrea Azzarone 2012-11-29 Approve on 2012-12-03
Review via email: mp+136828@code.launchpad.net

Commit Message

PanelService: show a menu with an Activate menu item for entries without menu

Description of the Change

There are some (badly written, imho) applications that have a menubar containing entries that can be clicked directly... Unity does not support this, but to allow these menus to work I added a simple menu entry that can be activated, when an IndicatorEntry has not a menu (but just a label).

Not to break the contract where an indicator should have a menu, and to allow menus scrubbing, this entry can be activated only using a new menu entry we added.

To post a comment you must log in.
Andrea Azzarone (azzar1) wrote :

LGTM. Works here.

review: Approve
lp:~3v1n0/unity/ups-empty-menu updated on 2012-12-05
2924. By Marco Trevisan (Treviño) on 2012-12-05

CMakeLists: Look for pkgconfig before getting variables, or it won't work the first time

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 2012-11-29 12:53:42 +0000
3+++ CMakeLists.txt 2012-12-05 01:17:24 +0000
4@@ -130,6 +130,10 @@
5 set (VERSION "${UNITY_VERSION}")
6 set (BUILDDIR "${CMAKE_BINARY_DIR}")
7
8+find_package (PkgConfig)
9+execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator3-0.4 --variable indicatordir OUTPUT_VARIABLE INDICATORDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
10+execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator3-0.4 --variable iconsdir OUTPUT_VARIABLE INDICATORICONDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
11+
12 configure_file (${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
13
14 #
15@@ -210,7 +214,6 @@
16 )
17 endif ()
18
19-find_package (PkgConfig)
20 pkg_check_modules (CACHED_UNITY_DEPS REQUIRED ${UNITY_PLUGIN_DEPS})
21 pkg_check_modules (CACHED_UNITY_PRIVATE_DEPS REQUIRED ${UNITY_PROTOCOL_PRIVATE_DEPS})
22 add_subdirectory(unity-shared)
23
24=== modified file 'config.h.cmake'
25--- config.h.cmake 2011-02-27 16:57:57 +0000
26+++ config.h.cmake 2012-12-05 01:17:24 +0000
27@@ -10,5 +10,7 @@
28 #cmakedefine TESTVALADIR "@TESTVALADIR@"
29 #cmakedefine TESTDATADIR "@TESTDIRDIR@"
30 #cmakedefine GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
31+#cmakedefine INDICATORDIR "@INDICATORDIR@"
32+#cmakedefine INDICATORICONDIR "@INDICATORICONDIR@"
33
34 #endif // CONFIG_H
35
36=== modified file 'manual-tests/PanelService.txt'
37--- manual-tests/PanelService.txt 2012-07-12 12:03:05 +0000
38+++ manual-tests/PanelService.txt 2012-12-05 01:17:24 +0000
39@@ -13,3 +13,20 @@
40 This means that the menus and indicators must not be removed and readded
41 from the unity panel.
42 For more info see bug #937119
43+
44+
45+Panel Service shows entries with no menus
46+-----------------------------------------
47+
48+Setup:
49+
50+Actions:
51+#. Start with a clean screen
52+#. Save this python script and run it http://pastebin.ubuntu.com/1395885/
53+#. Make sure the "Simple Menu" window is focused
54+#. Move the mouse pointer over the panel
55+
56+Expected Result:
57+ The panel should contains three menu entries: "File", "HiddenExit" and "Other",
58+ clicking over "HiddenExit" should bring up a menu with a single entry named
59+ "Activate". Clicking on it should close the "Simple Menu" application.
60\ No newline at end of file
61
62=== modified file 'po/POTFILES.in'
63--- po/POTFILES.in 2012-11-06 18:19:09 +0000
64+++ po/POTFILES.in 2012-12-05 01:17:24 +0000
65@@ -31,6 +31,7 @@
66 plugins/unityshell/unityshell.xml.in
67 shortcuts/ShortcutHintPrivate.cpp
68 shortcuts/ShortcutView.cpp
69+services/panel-service.c
70 unity-shared/DashStyle.cpp
71 unity-shared/SearchBar.cpp
72 gnome/50-unity-launchers.xml.in
73
74=== modified file 'services/CMakeLists.txt'
75--- services/CMakeLists.txt 2012-11-26 16:09:53 +0000
76+++ services/CMakeLists.txt 2012-12-05 01:17:24 +0000
77@@ -1,12 +1,20 @@
78 #
79 # Panel Service
80 #
81+
82+set(UNITY_PANEL_SERVICE_DEPS
83+ atk
84+ atk-bridge-2.0
85+ gio-2.0
86+ gobject-2.0
87+ gthread-2.0
88+ gtk+-3.0>=3.3
89+ indicator3-0.4>=0.4.90
90+ x11
91+)
92+
93 find_package(PkgConfig)
94-
95-pkg_check_modules(SERVICE_DEPS REQUIRED gtk+-3.0>=3.3 gobject-2.0 gio-2.0 gthread-2.0 indicator3-0.4>=0.4.90 x11 atk-bridge-2.0)
96-
97-execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator3-0.4 --variable indicatordir OUTPUT_VARIABLE _indicatordir OUTPUT_STRIP_TRAILING_WHITESPACE)
98-execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator3-0.4 --variable iconsdir OUTPUT_VARIABLE _iconsdir OUTPUT_STRIP_TRAILING_WHITESPACE)
99+pkg_check_modules(SERVICE_DEPS REQUIRED ${UNITY_PANEL_SERVICE_DEPS})
100
101 set(PANEL_SOURCES
102 panel-a11y.c
103@@ -33,14 +41,12 @@
104 COMMENT "Generating marshallers")
105
106 set(CFLAGS
107- "${SERVICE_DEPS_CFLAGS}"
108+ ${SERVICE_DEPS_CFLAGS}
109 ${SERVICE_DEPS_CFLAGS_OTHER}
110- "-DINDICATORDIR=\"${_indicatordir}\""
111- "-DINDICATORICONDIR=\"${_iconsdir}\""
112 "-Werror -Wall"
113 )
114 add_definitions(${CFLAGS})
115-include_directories(${CMAKE_CURRENT_BINARY_DIR})
116+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR})
117
118 set(LIBS ${SERVICE_DEPS_LIBRARIES})
119 link_libraries(${LIBS})
120
121=== modified file 'services/panel-main.c'
122--- services/panel-main.c 2012-12-04 00:33:01 +0000
123+++ services/panel-main.c 2012-12-05 01:17:24 +0000
124@@ -22,6 +22,7 @@
125 #include <gio/gio.h>
126 #include <gtk/gtk.h>
127
128+#include "config.h"
129 #include "panel-a11y.h"
130 #include "panel-service.h"
131
132
133=== modified file 'services/panel-service.c'
134--- services/panel-service.c 2012-12-04 00:33:01 +0000
135+++ services/panel-service.c 2012-12-05 01:17:24 +0000
136@@ -19,10 +19,7 @@
137 * Marco Trevisan (Treviño) <mail@3v1n0.net>
138 */
139
140-#if HAVE_CONFIG_H
141-#include <config.h>
142-#endif
143-
144+#include "config.h"
145 #include "panel-marshal.h"
146 #include "panel-service.h"
147
148@@ -30,6 +27,7 @@
149 #include <string.h>
150 #include <gtk/gtk.h>
151 #include <gdk/gdkx.h>
152+#include <glib/gi18n-lib.h>
153
154 #include <X11/extensions/XInput2.h>
155 #include <X11/XKBlib.h>
156@@ -836,14 +834,12 @@
157 {
158 g_signal_connect (entry->label, "notify::label",
159 G_CALLBACK (on_entry_property_changed), object);
160-
161 g_signal_connect (entry->label, "notify::sensitive",
162 G_CALLBACK (on_entry_property_changed), object);
163 g_signal_connect (entry->label, "show",
164 G_CALLBACK (on_entry_changed), object);
165 g_signal_connect (entry->label, "hide",
166 G_CALLBACK (on_entry_changed), object);
167-
168 }
169 if (GTK_IS_IMAGE (entry->image))
170 {
171@@ -859,14 +855,12 @@
172 G_CALLBACK (on_entry_property_changed), object);
173 g_signal_connect (entry->image, "notify::stock",
174 G_CALLBACK (on_entry_property_changed), object);
175-
176 g_signal_connect (entry->image, "notify::sensitive",
177 G_CALLBACK (on_entry_property_changed), object);
178 g_signal_connect (entry->image, "show",
179 G_CALLBACK (on_entry_changed), object);
180 g_signal_connect (entry->image, "hide",
181 G_CALLBACK (on_entry_changed), object);
182-
183 }
184
185 notify_object (object);
186@@ -1634,7 +1628,18 @@
187 menu_deactivated (GtkWidget *menu)
188 {
189 g_signal_handlers_disconnect_by_func (menu, menu_deactivated, NULL);
190- gtk_widget_destroy (menu);
191+
192+ if (g_object_is_floating (menu))
193+ g_object_ref_sink (menu);
194+
195+ g_object_unref (menu);
196+}
197+
198+static void
199+menuitem_activated (GtkWidget *menuitem, IndicatorObjectEntry *entry)
200+{
201+ IndicatorObject *object = get_entry_parent_indicator (entry);
202+ indicator_object_entry_activate (object, entry, CurrentTime);
203 }
204
205 static void
206@@ -1677,17 +1682,17 @@
207
208 if (entry != NULL)
209 {
210- if (xid > 0)
211- {
212- indicator_object_entry_activate_window (object, entry, xid, CurrentTime);
213- }
214- else
215- {
216- indicator_object_entry_activate (object, entry, CurrentTime);
217- }
218-
219 if (GTK_IS_MENU (entry->menu))
220 {
221+ if (xid > 0)
222+ {
223+ indicator_object_entry_activate_window (object, entry, xid, CurrentTime);
224+ }
225+ else
226+ {
227+ indicator_object_entry_activate (object, entry, CurrentTime);
228+ }
229+
230 priv->last_menu = entry->menu;
231 }
232 else
233@@ -1696,10 +1701,17 @@
234 rest of the code and to keep scrubbing fluidly, we'll create a
235 stub menu for the duration of this scrub. */
236 priv->last_menu = GTK_MENU (gtk_menu_new ());
237+
238+ GtkWidget *menu_item = gtk_menu_item_new_with_label (_("Activate"));
239+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->last_menu), menu_item);
240+ gtk_widget_show (menu_item);
241+
242 g_signal_connect (priv->last_menu, "deactivate",
243 G_CALLBACK (menu_deactivated), NULL);
244 g_signal_connect (priv->last_menu, "destroy",
245 G_CALLBACK (gtk_widget_destroyed), &priv->last_menu);
246+ g_signal_connect (menu_item, "activate",
247+ G_CALLBACK (menuitem_activated), entry);
248 }
249
250 GtkWidget *top_widget = gtk_widget_get_toplevel (GTK_WIDGET (priv->last_menu));
251
252=== modified file 'tests/CMakeLists.txt'
253--- tests/CMakeLists.txt 2012-12-04 15:25:01 +0000
254+++ tests/CMakeLists.txt 2012-12-05 01:17:24 +0000
255@@ -28,8 +28,6 @@
256 "-g"
257 "-DTESTDATADIR=\"${TESTDATADIR}\""
258 "-DGETTEXT_PACKAGE=\"unity\""
259- "-DINDICATORDIR=\"${CMAKE_BINARY_DIR}/tests\""
260- "-DINDICATORICONDIR=\"${CMAKE_BINARY_DIR}/tests\""
261 "-I${CMAKE_CURRENT_BINARY_DIR}"
262 )
263 add_definitions (${CFLAGS})