Merge lp:~ted/libappindicator/gdbus-for-the-win into lp:libappindicator

Proposed by Ted Gould
Status: Merged
Merged at revision: 173
Proposed branch: lp:~ted/libappindicator/gdbus-for-the-win
Merge into: lp:libappindicator
Diff against target: 1540 lines (+569/-403)
9 files modified
.bzrignore (+18/-4)
configure.ac (+16/-8)
src/Makefile.am (+22/-20)
src/app-indicator.c (+487/-341)
src/generate-id.c (+1/-1)
src/generate-id.h (+1/-1)
tests/Makefile.am (+16/-16)
tests/test-libappindicator-dbus-client.c (+8/-8)
tests/test-libappindicator-dbus-server.c (+0/-4)
To merge this branch: bzr merge lp:~ted/libappindicator/gdbus-for-the-win
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+43117@code.launchpad.net

Description of the change

Porting the lib over to GDBus. The test suite is still dbus-glib, but that should be fine for now.

To post a comment you must log in.
202. By Ted Gould

Wrong directory for the GTK 3 header. Fixed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-08-11 16:10:03 +0000
3+++ .bzrignore 2010-12-08 20:52:11 +0000
4@@ -96,10 +96,10 @@
5 bindings/mono/libappindicator-api.middle
6 bindings/mono/examples/IndicatorExample.exe
7 src/app-indicator-enum-types.gen.c
8-indicator-application-[0-9].[0-9].[0-9].tar.gz
9-indicator-application-[0-9].[0-9].[0-9].tar.gz.asc
10-indicator-application-[0-9].[0-9].[0-9][0-9].tar.gz
11-indicator-application-[0-9].[0-9].[0-9][0-9].tar.gz.asc
12+libappindicator-[0-9].[0-9].[0-9].tar.gz
13+libappindicator-[0-9].[0-9].[0-9].tar.gz.asc
14+libappindicator-[0-9].[0-9].[0-9][0-9].tar.gz
15+libappindicator-[0-9].[0-9].[0-9][0-9].tar.gz.asc
16 m4/gtk-doc.m4
17 src/AppIndicator-0.1.gir
18 src/AppIndicator-0.1.typelib
19@@ -115,3 +115,17 @@
20 bindings/mono/policy.0.0.appindicator-sharp.dll
21 src/libapplication_la-generate-id.lo
22 src/libappindicator_la-generate-id.lo
23+bindings/mono/app-indicator.c
24+bindings/mono/policy.0.1.appindicator-sharp.config
25+bindings/mono/policy.0.1.appindicator-sharp.dll
26+src/appindicator3-0.1.pc
27+src/notification-item.xml.c
28+src/notification-item.xml.h
29+src/notification-watcher.xml.c
30+src/notification-watcher.xml.h
31+src/gen-notification-item.xml.c
32+src/gen-notification-item.xml.h
33+src/gen-notification-watcher.xml.c
34+src/gen-notification-watcher.xml.h
35+src/libappindicator_la-gen-notification-item.xml.lo
36+src/libappindicator_la-gen-notification-watcher.xml.lo
37
38=== modified file 'configure.ac'
39--- configure.ac 2010-12-08 18:26:41 +0000
40+++ configure.ac 2010-12-08 20:52:11 +0000
41@@ -39,8 +39,10 @@
42
43 GTK_REQUIRED_VERSION=2.18
44 GTK3_REQUIRED_VERSION=2.91
45+GLIB_REQUIRED_VERSION=2.26
46+GIO_REQUIRED_VERSION=2.26
47 INDICATOR_REQUIRED_VERSION=0.3.5
48-DBUSMENUGTK_REQUIRED_VERSION=0.2.2
49+DBUSMENUGTK_REQUIRED_VERSION=0.3.90
50 DBUS_GLIB_REQUIRED_VERSION=0.82
51
52 AC_ARG_WITH([gtk],
53@@ -49,19 +51,21 @@
54 [],
55 [with_gtk=2])
56 AS_IF([test "x$with_gtk" = x3],
57- [PKG_CHECK_MODULES(LIBRARAY, gtk+-3.0 >= $GTK3_REQUIRED_VERSION
58- indicator3 >= $INDICATOR_REQUIRED_VERSION
59- dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
60- dbusmenu-gtk3 >= $DBUSMENUGTK_REQUIRED_VERSION)
61+ [PKG_CHECK_MODULES(LIBRARY, gtk+-3.0 >= $GTK3_REQUIRED_VERSION
62+ glib-2.0 >= $GLIB_REQUIRED_VERSION
63+ gio-2.0 >= $GIO_REQUIRED_VERSION
64+ indicator3 >= $INDICATOR_REQUIRED_VERSION
65+ dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION)
66 AC_SUBST(LIBRARY_CFLAGS)
67 AC_SUBST(LIBRARY_LIBS)
68 AC_DEFINE(HAVE_GTK3, 1, [whether gtk3 is available])
69 ],
70 [test "x$with_gtk" = x2],
71 [PKG_CHECK_MODULES(LIBRARY, gtk+-2.0 >= $GTK_REQUIRED_VERSION
72- indicator >= $INDICATOR_REQUIRED_VERSION
73- dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
74- dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION)
75+ glib-2.0 >= $GLIB_REQUIRED_VERSION
76+ gio-2.0 >= $GIO_REQUIRED_VERSION
77+ indicator >= $INDICATOR_REQUIRED_VERSION
78+ dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION)
79 AC_SUBST(LIBRARY_CFLAGS)
80 AC_SUBST(LIBRARY_LIBS)
81 ],
82@@ -69,6 +73,10 @@
83 )
84 AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3])
85
86+PKG_CHECK_MODULES(TESTDEPS, dbus-glib-1)
87+AC_SUBST(TESTDEPS_CFLAGS)
88+AC_SUBST(TESTDEPS_LIBS)
89+
90 ###########################
91 # GObject Introspection
92 ###########################
93
94=== modified file 'src/Makefile.am'
95--- src/Makefile.am 2010-12-04 04:00:38 +0000
96+++ src/Makefile.am 2010-12-08 20:52:11 +0000
97@@ -54,10 +54,6 @@
98 $(libappindicator_headers) \
99 $(glib_enum_h)
100
101-BUILT_SOURCES += \
102- notification-watcher-client.h \
103- notification-item-server.h
104-
105 libappindicator_la_SOURCES = \
106 $(libappindicator_headers) \
107 app-indicator-enum-types.c \
108@@ -65,7 +61,11 @@
109 application-service-marshal.c \
110 dbus-shared.h \
111 generate-id.h \
112- generate-id.c
113+ generate-id.c \
114+ gen-notification-item.xml.h \
115+ gen-notification-item.xml.c \
116+ gen-notification-watcher.xml.h \
117+ gen-notification-watcher.xml.c
118
119 libappindicator_la_LDFLAGS = \
120 -version-info 1:0:0 \
121@@ -99,25 +99,27 @@
122 notification-item.xml \
123 notification-watcher.xml
124
125-%-client.h: %.xml
126- dbus-binding-tool \
127- --prefix=_$(notdir $(subst -,_,$(<:.xml=)))_client \
128- --mode=glib-client \
129- --output=$@ \
130- $<
131+gen-%.xml.h: %.xml
132+ @echo "Building $@ from $<"
133+ @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@
134
135-%-server.h: %.xml
136- dbus-binding-tool \
137- --prefix=_$(notdir $(subst -,_,$(<:.xml=)))_server \
138- --mode=glib-server \
139- --output=$@ \
140- $<
141+gen-%.xml.c: %.xml
142+ @echo "Building $@ from $<"
143+ @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@
144+ @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@
145+ @echo ";" >> $@
146
147 BUILT_SOURCES += \
148- $(DBUS_SPECS:.xml=-client.h) \
149- $(DBUS_SPECS:.xml=-server.h)
150+ gen-notification-item.xml.c \
151+ gen-notification-item.xml.h \
152+ gen-notification-watcher.xml.c \
153+ gen-notification-watcher.xml.h
154
155-CLEANFILES += $(BUILT_SOURCES)
156+CLEANFILES += \
157+ gen-notification-item.xml.c \
158+ gen-notification-item.xml.h \
159+ gen-notification-watcher.xml.c \
160+ gen-notification-watcher.xml.h
161
162 EXTRA_DIST += $(DBUS_SPECS)
163
164
165=== modified file 'src/app-indicator.c'
166--- src/app-indicator.c 2010-12-04 04:02:03 +0000
167+++ src/app-indicator.c 2010-12-08 20:52:11 +0000
168@@ -31,16 +31,9 @@
169 #include "config.h"
170 #endif
171
172-#include <dbus/dbus-glib.h>
173-#include <dbus/dbus-glib-bindings.h>
174-
175 #include <libdbusmenu-glib/menuitem.h>
176 #include <libdbusmenu-glib/server.h>
177-#ifdef HAVE_GTK3
178-#include <libdbusmenu-gtk3/client.h>
179-#else
180 #include <libdbusmenu-gtk/client.h>
181-#endif
182
183 #include <libindicator/indicator-desktop-shortcuts.h>
184
185@@ -48,8 +41,8 @@
186 #include "app-indicator-enum-types.h"
187 #include "application-service-marshal.h"
188
189-#include "notification-item-server.h"
190-#include "notification-watcher-client.h"
191+#include "gen-notification-watcher.xml.h"
192+#include "gen-notification-item.xml.h"
193
194 #include "dbus-shared.h"
195 #include "generate-id.h"
196@@ -92,9 +85,10 @@
197 gint fallback_timer;
198
199 /* Fun stuff */
200- DBusGProxy *watcher_proxy;
201- DBusGConnection *connection;
202- DBusGProxy * dbus_proxy;
203+ GDBusProxy *watcher_proxy;
204+ GDBusConnection *connection;
205+ guint dbus_registration;
206+ gchar * path;
207
208 /* Might be used */
209 IndicatorDesktopShortcuts * shorties;
210@@ -106,7 +100,6 @@
211 NEW_ATTENTION_ICON,
212 NEW_STATUS,
213 NEW_LABEL,
214- X_NEW_LABEL,
215 CONNECTION_CHANGED,
216 NEW_ICON_THEME_PATH,
217 LAST_SIGNAL
218@@ -124,14 +117,10 @@
219 PROP_ICON_NAME,
220 PROP_ATTENTION_ICON_NAME,
221 PROP_ICON_THEME_PATH,
222- PROP_MENU,
223 PROP_CONNECTED,
224 PROP_LABEL,
225 PROP_LABEL_GUIDE,
226- PROP_X_LABEL,
227- PROP_X_LABEL_GUIDE,
228 PROP_ORDERING_INDEX,
229- PROP_X_ORDERING_INDEX,
230 PROP_DBUS_MENU_SERVER
231 };
232
233@@ -142,29 +131,28 @@
234 #define PROP_ICON_NAME_S "icon-name"
235 #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name"
236 #define PROP_ICON_THEME_PATH_S "icon-theme-path"
237-#define PROP_MENU_S "menu"
238 #define PROP_CONNECTED_S "connected"
239 #define PROP_LABEL_S "label"
240 #define PROP_LABEL_GUIDE_S "label-guide"
241-#define PROP_X_LABEL_S ("x-ayatana-" PROP_LABEL_S)
242-#define PROP_X_LABEL_GUIDE_S ("x-ayatana-" PROP_LABEL_GUIDE_S)
243 #define PROP_ORDERING_INDEX_S "ordering-index"
244-#define PROP_X_ORDERING_INDEX_S ("x-ayatana-" PROP_ORDERING_INDEX_S)
245 #define PROP_DBUS_MENU_SERVER_S "dbus-menu-server"
246
247 /* Private macro, shhhh! */
248 #define APP_INDICATOR_GET_PRIVATE(o) \
249 (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_INDICATOR_TYPE, AppIndicatorPrivate))
250
251-/* Signal wrapper */
252-#define APP_INDICATOR_SIGNAL_X_NEW_LABEL ("x-ayatana-" APP_INDICATOR_SIGNAL_NEW_LABEL)
253-
254 /* Default Path */
255 #define DEFAULT_ITEM_PATH "/org/ayatana/NotificationItem"
256
257 /* More constants */
258 #define DEFAULT_FALLBACK_TIMER 100 /* in milliseconds */
259
260+/* Globals */
261+static GDBusNodeInfo * item_node_info = NULL;
262+static GDBusInterfaceInfo * item_interface_info = NULL;
263+static GDBusNodeInfo * watcher_node_info = NULL;
264+static GDBusInterfaceInfo * watcher_interface_info = NULL;
265+
266 /* Boiler plate */
267 static void app_indicator_class_init (AppIndicatorClass *klass);
268 static void app_indicator_init (AppIndicator *self);
269@@ -176,7 +164,7 @@
270 /* Other stuff */
271 static void signal_label_change (AppIndicator * self);
272 static void check_connect (AppIndicator * self);
273-static void register_service_cb (DBusGProxy * proxy, GError * error, gpointer data);
274+static void register_service_cb (GObject * obj, GAsyncResult * res, gpointer user_data);
275 static void start_fallback_timer (AppIndicator * self, gboolean disable_timeout);
276 static gboolean fallback_timer_expire (gpointer data);
277 static GtkStatusIcon * fallback (AppIndicator * self);
278@@ -185,11 +173,19 @@
279 static void status_icon_activate (GtkStatusIcon * icon, gpointer data);
280 static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon);
281 static gchar * append_panel_icon_suffix (const gchar * icon_name);
282-static void watcher_proxy_destroyed (GObject * object, gpointer data);
283+static void watcher_owner_changed (GObject * obj, GParamSpec * pspec, gpointer user_data);
284 static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator);
285 static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data);
286-
287 static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data);
288+static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data);
289+static void bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data);
290+static void bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data);
291+
292+static const GDBusInterfaceVTable item_interface_table = {
293+ method_call: NULL, /* No methods on this object */
294+ get_property: bus_get_prop,
295+ set_property: NULL /* No properties that can be set */
296+};
297
298 /* GObject type */
299 G_DEFINE_TYPE (AppIndicator, app_indicator, G_TYPE_OBJECT);
300@@ -298,19 +294,6 @@
301 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
302
303 /**
304- AppIndicator:menu:
305-
306- A method for getting the menu path as a string for DBus.
307- */
308- g_object_class_install_property(object_class,
309- PROP_MENU,
310- g_param_spec_boxed (PROP_MENU_S,
311- "The object path of the menu on DBus.",
312- "A method for getting the menu path as a string for DBus.",
313- DBUS_TYPE_G_OBJECT_PATH,
314- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
315-
316- /**
317 AppIndicator:connected:
318
319 Pretty simple, %TRUE if we have a reasonable expectation of being
320@@ -377,47 +360,7 @@
321 "A way to override the default ordering of the applications by providing a very specific idea of where this entry should be placed.",
322 0, G_MAXUINT32, 0,
323 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
324- /**
325- AppIndicator:x-ayatana-ordering-index:
326-
327- A wrapper for #AppIndicator:ordering-index so that it can match the
328- dbus interface currently. It will hopefully be retired, please don't
329- use it anywhere.
330- */
331- g_object_class_install_property(object_class,
332- PROP_X_ORDERING_INDEX,
333- g_param_spec_uint (PROP_X_ORDERING_INDEX_S,
334- "A wrapper, please don't use.",
335- "A wrapper, please don't use.",
336- 0, G_MAXUINT32, 0,
337- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
338-
339- /**
340- AppIndicator:x-ayatana-label:
341-
342- Wrapper for #AppIndicator:label. Please use that in all of your
343- code.
344- */
345- g_object_class_install_property(object_class,
346- PROP_X_LABEL,
347- g_param_spec_string (PROP_X_LABEL_S,
348- "A wrapper, please don't use.",
349- "A wrapper, please don't use.",
350- NULL,
351- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
352- /**
353- AppIndicator:x-ayatana-label-guide:
354-
355- Wrapper for #AppIndicator:label-guide. Please use that in all of your
356- code.
357- */
358- g_object_class_install_property(object_class,
359- PROP_X_LABEL_GUIDE,
360- g_param_spec_string (PROP_X_LABEL_GUIDE_S,
361- "A wrapper, please don't use.",
362- "A wrapper, please don't use.",
363- NULL,
364- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
365+
366 /**
367 AppIndicator:dbus-menu-server:
368
369@@ -495,22 +438,6 @@
370 _application_service_marshal_VOID__STRING_STRING,
371 G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
372
373- /**
374- AppIndicator::x-ayatana-new-label:
375- @arg0: The #AppIndicator object
376- @arg1: The string for the label
377- @arg1: The string for the guide
378-
379- Wrapper for #AppIndicator::new-label, please don't use this signal
380- use the other one.
381- */
382- signals[X_NEW_LABEL] = g_signal_new (APP_INDICATOR_SIGNAL_X_NEW_LABEL,
383- G_TYPE_FROM_CLASS(klass),
384- G_SIGNAL_RUN_LAST,
385- G_STRUCT_OFFSET (AppIndicatorClass, new_label),
386- NULL, NULL,
387- _application_service_marshal_VOID__STRING_STRING,
388- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
389
390 /**
391 AppIndicator::connection-changed:
392@@ -542,9 +469,42 @@
393 g_cclosure_marshal_VOID__STRING,
394 G_TYPE_NONE, 1, G_TYPE_STRING);
395
396- /* Initialize the object as a DBus type */
397- dbus_g_object_type_install_info(APP_INDICATOR_TYPE,
398- &dbus_glib__notification_item_server_object_info);
399+ /* DBus interfaces */
400+ if (item_node_info == NULL) {
401+ GError * error = NULL;
402+
403+ item_node_info = g_dbus_node_info_new_for_xml(_notification_item, &error);
404+ if (error != NULL) {
405+ g_error("Unable to parse Notification Item DBus interface: %s", error->message);
406+ g_error_free(error);
407+ }
408+ }
409+
410+ if (item_interface_info == NULL && item_node_info != NULL) {
411+ item_interface_info = g_dbus_node_info_lookup_interface(item_node_info, NOTIFICATION_ITEM_DBUS_IFACE);
412+
413+ if (item_interface_info == NULL) {
414+ g_error("Unable to find interface '" NOTIFICATION_ITEM_DBUS_IFACE "'");
415+ }
416+ }
417+
418+ if (watcher_node_info == NULL) {
419+ GError * error = NULL;
420+
421+ watcher_node_info = g_dbus_node_info_new_for_xml(_notification_watcher, &error);
422+ if (error != NULL) {
423+ g_error("Unable to parse Notification Item DBus interface: %s", error->message);
424+ g_error_free(error);
425+ }
426+ }
427+
428+ if (watcher_interface_info == NULL && watcher_node_info != NULL) {
429+ watcher_interface_info = g_dbus_node_info_lookup_interface(watcher_node_info, NOTIFICATION_WATCHER_DBUS_IFACE);
430+
431+ if (watcher_interface_info == NULL) {
432+ g_error("Unable to find interface '" NOTIFICATION_WATCHER_DBUS_IFACE "'");
433+ }
434+ }
435
436 return;
437 }
438@@ -570,22 +530,17 @@
439
440 priv->watcher_proxy = NULL;
441 priv->connection = NULL;
442- priv->dbus_proxy = NULL;
443+ priv->dbus_registration = 0;
444+ priv->path = NULL;
445
446 priv->status_icon = NULL;
447 priv->fallback_timer = 0;
448
449 priv->shorties = NULL;
450
451- /* Put the object on DBus */
452- GError * error = NULL;
453- priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
454- if (error != NULL) {
455- g_error("Unable to connect to the session bus when creating application indicator: %s", error->message);
456- g_error_free(error);
457- return;
458- }
459- dbus_g_connection_ref(priv->connection);
460+ /* Start getting the session bus */
461+ g_object_ref(self); /* ref for the bus creation callback */
462+ g_bus_get(G_BUS_TYPE_SESSION, NULL, bus_creation, self);
463
464 g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()),
465 "changed", G_CALLBACK(theme_changed_cb), self);
466@@ -603,6 +558,11 @@
467 AppIndicator *self = APP_INDICATOR (object);
468 AppIndicatorPrivate *priv = self->priv;
469
470+ if (priv->dbus_registration != 0) {
471+ g_dbus_connection_unregister_object(priv->connection, priv->dbus_registration);
472+ priv->dbus_registration = 0;
473+ }
474+
475 if (priv->shorties != NULL) {
476 g_object_unref(G_OBJECT(priv->shorties));
477 priv->shorties = NULL;
478@@ -638,18 +598,12 @@
479 priv->menu = NULL;
480 }
481
482- if (priv->menuservice != NULL) {
483- g_object_unref (priv->menuservice);
484- }
485-
486- if (priv->dbus_proxy != NULL) {
487- g_object_unref(G_OBJECT(priv->dbus_proxy));
488- priv->dbus_proxy = NULL;
489+ if (priv->menuservice != NULL) {
490+ g_object_unref (priv->menuservice);
491 }
492
493 if (priv->watcher_proxy != NULL) {
494- dbus_g_connection_flush(priv->connection);
495- g_signal_handlers_disconnect_by_func(G_OBJECT(priv->watcher_proxy), watcher_proxy_destroyed, self);
496+ g_signal_handlers_disconnect_by_func(G_OBJECT(priv->watcher_proxy), watcher_owner_changed, self);
497 g_object_unref(G_OBJECT(priv->watcher_proxy));
498 priv->watcher_proxy = NULL;
499
500@@ -658,7 +612,7 @@
501 }
502
503 if (priv->connection != NULL) {
504- dbus_g_connection_unref(priv->connection);
505+ g_object_unref(G_OBJECT(priv->connection));
506 priv->connection = NULL;
507 }
508
509@@ -671,8 +625,8 @@
510 static void
511 app_indicator_finalize (GObject *object)
512 {
513- AppIndicator * self = APP_INDICATOR(object);
514- AppIndicatorPrivate *priv = self->priv;
515+ AppIndicator * self = APP_INDICATOR(object);
516+ AppIndicatorPrivate *priv = self->priv;
517
518 if (priv->status != APP_INDICATOR_STATUS_PASSIVE) {
519 g_warning("Finalizing Application Status with the status set to: %d", priv->status);
520@@ -713,6 +667,11 @@
521 priv->label_guide = NULL;
522 }
523
524+ if (priv->path != NULL) {
525+ g_free(priv->path);
526+ priv->path = NULL;
527+ }
528+
529 G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object);
530 return;
531 }
532@@ -783,7 +742,6 @@
533 check_connect (self);
534 break;
535
536- case PROP_X_LABEL:
537 case PROP_LABEL: {
538 gchar * oldlabel = priv->label;
539 priv->label = g_value_dup_string(value);
540@@ -802,7 +760,6 @@
541 }
542 break;
543 }
544- case PROP_X_LABEL_GUIDE:
545 case PROP_LABEL_GUIDE: {
546 gchar * oldguide = priv->label_guide;
547 priv->label_guide = g_value_dup_string(value);
548@@ -821,7 +778,6 @@
549 }
550 break;
551 }
552- case PROP_X_ORDERING_INDEX:
553 case PROP_ORDERING_INDEX:
554 priv->ordering_index = g_value_get_uint(value);
555 break;
556@@ -877,31 +833,29 @@
557 g_value_set_string (value, priv->icon_theme_path);
558 break;
559
560- case PROP_MENU:
561- if (priv->menuservice != NULL) {
562- GValue strval = { 0 };
563- g_value_init(&strval, G_TYPE_STRING);
564- g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval);
565- g_value_set_boxed(value, g_value_get_string(&strval));
566- g_value_unset(&strval);
567- }
568- break;
569-
570- case PROP_CONNECTED:
571- g_value_set_boolean (value, priv->watcher_proxy != NULL ? TRUE : FALSE);
572- break;
573-
574- case PROP_X_LABEL:
575+ case PROP_CONNECTED: {
576+ gboolean connected = FALSE;
577+
578+ if (priv->watcher_proxy != NULL) {
579+ gchar * name = g_dbus_proxy_get_name_owner(priv->watcher_proxy);
580+ if (name != NULL) {
581+ connected = TRUE;
582+ g_free(name);
583+ }
584+ }
585+
586+ g_value_set_boolean (value, connected);
587+ break;
588+ }
589+
590 case PROP_LABEL:
591 g_value_set_string (value, priv->label);
592 break;
593
594- case PROP_X_LABEL_GUIDE:
595 case PROP_LABEL_GUIDE:
596 g_value_set_string (value, priv->label_guide);
597 break;
598
599- case PROP_X_ORDERING_INDEX:
600 case PROP_ORDERING_INDEX:
601 g_value_set_uint(value, priv->ordering_index);
602 break;
603@@ -918,6 +872,81 @@
604 return;
605 }
606
607+/* DBus bus has been created, well maybe, but we got a call
608+ back about it so we need to check into it. */
609+static void
610+bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data)
611+{
612+ GError * error = NULL;
613+
614+ GDBusConnection * connection = g_bus_get_finish(res, &error);
615+ if (error != NULL) {
616+ g_warning("Unable to get the session bus: %s", error->message);
617+ g_error_free(error);
618+ g_object_unref(G_OBJECT(user_data));
619+ return;
620+ }
621+
622+ AppIndicator * app = APP_INDICATOR(user_data);
623+ app->priv->connection = connection;
624+
625+ /* If the connection was blocking the exporting of the
626+ object this function will export everything. */
627+ check_connect(app);
628+
629+ g_object_unref(G_OBJECT(app));
630+
631+ return;
632+}
633+
634+/* DBus is asking for a property so we should figure out what it
635+ wants and try and deliver. */
636+static GVariant *
637+bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data)
638+{
639+ g_return_val_if_fail(IS_APP_INDICATOR(user_data), NULL);
640+ AppIndicator * app = APP_INDICATOR(user_data);
641+ AppIndicatorPrivate *priv = app->priv;
642+
643+ if (g_strcmp0(property, "Id") == 0) {
644+ return g_variant_new_string(app->priv->id);
645+ } else if (g_strcmp0(property, "Category") == 0) {
646+ GEnumValue *enum_value;
647+ enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY), priv->category);
648+ return g_variant_new_string(enum_value->value_nick);
649+ } else if (g_strcmp0(property, "Status") == 0) {
650+ GEnumValue *enum_value;
651+ enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), priv->status);
652+ return g_variant_new_string(enum_value->value_nick);
653+ } else if (g_strcmp0(property, "IconName") == 0) {
654+ return g_variant_new_string(priv->icon_name);
655+ } else if (g_strcmp0(property, "AttentionIconName") == 0) {
656+ return g_variant_new_string(priv->attention_icon_name);
657+ } else if (g_strcmp0(property, "IconThemePath") == 0) {
658+ return g_variant_new_string(priv->icon_theme_path);
659+ } else if (g_strcmp0(property, "Menu") == 0) {
660+ if (priv->menuservice != NULL) {
661+ GValue strval = { 0 };
662+ g_value_init(&strval, G_TYPE_STRING);
663+ g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval);
664+ GVariant * var = g_variant_new("o", g_value_get_string(&strval));
665+ g_value_unset(&strval);
666+ return var;
667+ } else {
668+ return g_variant_new("o", "/");
669+ }
670+ } else if (g_strcmp0(property, "XAyatanaLabel") == 0) {
671+ return g_variant_new_string(priv->label);
672+ } else if (g_strcmp0(property, "XAyatanaLabelGuide") == 0) {
673+ return g_variant_new_string(priv->label_guide);
674+ } else if (g_strcmp0(property, "XAyatanaOrderingIndex") == 0) {
675+ return g_variant_new_uint32(priv->ordering_index);
676+ }
677+
678+ *error = g_error_new(0, 0, "Unknown property: %s", property);
679+ return NULL;
680+}
681+
682 /* Sends the label changed signal and resets the source ID */
683 static gboolean
684 signal_label_change_idle (gpointer user_data)
685@@ -925,14 +954,27 @@
686 AppIndicator * self = (AppIndicator *)user_data;
687 AppIndicatorPrivate *priv = self->priv;
688
689+ gchar * label = priv->label != NULL ? priv->label : "";
690+ gchar * guide = priv->label_guide != NULL ? priv->label_guide : "";
691+
692 g_signal_emit(G_OBJECT(self), signals[NEW_LABEL], 0,
693- priv->label != NULL ? priv->label : "",
694- priv->label_guide != NULL ? priv->label_guide : "",
695- TRUE);
696- g_signal_emit(G_OBJECT(self), signals[X_NEW_LABEL], 0,
697- priv->label != NULL ? priv->label : "",
698- priv->label_guide != NULL ? priv->label_guide : "",
699- TRUE);
700+ label, guide, TRUE);
701+ if (priv->dbus_registration != 0 && priv->connection != NULL) {
702+ GError * error = NULL;
703+
704+ g_dbus_connection_emit_signal(priv->connection,
705+ NULL,
706+ priv->path,
707+ NOTIFICATION_ITEM_DBUS_IFACE,
708+ "XAyatanaNewLabel",
709+ g_variant_new("(ss)", label, guide),
710+ &error);
711+
712+ if (error != NULL) {
713+ g_warning("Unable to send signal for NewIcon: %s", error->message);
714+ g_error_free(error);
715+ }
716+ }
717
718 priv->label_change_idle = 0;
719
720@@ -963,93 +1005,197 @@
721 {
722 AppIndicatorPrivate *priv = self->priv;
723
724- /* We're alreadying connecting or trying to connect. */
725- if (priv->watcher_proxy != NULL) return;
726+ /* Do we have a connection? */
727+ if (priv->connection == NULL) return;
728+
729+ /* If we already have a proxy, let's see if it has someone
730+ implementing it. If not, we can't do much more than to
731+ do nothing. */
732+ if (priv->watcher_proxy != NULL) {
733+ gchar * name = g_dbus_proxy_get_name_owner(priv->watcher_proxy);
734+ if (name == NULL) {
735+ return;
736+ }
737+ g_free(name);
738+ }
739
740 /* Do we have enough information? */
741 if (priv->menu == NULL) return;
742 if (priv->icon_name == NULL) return;
743 if (priv->id == NULL) return;
744
745- gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->clean_id);
746-
747- dbus_g_connection_register_g_object(priv->connection,
748- path,
749- G_OBJECT(self));
750-
751+ if (priv->path == NULL) {
752+ priv->path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->clean_id);
753+ }
754+
755+ if (priv->dbus_registration == 0) {
756+ GError * error = NULL;
757+ priv->dbus_registration = g_dbus_connection_register_object(priv->connection,
758+ priv->path,
759+ item_interface_info,
760+ &item_interface_table,
761+ self,
762+ NULL,
763+ &error);
764+ if (error != NULL) {
765+ g_warning("Unable to register object on path '%s': %s", priv->path, error->message);
766+ g_error_free(error);
767+ return;
768+ }
769+ }
770+
771+ /* NOTE: It's really important the order here. We make sure to *publish*
772+ the object on the bus and *then* get the proxy. The reason is that we
773+ want to ensure all the filters are setup before talking to the watcher
774+ and that's where the order is important. */
775+
776+ g_object_ref(G_OBJECT(self)); /* Unref in watcher_ready() */
777+ if (priv->watcher_proxy == NULL) {
778+ /* Build Watcher Proxy */
779+ g_dbus_proxy_new(priv->connection,
780+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, /* We don't use these, don't bother with them */
781+ watcher_interface_info,
782+ NOTIFICATION_WATCHER_DBUS_ADDR,
783+ NOTIFICATION_WATCHER_DBUS_OBJ,
784+ NOTIFICATION_WATCHER_DBUS_IFACE,
785+ NULL, /* cancellable */
786+ bus_watcher_ready,
787+ self);
788+ } else {
789+ bus_watcher_ready(NULL, NULL, self);
790+ }
791+
792+ return;
793+}
794+
795+/* Callback for when the watcher proxy has been created, or not
796+ but we got called none-the-less. */
797+static void
798+bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data)
799+{
800 GError * error = NULL;
801- priv->watcher_proxy = dbus_g_proxy_new_for_name_owner(priv->connection,
802- NOTIFICATION_WATCHER_DBUS_ADDR,
803- NOTIFICATION_WATCHER_DBUS_OBJ,
804- NOTIFICATION_WATCHER_DBUS_IFACE,
805- &error);
806+
807+ GDBusProxy * proxy = NULL;
808+ if (res != NULL) {
809+ proxy = g_dbus_proxy_new_finish(res, &error);
810+ }
811+
812 if (error != NULL) {
813 /* Unable to get proxy, but we're handling that now so
814 it's not a warning anymore. */
815 g_error_free(error);
816- dbus_g_connection_unregister_g_object(priv->connection,
817- G_OBJECT(self));
818+
819+ if (IS_APP_INDICATOR(user_data)) {
820+ start_fallback_timer(APP_INDICATOR(user_data), FALSE);
821+ }
822+
823+ g_object_unref(G_OBJECT(user_data));
824+ return;
825+ }
826+
827+ AppIndicator * app = APP_INDICATOR(user_data);
828+
829+ if (res != NULL) {
830+ app->priv->watcher_proxy = proxy;
831+
832+ /* Setting up a signal to watch when the unique name
833+ changes */
834+ g_signal_connect(G_OBJECT(app->priv->watcher_proxy), "notify::g-name-owner", G_CALLBACK(watcher_owner_changed), user_data);
835+ }
836+
837+ /* Let's insure that someone is on the other side, else we're
838+ still in a fallback scenario. */
839+ gchar * name = g_dbus_proxy_get_name_owner(app->priv->watcher_proxy);
840+ if (name == NULL) {
841+ start_fallback_timer(APP_INDICATOR(user_data), FALSE);
842+ g_object_unref(G_OBJECT(user_data));
843+ return;
844+ }
845+
846+ /* g_object_unref(G_OBJECT(user_data)); */
847+ /* Why is this commented out? Oh, wait, we don't want to
848+ unref in this case because we need to ref again to do the
849+ register callback. Let's not unref to ref again. */
850+
851+ g_dbus_proxy_call(app->priv->watcher_proxy,
852+ "RegisterStatusNotifierItem",
853+ g_variant_new("(s)", app->priv->path),
854+ G_DBUS_CALL_FLAGS_NONE,
855+ -1,
856+ NULL, /* cancelable */
857+ register_service_cb,
858+ user_data);
859+
860+ return;
861+}
862+
863+/* Watching for when the name owner changes on the interface
864+ to know whether we should be connected or not. */
865+static void
866+watcher_owner_changed (GObject * obj, GParamSpec * pspec, gpointer user_data)
867+{
868+ AppIndicator * self = APP_INDICATOR(user_data);
869+ g_return_if_fail(self != NULL);
870+ g_return_if_fail(self->priv->watcher_proxy != NULL);
871+
872+ gchar * name = g_dbus_proxy_get_name_owner(self->priv->watcher_proxy);
873+
874+ if (name == NULL) {
875+ /* Emit the AppIndicator::connection-changed signal*/
876+ g_signal_emit (self, signals[CONNECTION_CHANGED], 0, FALSE);
877+
878 start_fallback_timer(self, FALSE);
879- g_free(path);
880- return;
881+ } else {
882+ if (self->priv->fallback_timer != 0) {
883+ /* Stop the timer */
884+ g_source_remove(self->priv->fallback_timer);
885+ self->priv->fallback_timer = 0;
886+ }
887+
888+ check_connect(self);
889 }
890
891- g_signal_connect(G_OBJECT(priv->watcher_proxy), "destroy", G_CALLBACK(watcher_proxy_destroyed), self);
892- org_kde_StatusNotifierWatcher_register_status_notifier_item_async(priv->watcher_proxy, path, register_service_cb, self);
893- g_free(path);
894-
895- /* Emit the AppIndicator::connection-changed signal*/
896- g_signal_emit (self, signals[CONNECTION_CHANGED], 0, TRUE);
897-
898- return;
899-}
900-
901-/* A function that gets called when the watcher dies. Like
902- dies dies. Not our friend anymore. */
903-static void
904-watcher_proxy_destroyed (GObject * object, gpointer data)
905-{
906- AppIndicator * self = APP_INDICATOR(data);
907- g_return_if_fail(self != NULL);
908-
909- dbus_g_connection_unregister_g_object(self->priv->connection,
910- G_OBJECT(self));
911- self->priv->watcher_proxy = NULL;
912-
913- /* Emit the AppIndicator::connection-changed signal*/
914- g_signal_emit (self, signals[CONNECTION_CHANGED], 0, FALSE);
915-
916- start_fallback_timer(self, FALSE);
917 return;
918 }
919
920 /* Responce from the DBus command to register a service
921 with a NotificationWatcher. */
922 static void
923-register_service_cb (DBusGProxy * proxy, GError * error, gpointer data)
924+register_service_cb (GObject * obj, GAsyncResult * res, gpointer user_data)
925 {
926- g_return_if_fail(IS_APP_INDICATOR(data));
927- AppIndicatorPrivate * priv = APP_INDICATOR(data)->priv;
928+ GError * error = NULL;
929+ GVariant * returns = g_dbus_proxy_call_finish(G_DBUS_PROXY(obj), res, &error);
930+
931+ /* We don't care about any return values */
932+ if (returns != NULL) {
933+ g_variant_unref(returns);
934+ }
935
936 if (error != NULL) {
937 /* They didn't respond, ewww. Not sure what they could
938 be doing */
939 g_warning("Unable to connect to the Notification Watcher: %s", error->message);
940- dbus_g_connection_unregister_g_object(priv->connection,
941- G_OBJECT(data));
942- g_object_unref(G_OBJECT(priv->watcher_proxy));
943- priv->watcher_proxy = NULL;
944- start_fallback_timer(APP_INDICATOR(data), TRUE);
945+ start_fallback_timer(APP_INDICATOR(user_data), TRUE);
946+ g_object_unref(G_OBJECT(user_data));
947+ return;
948 }
949
950+ g_return_if_fail(IS_APP_INDICATOR(user_data));
951+ AppIndicator * app = APP_INDICATOR(user_data);
952+ AppIndicatorPrivate * priv = app->priv;
953+
954+ /* Emit the AppIndicator::connection-changed signal*/
955+ g_signal_emit (app, signals[CONNECTION_CHANGED], 0, TRUE);
956+
957 if (priv->status_icon) {
958- AppIndicatorClass * class = APP_INDICATOR_GET_CLASS(data);
959+ AppIndicatorClass * class = APP_INDICATOR_GET_CLASS(app);
960 if (class->unfallback != NULL) {
961- class->unfallback(APP_INDICATOR(data), priv->status_icon);
962+ class->unfallback(app, priv->status_icon);
963 priv->status_icon = NULL;
964 }
965 }
966
967+ g_object_unref(G_OBJECT(user_data));
968 return;
969 }
970
971@@ -1064,89 +1210,6 @@
972 return value->value_nick;
973 }
974
975-/* Watching the dbus owner change events to see if someone
976- we care about pops up! */
977-static void
978-dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, gpointer data)
979-{
980- if (new == NULL || new[0] == '\0') {
981- /* We only care about folks coming on the bus. Exit quickly otherwise. */
982- return;
983- }
984-
985- if (g_strcmp0(name, NOTIFICATION_WATCHER_DBUS_ADDR)) {
986- /* We only care about this address, reject all others. */
987- return;
988- }
989-
990- /* Woot, there's a new notification watcher in town. */
991-
992- AppIndicatorPrivate * priv = APP_INDICATOR_GET_PRIVATE(data);
993-
994- if (priv->fallback_timer != 0) {
995- /* Stop a timer */
996- g_source_remove(priv->fallback_timer);
997-
998- /* Stop listening to bus events */
999- g_object_unref(G_OBJECT(priv->dbus_proxy));
1000- priv->dbus_proxy = NULL;
1001- }
1002-
1003- /* Let's start from the very beginning */
1004- check_connect(APP_INDICATOR(data));
1005-
1006- return;
1007-}
1008-
1009-/* Checking to see if someone already has the name we're looking for */
1010-static void
1011-check_owner_cb (DBusGProxy *proxy, gboolean exists, GError *error, gpointer userdata)
1012-{
1013- if (error != NULL) {
1014- g_warning("Unable to check for '" NOTIFICATION_WATCHER_DBUS_ADDR "' on DBus. No worries, but concerning.");
1015- return;
1016- }
1017-
1018- if (exists) {
1019- g_debug("Woah, we actually has a race condition with dbus");
1020- dbus_owner_change(proxy, NOTIFICATION_WATCHER_DBUS_ADDR, NULL, "Non NULL", userdata);
1021- }
1022-
1023- return;
1024-}
1025-
1026-/* This is an idle function to create the proxy. This is mostly
1027- because start_fallback_timer can get called in the distruction
1028- of a proxy and thus the proxy manager gets confused when creating
1029- a new proxy as part of destroying an old one. This function being
1030- on idle means that we'll just do it outside of the same stack where
1031- the previous proxy is being destroyed. */
1032-static gboolean
1033-setup_name_owner_proxy (gpointer data)
1034-{
1035- g_return_val_if_fail(IS_APP_INDICATOR(data), FALSE);
1036- AppIndicatorPrivate * priv = APP_INDICATOR(data)->priv;
1037-
1038- if (priv->dbus_proxy == NULL) {
1039- priv->dbus_proxy = dbus_g_proxy_new_for_name(priv->connection,
1040- DBUS_SERVICE_DBUS,
1041- DBUS_PATH_DBUS,
1042- DBUS_INTERFACE_DBUS);
1043- dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged",
1044- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
1045- G_TYPE_INVALID);
1046- dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged",
1047- G_CALLBACK(dbus_owner_change), data, NULL);
1048-
1049- /* Check to see if anyone has the name we're looking for
1050- just incase we missed it changing. */
1051-
1052- org_freedesktop_DBus_name_has_owner_async(priv->dbus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, check_owner_cb, data);
1053- }
1054-
1055- return FALSE;
1056-}
1057-
1058 /* A function that will start the fallback timer if it's not
1059 already started. It sets up the DBus watcher to see if
1060 there is a change. Also, provides an override mode for cases
1061@@ -1168,11 +1231,6 @@
1062 return;
1063 }
1064
1065- if (priv->dbus_proxy == NULL) {
1066- /* NOTE: Read the comment on setup_name_owner_proxy */
1067- g_idle_add(setup_name_owner_proxy, self);
1068- }
1069-
1070 if (disable_timeout) {
1071 fallback_timer_expire(self);
1072 } else {
1073@@ -1214,6 +1272,28 @@
1074 theme_changed_cb (GtkIconTheme * theme, gpointer user_data)
1075 {
1076 g_signal_emit (user_data, signals[NEW_ICON], 0, TRUE);
1077+
1078+ AppIndicator * self = (AppIndicator *)user_data;
1079+ AppIndicatorPrivate *priv = self->priv;
1080+
1081+ if (priv->dbus_registration != 0 && priv->connection != NULL) {
1082+ GError * error = NULL;
1083+
1084+ g_dbus_connection_emit_signal(priv->connection,
1085+ NULL,
1086+ priv->path,
1087+ NOTIFICATION_ITEM_DBUS_IFACE,
1088+ "NewIcon",
1089+ NULL,
1090+ &error);
1091+
1092+ if (error != NULL) {
1093+ g_warning("Unable to send signal for NewIcon: %s", error->message);
1094+ g_error_free(error);
1095+ }
1096+ }
1097+
1098+ return;
1099 }
1100
1101 /* Creates a StatusIcon that can be used when the application
1102@@ -1417,15 +1497,33 @@
1103 void
1104 app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status)
1105 {
1106- g_return_if_fail (IS_APP_INDICATOR (self));
1107-
1108- if (self->priv->status != status)
1109- {
1110- GEnumValue *value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), status);
1111-
1112- self->priv->status = status;
1113- g_signal_emit (self, signals[NEW_STATUS], 0, value->value_nick);
1114- }
1115+ g_return_if_fail (IS_APP_INDICATOR (self));
1116+
1117+ if (self->priv->status != status) {
1118+ GEnumValue *value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), status);
1119+
1120+ self->priv->status = status;
1121+ g_signal_emit (self, signals[NEW_STATUS], 0, value->value_nick);
1122+
1123+ if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) {
1124+ GError * error = NULL;
1125+
1126+ g_dbus_connection_emit_signal(self->priv->connection,
1127+ NULL,
1128+ self->priv->path,
1129+ NOTIFICATION_ITEM_DBUS_IFACE,
1130+ "NewStatus",
1131+ g_variant_new("(s)", value->value_nick),
1132+ &error);
1133+
1134+ if (error != NULL) {
1135+ g_warning("Unable to send signal for NewStatus: %s", error->message);
1136+ g_error_free(error);
1137+ }
1138+ }
1139+ }
1140+
1141+ return;
1142 }
1143
1144 /**
1145@@ -1438,20 +1536,36 @@
1146 void
1147 app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name)
1148 {
1149- g_return_if_fail (IS_APP_INDICATOR (self));
1150- g_return_if_fail (icon_name != NULL);
1151-
1152- if (g_strcmp0 (self->priv->attention_icon_name, icon_name) != 0)
1153- {
1154- if (self->priv->attention_icon_name)
1155- g_free (self->priv->attention_icon_name);
1156-
1157- self->priv->attention_icon_name = g_strdup(icon_name);
1158-
1159- g_signal_emit (self, signals[NEW_ATTENTION_ICON], 0, TRUE);
1160- }
1161-
1162- return;
1163+ g_return_if_fail (IS_APP_INDICATOR (self));
1164+ g_return_if_fail (icon_name != NULL);
1165+
1166+ if (g_strcmp0 (self->priv->attention_icon_name, icon_name) != 0) {
1167+ if (self->priv->attention_icon_name)
1168+ g_free (self->priv->attention_icon_name);
1169+
1170+ self->priv->attention_icon_name = g_strdup(icon_name);
1171+
1172+ g_signal_emit (self, signals[NEW_ATTENTION_ICON], 0, TRUE);
1173+
1174+ if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) {
1175+ GError * error = NULL;
1176+
1177+ g_dbus_connection_emit_signal(self->priv->connection,
1178+ NULL,
1179+ self->priv->path,
1180+ NOTIFICATION_ITEM_DBUS_IFACE,
1181+ "NewAttentionIcon",
1182+ NULL,
1183+ &error);
1184+
1185+ if (error != NULL) {
1186+ g_warning("Unable to send signal for NewAttentionIcon: %s", error->message);
1187+ g_error_free(error);
1188+ }
1189+ }
1190+ }
1191+
1192+ return;
1193 }
1194
1195 /**
1196@@ -1467,20 +1581,36 @@
1197 void
1198 app_indicator_set_icon (AppIndicator *self, const gchar *icon_name)
1199 {
1200- g_return_if_fail (IS_APP_INDICATOR (self));
1201- g_return_if_fail (icon_name != NULL);
1202-
1203- if (g_strcmp0 (self->priv->icon_name, icon_name) != 0)
1204- {
1205- if (self->priv->icon_name)
1206- g_free (self->priv->icon_name);
1207-
1208- self->priv->icon_name = g_strdup(icon_name);
1209-
1210- g_signal_emit (self, signals[NEW_ICON], 0, TRUE);
1211- }
1212-
1213- return;
1214+ g_return_if_fail (IS_APP_INDICATOR (self));
1215+ g_return_if_fail (icon_name != NULL);
1216+
1217+ if (g_strcmp0 (self->priv->icon_name, icon_name) != 0) {
1218+ if (self->priv->icon_name)
1219+ g_free (self->priv->icon_name);
1220+
1221+ self->priv->icon_name = g_strdup(icon_name);
1222+
1223+ g_signal_emit (self, signals[NEW_ICON], 0, TRUE);
1224+
1225+ if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) {
1226+ GError * error = NULL;
1227+
1228+ g_dbus_connection_emit_signal(self->priv->connection,
1229+ NULL,
1230+ self->priv->path,
1231+ NOTIFICATION_ITEM_DBUS_IFACE,
1232+ "NewIcon",
1233+ NULL,
1234+ &error);
1235+
1236+ if (error != NULL) {
1237+ g_warning("Unable to send signal for NewIcon: %s", error->message);
1238+ g_error_free(error);
1239+ }
1240+ }
1241+ }
1242+
1243+ return;
1244 }
1245
1246 /**
1247@@ -1518,19 +1648,35 @@
1248 void
1249 app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_path)
1250 {
1251- g_return_if_fail (IS_APP_INDICATOR (self));
1252-
1253- if (g_strcmp0 (self->priv->icon_theme_path, icon_theme_path) != 0)
1254- {
1255- if (self->priv->icon_theme_path != NULL)
1256- g_free(self->priv->icon_theme_path);
1257-
1258- self->priv->icon_theme_path = g_strdup(icon_theme_path);
1259-
1260- g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, g_strdup(self->priv->icon_theme_path));
1261- }
1262-
1263- return;
1264+ g_return_if_fail (IS_APP_INDICATOR (self));
1265+
1266+ if (g_strcmp0 (self->priv->icon_theme_path, icon_theme_path) != 0) {
1267+ if (self->priv->icon_theme_path != NULL)
1268+ g_free(self->priv->icon_theme_path);
1269+
1270+ self->priv->icon_theme_path = g_strdup(icon_theme_path);
1271+
1272+ g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, self->priv->icon_theme_path, TRUE);
1273+
1274+ if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) {
1275+ GError * error = NULL;
1276+
1277+ g_dbus_connection_emit_signal(self->priv->connection,
1278+ NULL,
1279+ self->priv->path,
1280+ NOTIFICATION_ITEM_DBUS_IFACE,
1281+ "NewIconThemePath",
1282+ g_variant_new("(s)", self->priv->icon_theme_path),
1283+ &error);
1284+
1285+ if (error != NULL) {
1286+ g_warning("Unable to send signal for NewIconThemePath: %s", error->message);
1287+ g_error_free(error);
1288+ }
1289+ }
1290+ }
1291+
1292+ return;
1293 }
1294
1295 static void
1296@@ -2150,7 +2296,7 @@
1297 g_return_val_if_fail (IS_APP_INDICATOR (self), 0);
1298
1299 if (self->priv->ordering_index == 0) {
1300- return generate_id(self->priv->category, self->priv->id);
1301+ return _generate_id(self->priv->category, self->priv->id);
1302 } else {
1303 return self->priv->ordering_index;
1304 }
1305
1306=== modified file 'src/generate-id.c'
1307--- src/generate-id.c 2010-08-11 20:35:08 +0000
1308+++ src/generate-id.c 2010-12-08 20:52:11 +0000
1309@@ -24,7 +24,7 @@
1310 #define MULTIPLIER 32
1311
1312 guint32
1313-generate_id (const AppIndicatorCategory catenum, const gchar * id)
1314+_generate_id (const AppIndicatorCategory catenum, const gchar * id)
1315 {
1316 guchar category = 0;
1317 guchar first = 0;
1318
1319=== modified file 'src/generate-id.h'
1320--- src/generate-id.h 2010-08-11 15:10:45 +0000
1321+++ src/generate-id.h 2010-12-08 20:52:11 +0000
1322@@ -25,6 +25,6 @@
1323 #include <glib.h>
1324 #include "app-indicator.h"
1325
1326-guint32 generate_id (const AppIndicatorCategory category, const gchar * id);
1327+guint32 _generate_id (const AppIndicatorCategory category, const gchar * id);
1328
1329 #endif /* __GENERATE_ID_H__ */
1330
1331=== modified file 'tests/Makefile.am'
1332--- tests/Makefile.am 2010-12-04 04:00:38 +0000
1333+++ tests/Makefile.am 2010-12-08 20:52:11 +0000
1334@@ -24,13 +24,13 @@
1335 test-libappindicator.c
1336
1337 test_libappindicator_CFLAGS = \
1338- $(LIBRARY_CFLAGS) \
1339+ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \
1340 -DSRCDIR="\"$(srcdir)\"" \
1341 -Wall -Werror \
1342 -I$(top_srcdir)/src
1343
1344 test_libappindicator_LDADD = \
1345- $(LIBRARY_LIBS) \
1346+ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
1347 $(top_builddir)/src/libappindicator.la
1348
1349 #########################################
1350@@ -42,12 +42,12 @@
1351 test-libappindicator-dbus-client.c
1352
1353 test_libappindicator_dbus_client_CFLAGS = \
1354- $(LIBRARY_CFLAGS) \
1355+ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \
1356 -Wall -Werror \
1357 -I$(top_srcdir)/src
1358
1359 test_libappindicator_dbus_client_LDADD = \
1360- $(LIBRARY_LIBS) \
1361+ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
1362 $(top_builddir)/src/libappindicator.la
1363
1364 #########################################
1365@@ -59,12 +59,12 @@
1366 test-libappindicator-dbus-server.c
1367
1368 test_libappindicator_dbus_server_CFLAGS = \
1369- $(LIBRARY_CFLAGS) \
1370+ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \
1371 -Wall -Werror \
1372 -I$(top_srcdir)/src
1373
1374 test_libappindicator_dbus_server_LDADD = \
1375- $(LIBRARY_LIBS) \
1376+ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
1377 $(top_builddir)/src/libappindicator.la
1378
1379 #########################################
1380@@ -76,12 +76,12 @@
1381 test-libappindicator-status-client.c
1382
1383 test_libappindicator_status_client_CFLAGS = \
1384- $(LIBRARY_CFLAGS) \
1385+ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \
1386 -Wall -Werror \
1387 -I$(top_srcdir)/src
1388
1389 test_libappindicator_status_client_LDADD = \
1390- $(LIBRARY_LIBS) \
1391+ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
1392 $(top_builddir)/src/libappindicator.la
1393
1394 #########################################
1395@@ -93,12 +93,12 @@
1396 test-libappindicator-status-server.c
1397
1398 test_libappindicator_status_server_CFLAGS = \
1399- $(LIBRARY_CFLAGS) \
1400+ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \
1401 -Wall -Werror \
1402 -I$(top_srcdir)/src
1403
1404 test_libappindicator_status_server_LDADD = \
1405- $(LIBRARY_LIBS) \
1406+ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
1407 $(top_builddir)/src/libappindicator.la
1408
1409 #########################################
1410@@ -109,24 +109,24 @@
1411 test-libappindicator-fallback-watcher.c
1412
1413 test_libappindicator_fallback_watcher_CFLAGS = \
1414- $(LIBRARY_CFLAGS) \
1415+ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \
1416 -Wall -Werror \
1417 -I$(top_srcdir)/src
1418
1419 test_libappindicator_fallback_watcher_LDADD = \
1420- $(LIBRARY_LIBS) \
1421+ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
1422 $(top_builddir)/src/libappindicator.la
1423
1424 test_libappindicator_fallback_item_SOURCES = \
1425 test-libappindicator-fallback-item.c
1426
1427 test_libappindicator_fallback_item_CFLAGS = \
1428- $(LIBRARY_CFLAGS) \
1429+ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \
1430 -Wall -Werror \
1431 -I$(top_srcdir)/src
1432
1433 test_libappindicator_fallback_item_LDADD = \
1434- $(LIBRARY_LIBS) \
1435+ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
1436 $(top_builddir)/src/libappindicator.la
1437
1438 test-libappindicator-fallback: test-libappindicator-fallback-watcher test-libappindicator-fallback-item Makefile.am
1439@@ -185,11 +185,11 @@
1440 test-simple-app.c
1441
1442 test_simple_app_CFLAGS = \
1443- $(LIBRARY_CFLAGS) \
1444+ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \
1445 -Wall -Werror \
1446 -I$(top_srcdir)/src
1447
1448 test_simple_app_LDADD = \
1449- $(LIBRARY_LIBS) \
1450+ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \
1451 $(top_builddir)/src/libappindicator.la
1452
1453
1454=== modified file 'tests/test-libappindicator-dbus-client.c'
1455--- tests/test-libappindicator-dbus-client.c 2010-04-29 16:31:36 +0000
1456+++ tests/test-libappindicator-dbus-client.c 2010-12-08 20:52:11 +0000
1457@@ -206,8 +206,6 @@
1458 {
1459 g_type_init();
1460
1461- g_usleep(500000);
1462-
1463 GError * error = NULL;
1464 DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
1465 if (error != NULL) {
1466@@ -230,8 +228,10 @@
1467
1468 dbus_connection_add_filter(dbus_g_connection_get_connection(session_bus), dbus_filter, NULL, NULL);
1469
1470+ g_usleep(500000);
1471+
1472 DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus,
1473- ":1.0",
1474+ ":1.2",
1475 "/org/ayatana/NotificationItem/my_id",
1476 DBUS_INTERFACE_PROPERTIES,
1477 &error);
1478@@ -244,35 +244,35 @@
1479 "Get",
1480 prop_id_cb,
1481 NULL, NULL,
1482- G_TYPE_STRING, "org.ayatana.indicator.application.NotificationItem",
1483+ G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE,
1484 G_TYPE_STRING, "Id",
1485 G_TYPE_INVALID);
1486 dbus_g_proxy_begin_call (props,
1487 "Get",
1488 prop_category_cb,
1489 NULL, NULL,
1490- G_TYPE_STRING, "org.ayatana.indicator.application.NotificationItem",
1491+ G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE,
1492 G_TYPE_STRING, "Category",
1493 G_TYPE_INVALID);
1494 dbus_g_proxy_begin_call (props,
1495 "Get",
1496 prop_status_cb,
1497 NULL, NULL,
1498- G_TYPE_STRING, "org.ayatana.indicator.application.NotificationItem",
1499+ G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE,
1500 G_TYPE_STRING, "Status",
1501 G_TYPE_INVALID);
1502 dbus_g_proxy_begin_call (props,
1503 "Get",
1504 prop_icon_name_cb,
1505 NULL, NULL,
1506- G_TYPE_STRING, "org.ayatana.indicator.application.NotificationItem",
1507+ G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE,
1508 G_TYPE_STRING, "IconName",
1509 G_TYPE_INVALID);
1510 dbus_g_proxy_begin_call (props,
1511 "Get",
1512 prop_attention_icon_name_cb,
1513 NULL, NULL,
1514- G_TYPE_STRING, "org.ayatana.indicator.application.NotificationItem",
1515+ G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE,
1516 G_TYPE_STRING, "AttentionIconName",
1517 G_TYPE_INVALID);
1518
1519
1520=== modified file 'tests/test-libappindicator-dbus-server.c'
1521--- tests/test-libappindicator-dbus-server.c 2010-04-29 16:31:36 +0000
1522+++ tests/test-libappindicator-dbus-server.c 2010-12-08 20:52:11 +0000
1523@@ -21,8 +21,6 @@
1524 */
1525
1526
1527-#include <dbus/dbus-glib.h>
1528-#include <dbus/dbus-glib-lowlevel.h>
1529 #include <gtk/gtk.h>
1530 #include <app-indicator.h>
1531 #include "test-defines.h"
1532@@ -41,8 +39,6 @@
1533 {
1534 gtk_init(&argc, &argv);
1535
1536- g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
1537-
1538 AppIndicator * ci = app_indicator_new (TEST_ID, TEST_ICON_NAME, TEST_CATEGORY);
1539
1540 app_indicator_set_status (ci, TEST_STATE);

Subscribers

People subscribed via source and target branches