Merge lp:~larsu/ubiquity/fix-indicators into lp:ubiquity

Proposed by Lars Karlitski
Status: Merged
Merged at revision: 5967
Proposed branch: lp:~larsu/ubiquity/fix-indicators
Merge into: lp:ubiquity
Diff against target: 277 lines (+95/-60)
4 files modified
configure.ac (+7/-1)
debian/control (+1/-1)
src/panel/Makefile.am (+1/-1)
src/panel/panel.c (+86/-57)
To merge this branch: bzr merge lp:~larsu/ubiquity/fix-indicators
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+177438@code.launchpad.net

Description of the change

Port to new indicator architecture.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2013-07-11 18:23:07 +0000
3+++ configure.ac 2013-07-29 17:32:28 +0000
4@@ -25,11 +25,14 @@
5
6 GTK3_REQUIRED=3.1.4
7 GIO_REQUIRED=2.5.11
8+INDICATOR_REQUIRED=12.10.2
9+IDO_REQUIRED=13.10.1
10
11 if test "x$UBIQUITY_NO_GTK" = x; then
12 PKG_CHECK_MODULES(PANEL, [glib-2.0
13 gtk+-3.0 >= $GTK3_REQUIRED
14- indicator3-0.4
15+ indicator3-0.4 >= $INDICATOR_REQUIRED
16+ libido3-0.1 >= $IDO_REQUIRED
17 x11])
18 AC_SUBST(PANEL_CFLAGS)
19 AC_SUBST(PANEL_LIBS)
20@@ -62,6 +65,9 @@
21 pixmapsdir="${datadir}/${PACKAGE}/pixmaps"
22 AC_SUBST([pixmapsdir])
23
24+INDICATOR_DIR=${datadir}/unity/indicators
25+AC_SUBST(INDICATOR_DIR)
26+
27 AC_CONFIG_FILES([
28 Makefile
29 data/Makefile
30
31=== modified file 'debian/control'
32--- debian/control 2013-07-01 11:32:25 +0000
33+++ debian/control 2013-07-29 17:32:28 +0000
34@@ -3,7 +3,7 @@
35 Priority: optional
36 Maintainer: Ubuntu Installer Team <ubuntu-installer@lists.ubuntu.com>
37 Uploaders: Colin Watson <cjwatson@ubuntu.com>, Evan Dandrea <ev@ubuntu.com>
38-Build-Depends: apt, autopoint, bf-utf-source, dctrl-tools, debconf (>= 1.5.43), debconf-utils, debhelper (>= 9), devio, dh-autoreconf, dh-di (>= 3), dpkg-dev (>= 1.15.7), gir1.2-gnomekeyring-1.0, gir1.2-soup-2.4, gir1.2-timezonemap-1.0, gir1.2-webkit-3.0, gir1.2-xkl-1.0, gnome-icon-theme, gobject-introspection, intltool (>= 0.40.0), intltool-debian (>= 0.30+20040212), iso-codes, isoquery, keymapper (>= 0.5.3-7), libbogl-dev, libcairo2-dev, libdebconfclient0-dev (>= 0.68), libdebian-installer4-dev (>= 0.76), libgirepository1.0-dev, libglib2.0-dev, libgtk-3-dev, libindicator3-dev, libiw-dev (>= 27+28pre9), liblocale-gettext-perl, libparted-dev, libparted0-dev (>= 2.2), locales, pep8, pkg-config, po-debconf (>= 1.0), pyflakes (>= 0.7.2), python-gi-dev, python-scour, python3-all (>= 3.1), python3-apt (>= 0.7.100.3~), python3-cairo, python3-dbus, python3-gi, python3-gi-cairo, python3-mock (>= 0.7.0), python3-oauthlib, python3-pyicu (>= 1.0), tzdata, ubuntu-artwork, udev, wget, xkb-data (>= 0.9), xkb-data-i18n, xvfb
39+Build-Depends: apt, autopoint, bf-utf-source, dctrl-tools, debconf (>= 1.5.43), debconf-utils, debhelper (>= 9), devio, dh-autoreconf, dh-di (>= 3), dpkg-dev (>= 1.15.7), gir1.2-gnomekeyring-1.0, gir1.2-soup-2.4, gir1.2-timezonemap-1.0, gir1.2-webkit-3.0, gir1.2-xkl-1.0, gnome-icon-theme, gobject-introspection, intltool (>= 0.40.0), intltool-debian (>= 0.30+20040212), iso-codes, isoquery, keymapper (>= 0.5.3-7), libbogl-dev, libcairo2-dev, libdebconfclient0-dev (>= 0.68), libdebian-installer4-dev (>= 0.76), libgirepository1.0-dev, libglib2.0-dev, libgtk-3-dev, libido3-0.1-dev, libindicator3-dev, libiw-dev (>= 27+28pre9), liblocale-gettext-perl, libparted-dev, libparted0-dev (>= 2.2), locales, pep8, pkg-config, po-debconf (>= 1.0), pyflakes (>= 0.7.2), python-gi-dev, python-scour, python3-all (>= 3.1), python3-apt (>= 0.7.100.3~), python3-cairo, python3-dbus, python3-gi, python3-gi-cairo, python3-mock (>= 0.7.0), python3-oauthlib, python3-pyicu (>= 1.0), tzdata, ubuntu-artwork, udev, wget, xkb-data (>= 0.9), xkb-data-i18n, xvfb
40 Standards-Version: 3.9.4
41 X-Python3-Version: >= 3.1
42 XS-Testsuite: autopkgtest
43
44=== modified file 'src/panel/Makefile.am'
45--- src/panel/Makefile.am 2012-02-12 02:41:56 +0000
46+++ src/panel/Makefile.am 2013-07-29 17:32:28 +0000
47@@ -1,4 +1,4 @@
48-AM_CPPFLAGS = $(PANEL_CFLAGS)
49+AM_CPPFLAGS = $(PANEL_CFLAGS) -DINDICATOR_DIR=\"${INDICATOR_DIR}\"
50 AM_LDFLAGS = $(PANEL_LIBS)
51
52 pkglibexec_PROGRAMS = panel
53
54=== modified file 'src/panel/panel.c'
55--- src/panel/panel.c 2013-02-20 23:36:48 +0000
56+++ src/panel/panel.c 2013-07-29 17:32:28 +0000
57@@ -29,21 +29,11 @@
58 #include <X11/Xatom.h>
59 #include <X11/Xlib.h>
60 #include <X11/Xutil.h>
61-#include <libindicator/indicator-object.h>
62+#include <libindicator/indicator-ng.h>
63+#include <libido/libido.h>
64
65 #define ENTRY_DATA_NAME "indicator-custom-entry-data"
66
67-
68-static gchar * indicator_order[] = {
69- "indicator-session-devices",
70- "indicator-sound",
71- "nm-applet",
72- "bluetooth-manager",
73- "ubiquity",
74- "keyboard",
75- NULL
76-};
77-
78 enum {
79 STRUT_LEFT = 0,
80 STRUT_RIGHT = 1,
81@@ -108,13 +98,41 @@
82 gdk_error_trap_pop_ignored ();
83 }
84
85+/* like gtk_menu_shell_insert, but appends/prepends if @position is out
86+ * of range */
87+static void
88+menu_shell_insert (GtkMenuShell *shell,
89+ GtkWidget *item,
90+ gint position)
91+{
92+ if (position <= 0) {
93+ gtk_menu_shell_prepend (shell, item);
94+ }
95+ else {
96+ GList *children = gtk_container_get_children (GTK_CONTAINER (shell));
97+ if (children) {
98+ if (position < g_list_length (children))
99+ gtk_menu_shell_insert (shell, item, position);
100+ else
101+ gtk_menu_shell_append (shell, item);
102+ g_list_free (children);
103+ }
104+ else
105+ gtk_menu_shell_prepend (shell, item);
106+ }
107+}
108+
109 /* Stolen from indicator-loader.c in unity. */
110 static void
111 entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data)
112 {
113+ GtkMenuShell *menubar = user_data;
114+
115 g_debug("Signal: Entry Added");
116
117 GtkWidget * menuitem = gtk_menu_item_new();
118+ g_object_set_data_full (G_OBJECT (menuitem), "indicator object", g_object_ref (io), g_object_unref);
119+
120 GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
121
122 if (entry->image != NULL) {
123@@ -127,23 +145,24 @@
124 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
125 }
126
127- if (entry->name_hint != NULL) {
128- int i;
129- int found = 0;
130- for (i = 0; indicator_order[i] != NULL; i++) {
131- if (g_strcmp0(entry->name_hint, indicator_order[i]) == 0) {
132- gtk_menu_shell_insert(GTK_MENU_SHELL(user_data), menuitem, i);
133- found = 1;
134- break;
135+ gint position = indicator_object_get_position (io);
136+ gint i = -1;
137+
138+ if (position > 0) {
139+ i = 0;
140+ GList *items = gtk_container_get_children (GTK_CONTAINER (menubar));
141+ if (items) {
142+ GList *it;
143+ for (it = items; it != NULL; it = it->next, i++) {
144+ IndicatorObject *item_io = g_object_get_data (it->data, "indicator object");
145+ gint item_position = indicator_object_get_position (item_io);
146+ if (position > item_position)
147+ break;
148 }
149- }
150- if (found == 0) {
151- gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem);
152- }
153- }
154- else {
155- gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem);
156- }
157+ g_list_free (items);
158+ }
159+ }
160+ menu_shell_insert (menubar, menuitem, i);
161
162 gtk_widget_show(menuitem);
163
164@@ -176,19 +195,9 @@
165 }
166
167 static gboolean
168-load_module (const gchar * name, GtkWidget * menu)
169+load_indicator (IndicatorObject *io, GtkWidget * menu)
170 {
171- g_debug("Looking at Module: %s", name);
172- g_return_val_if_fail(name != NULL, FALSE);
173-
174- if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
175- return FALSE;
176- }
177-
178- g_debug("Loading Module: %s", name);
179-
180- /* Build the object for the module */
181- IndicatorObject * io = indicator_object_new_from_file(name);
182+ g_return_val_if_fail(io != NULL, FALSE);
183
184 /* Connect to its signals */
185 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menu);
186@@ -207,6 +216,36 @@
187 return TRUE;
188 }
189
190+static void
191+load_indicator_files (const gchar *directory, GtkWidget *menu)
192+{
193+ GDir *dir;
194+ GError *error = NULL;
195+ const gchar *name;
196+
197+ dir = g_dir_open (INDICATOR_DIR, 0, &error);
198+ if (dir == NULL) {
199+ g_warning ("unable to open indicator directory: %s", error->message);
200+ g_error_free (error);
201+ return;
202+ }
203+
204+ while ((name = g_dir_read_name (dir))) {
205+ gchar *path = g_build_filename (directory, name, NULL);
206+ IndicatorNg *io = indicator_ng_new_for_profile (path, "ubiquity", &error);
207+ if (io) {
208+ load_indicator (INDICATOR_OBJECT (io), menu);
209+ }
210+ else {
211+ g_warning ("unable to load indicator '%s': %s", name, error->message);
212+ g_clear_error (&error);
213+ }
214+ g_free (path);
215+ }
216+
217+ g_dir_close (dir);
218+}
219+
220 /* At some point subclass GtkWindow instead. */
221 static void
222 on_realize(GtkWidget *win, gpointer data) {
223@@ -230,13 +269,6 @@
224 on_realize(win, NULL);
225 }
226
227-static const char* indicators[] = {
228- "/usr/lib/indicators3/7/libsession.so",
229- "/usr/lib/indicators3/7/libapplication.so",
230- "/usr/lib/indicators3/7/libsoundmenu.so",
231- NULL
232-};
233-
234 static void
235 draw_child (GtkWidget *child, gpointer client_data) {
236 struct {
237@@ -280,10 +312,12 @@
238 GtkWidget *win;
239 GtkCssProvider *cssprovider;
240 GdkScreen *screen;
241+ GError *error;
242
243 /* Disable global menus */
244 g_unsetenv ("UBUNTU_MENUPROXY");
245 gtk_init(&argc, &argv);
246+ ido_init ();
247 screen = gdk_screen_get_default();
248 win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
249 g_signal_connect(win, "realize", G_CALLBACK(on_realize), NULL);
250@@ -299,22 +333,17 @@
251 "GtkWidget {\n"
252 " -GtkWidget-focus-line-width: 0;\n"
253 " -GtkWidget-focus-padding: 0;\n"
254- "}\n"
255- ".menuitem {\n"
256- " padding: 0px 0px 0px 0px;\n"
257 "}\n", -1, NULL);
258
259 gtk_style_context_add_provider_for_screen(screen,
260 GTK_STYLE_PROVIDER (cssprovider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
261
262 GtkWidget* menubar = gtk_menu_bar_new();
263- gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar), GTK_PACK_DIRECTION_RTL);
264- int i;
265- for(i = 0; indicators[i]; i++) {
266- if (!load_module(indicators[i], menubar)) {
267- g_error("Unable to load module");
268- }
269- }
270+
271+ load_indicator_files (INDICATOR_DIR, menubar);
272+ IndicatorObject * io = indicator_object_new_from_file("/usr/lib/indicators3/7/libapplication.so");
273+ load_indicator(io, menubar);
274+
275 GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
276 gtk_container_add(GTK_CONTAINER(win), hbox);
277 gtk_box_pack_end(GTK_BOX(hbox), menubar, FALSE, FALSE, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: