Merge lp:~mterry/indicator-appmenu/gdbus into lp:indicator-appmenu/0.3
- gdbus
- Merge into trunk
Proposed by
Michael Terry
Status: | Merged |
---|---|
Merged at revision: | 86 |
Proposed branch: | lp:~mterry/indicator-appmenu/gdbus |
Merge into: | lp:indicator-appmenu/0.3 |
Diff against target: |
1428 lines (+597/-333) 8 files modified
configure.ac (+10/-4) scripts/menu-pusher.c (+9/-8) src/Makefile.am (+20/-18) src/application-menu-renderer.xml (+1/-1) src/clean-namespaces.xslt (+14/-0) src/indicator-appmenu.c (+414/-228) src/window-menus.c (+87/-43) tools/mock-json-app.c (+42/-31) |
To merge this branch: | bzr merge lp:~mterry/indicator-appmenu/gdbus |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
- 87. By Michael Terry
-
add log domain; don't detach menus that aren't attached
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ted Gould (ted) : | # |
review:
Approve
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 2010-10-06 18:43:21 +0000 | |||
3 | +++ configure.ac 2011-01-13 04:42:14 +0000 | |||
4 | @@ -47,15 +47,15 @@ | |||
5 | 47 | ########################### | 47 | ########################### |
6 | 48 | 48 | ||
7 | 49 | GTK_REQUIRED_VERSION=2.12 | 49 | GTK_REQUIRED_VERSION=2.12 |
8 | 50 | GIO_REQUIRED_VERSION=2.26 | ||
9 | 50 | INDICATOR_REQUIRED_VERSION=0.3.14 | 51 | INDICATOR_REQUIRED_VERSION=0.3.14 |
10 | 51 | DBUSMENUGTK_REQUIRED_VERSION=0.3.3 | 52 | DBUSMENUGTK_REQUIRED_VERSION=0.3.3 |
11 | 52 | DBUS_GLIB_REQUIRED_VERSION=0.82 | ||
12 | 53 | BAMF_REQUIRED_VERSION=0.2.53 | 53 | BAMF_REQUIRED_VERSION=0.2.53 |
13 | 54 | 54 | ||
14 | 55 | PKG_CHECK_MODULES(INDICATOR, gtk+-2.0 >= $GTK_REQUIRED_VERSION | 55 | PKG_CHECK_MODULES(INDICATOR, gtk+-2.0 >= $GTK_REQUIRED_VERSION |
15 | 56 | gio-2.0 >= $GIO_REQUIRED_VERSION | ||
16 | 56 | indicator >= $INDICATOR_REQUIRED_VERSION | 57 | indicator >= $INDICATOR_REQUIRED_VERSION |
19 | 57 | dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION | 58 | dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION |
18 | 58 | dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION | ||
20 | 59 | libbamf >= $BAMF_REQUIRED_VERSION) | 59 | libbamf >= $BAMF_REQUIRED_VERSION) |
21 | 60 | 60 | ||
22 | 61 | AC_SUBST(INDICATOR_CFLAGS) | 61 | AC_SUBST(INDICATOR_CFLAGS) |
23 | @@ -68,13 +68,19 @@ | |||
24 | 68 | DBUSMENU_JSONLOADER_REQUIRED_VERSION=0.3.3 | 68 | DBUSMENU_JSONLOADER_REQUIRED_VERSION=0.3.3 |
25 | 69 | 69 | ||
26 | 70 | PKG_CHECK_MODULES(INDICATORTEST, | 70 | PKG_CHECK_MODULES(INDICATORTEST, |
28 | 71 | dbusmenu-jsonloader >= $DBUSMENU_JSONLOADER_REQUIRED_VERSION | 71 | dbusmenu-jsonloader-0.4 >= $DBUSMENU_JSONLOADER_REQUIRED_VERSION |
29 | 72 | ) | 72 | ) |
30 | 73 | 73 | ||
31 | 74 | AC_SUBST(INDICATORTEST_CFLAGS) | 74 | AC_SUBST(INDICATORTEST_CFLAGS) |
32 | 75 | AC_SUBST(INDICATORTEST_LIBS) | 75 | AC_SUBST(INDICATORTEST_LIBS) |
33 | 76 | 76 | ||
34 | 77 | ########################### | 77 | ########################### |
35 | 78 | # XSLT Processor | ||
36 | 79 | ########################### | ||
37 | 80 | |||
38 | 81 | AC_PATH_PROG([XSLT_PROC], [xsltproc]) | ||
39 | 82 | |||
40 | 83 | ########################### | ||
41 | 78 | # Check to see if we're local | 84 | # Check to see if we're local |
42 | 79 | ########################### | 85 | ########################### |
43 | 80 | 86 | ||
44 | 81 | 87 | ||
45 | === modified file 'scripts/menu-pusher.c' | |||
46 | --- scripts/menu-pusher.c 2010-07-20 21:48:25 +0000 | |||
47 | +++ scripts/menu-pusher.c 2011-01-13 04:42:14 +0000 | |||
48 | @@ -20,12 +20,11 @@ | |||
49 | 20 | */ | 20 | */ |
50 | 21 | 21 | ||
51 | 22 | #include <gtk/gtk.h> | 22 | #include <gtk/gtk.h> |
53 | 23 | #include <dbus/dbus-glib.h> | 23 | #include <gio/gio.h> |
54 | 24 | #include <libdbusmenu-glib/menuitem.h> | 24 | #include <libdbusmenu-glib/menuitem.h> |
55 | 25 | #include <libdbusmenu-glib/server.h> | 25 | #include <libdbusmenu-glib/server.h> |
56 | 26 | #include <libdbusmenu-gtk/menuitem.h> | 26 | #include <libdbusmenu-gtk/menuitem.h> |
57 | 27 | #include "../src/dbus-shared.h" | 27 | #include "../src/dbus-shared.h" |
58 | 28 | #include "../src/application-menu-registrar-client.h" | ||
59 | 29 | 28 | ||
60 | 30 | int | 29 | int |
61 | 31 | main (int argv, char ** argc) | 30 | main (int argv, char ** argc) |
62 | @@ -73,16 +72,18 @@ | |||
63 | 73 | dbusmenu_server_set_root(server, root); | 72 | dbusmenu_server_set_root(server, root); |
64 | 74 | 73 | ||
65 | 75 | 74 | ||
70 | 76 | DBusGConnection * session = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); | 75 | GDBusProxy * proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION, |
71 | 77 | g_return_val_if_fail(session != NULL, 1); | 76 | G_DBUS_PROXY_FLAGS_NONE, |
72 | 78 | 77 | NULL, DBUS_NAME, | |
73 | 79 | DBusGProxy * proxy = dbus_g_proxy_new_for_name_owner(session, DBUS_NAME, REG_OBJECT, REG_IFACE, NULL); | 78 | REG_OBJECT, REG_IFACE, |
74 | 79 | NULL, NULL); | ||
75 | 80 | g_return_val_if_fail(proxy != NULL, 1); | 80 | g_return_val_if_fail(proxy != NULL, 1); |
76 | 81 | 81 | ||
78 | 82 | org_ayatana_AppMenu_Registrar_register_window(proxy, 0, "/this/is/a/long/object/path", NULL); | 82 | g_dbus_proxy_call_sync(proxy, "RegisterWindow", |
79 | 83 | g_variant_new("(uo)", 0, "/this/is/a/long/object/path"), | ||
80 | 84 | G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); | ||
81 | 83 | 85 | ||
82 | 84 | gtk_main(); | 86 | gtk_main(); |
83 | 85 | 87 | ||
84 | 86 | |||
85 | 87 | return 0; | 88 | return 0; |
86 | 88 | } | 89 | } |
87 | 89 | 90 | ||
88 | === modified file 'src/Makefile.am' | |||
89 | --- src/Makefile.am 2010-09-03 16:30:59 +0000 | |||
90 | +++ src/Makefile.am 2011-01-13 04:42:14 +0000 | |||
91 | @@ -12,7 +12,6 @@ | |||
92 | 12 | appmenulibdir = $(INDICATORDIR) | 12 | appmenulibdir = $(INDICATORDIR) |
93 | 13 | appmenulib_LTLIBRARIES = libappmenu.la | 13 | appmenulib_LTLIBRARIES = libappmenu.la |
94 | 14 | libappmenu_la_SOURCES = \ | 14 | libappmenu_la_SOURCES = \ |
95 | 15 | application-menu-registrar-server.h \ | ||
96 | 16 | dbus-shared.h \ | 15 | dbus-shared.h \ |
97 | 17 | gdk-get-func.h \ | 16 | gdk-get-func.h \ |
98 | 18 | gdk-get-func.c \ | 17 | gdk-get-func.c \ |
99 | @@ -20,8 +19,12 @@ | |||
100 | 20 | indicator-appmenu.c \ | 19 | indicator-appmenu.c \ |
101 | 21 | indicator-appmenu-marshal.c \ | 20 | indicator-appmenu-marshal.c \ |
102 | 22 | window-menus.c \ | 21 | window-menus.c \ |
105 | 23 | window-menus.h | 22 | window-menus.h \ |
106 | 24 | libappmenu_la_CFLAGS = $(INDICATOR_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror | 23 | gen-application-menu-renderer.xml.c \ |
107 | 24 | gen-application-menu-renderer.xml.h \ | ||
108 | 25 | gen-application-menu-registrar.xml.c \ | ||
109 | 26 | gen-application-menu-registrar.xml.h | ||
110 | 27 | libappmenu_la_CFLAGS = $(INDICATOR_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror -DG_LOG_DOMAIN=\"Indicator-Appmenu\" | ||
111 | 25 | libappmenu_la_LIBADD = $(INDICATOR_LIBS) -lX11 | 28 | libappmenu_la_LIBADD = $(INDICATOR_LIBS) -lX11 |
112 | 26 | libappmenu_la_LDFLAGS = -module -avoid-version | 29 | libappmenu_la_LDFLAGS = -module -avoid-version |
113 | 27 | 30 | ||
114 | @@ -40,24 +43,23 @@ | |||
115 | 40 | application-menu-renderer.xml \ | 43 | application-menu-renderer.xml \ |
116 | 41 | application-menu-registrar.xml | 44 | application-menu-registrar.xml |
117 | 42 | 45 | ||
124 | 43 | %-client.h: %.xml | 46 | gen-%.xml.c: %.xml |
125 | 44 | dbus-binding-tool \ | 47 | @echo "Building $@ from $<" |
126 | 45 | --prefix=_$(notdir $(subst -,_,$(<:.xml=)))_client \ | 48 | @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@ |
127 | 46 | --mode=glib-client \ | 49 | @$(XSLT_PROC) $(srcdir)/clean-namespaces.xslt $< | \ |
128 | 47 | --output=$@ \ | 50 | sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": >> $@ |
129 | 48 | $< | 51 | @echo ";" >> $@ |
130 | 49 | 52 | ||
137 | 50 | %-server.h: %.xml | 53 | gen-%.xml.h: %.xml |
138 | 51 | dbus-binding-tool \ | 54 | @echo "Building $@ from $<" |
139 | 52 | --prefix=_$(notdir $(subst -,_,$(<:.xml=)))_server \ | 55 | @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@ |
134 | 53 | --mode=glib-server \ | ||
135 | 54 | --output=$@ \ | ||
136 | 55 | $< | ||
140 | 56 | 56 | ||
141 | 57 | BUILT_SOURCES += \ | 57 | BUILT_SOURCES += \ |
144 | 58 | $(DBUS_SPECS:.xml=-client.h) \ | 58 | gen-application-menu-renderer.xml.c \ |
145 | 59 | $(DBUS_SPECS:.xml=-server.h) | 59 | gen-application-menu-renderer.xml.h \ |
146 | 60 | gen-application-menu-registrar.xml.c \ | ||
147 | 61 | gen-application-menu-registrar.xml.h | ||
148 | 60 | 62 | ||
149 | 61 | CLEANFILES += $(BUILT_SOURCES) | 63 | CLEANFILES += $(BUILT_SOURCES) |
150 | 62 | 64 | ||
152 | 63 | EXTRA_DIST += $(DBUS_SPECS) | 65 | EXTRA_DIST += $(DBUS_SPECS) clean-namespaces.xslt |
153 | 64 | 66 | ||
154 | === modified file 'src/application-menu-renderer.xml' | |||
155 | --- src/application-menu-renderer.xml 2010-07-13 19:52:07 +0000 | |||
156 | +++ src/application-menu-renderer.xml 2011-01-13 04:42:14 +0000 | |||
157 | @@ -1,5 +1,5 @@ | |||
158 | 1 | <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> | 1 | <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> |
160 | 2 | <node name="/org/ayatana/AppMenu/Renderer"> | 2 | <node name="/org/ayatana/AppMenu/Renderer" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd"> |
161 | 3 | <dox:d><![CDATA[ | 3 | <dox:d><![CDATA[ |
162 | 4 | @mainpage | 4 | @mainpage |
163 | 5 | 5 | ||
164 | 6 | 6 | ||
165 | === added file 'src/clean-namespaces.xslt' | |||
166 | --- src/clean-namespaces.xslt 1970-01-01 00:00:00 +0000 | |||
167 | +++ src/clean-namespaces.xslt 2011-01-13 04:42:14 +0000 | |||
168 | @@ -0,0 +1,14 @@ | |||
169 | 1 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd"> | ||
170 | 2 | <xsl:template match="*|@*"> | ||
171 | 3 | <xsl:copy> | ||
172 | 4 | <xsl:apply-templates select="*|@*" /> | ||
173 | 5 | </xsl:copy> | ||
174 | 6 | </xsl:template> | ||
175 | 7 | <xsl:template match="@dox:*|dox:*"/> | ||
176 | 8 | <xsl:template match="*"> | ||
177 | 9 | <xsl:element name="{local-name()}"> | ||
178 | 10 | <xsl:apply-templates select="@* | node()"/> | ||
179 | 11 | </xsl:element> | ||
180 | 12 | </xsl:template> | ||
181 | 13 | </xsl:stylesheet> | ||
182 | 14 | |||
183 | 0 | 15 | ||
184 | === modified file 'src/indicator-appmenu.c' | |||
185 | --- src/indicator-appmenu.c 2010-10-06 18:43:21 +0000 | |||
186 | +++ src/indicator-appmenu.c 2011-01-13 04:42:14 +0000 | |||
187 | @@ -25,11 +25,7 @@ | |||
188 | 25 | 25 | ||
189 | 26 | #include <X11/Xlib.h> | 26 | #include <X11/Xlib.h> |
190 | 27 | #include <gdk/gdkx.h> | 27 | #include <gdk/gdkx.h> |
196 | 28 | 28 | #include <gio/gio.h> | |
192 | 29 | #include <dbus/dbus-glib.h> | ||
193 | 30 | #include <dbus/dbus-glib-bindings.h> | ||
194 | 31 | #include <dbus/dbus-glib-lowlevel.h> | ||
195 | 32 | #include <dbus/dbus-gtype-specialized.h> | ||
197 | 33 | 29 | ||
198 | 34 | #include <libindicator/indicator.h> | 30 | #include <libindicator/indicator.h> |
199 | 35 | #include <libindicator/indicator-object.h> | 31 | #include <libindicator/indicator-object.h> |
200 | @@ -39,6 +35,8 @@ | |||
201 | 39 | 35 | ||
202 | 40 | #include <libbamf/bamf-matcher.h> | 36 | #include <libbamf/bamf-matcher.h> |
203 | 41 | 37 | ||
204 | 38 | #include "gen-application-menu-registrar.xml.h" | ||
205 | 39 | #include "gen-application-menu-renderer.xml.h" | ||
206 | 42 | #include "indicator-appmenu-marshal.h" | 40 | #include "indicator-appmenu-marshal.h" |
207 | 43 | #include "window-menus.h" | 41 | #include "window-menus.h" |
208 | 44 | #include "dbus-shared.h" | 42 | #include "dbus-shared.h" |
209 | @@ -102,6 +100,10 @@ | |||
210 | 102 | WindowMenus * desktop_menu; | 100 | WindowMenus * desktop_menu; |
211 | 103 | 101 | ||
212 | 104 | IndicatorAppmenuDebug * debug; | 102 | IndicatorAppmenuDebug * debug; |
213 | 103 | |||
214 | 104 | GDBusConnection * bus; | ||
215 | 105 | guint owner_id; | ||
216 | 106 | guint dbus_registration; | ||
217 | 105 | }; | 107 | }; |
218 | 106 | 108 | ||
219 | 107 | 109 | ||
220 | @@ -124,6 +126,9 @@ | |||
221 | 124 | struct _IndicatorAppmenuDebug { | 126 | struct _IndicatorAppmenuDebug { |
222 | 125 | GObject parent; | 127 | GObject parent; |
223 | 126 | IndicatorAppmenu * appmenu; | 128 | IndicatorAppmenu * appmenu; |
224 | 129 | GCancellable * bus_cancel; | ||
225 | 130 | GDBusConnection * bus; | ||
226 | 131 | guint dbus_registration; | ||
227 | 127 | }; | 132 | }; |
228 | 128 | 133 | ||
229 | 129 | 134 | ||
230 | @@ -136,6 +141,7 @@ | |||
231 | 136 | static void indicator_appmenu_finalize (GObject *object); | 141 | static void indicator_appmenu_finalize (GObject *object); |
232 | 137 | static void indicator_appmenu_debug_class_init (IndicatorAppmenuDebugClass *klass); | 142 | static void indicator_appmenu_debug_class_init (IndicatorAppmenuDebugClass *klass); |
233 | 138 | static void indicator_appmenu_debug_init (IndicatorAppmenuDebug *self); | 143 | static void indicator_appmenu_debug_init (IndicatorAppmenuDebug *self); |
234 | 144 | static void indicator_appmenu_debug_dispose (GObject *object); | ||
235 | 139 | static void build_window_menus (IndicatorAppmenu * iapp); | 145 | static void build_window_menus (IndicatorAppmenu * iapp); |
236 | 140 | static GList * get_entries (IndicatorObject * io); | 146 | static GList * get_entries (IndicatorObject * io); |
237 | 141 | static guint get_location (IndicatorObject * io, | 147 | static guint get_location (IndicatorObject * io, |
238 | @@ -153,25 +159,6 @@ | |||
239 | 153 | static void old_window (BamfMatcher * matcher, | 159 | static void old_window (BamfMatcher * matcher, |
240 | 154 | BamfView * view, | 160 | BamfView * view, |
241 | 155 | gpointer user_data); | 161 | gpointer user_data); |
242 | 156 | static gboolean _application_menu_registrar_server_register_window (IndicatorAppmenu * iapp, | ||
243 | 157 | guint windowid, | ||
244 | 158 | const gchar * objectpath, | ||
245 | 159 | DBusGMethodInvocation * method); | ||
246 | 160 | static gboolean _application_menu_registrar_server_unregister_window (IndicatorAppmenu * iapp, | ||
247 | 161 | guint windowid, | ||
248 | 162 | GError ** error); | ||
249 | 163 | static gboolean _application_menu_registrar_server_get_menu_for_window (IndicatorAppmenu * iapp, | ||
250 | 164 | guint windowid, | ||
251 | 165 | gchar ** objectpath, | ||
252 | 166 | gchar ** address, | ||
253 | 167 | GError ** error); | ||
254 | 168 | static gboolean _application_menu_registrar_server_get_menus (IndicatorAppmenu * iapp, | ||
255 | 169 | GPtrArray ** entries, | ||
256 | 170 | GError ** error); | ||
257 | 171 | static void request_name_cb (DBusGProxy *proxy, | ||
258 | 172 | guint result, | ||
259 | 173 | GError *error, | ||
260 | 174 | gpointer userdata); | ||
261 | 175 | static void window_entry_added (WindowMenus * mw, | 162 | static void window_entry_added (WindowMenus * mw, |
262 | 176 | IndicatorObjectEntry * entry, | 163 | IndicatorObjectEntry * entry, |
263 | 177 | gpointer user_data); | 164 | gpointer user_data); |
264 | @@ -186,22 +173,36 @@ | |||
265 | 186 | BamfView * oldview, | 173 | BamfView * oldview, |
266 | 187 | BamfView * newview, | 174 | BamfView * newview, |
267 | 188 | gpointer user_data); | 175 | gpointer user_data); |
268 | 189 | static gboolean _application_menu_renderer_server_get_current_menu (IndicatorAppmenuDebug * iappd, | ||
269 | 190 | gchar ** objectpath, | ||
270 | 191 | gchar ** address, | ||
271 | 192 | GError ** error); | ||
272 | 193 | static gboolean _application_menu_renderer_server_activate_menu_item (IndicatorAppmenuDebug * iappd, | ||
273 | 194 | GArray * menulist, | ||
274 | 195 | GError ** error); | ||
275 | 196 | static gboolean _application_menu_renderer_server_dump_current_menu (IndicatorAppmenuDebug * iappd, | ||
276 | 197 | gchar ** jsondata, | ||
277 | 198 | GError ** error); | ||
278 | 199 | static gboolean _application_menu_renderer_server_dump_menu (IndicatorAppmenuDebug * iappd, | ||
279 | 200 | guint windowid, | ||
280 | 201 | gchar ** jsondata, | ||
281 | 202 | GError ** error); | ||
282 | 203 | static GQuark error_quark (void); | 176 | static GQuark error_quark (void); |
283 | 204 | static gboolean retry_registration (gpointer user_data); | 177 | static gboolean retry_registration (gpointer user_data); |
284 | 178 | static void bus_method_call (GDBusConnection * connection, | ||
285 | 179 | const gchar * sender, | ||
286 | 180 | const gchar * path, | ||
287 | 181 | const gchar * interface, | ||
288 | 182 | const gchar * method, | ||
289 | 183 | GVariant * params, | ||
290 | 184 | GDBusMethodInvocation * invocation, | ||
291 | 185 | gpointer user_data); | ||
292 | 186 | static void on_bus_acquired (GDBusConnection * connection, | ||
293 | 187 | const gchar * name, | ||
294 | 188 | gpointer user_data); | ||
295 | 189 | static void on_name_acquired (GDBusConnection * connection, | ||
296 | 190 | const gchar * name, | ||
297 | 191 | gpointer user_data); | ||
298 | 192 | static void on_name_lost (GDBusConnection * connection, | ||
299 | 193 | const gchar * name, | ||
300 | 194 | gpointer user_data); | ||
301 | 195 | static void dbg_bus_method_call (GDBusConnection * connection, | ||
302 | 196 | const gchar * sender, | ||
303 | 197 | const gchar * path, | ||
304 | 198 | const gchar * interface, | ||
305 | 199 | const gchar * method, | ||
306 | 200 | GVariant * params, | ||
307 | 201 | GDBusMethodInvocation * invocation, | ||
308 | 202 | gpointer user_data); | ||
309 | 203 | static void dbg_bus_get_cb (GObject * object, | ||
310 | 204 | GAsyncResult * res, | ||
311 | 205 | gpointer user_data); | ||
312 | 205 | 206 | ||
313 | 206 | /* Unique error codes for debug interface */ | 207 | /* Unique error codes for debug interface */ |
314 | 207 | enum { | 208 | enum { |
315 | @@ -213,16 +214,21 @@ | |||
316 | 213 | /********************** | 214 | /********************** |
317 | 214 | DBus Interfaces | 215 | DBus Interfaces |
318 | 215 | **********************/ | 216 | **********************/ |
329 | 216 | #include "application-menu-registrar-server.h" | 217 | static GDBusNodeInfo * node_info = NULL; |
330 | 217 | #include "application-menu-renderer-server.h" | 218 | static GDBusInterfaceInfo * interface_info = NULL; |
331 | 218 | 219 | static GDBusInterfaceVTable interface_table = { | |
332 | 219 | enum { | 220 | method_call: bus_method_call, |
333 | 220 | WINDOW_REGISTERED, | 221 | get_property: NULL, /* No properties */ |
334 | 221 | WINDOW_UNREGISTERED, | 222 | set_property: NULL /* No properties */ |
335 | 222 | LAST_SIGNAL | 223 | }; |
336 | 223 | }; | 224 | |
337 | 224 | 225 | static GDBusNodeInfo * dbg_node_info = NULL; | |
338 | 225 | static guint signals[LAST_SIGNAL] = { 0 }; | 226 | static GDBusInterfaceInfo * dbg_interface_info = NULL; |
339 | 227 | static GDBusInterfaceVTable dbg_interface_table = { | ||
340 | 228 | method_call: dbg_bus_method_call, | ||
341 | 229 | get_property: NULL, /* No properties */ | ||
342 | 230 | set_property: NULL /* No properties */ | ||
343 | 231 | }; | ||
344 | 226 | 232 | ||
345 | 227 | G_DEFINE_TYPE (IndicatorAppmenu, indicator_appmenu, INDICATOR_OBJECT_TYPE); | 233 | G_DEFINE_TYPE (IndicatorAppmenu, indicator_appmenu, INDICATOR_OBJECT_TYPE); |
346 | 228 | 234 | ||
347 | @@ -241,22 +247,24 @@ | |||
348 | 241 | ioclass->get_location = get_location; | 247 | ioclass->get_location = get_location; |
349 | 242 | ioclass->entry_activate = entry_activate; | 248 | ioclass->entry_activate = entry_activate; |
350 | 243 | 249 | ||
367 | 244 | signals[WINDOW_REGISTERED] = g_signal_new("window-registered", | 250 | /* Setting up the DBus interfaces */ |
368 | 245 | G_TYPE_FROM_CLASS(klass), | 251 | if (node_info == NULL) { |
369 | 246 | G_SIGNAL_RUN_LAST, | 252 | GError * error = NULL; |
370 | 247 | G_STRUCT_OFFSET (IndicatorAppmenuClass, window_registered), | 253 | |
371 | 248 | NULL, NULL, | 254 | node_info = g_dbus_node_info_new_for_xml(_application_menu_registrar, &error); |
372 | 249 | _indicator_appmenu_marshal_VOID__UINT_STRING_BOXED, | 255 | if (error != NULL) { |
373 | 250 | G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH); | 256 | g_error("Unable to parse Application Menu Interface description: %s", error->message); |
374 | 251 | signals[WINDOW_UNREGISTERED] = g_signal_new("window-unregistered", | 257 | g_error_free(error); |
375 | 252 | G_TYPE_FROM_CLASS(klass), | 258 | } |
376 | 253 | G_SIGNAL_RUN_LAST, | 259 | } |
377 | 254 | G_STRUCT_OFFSET (IndicatorAppmenuClass, window_unregistered), | 260 | |
378 | 255 | NULL, NULL, | 261 | if (interface_info == NULL) { |
379 | 256 | _indicator_appmenu_marshal_VOID__UINT, | 262 | interface_info = g_dbus_node_info_lookup_interface(node_info, REG_IFACE); |
380 | 257 | G_TYPE_NONE, 1, G_TYPE_UINT); | 263 | |
381 | 258 | 264 | if (interface_info == NULL) { | |
382 | 259 | dbus_g_object_type_install_info(INDICATOR_APPMENU_TYPE, &dbus_glib__application_menu_registrar_server_object_info); | 265 | g_error("Unable to find interface '" REG_IFACE "'"); |
383 | 266 | } | ||
384 | 267 | } | ||
385 | 260 | 268 | ||
386 | 261 | return; | 269 | return; |
387 | 262 | } | 270 | } |
388 | @@ -273,6 +281,9 @@ | |||
389 | 273 | self->active_stubs = STUBS_UNKNOWN; | 281 | self->active_stubs = STUBS_UNKNOWN; |
390 | 274 | self->close_item = NULL; | 282 | self->close_item = NULL; |
391 | 275 | self->retry_registration = 0; | 283 | self->retry_registration = 0; |
392 | 284 | self->bus = NULL; | ||
393 | 285 | self->owner_id = 0; | ||
394 | 286 | self->dbus_registration = 0; | ||
395 | 276 | 287 | ||
396 | 277 | /* Setup the entries for the fallbacks */ | 288 | /* Setup the entries for the fallbacks */ |
397 | 278 | self->window_menus = g_array_sized_new(FALSE, FALSE, sizeof(IndicatorObjectEntry), 2); | 289 | self->window_menus = g_array_sized_new(FALSE, FALSE, sizeof(IndicatorObjectEntry), 2); |
398 | @@ -299,38 +310,8 @@ | |||
399 | 299 | 310 | ||
400 | 300 | find_desktop_windows(self); | 311 | find_desktop_windows(self); |
401 | 301 | 312 | ||
434 | 302 | /* Register this object on DBus */ | 313 | /* Request a name so others can find us */ |
435 | 303 | gboolean sent_registration = FALSE; | 314 | retry_registration(self); |
404 | 304 | GError * error = NULL; | ||
405 | 305 | DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); | ||
406 | 306 | if (connection != NULL && error == NULL) { | ||
407 | 307 | dbus_g_connection_register_g_object(connection, | ||
408 | 308 | REG_OBJECT, | ||
409 | 309 | G_OBJECT(self)); | ||
410 | 310 | |||
411 | 311 | /* Request a name so others can find us */ | ||
412 | 312 | DBusGProxy * dbus_proxy = dbus_g_proxy_new_for_name_owner(connection, | ||
413 | 313 | DBUS_SERVICE_DBUS, | ||
414 | 314 | DBUS_PATH_DBUS, | ||
415 | 315 | DBUS_INTERFACE_DBUS, | ||
416 | 316 | NULL); | ||
417 | 317 | if (dbus_proxy != NULL) { | ||
418 | 318 | org_freedesktop_DBus_request_name_async (dbus_proxy, | ||
419 | 319 | DBUS_NAME, | ||
420 | 320 | DBUS_NAME_FLAG_DO_NOT_QUEUE, | ||
421 | 321 | request_name_cb, | ||
422 | 322 | self); | ||
423 | 323 | sent_registration = TRUE; | ||
424 | 324 | } else { | ||
425 | 325 | g_warning("Unable to get proxy to DBus daemon"); | ||
426 | 326 | } | ||
427 | 327 | } else { | ||
428 | 328 | g_warning("Unable to connect to session bus"); | ||
429 | 329 | } | ||
430 | 330 | |||
431 | 331 | if (!sent_registration) { | ||
432 | 332 | self->retry_registration = g_timeout_add_seconds(1, retry_registration, self); | ||
433 | 333 | } | ||
436 | 334 | 315 | ||
437 | 335 | /* Setup debug interface */ | 316 | /* Setup debug interface */ |
438 | 336 | self->debug = g_object_new(INDICATOR_APPMENU_DEBUG_TYPE, NULL); | 317 | self->debug = g_object_new(INDICATOR_APPMENU_DEBUG_TYPE, NULL); |
439 | @@ -339,6 +320,82 @@ | |||
440 | 339 | return; | 320 | return; |
441 | 340 | } | 321 | } |
442 | 341 | 322 | ||
443 | 323 | /* If we weren't able to register on the bus, then we need | ||
444 | 324 | to try it all again. */ | ||
445 | 325 | static gboolean | ||
446 | 326 | retry_registration (gpointer user_data) | ||
447 | 327 | { | ||
448 | 328 | g_return_val_if_fail(IS_INDICATOR_APPMENU(user_data), FALSE); | ||
449 | 329 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(user_data); | ||
450 | 330 | |||
451 | 331 | iapp->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, | ||
452 | 332 | DBUS_NAME, | ||
453 | 333 | G_BUS_NAME_OWNER_FLAGS_NONE, | ||
454 | 334 | iapp->dbus_registration == 0 ? on_bus_acquired : NULL, | ||
455 | 335 | on_name_acquired, | ||
456 | 336 | on_name_lost, | ||
457 | 337 | g_object_ref(iapp), | ||
458 | 338 | g_object_unref); | ||
459 | 339 | |||
460 | 340 | return TRUE; | ||
461 | 341 | } | ||
462 | 342 | |||
463 | 343 | static void | ||
464 | 344 | on_bus_acquired (GDBusConnection * connection, const gchar * name, | ||
465 | 345 | gpointer user_data) | ||
466 | 346 | { | ||
467 | 347 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(user_data); | ||
468 | 348 | GError * error = NULL; | ||
469 | 349 | |||
470 | 350 | iapp->bus = connection; | ||
471 | 351 | |||
472 | 352 | /* Now register our object on our new connection */ | ||
473 | 353 | iapp->dbus_registration = g_dbus_connection_register_object(connection, | ||
474 | 354 | REG_OBJECT, | ||
475 | 355 | interface_info, | ||
476 | 356 | &interface_table, | ||
477 | 357 | user_data, | ||
478 | 358 | NULL, | ||
479 | 359 | &error); | ||
480 | 360 | |||
481 | 361 | if (error != NULL) { | ||
482 | 362 | g_error("Unable to register the object to DBus: %s", error->message); | ||
483 | 363 | g_error_free(error); | ||
484 | 364 | g_bus_unown_name(iapp->owner_id); | ||
485 | 365 | iapp->owner_id = 0; | ||
486 | 366 | iapp->retry_registration = g_timeout_add_seconds(1, retry_registration, iapp); | ||
487 | 367 | return; | ||
488 | 368 | } | ||
489 | 369 | |||
490 | 370 | return; | ||
491 | 371 | } | ||
492 | 372 | |||
493 | 373 | static void | ||
494 | 374 | on_name_acquired (GDBusConnection * connection, const gchar * name, | ||
495 | 375 | gpointer user_data) | ||
496 | 376 | { | ||
497 | 377 | } | ||
498 | 378 | |||
499 | 379 | static void | ||
500 | 380 | on_name_lost (GDBusConnection * connection, const gchar * name, | ||
501 | 381 | gpointer user_data) | ||
502 | 382 | { | ||
503 | 383 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(user_data); | ||
504 | 384 | |||
505 | 385 | if (connection == NULL) { | ||
506 | 386 | g_error("OMG! Unable to get a connection to DBus"); | ||
507 | 387 | } | ||
508 | 388 | else { | ||
509 | 389 | g_error("Unable to claim the name %s", DBUS_NAME); | ||
510 | 390 | } | ||
511 | 391 | |||
512 | 392 | /* We can rest assured no one will register with us, but let's | ||
513 | 393 | just ensure we're not showing anything. */ | ||
514 | 394 | switch_default_app(iapp, NULL, NULL); | ||
515 | 395 | |||
516 | 396 | iapp->owner_id = 0; | ||
517 | 397 | } | ||
518 | 398 | |||
519 | 342 | /* Object refs decrement */ | 399 | /* Object refs decrement */ |
520 | 343 | static void | 400 | static void |
521 | 344 | indicator_appmenu_dispose (GObject *object) | 401 | indicator_appmenu_dispose (GObject *object) |
522 | @@ -351,6 +408,22 @@ | |||
523 | 351 | iapp->retry_registration = 0; | 408 | iapp->retry_registration = 0; |
524 | 352 | } | 409 | } |
525 | 353 | 410 | ||
526 | 411 | if (iapp->dbus_registration != 0) { | ||
527 | 412 | g_dbus_connection_unregister_object(iapp->bus, iapp->dbus_registration); | ||
528 | 413 | /* Don't care if it fails, there's nothing we can do */ | ||
529 | 414 | iapp->dbus_registration = 0; | ||
530 | 415 | } | ||
531 | 416 | |||
532 | 417 | if (iapp->bus != NULL) { | ||
533 | 418 | g_object_unref(iapp->bus); | ||
534 | 419 | iapp->bus = NULL; | ||
535 | 420 | } | ||
536 | 421 | |||
537 | 422 | if (iapp->owner_id != 0) { | ||
538 | 423 | g_bus_unown_name(iapp->owner_id); | ||
539 | 424 | iapp->owner_id = 0; | ||
540 | 425 | } | ||
541 | 426 | |||
542 | 354 | /* bring down the matcher before resetting to no menu so we don't | 427 | /* bring down the matcher before resetting to no menu so we don't |
543 | 355 | get match signals */ | 428 | get match signals */ |
544 | 356 | if (iapp->matcher != NULL) { | 429 | if (iapp->matcher != NULL) { |
545 | @@ -411,7 +484,28 @@ | |||
546 | 411 | static void | 484 | static void |
547 | 412 | indicator_appmenu_debug_class_init (IndicatorAppmenuDebugClass *klass) | 485 | indicator_appmenu_debug_class_init (IndicatorAppmenuDebugClass *klass) |
548 | 413 | { | 486 | { |
550 | 414 | dbus_g_object_type_install_info(INDICATOR_APPMENU_DEBUG_TYPE, &dbus_glib__application_menu_renderer_server_object_info); | 487 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
551 | 488 | |||
552 | 489 | object_class->dispose = indicator_appmenu_debug_dispose; | ||
553 | 490 | |||
554 | 491 | /* Setting up the DBus interfaces */ | ||
555 | 492 | if (dbg_node_info == NULL) { | ||
556 | 493 | GError * error = NULL; | ||
557 | 494 | |||
558 | 495 | dbg_node_info = g_dbus_node_info_new_for_xml(_application_menu_renderer, &error); | ||
559 | 496 | if (error != NULL) { | ||
560 | 497 | g_error("Unable to parse Application Menu Renderer Interface description: %s", error->message); | ||
561 | 498 | g_error_free(error); | ||
562 | 499 | } | ||
563 | 500 | } | ||
564 | 501 | |||
565 | 502 | if (dbg_interface_info == NULL) { | ||
566 | 503 | dbg_interface_info = g_dbus_node_info_lookup_interface(dbg_node_info, DEBUG_IFACE); | ||
567 | 504 | |||
568 | 505 | if (dbg_interface_info == NULL) { | ||
569 | 506 | g_error("Unable to find interface '" DEBUG_IFACE "'"); | ||
570 | 507 | } | ||
571 | 508 | } | ||
572 | 415 | 509 | ||
573 | 416 | return; | 510 | return; |
574 | 417 | } | 511 | } |
575 | @@ -421,52 +515,107 @@ | |||
576 | 421 | indicator_appmenu_debug_init (IndicatorAppmenuDebug *self) | 515 | indicator_appmenu_debug_init (IndicatorAppmenuDebug *self) |
577 | 422 | { | 516 | { |
578 | 423 | self->appmenu = NULL; | 517 | self->appmenu = NULL; |
579 | 518 | self->bus_cancel = NULL; | ||
580 | 519 | self->bus = NULL; | ||
581 | 520 | self->dbus_registration = 0; | ||
582 | 424 | 521 | ||
583 | 425 | /* Register this object on DBus */ | 522 | /* Register this object on DBus */ |
628 | 426 | DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); | 523 | self->bus_cancel = g_cancellable_new(); |
629 | 427 | dbus_g_connection_register_g_object(connection, | 524 | g_bus_get(G_BUS_TYPE_SESSION, |
630 | 428 | DEBUG_OBJECT, | 525 | self->bus_cancel, |
631 | 429 | G_OBJECT(self)); | 526 | dbg_bus_get_cb, |
632 | 430 | 527 | self); | |
633 | 431 | return; | 528 | |
634 | 432 | } | 529 | return; |
635 | 433 | 530 | } | |
636 | 434 | /* If we weren't able to register on the bus, then we need | 531 | |
637 | 435 | to try it all again. */ | 532 | static void |
638 | 436 | static gboolean | 533 | dbg_bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data) |
639 | 437 | retry_registration (gpointer user_data) | 534 | { |
640 | 438 | { | 535 | GError * error = NULL; |
641 | 439 | g_return_val_if_fail(IS_INDICATOR_APPMENU(user_data), FALSE); | 536 | GDBusConnection * connection = g_bus_get_finish(res, &error); |
642 | 440 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(user_data); | 537 | |
643 | 441 | 538 | if (error != NULL) { | |
644 | 442 | DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); | 539 | g_error("OMG! Unable to get a connection to DBus: %s", error->message); |
645 | 443 | if (connection != NULL) { | 540 | g_error_free(error); |
646 | 444 | dbus_g_connection_register_g_object(connection, | 541 | return; |
647 | 445 | REG_OBJECT, | 542 | } |
648 | 446 | G_OBJECT(iapp)); | 543 | |
649 | 447 | 544 | IndicatorAppmenuDebug * iappd = (IndicatorAppmenuDebug *)user_data; | |
650 | 448 | /* Request a name so others can find us */ | 545 | |
651 | 449 | DBusGProxy * dbus_proxy = dbus_g_proxy_new_for_name_owner(connection, | 546 | g_warn_if_fail(iappd->bus == NULL); |
652 | 450 | DBUS_SERVICE_DBUS, | 547 | iappd->bus = connection; |
653 | 451 | DBUS_PATH_DBUS, | 548 | |
654 | 452 | DBUS_INTERFACE_DBUS, | 549 | if (iappd->bus_cancel != NULL) { |
655 | 453 | NULL); | 550 | g_object_unref(iappd->bus_cancel); |
656 | 454 | if (dbus_proxy != NULL) { | 551 | iappd->bus_cancel = NULL; |
657 | 455 | org_freedesktop_DBus_request_name_async (dbus_proxy, | 552 | } |
658 | 456 | DBUS_NAME, | 553 | |
659 | 457 | DBUS_NAME_FLAG_DO_NOT_QUEUE, | 554 | /* Now register our object on our new connection */ |
660 | 458 | request_name_cb, | 555 | iappd->dbus_registration = g_dbus_connection_register_object(iappd->bus, |
661 | 459 | iapp); | 556 | DEBUG_OBJECT, |
662 | 460 | iapp->retry_registration = 0; | 557 | dbg_interface_info, |
663 | 461 | return FALSE; | 558 | &dbg_interface_table, |
664 | 462 | } else { | 559 | user_data, |
665 | 463 | g_warning("Unable to get proxy to DBus daemon"); | 560 | NULL, |
666 | 464 | } | 561 | &error); |
667 | 465 | } else { | 562 | |
668 | 466 | g_warning("Unable to connect to session bus"); | 563 | if (error != NULL) { |
669 | 467 | } | 564 | g_error("Unable to register the object to DBus: %s", error->message); |
670 | 468 | 565 | g_error_free(error); | |
671 | 469 | return TRUE; | 566 | return; |
672 | 567 | } | ||
673 | 568 | |||
674 | 569 | return; | ||
675 | 570 | } | ||
676 | 571 | |||
677 | 572 | /* Object refs decrement */ | ||
678 | 573 | static void | ||
679 | 574 | indicator_appmenu_debug_dispose (GObject *object) | ||
680 | 575 | { | ||
681 | 576 | IndicatorAppmenuDebug * iappd = INDICATOR_APPMENU_DEBUG(object); | ||
682 | 577 | |||
683 | 578 | if (iappd->dbus_registration != 0) { | ||
684 | 579 | g_dbus_connection_unregister_object(iappd->bus, iappd->dbus_registration); | ||
685 | 580 | /* Don't care if it fails, there's nothing we can do */ | ||
686 | 581 | iappd->dbus_registration = 0; | ||
687 | 582 | } | ||
688 | 583 | |||
689 | 584 | if (iappd->bus != NULL) { | ||
690 | 585 | g_object_unref(iappd->bus); | ||
691 | 586 | iappd->bus = NULL; | ||
692 | 587 | } | ||
693 | 588 | |||
694 | 589 | if (iappd->bus_cancel != NULL) { | ||
695 | 590 | g_cancellable_cancel(iappd->bus_cancel); | ||
696 | 591 | g_object_unref(iappd->bus_cancel); | ||
697 | 592 | iappd->bus_cancel = NULL; | ||
698 | 593 | } | ||
699 | 594 | |||
700 | 595 | G_OBJECT_CLASS (indicator_appmenu_debug_parent_class)->dispose (object); | ||
701 | 596 | return; | ||
702 | 597 | } | ||
703 | 598 | |||
704 | 599 | static void | ||
705 | 600 | emit_signal (IndicatorAppmenu * iapp, const gchar * name, GVariant * variant) | ||
706 | 601 | { | ||
707 | 602 | GError * error = NULL; | ||
708 | 603 | |||
709 | 604 | g_dbus_connection_emit_signal (iapp->bus, | ||
710 | 605 | NULL, | ||
711 | 606 | REG_OBJECT, | ||
712 | 607 | REG_IFACE, | ||
713 | 608 | name, | ||
714 | 609 | variant, | ||
715 | 610 | &error); | ||
716 | 611 | |||
717 | 612 | if (error != NULL) { | ||
718 | 613 | g_error("Unable to send %s signal: %s", name, error->message); | ||
719 | 614 | g_error_free(error); | ||
720 | 615 | return; | ||
721 | 616 | } | ||
722 | 617 | |||
723 | 618 | return; | ||
724 | 470 | } | 619 | } |
725 | 471 | 620 | ||
726 | 472 | /* Close the current application using magic */ | 621 | /* Close the current application using magic */ |
727 | @@ -895,7 +1044,7 @@ | |||
728 | 895 | gtk_widget_hide(GTK_WIDGET(entry->label)); | 1044 | gtk_widget_hide(GTK_WIDGET(entry->label)); |
729 | 896 | } | 1045 | } |
730 | 897 | 1046 | ||
732 | 898 | if (entry->menu != NULL) { | 1047 | if (entry->menu != NULL && gtk_menu_get_attach_widget(entry->menu) != NULL) { |
733 | 899 | gtk_menu_detach(entry->menu); | 1048 | gtk_menu_detach(entry->menu); |
734 | 900 | } | 1049 | } |
735 | 901 | 1050 | ||
736 | @@ -1064,10 +1213,10 @@ | |||
737 | 1064 | } | 1213 | } |
738 | 1065 | 1214 | ||
739 | 1066 | /* A new window wishes to register it's windows with us */ | 1215 | /* A new window wishes to register it's windows with us */ |
742 | 1067 | static gboolean | 1216 | static GVariant * |
743 | 1068 | _application_menu_registrar_server_register_window (IndicatorAppmenu * iapp, guint windowid, const gchar * objectpath, DBusGMethodInvocation * method) | 1217 | register_window (IndicatorAppmenu * iapp, guint windowid, const gchar * objectpath, |
744 | 1218 | const gchar * sender) | ||
745 | 1069 | { | 1219 | { |
746 | 1070 | const gchar * sender = dbus_g_method_get_sender(method); | ||
747 | 1071 | g_debug("Registering window ID %d with path %s from %s", windowid, objectpath, sender); | 1220 | g_debug("Registering window ID %d with path %s from %s", windowid, objectpath, sender); |
748 | 1072 | 1221 | ||
749 | 1073 | if (g_hash_table_lookup(iapp->apps, GUINT_TO_POINTER(windowid)) == NULL && windowid != 0) { | 1222 | if (g_hash_table_lookup(iapp->apps, GUINT_TO_POINTER(windowid)) == NULL && windowid != 0) { |
750 | @@ -1078,7 +1227,8 @@ | |||
751 | 1078 | 1227 | ||
752 | 1079 | g_hash_table_insert(iapp->apps, GUINT_TO_POINTER(windowid), wm); | 1228 | g_hash_table_insert(iapp->apps, GUINT_TO_POINTER(windowid), wm); |
753 | 1080 | 1229 | ||
755 | 1081 | g_signal_emit(G_OBJECT(iapp), signals[WINDOW_REGISTERED], 0, windowid, sender, objectpath, TRUE); | 1230 | emit_signal(iapp, "WindowRegistered", |
756 | 1231 | g_variant_new("(uso)", windowid, sender, objectpath)); | ||
757 | 1082 | 1232 | ||
758 | 1083 | gpointer pdesktop = g_hash_table_lookup(iapp->desktop_windows, GUINT_TO_POINTER(windowid)); | 1233 | gpointer pdesktop = g_hash_table_lookup(iapp->desktop_windows, GUINT_TO_POINTER(windowid)); |
759 | 1084 | if (pdesktop != NULL) { | 1234 | if (pdesktop != NULL) { |
760 | @@ -1097,22 +1247,21 @@ | |||
761 | 1097 | } | 1247 | } |
762 | 1098 | } | 1248 | } |
763 | 1099 | 1249 | ||
766 | 1100 | dbus_g_method_return(method); | 1250 | return g_variant_new("()"); |
765 | 1101 | return TRUE; | ||
767 | 1102 | } | 1251 | } |
768 | 1103 | 1252 | ||
769 | 1104 | /* Kindly remove an entry from our DB */ | 1253 | /* Kindly remove an entry from our DB */ |
772 | 1105 | static gboolean | 1254 | static GVariant * |
773 | 1106 | _application_menu_registrar_server_unregister_window (IndicatorAppmenu * iapp, guint windowid, GError ** error) | 1255 | unregister_window (IndicatorAppmenu * iapp, guint windowid) |
774 | 1107 | { | 1256 | { |
775 | 1108 | /* TODO: Do it */ | 1257 | /* TODO: Do it */ |
776 | 1109 | 1258 | ||
778 | 1110 | return FALSE; | 1259 | return g_variant_new("()"); |
779 | 1111 | } | 1260 | } |
780 | 1112 | 1261 | ||
781 | 1113 | /* Grab the menu information for a specific window */ | 1262 | /* Grab the menu information for a specific window */ |
784 | 1114 | static gboolean | 1263 | static GVariant * |
785 | 1115 | _application_menu_registrar_server_get_menu_for_window (IndicatorAppmenu * iapp, guint windowid, gchar ** objectpath, gchar ** address, GError ** error) | 1264 | get_menu_for_window (IndicatorAppmenu * iapp, guint windowid, GError ** error) |
786 | 1116 | { | 1265 | { |
787 | 1117 | WindowMenus * wm = NULL; | 1266 | WindowMenus * wm = NULL; |
788 | 1118 | 1267 | ||
789 | @@ -1124,81 +1273,77 @@ | |||
790 | 1124 | 1273 | ||
791 | 1125 | if (wm == NULL) { | 1274 | if (wm == NULL) { |
792 | 1126 | g_set_error_literal(error, error_quark(), ERROR_WINDOW_NOT_FOUND, "Window not found"); | 1275 | g_set_error_literal(error, error_quark(), ERROR_WINDOW_NOT_FOUND, "Window not found"); |
794 | 1127 | return FALSE; | 1276 | return NULL; |
795 | 1128 | } | 1277 | } |
796 | 1129 | 1278 | ||
801 | 1130 | *objectpath = window_menus_get_path(wm); | 1279 | return g_variant_new("(so)", window_menus_get_address(wm), |
802 | 1131 | *address = window_menus_get_address(wm); | 1280 | window_menus_get_path(wm)); |
799 | 1132 | |||
800 | 1133 | return TRUE; | ||
803 | 1134 | } | 1281 | } |
804 | 1135 | 1282 | ||
805 | 1136 | /* Get all the menus we have */ | 1283 | /* Get all the menus we have */ |
808 | 1137 | static gboolean | 1284 | static GVariant * |
809 | 1138 | _application_menu_registrar_server_get_menus (IndicatorAppmenu * iapp, GPtrArray ** entries, GError ** error) | 1285 | get_menus (IndicatorAppmenu * iapp, GError ** error) |
810 | 1139 | { | 1286 | { |
811 | 1140 | if (iapp->apps == NULL) { | 1287 | if (iapp->apps == NULL) { |
812 | 1141 | g_set_error_literal(error, error_quark(), ERROR_NO_APPLICATIONS, "No applications are registered"); | 1288 | g_set_error_literal(error, error_quark(), ERROR_NO_APPLICATIONS, "No applications are registered"); |
814 | 1142 | return FALSE; | 1289 | return NULL; |
815 | 1143 | } | 1290 | } |
816 | 1144 | 1291 | ||
819 | 1145 | *entries = g_ptr_array_new(); | 1292 | GVariantBuilder * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); |
818 | 1146 | |||
820 | 1147 | GList * appkeys = NULL; | 1293 | GList * appkeys = NULL; |
821 | 1148 | for (appkeys = g_hash_table_get_keys(iapp->apps); appkeys != NULL; appkeys = g_list_next(appkeys)) { | 1294 | for (appkeys = g_hash_table_get_keys(iapp->apps); appkeys != NULL; appkeys = g_list_next(appkeys)) { |
822 | 1149 | GValueArray * structval = g_value_array_new(3); | ||
823 | 1150 | gpointer hash_val = g_hash_table_lookup(iapp->apps, appkeys->data); | 1295 | gpointer hash_val = g_hash_table_lookup(iapp->apps, appkeys->data); |
824 | 1151 | 1296 | ||
825 | 1152 | if (hash_val == NULL) { continue; } | 1297 | if (hash_val == NULL) { continue; } |
826 | 1153 | 1298 | ||
846 | 1154 | GValue winid = {0}; | 1299 | g_variant_builder_add (builder, "(uso)", |
847 | 1155 | g_value_init(&winid, G_TYPE_UINT); | 1300 | window_menus_get_xid(WINDOW_MENUS(hash_val)), |
848 | 1156 | g_value_set_uint(&winid, window_menus_get_xid(WINDOW_MENUS(hash_val))); | 1301 | window_menus_get_path(WINDOW_MENUS(hash_val)), |
849 | 1157 | g_value_array_append(structval, &winid); | 1302 | window_menus_get_address(WINDOW_MENUS(hash_val))); |
831 | 1158 | g_value_unset(&winid); | ||
832 | 1159 | |||
833 | 1160 | GValue path = {0}; | ||
834 | 1161 | g_value_init(&path, DBUS_TYPE_G_OBJECT_PATH); | ||
835 | 1162 | g_value_take_boxed(&path, window_menus_get_path(WINDOW_MENUS(hash_val))); | ||
836 | 1163 | g_value_array_append(structval, &path); | ||
837 | 1164 | g_value_unset(&path); | ||
838 | 1165 | |||
839 | 1166 | GValue address = {0}; | ||
840 | 1167 | g_value_init(&address, G_TYPE_STRING); | ||
841 | 1168 | g_value_take_string(&address, window_menus_get_address(WINDOW_MENUS(hash_val))); | ||
842 | 1169 | g_value_array_append(structval, &address); | ||
843 | 1170 | g_value_unset(&address); | ||
844 | 1171 | |||
845 | 1172 | g_ptr_array_add(*entries, structval); | ||
850 | 1173 | } | 1303 | } |
851 | 1174 | 1304 | ||
853 | 1175 | return TRUE; | 1305 | return g_variant_new("(a(uso))", builder); |
854 | 1176 | } | 1306 | } |
855 | 1177 | 1307 | ||
857 | 1178 | /* Response to whether we got our name or not */ | 1308 | /* A method has been called from our dbus inteface. Figure out what it |
858 | 1309 | is and dispatch it. */ | ||
859 | 1179 | static void | 1310 | static void |
861 | 1180 | request_name_cb (DBusGProxy *proxy, guint result, GError * inerror, gpointer userdata) | 1311 | bus_method_call (GDBusConnection * connection, const gchar * sender, |
862 | 1312 | const gchar * path, const gchar * interface, | ||
863 | 1313 | const gchar * method, GVariant * params, | ||
864 | 1314 | GDBusMethodInvocation * invocation, gpointer user_data) | ||
865 | 1181 | { | 1315 | { |
886 | 1182 | gboolean error = FALSE; | 1316 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(user_data); |
887 | 1183 | 1317 | GVariant * retval = NULL; | |
888 | 1184 | if (inerror != NULL) { | 1318 | GError * error = NULL; |
889 | 1185 | g_warning("Unable to get name request: %s", inerror->message); | 1319 | |
890 | 1186 | error = TRUE; | 1320 | if (g_strcmp0(method, "RegisterWindow") == 0) { |
891 | 1187 | } | 1321 | guint32 xid; |
892 | 1188 | 1322 | const gchar * path; | |
893 | 1189 | if (!error && result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER && result != DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) { | 1323 | g_variant_get(params, "(u&o)", &xid, &path); |
894 | 1190 | g_warning("The dbus name we want is already taken"); | 1324 | retval = register_window(iapp, xid, path, sender); |
895 | 1191 | error = TRUE; | 1325 | } else if (g_strcmp0(method, "UnregisterWindow") == 0) { |
896 | 1192 | } | 1326 | guint32 xid; |
897 | 1193 | 1327 | g_variant_get(params, "(u)", &xid); | |
898 | 1194 | if (error) { | 1328 | retval = unregister_window(iapp, xid); |
899 | 1195 | /* We can rest assured no one will register with us, but let's | 1329 | } else if (g_strcmp0(method, "GetMenuForWindow") == 0) { |
900 | 1196 | just ensure we're not showing anything. */ | 1330 | guint32 xid; |
901 | 1197 | switch_default_app(INDICATOR_APPMENU(userdata), NULL, NULL); | 1331 | g_variant_get(params, "(u)", &xid); |
902 | 1198 | } | 1332 | retval = get_menu_for_window(iapp, xid, &error); |
903 | 1199 | 1333 | } else if (g_strcmp0(method, "GetMenus") == 0) { | |
904 | 1200 | g_object_unref(proxy); | 1334 | retval = get_menus(iapp, &error); |
905 | 1201 | 1335 | } else { | |
906 | 1336 | g_warning("Calling method '%s' on the indicator service and it's unknown", method); | ||
907 | 1337 | } | ||
908 | 1338 | |||
909 | 1339 | if (error != NULL) { | ||
910 | 1340 | g_dbus_method_invocation_return_dbus_error(invocation, | ||
911 | 1341 | "org.ayatana.AppMenu.Error", | ||
912 | 1342 | error->message); | ||
913 | 1343 | g_error_free(error); | ||
914 | 1344 | } else { | ||
915 | 1345 | g_dbus_method_invocation_return_value(invocation, retval); | ||
916 | 1346 | } | ||
917 | 1202 | return; | 1347 | return; |
918 | 1203 | } | 1348 | } |
919 | 1204 | 1349 | ||
920 | @@ -1453,44 +1598,36 @@ | |||
921 | 1453 | } | 1598 | } |
922 | 1454 | 1599 | ||
923 | 1455 | /* Grab the location of the dbusmenu of the current menu */ | 1600 | /* Grab the location of the dbusmenu of the current menu */ |
926 | 1456 | static gboolean | 1601 | static GVariant * |
927 | 1457 | _application_menu_renderer_server_get_current_menu (IndicatorAppmenuDebug * iappd, gchar ** objectpath, gchar ** address, GError ** error) | 1602 | get_current_menu (IndicatorAppmenuDebug * iappd, GError ** error) |
928 | 1458 | { | 1603 | { |
929 | 1459 | IndicatorAppmenu * iapp = iappd->appmenu; | 1604 | IndicatorAppmenu * iapp = iappd->appmenu; |
930 | 1460 | 1605 | ||
931 | 1461 | if (iapp->default_app == NULL) { | 1606 | if (iapp->default_app == NULL) { |
932 | 1462 | g_set_error_literal(error, error_quark(), ERROR_NO_DEFAULT_APP, "Not currently showing an application"); | 1607 | g_set_error_literal(error, error_quark(), ERROR_NO_DEFAULT_APP, "Not currently showing an application"); |
934 | 1463 | return FALSE; | 1608 | return NULL; |
935 | 1464 | } | 1609 | } |
936 | 1465 | 1610 | ||
941 | 1466 | *objectpath = window_menus_get_path(iapp->default_app); | 1611 | return g_variant_new("(so)", window_menus_get_address(iapp->default_app), |
942 | 1467 | *address = window_menus_get_address(iapp->default_app); | 1612 | window_menus_get_path(iapp->default_app)); |
939 | 1468 | |||
940 | 1469 | return TRUE; | ||
943 | 1470 | } | 1613 | } |
944 | 1471 | 1614 | ||
945 | 1472 | /* Activate menu items through a script given as a parameter */ | 1615 | /* Activate menu items through a script given as a parameter */ |
948 | 1473 | static gboolean | 1616 | static GVariant * |
949 | 1474 | _application_menu_renderer_server_activate_menu_item (IndicatorAppmenuDebug * iappd, GArray * menulist, GError ** error) | 1617 | activate_menu_item (IndicatorAppmenuDebug * iappd, GVariantIter * iter, GError ** error) |
950 | 1475 | { | 1618 | { |
951 | 1476 | /* TODO: Do it */ | 1619 | /* TODO: Do it */ |
952 | 1477 | 1620 | ||
961 | 1478 | return FALSE; | 1621 | return g_variant_new("()"); |
954 | 1479 | } | ||
955 | 1480 | |||
956 | 1481 | /* Dump the current menu to a JSON file */ | ||
957 | 1482 | static gboolean | ||
958 | 1483 | _application_menu_renderer_server_dump_current_menu (IndicatorAppmenuDebug * iappd, gchar ** jsondata, GError ** error) | ||
959 | 1484 | { | ||
960 | 1485 | return _application_menu_renderer_server_dump_menu(iappd, 0, jsondata, error); | ||
962 | 1486 | } | 1622 | } |
963 | 1487 | 1623 | ||
964 | 1488 | /* Dump a specific window's menus to a JSON file */ | 1624 | /* Dump a specific window's menus to a JSON file */ |
967 | 1489 | static gboolean | 1625 | static GVariant * |
968 | 1490 | _application_menu_renderer_server_dump_menu (IndicatorAppmenuDebug * iappd, guint windowid, gchar ** jsondata, GError ** error) | 1626 | dump_menu (IndicatorAppmenuDebug * iappd, guint windowid, GError ** error) |
969 | 1491 | { | 1627 | { |
970 | 1492 | IndicatorAppmenu * iapp = iappd->appmenu; | 1628 | IndicatorAppmenu * iapp = iappd->appmenu; |
971 | 1493 | WindowMenus * wm = NULL; | 1629 | WindowMenus * wm = NULL; |
972 | 1630 | gchar * jsondata = NULL; | ||
973 | 1494 | 1631 | ||
974 | 1495 | if (windowid == 0) { | 1632 | if (windowid == 0) { |
975 | 1496 | wm = iapp->default_app; | 1633 | wm = iapp->default_app; |
976 | @@ -1500,7 +1637,7 @@ | |||
977 | 1500 | 1637 | ||
978 | 1501 | if (wm == NULL) { | 1638 | if (wm == NULL) { |
979 | 1502 | g_set_error_literal(error, error_quark(), ERROR_WINDOW_NOT_FOUND, "Window not found"); | 1639 | g_set_error_literal(error, error_quark(), ERROR_WINDOW_NOT_FOUND, "Window not found"); |
981 | 1503 | return FALSE; | 1640 | return NULL; |
982 | 1504 | } | 1641 | } |
983 | 1505 | 1642 | ||
984 | 1506 | GArray * strings = g_array_new(TRUE, FALSE, sizeof(gchar *)); | 1643 | GArray * strings = g_array_new(TRUE, FALSE, sizeof(gchar *)); |
985 | @@ -1548,10 +1685,59 @@ | |||
986 | 1548 | temp = g_strdup("}"); | 1685 | temp = g_strdup("}"); |
987 | 1549 | g_array_append_val(strings, temp); | 1686 | g_array_append_val(strings, temp); |
988 | 1550 | 1687 | ||
990 | 1551 | *jsondata = g_strjoinv(NULL, (gchar **)strings->data); | 1688 | jsondata = g_strjoinv(NULL, (gchar **)strings->data); |
991 | 1552 | g_strfreev((gchar **)strings->data); | 1689 | g_strfreev((gchar **)strings->data); |
992 | 1553 | g_array_free(strings, FALSE); | 1690 | g_array_free(strings, FALSE); |
993 | 1554 | 1691 | ||
995 | 1555 | return TRUE; | 1692 | GVariant * rv = g_variant_new("(s)", jsondata); |
996 | 1693 | g_free(jsondata); | ||
997 | 1694 | return rv; | ||
998 | 1695 | } | ||
999 | 1696 | |||
1000 | 1697 | /* Dump the current menu to a JSON file */ | ||
1001 | 1698 | static GVariant * | ||
1002 | 1699 | dump_current_menu (IndicatorAppmenuDebug * iappd, GError ** error) | ||
1003 | 1700 | { | ||
1004 | 1701 | return dump_menu(iappd, 0, error); | ||
1005 | 1702 | } | ||
1006 | 1703 | |||
1007 | 1704 | /* A method has been called from our dbus inteface. Figure out what it | ||
1008 | 1705 | is and dispatch it. */ | ||
1009 | 1706 | static void | ||
1010 | 1707 | dbg_bus_method_call (GDBusConnection * connection, const gchar * sender, | ||
1011 | 1708 | const gchar * path, const gchar * interface, | ||
1012 | 1709 | const gchar * method, GVariant * params, | ||
1013 | 1710 | GDBusMethodInvocation * invocation, gpointer user_data) | ||
1014 | 1711 | { | ||
1015 | 1712 | IndicatorAppmenuDebug * iappd = INDICATOR_APPMENU_DEBUG(user_data); | ||
1016 | 1713 | GVariant * retval = NULL; | ||
1017 | 1714 | GError * error = NULL; | ||
1018 | 1715 | |||
1019 | 1716 | if (g_strcmp0(method, "GetCurrentMenu") == 0) { | ||
1020 | 1717 | retval = get_current_menu(iappd, &error); | ||
1021 | 1718 | } else if (g_strcmp0(method, "ActivateMenuItem") == 0) { | ||
1022 | 1719 | GVariantIter *iter; | ||
1023 | 1720 | g_variant_get(params, "(ai)", &iter); | ||
1024 | 1721 | retval = activate_menu_item(iappd, iter, &error); | ||
1025 | 1722 | g_variant_iter_free(iter); | ||
1026 | 1723 | } else if (g_strcmp0(method, "DumpCurrentMenu") == 0) { | ||
1027 | 1724 | retval = dump_current_menu(iappd, &error); | ||
1028 | 1725 | } else if (g_strcmp0(method, "DumpMenu") == 0) { | ||
1029 | 1726 | guint32 xid; | ||
1030 | 1727 | g_variant_get(params, "(u)", &xid); | ||
1031 | 1728 | retval = dump_menu(iappd, xid, &error); | ||
1032 | 1729 | } else { | ||
1033 | 1730 | g_warning("Calling method '%s' on the indicator service and it's unknown", method); | ||
1034 | 1731 | } | ||
1035 | 1732 | |||
1036 | 1733 | if (error != NULL) { | ||
1037 | 1734 | g_dbus_method_invocation_return_dbus_error(invocation, | ||
1038 | 1735 | "org.ayatana.AppMenu.Error", | ||
1039 | 1736 | error->message); | ||
1040 | 1737 | g_error_free(error); | ||
1041 | 1738 | } else { | ||
1042 | 1739 | g_dbus_method_invocation_return_value(invocation, retval); | ||
1043 | 1740 | } | ||
1044 | 1741 | return; | ||
1045 | 1556 | } | 1742 | } |
1046 | 1557 | 1743 | ||
1047 | 1558 | 1744 | ||
1048 | === modified file 'src/window-menus.c' | |||
1049 | --- src/window-menus.c 2010-12-10 22:28:31 +0000 | |||
1050 | +++ src/window-menus.c 2011-01-13 04:42:14 +0000 | |||
1051 | @@ -24,8 +24,8 @@ | |||
1052 | 24 | #endif | 24 | #endif |
1053 | 25 | 25 | ||
1054 | 26 | #include <libdbusmenu-gtk/menu.h> | 26 | #include <libdbusmenu-gtk/menu.h> |
1055 | 27 | #include <dbus/dbus-glib.h> | ||
1056 | 28 | #include <glib.h> | 27 | #include <glib.h> |
1057 | 28 | #include <gio/gio.h> | ||
1058 | 29 | 29 | ||
1059 | 30 | #include "window-menus.h" | 30 | #include "window-menus.h" |
1060 | 31 | #include "indicator-appmenu-marshal.h" | 31 | #include "indicator-appmenu-marshal.h" |
1061 | @@ -37,13 +37,14 @@ | |||
1062 | 37 | guint windowid; | 37 | guint windowid; |
1063 | 38 | DbusmenuGtkClient * client; | 38 | DbusmenuGtkClient * client; |
1064 | 39 | DbusmenuMenuitem * root; | 39 | DbusmenuMenuitem * root; |
1066 | 40 | DBusGProxy * props; | 40 | GCancellable * props_cancel; |
1067 | 41 | GDBusProxy * props; | ||
1068 | 41 | GArray * entries; | 42 | GArray * entries; |
1069 | 42 | gboolean error_state; | 43 | gboolean error_state; |
1070 | 43 | guint retry_timer; | 44 | guint retry_timer; |
1071 | 44 | gint retry_id; | 45 | gint retry_id; |
1072 | 45 | gchar * retry_name; | 46 | gchar * retry_name; |
1074 | 46 | GValue retry_data; | 47 | GVariant * retry_data; |
1075 | 47 | guint retry_timestamp; | 48 | guint retry_timestamp; |
1076 | 48 | }; | 49 | }; |
1077 | 49 | 50 | ||
1078 | @@ -77,12 +78,13 @@ | |||
1079 | 77 | static void window_menus_init (WindowMenus *self); | 78 | static void window_menus_init (WindowMenus *self); |
1080 | 78 | static void window_menus_dispose (GObject *object); | 79 | static void window_menus_dispose (GObject *object); |
1081 | 79 | static void window_menus_finalize (GObject *object); | 80 | static void window_menus_finalize (GObject *object); |
1083 | 80 | static void properties_destroyed (GObject * object, gpointer user_data); | 81 | static void name_owner_changed (GObject * gobject, GParamSpec * pspec, gpointer user_data); |
1084 | 81 | static void root_changed (DbusmenuClient * client, DbusmenuMenuitem * new_root, gpointer user_data); | 82 | static void root_changed (DbusmenuClient * client, DbusmenuMenuitem * new_root, gpointer user_data); |
1085 | 82 | static void menu_entry_added (DbusmenuMenuitem * root, DbusmenuMenuitem * newentry, guint position, gpointer user_data); | 83 | static void menu_entry_added (DbusmenuMenuitem * root, DbusmenuMenuitem * newentry, guint position, gpointer user_data); |
1086 | 83 | static void menu_entry_removed (DbusmenuMenuitem * root, DbusmenuMenuitem * oldentry, gpointer user_data); | 84 | static void menu_entry_removed (DbusmenuMenuitem * root, DbusmenuMenuitem * oldentry, gpointer user_data); |
1087 | 84 | static void menu_entry_realized (DbusmenuMenuitem * newentry, gpointer user_data); | 85 | static void menu_entry_realized (DbusmenuMenuitem * newentry, gpointer user_data); |
1088 | 85 | static void menu_child_realized (DbusmenuMenuitem * child, gpointer user_data); | 86 | static void menu_child_realized (DbusmenuMenuitem * child, gpointer user_data); |
1089 | 87 | static void props_cb (GObject * object, GAsyncResult * res, gpointer user_data); | ||
1090 | 86 | 88 | ||
1091 | 87 | G_DEFINE_TYPE (WindowMenus, window_menus, G_TYPE_OBJECT); | 89 | G_DEFINE_TYPE (WindowMenus, window_menus, G_TYPE_OBJECT); |
1092 | 88 | 90 | ||
1093 | @@ -144,6 +146,7 @@ | |||
1094 | 144 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(self); | 146 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(self); |
1095 | 145 | 147 | ||
1096 | 146 | priv->client = NULL; | 148 | priv->client = NULL; |
1097 | 149 | priv->props_cancel = NULL; | ||
1098 | 147 | priv->props = NULL; | 150 | priv->props = NULL; |
1099 | 148 | priv->root = NULL; | 151 | priv->root = NULL; |
1100 | 149 | priv->error_state = FALSE; | 152 | priv->error_state = FALSE; |
1101 | @@ -176,11 +179,17 @@ | |||
1102 | 176 | priv->props = NULL; | 179 | priv->props = NULL; |
1103 | 177 | } | 180 | } |
1104 | 178 | 181 | ||
1105 | 182 | if (priv->props_cancel != NULL) { | ||
1106 | 183 | g_cancellable_cancel(priv->props_cancel); | ||
1107 | 184 | g_object_unref(priv->props_cancel); | ||
1108 | 185 | priv->props_cancel = NULL; | ||
1109 | 186 | } | ||
1110 | 187 | |||
1111 | 179 | if (priv->retry_timer != 0) { | 188 | if (priv->retry_timer != 0) { |
1112 | 180 | g_source_remove(priv->retry_timer); | 189 | g_source_remove(priv->retry_timer); |
1113 | 181 | priv->retry_timer = 0; | 190 | priv->retry_timer = 0; |
1116 | 182 | g_value_unset(&priv->retry_data); | 191 | g_variant_unref(priv->retry_data); |
1117 | 183 | g_value_reset(&priv->retry_data); | 192 | priv->retry_data = NULL; |
1118 | 184 | g_free(priv->retry_name); | 193 | g_free(priv->retry_name); |
1119 | 185 | priv->retry_name = NULL; | 194 | priv->retry_name = NULL; |
1120 | 186 | } | 195 | } |
1121 | @@ -227,11 +236,11 @@ | |||
1122 | 227 | g_return_val_if_fail(IS_WINDOW_MENUS(user_data), FALSE); | 236 | g_return_val_if_fail(IS_WINDOW_MENUS(user_data), FALSE); |
1123 | 228 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(user_data); | 237 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(user_data); |
1124 | 229 | 238 | ||
1126 | 230 | dbusmenu_client_send_event(DBUSMENU_CLIENT(priv->client), priv->retry_id, priv->retry_name, &priv->retry_data, priv->retry_timestamp); | 239 | dbusmenu_client_send_event(DBUSMENU_CLIENT(priv->client), priv->retry_id, priv->retry_name, priv->retry_data, priv->retry_timestamp); |
1127 | 231 | 240 | ||
1128 | 232 | priv->retry_timer = 0; | 241 | priv->retry_timer = 0; |
1131 | 233 | g_value_unset(&priv->retry_data); | 242 | g_variant_unref(priv->retry_data); |
1132 | 234 | g_value_reset(&priv->retry_data); | 243 | priv->retry_data = NULL; |
1133 | 235 | g_free(priv->retry_name); | 244 | g_free(priv->retry_name); |
1134 | 236 | priv->retry_name = NULL; | 245 | priv->retry_name = NULL; |
1135 | 237 | 246 | ||
1136 | @@ -240,7 +249,7 @@ | |||
1137 | 240 | 249 | ||
1138 | 241 | /* Listen to whether our events are successfully sent */ | 250 | /* Listen to whether our events are successfully sent */ |
1139 | 242 | static void | 251 | static void |
1141 | 243 | event_status (DbusmenuClient * client, DbusmenuMenuitem * mi, gchar * event, GValue * evdata, guint timestamp, GError * error, gpointer user_data) | 252 | event_status (DbusmenuClient * client, DbusmenuMenuitem * mi, gchar * event, GVariant * evdata, guint timestamp, GError * error, gpointer user_data) |
1142 | 244 | { | 253 | { |
1143 | 245 | g_return_if_fail(IS_WINDOW_MENUS(user_data)); | 254 | g_return_if_fail(IS_WINDOW_MENUS(user_data)); |
1144 | 246 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(user_data); | 255 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(user_data); |
1145 | @@ -266,8 +275,8 @@ | |||
1146 | 266 | if (priv->retry_timer != 0) { | 275 | if (priv->retry_timer != 0) { |
1147 | 267 | g_source_remove(priv->retry_timer); | 276 | g_source_remove(priv->retry_timer); |
1148 | 268 | priv->retry_timer = 0; | 277 | priv->retry_timer = 0; |
1151 | 269 | g_value_unset(&priv->retry_data); | 278 | g_variant_unref(priv->retry_data); |
1152 | 270 | g_value_reset(&priv->retry_data); | 279 | priv->retry_data = NULL; |
1153 | 271 | g_free(priv->retry_name); | 280 | g_free(priv->retry_name); |
1154 | 272 | priv->retry_name = NULL; | 281 | priv->retry_name = NULL; |
1155 | 273 | } | 282 | } |
1156 | @@ -297,8 +306,7 @@ | |||
1157 | 297 | 306 | ||
1158 | 298 | priv->retry_id = dbusmenu_menuitem_get_id(mi); | 307 | priv->retry_id = dbusmenu_menuitem_get_id(mi); |
1159 | 299 | priv->retry_name = g_strdup(event); | 308 | priv->retry_name = g_strdup(event); |
1162 | 300 | g_value_init(&priv->retry_data, G_VALUE_TYPE(evdata)); | 309 | priv->retry_data = g_variant_ref(evdata); |
1161 | 301 | g_value_copy(evdata, &priv->retry_data); | ||
1163 | 302 | priv->retry_timestamp = timestamp; | 310 | priv->retry_timestamp = timestamp; |
1164 | 303 | } | 311 | } |
1165 | 304 | 312 | ||
1166 | @@ -360,26 +368,22 @@ | |||
1167 | 360 | g_return_val_if_fail(dbus_addr != NULL, NULL); | 368 | g_return_val_if_fail(dbus_addr != NULL, NULL); |
1168 | 361 | g_return_val_if_fail(dbus_object != NULL, NULL); | 369 | g_return_val_if_fail(dbus_object != NULL, NULL); |
1169 | 362 | 370 | ||
1170 | 363 | DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); | ||
1171 | 364 | g_return_val_if_fail(session_bus != NULL, NULL); | ||
1172 | 365 | |||
1173 | 366 | WindowMenus * newmenu = WINDOW_MENUS(g_object_new(WINDOW_MENUS_TYPE, NULL)); | 371 | WindowMenus * newmenu = WINDOW_MENUS(g_object_new(WINDOW_MENUS_TYPE, NULL)); |
1174 | 367 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(newmenu); | 372 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(newmenu); |
1175 | 368 | 373 | ||
1176 | 369 | priv->windowid = windowid; | 374 | priv->windowid = windowid; |
1177 | 370 | 375 | ||
1190 | 371 | priv->props = dbus_g_proxy_new_for_name_owner(session_bus, | 376 | /* Build the service proxy */ |
1191 | 372 | dbus_addr, | 377 | priv->props_cancel = g_cancellable_new(); |
1192 | 373 | dbus_object, | 378 | g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION, |
1193 | 374 | DBUS_INTERFACE_PROPERTIES, | 379 | G_DBUS_PROXY_FLAGS_NONE, |
1194 | 375 | NULL); | 380 | NULL, |
1195 | 376 | if (priv->props == NULL) { | 381 | dbus_addr, |
1196 | 377 | g_warning("Unable to get property proxy on '%s' object '%s'", dbus_addr, dbus_object); | 382 | dbus_object, |
1197 | 378 | g_object_unref(newmenu); | 383 | "org.freedesktop.DBus.Properties", |
1198 | 379 | return NULL; | 384 | priv->props_cancel, |
1199 | 380 | } | 385 | props_cb, |
1200 | 381 | 386 | newmenu); | |
1189 | 382 | g_signal_connect(G_OBJECT(priv->props), "destroy", G_CALLBACK(properties_destroyed), newmenu); | ||
1201 | 383 | 387 | ||
1202 | 384 | priv->client = dbusmenu_gtkclient_new((gchar *)dbus_addr, (gchar *)dbus_object); | 388 | priv->client = dbusmenu_gtkclient_new((gchar *)dbus_addr, (gchar *)dbus_object); |
1203 | 385 | GtkAccelGroup * agroup = gtk_accel_group_new(); | 389 | GtkAccelGroup * agroup = gtk_accel_group_new(); |
1204 | @@ -397,17 +401,57 @@ | |||
1205 | 397 | return newmenu; | 401 | return newmenu; |
1206 | 398 | } | 402 | } |
1207 | 399 | 403 | ||
1212 | 400 | /* Respond to the proxies getting destoryed. I means that we need | 404 | /* Callback from trying to create the proxy for the service, this |
1213 | 401 | to kill ourselves. */ | 405 | could include starting the service. */ |
1214 | 402 | static void | 406 | static void |
1215 | 403 | properties_destroyed (GObject * object, gpointer user_data) | 407 | props_cb (GObject * object, GAsyncResult * res, gpointer user_data) |
1216 | 408 | { | ||
1217 | 409 | GError * error = NULL; | ||
1218 | 410 | |||
1219 | 411 | WindowMenus * self = WINDOW_MENUS(user_data); | ||
1220 | 412 | g_return_if_fail(self != NULL); | ||
1221 | 413 | |||
1222 | 414 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(self); | ||
1223 | 415 | GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); | ||
1224 | 416 | |||
1225 | 417 | if (priv->props_cancel != NULL) { | ||
1226 | 418 | g_object_unref(priv->props_cancel); | ||
1227 | 419 | priv->props_cancel = NULL; | ||
1228 | 420 | } | ||
1229 | 421 | |||
1230 | 422 | if (error != NULL) { | ||
1231 | 423 | g_error("Could not grab DBus proxy for window %u: %s", priv->windowid, error->message); | ||
1232 | 424 | g_error_free(error); | ||
1233 | 425 | return; | ||
1234 | 426 | } | ||
1235 | 427 | |||
1236 | 428 | /* Okay, we're good to grab the proxy at this point, we're | ||
1237 | 429 | sure that it's ours. */ | ||
1238 | 430 | priv->props = proxy; | ||
1239 | 431 | |||
1240 | 432 | g_signal_connect(proxy, "notify::g-name-owner", G_CALLBACK(name_owner_changed), self); | ||
1241 | 433 | |||
1242 | 434 | return; | ||
1243 | 435 | } | ||
1244 | 436 | |||
1245 | 437 | /* Gets called when the proxy changes owners, which is usually when it | ||
1246 | 438 | drops off of the bus. */ | ||
1247 | 439 | static void | ||
1248 | 440 | name_owner_changed (GObject * gobject, GParamSpec * pspec, gpointer user_data) | ||
1249 | 404 | { | 441 | { |
1250 | 405 | WindowMenus * wm = WINDOW_MENUS(user_data); | 442 | WindowMenus * wm = WINDOW_MENUS(user_data); |
1251 | 406 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(wm); | 443 | WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(wm); |
1254 | 407 | 444 | GDBusProxy * proxy = G_DBUS_PROXY(gobject); | |
1255 | 408 | priv->props = NULL; | 445 | |
1256 | 446 | gchar * owner = g_dbus_proxy_get_name_owner(proxy); | ||
1257 | 447 | if (owner != NULL) { | ||
1258 | 448 | /* OK, carry on */ | ||
1259 | 449 | g_free (owner); | ||
1260 | 450 | return; | ||
1261 | 451 | } | ||
1262 | 452 | |||
1263 | 453 | /* We should die now */ | ||
1264 | 409 | g_debug("Properties destroyed for window: %d", priv->windowid); | 454 | g_debug("Properties destroyed for window: %d", priv->windowid); |
1265 | 410 | |||
1266 | 411 | g_object_unref(G_OBJECT(wm)); | 455 | g_object_unref(G_OBJECT(wm)); |
1267 | 412 | return; | 456 | return; |
1268 | 413 | } | 457 | } |
1269 | @@ -554,13 +598,13 @@ | |||
1270 | 554 | /* Respond to properties changing on the menu item so that we can | 598 | /* Respond to properties changing on the menu item so that we can |
1271 | 555 | properly hide and show them. */ | 599 | properly hide and show them. */ |
1272 | 556 | static void | 600 | static void |
1274 | 557 | menu_prop_changed (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data) | 601 | menu_prop_changed (DbusmenuMenuitem * item, const gchar * property, GVariant * value, gpointer user_data) |
1275 | 558 | { | 602 | { |
1276 | 559 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)user_data; | 603 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)user_data; |
1277 | 560 | WMEntry * wmentry = (WMEntry *)user_data; | 604 | WMEntry * wmentry = (WMEntry *)user_data; |
1278 | 561 | 605 | ||
1279 | 562 | if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_VISIBLE)) { | 606 | if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_VISIBLE)) { |
1281 | 563 | if (g_value_get_boolean(value)) { | 607 | if (g_variant_get_boolean(value)) { |
1282 | 564 | gtk_widget_show(GTK_WIDGET(entry->label)); | 608 | gtk_widget_show(GTK_WIDGET(entry->label)); |
1283 | 565 | wmentry->hidden = FALSE; | 609 | wmentry->hidden = FALSE; |
1284 | 566 | } else { | 610 | } else { |
1285 | @@ -568,10 +612,10 @@ | |||
1286 | 568 | wmentry->hidden = TRUE; | 612 | wmentry->hidden = TRUE; |
1287 | 569 | } | 613 | } |
1288 | 570 | } else if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ENABLED)) { | 614 | } else if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ENABLED)) { |
1291 | 571 | gtk_widget_set_sensitive(GTK_WIDGET(entry->label), g_value_get_boolean(value)); | 615 | gtk_widget_set_sensitive(GTK_WIDGET(entry->label), g_variant_get_boolean(value)); |
1292 | 572 | wmentry->disabled = !g_value_get_boolean(value); | 616 | wmentry->disabled = !g_variant_get_boolean(value); |
1293 | 573 | } else if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_LABEL)) { | 617 | } else if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_LABEL)) { |
1295 | 574 | gtk_label_set_text_with_mnemonic(entry->label, g_value_get_string(value)); | 618 | gtk_label_set_text_with_mnemonic(entry->label, g_variant_get_string(value, NULL)); |
1296 | 575 | } | 619 | } |
1297 | 576 | 620 | ||
1298 | 577 | return; | 621 | return; |
1299 | @@ -609,7 +653,7 @@ | |||
1300 | 609 | 653 | ||
1301 | 610 | g_signal_connect(G_OBJECT(newentry), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_changed), entry); | 654 | g_signal_connect(G_OBJECT(newentry), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_changed), entry); |
1302 | 611 | 655 | ||
1304 | 612 | if (dbusmenu_menuitem_property_get_value(newentry, DBUSMENU_MENUITEM_PROP_VISIBLE) != NULL | 656 | if (dbusmenu_menuitem_property_get_variant(newentry, DBUSMENU_MENUITEM_PROP_VISIBLE) != NULL |
1305 | 613 | && dbusmenu_menuitem_property_get_bool(newentry, DBUSMENU_MENUITEM_PROP_VISIBLE) == FALSE) { | 657 | && dbusmenu_menuitem_property_get_bool(newentry, DBUSMENU_MENUITEM_PROP_VISIBLE) == FALSE) { |
1306 | 614 | gtk_widget_hide(GTK_WIDGET(entry->label)); | 658 | gtk_widget_hide(GTK_WIDGET(entry->label)); |
1307 | 615 | wmentry->hidden = TRUE; | 659 | wmentry->hidden = TRUE; |
1308 | @@ -618,7 +662,7 @@ | |||
1309 | 618 | wmentry->hidden = FALSE; | 662 | wmentry->hidden = FALSE; |
1310 | 619 | } | 663 | } |
1311 | 620 | 664 | ||
1313 | 621 | if (dbusmenu_menuitem_property_get_value (newentry, DBUSMENU_MENUITEM_PROP_ENABLED) != NULL) { | 665 | if (dbusmenu_menuitem_property_get_variant (newentry, DBUSMENU_MENUITEM_PROP_ENABLED) != NULL) { |
1314 | 622 | gboolean sensitive = dbusmenu_menuitem_property_get_bool(newentry, DBUSMENU_MENUITEM_PROP_ENABLED); | 666 | gboolean sensitive = dbusmenu_menuitem_property_get_bool(newentry, DBUSMENU_MENUITEM_PROP_ENABLED); |
1315 | 623 | gtk_widget_set_sensitive(GTK_WIDGET(entry->label), sensitive); | 667 | gtk_widget_set_sensitive(GTK_WIDGET(entry->label), sensitive); |
1316 | 624 | wmentry->disabled = !sensitive; | 668 | wmentry->disabled = !sensitive; |
1317 | 625 | 669 | ||
1318 | === modified file 'tools/mock-json-app.c' | |||
1319 | --- tools/mock-json-app.c 2010-07-20 21:48:25 +0000 | |||
1320 | +++ tools/mock-json-app.c 2011-01-13 04:42:14 +0000 | |||
1321 | @@ -22,43 +22,49 @@ | |||
1322 | 22 | 22 | ||
1323 | 23 | #include <gtk/gtk.h> | 23 | #include <gtk/gtk.h> |
1324 | 24 | #include <gdk/gdkx.h> | 24 | #include <gdk/gdkx.h> |
1326 | 25 | #include <dbus/dbus-glib.h> | 25 | #include <gio/gio.h> |
1327 | 26 | #include <libdbusmenu-glib/server.h> | 26 | #include <libdbusmenu-glib/server.h> |
1328 | 27 | #include <libdbusmenu-jsonloader/json-loader.h> | 27 | #include <libdbusmenu-jsonloader/json-loader.h> |
1329 | 28 | 28 | ||
1330 | 29 | #include "../src/dbus-shared.h" | 29 | #include "../src/dbus-shared.h" |
1331 | 30 | #include "../src/application-menu-registrar-client.h" | ||
1332 | 31 | 30 | ||
1333 | 32 | #define MENU_PATH "/mock/json/app/menu" | 31 | #define MENU_PATH "/mock/json/app/menu" |
1334 | 33 | 32 | ||
1335 | 34 | GtkWidget * window = NULL; | 33 | GtkWidget * window = NULL; |
1336 | 35 | DbusmenuServer * server = NULL; | 34 | DbusmenuServer * server = NULL; |
1352 | 36 | DBusGProxy * registrar = NULL; | 35 | GDBusProxy * registrar = NULL; |
1353 | 37 | 36 | ||
1354 | 38 | static void | 37 | static void |
1355 | 39 | register_cb (DBusGProxy *proxy, GError *error, gpointer userdata) | 38 | dbus_owner_change (GObject *gobject, GParamSpec *pspec, gpointer user_data) |
1356 | 40 | { | 39 | { |
1357 | 41 | if (error != NULL) { | 40 | GDBusProxy * proxy = G_DBUS_PROXY(gobject); |
1358 | 42 | g_warning("Unable to register: %s", error->message); | 41 | |
1359 | 43 | } | 42 | gchar * owner = g_dbus_proxy_get_name_owner(proxy); |
1360 | 44 | return; | 43 | |
1361 | 45 | } | 44 | if (owner == NULL || owner[0] == '\0') { |
1347 | 46 | |||
1348 | 47 | static void | ||
1349 | 48 | dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, gpointer data) | ||
1350 | 49 | { | ||
1351 | 50 | if (new == NULL || new[0] == '\0') { | ||
1362 | 51 | /* We only care about folks coming on the bus. Exit quickly otherwise. */ | 45 | /* We only care about folks coming on the bus. Exit quickly otherwise. */ |
1363 | 46 | g_free(owner); | ||
1364 | 52 | return; | 47 | return; |
1365 | 53 | } | 48 | } |
1366 | 54 | 49 | ||
1368 | 55 | if (g_strcmp0(name, DBUS_NAME)) { | 50 | if (g_strcmp0(owner, DBUS_NAME)) { |
1369 | 56 | /* We only care about this address, reject all others. */ | 51 | /* We only care about this address, reject all others. */ |
1370 | 52 | g_free(owner); | ||
1371 | 57 | return; | 53 | return; |
1372 | 58 | } | 54 | } |
1373 | 59 | 55 | ||
1375 | 60 | org_ayatana_AppMenu_Registrar_register_window_async(registrar, GDK_WINDOW_XID (gtk_widget_get_window (window)), MENU_PATH, register_cb, NULL); | 56 | GError * error = NULL; |
1376 | 57 | g_dbus_proxy_call_sync(registrar, "RegisterWindow", | ||
1377 | 58 | g_variant_new("(uo)", | ||
1378 | 59 | GDK_WINDOW_XID (gtk_widget_get_window (window)), | ||
1379 | 60 | MENU_PATH), | ||
1380 | 61 | G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); | ||
1381 | 62 | if (error != NULL) { | ||
1382 | 63 | g_warning("Unable to register: %s", error->message); | ||
1383 | 64 | g_error_free(error); | ||
1384 | 65 | } | ||
1385 | 61 | 66 | ||
1386 | 67 | g_free(owner); | ||
1387 | 62 | return; | 68 | return; |
1388 | 63 | } | 69 | } |
1389 | 64 | 70 | ||
1390 | @@ -71,21 +77,26 @@ | |||
1391 | 71 | DbusmenuServer * server = dbusmenu_server_new(MENU_PATH); | 77 | DbusmenuServer * server = dbusmenu_server_new(MENU_PATH); |
1392 | 72 | dbusmenu_server_set_root(server, root); | 78 | dbusmenu_server_set_root(server, root); |
1393 | 73 | 79 | ||
1396 | 74 | DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); | 80 | registrar = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION, |
1397 | 75 | registrar = dbus_g_proxy_new_for_name(session_bus, DBUS_NAME, REG_OBJECT, REG_IFACE); | 81 | G_DBUS_PROXY_FLAGS_NONE, |
1398 | 82 | NULL, DBUS_NAME, | ||
1399 | 83 | REG_OBJECT, REG_IFACE, | ||
1400 | 84 | NULL, NULL); | ||
1401 | 76 | g_return_val_if_fail(registrar != NULL, FALSE); | 85 | g_return_val_if_fail(registrar != NULL, FALSE); |
1402 | 77 | 86 | ||
1404 | 78 | org_ayatana_AppMenu_Registrar_register_window_async(registrar, GDK_WINDOW_XID (gtk_widget_get_window (window)), MENU_PATH, register_cb, NULL); | 87 | GError * error = NULL; |
1405 | 88 | g_dbus_proxy_call_sync(registrar, "RegisterWindow", | ||
1406 | 89 | g_variant_new("(uo)", | ||
1407 | 90 | GDK_WINDOW_XID (gtk_widget_get_window (window)), | ||
1408 | 91 | MENU_PATH), | ||
1409 | 92 | G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); | ||
1410 | 93 | if (error != NULL) { | ||
1411 | 94 | g_warning("Unable to register: %s", error->message); | ||
1412 | 95 | g_error_free(error); | ||
1413 | 96 | } | ||
1414 | 79 | 97 | ||
1424 | 80 | DBusGProxy * dbus_proxy = dbus_g_proxy_new_for_name(session_bus, | 98 | g_signal_connect(registrar, "notify::g-name-owner", |
1425 | 81 | DBUS_SERVICE_DBUS, | 99 | G_CALLBACK(dbus_owner_change), NULL); |
1417 | 82 | DBUS_PATH_DBUS, | ||
1418 | 83 | DBUS_INTERFACE_DBUS); | ||
1419 | 84 | dbus_g_proxy_add_signal(dbus_proxy, "NameOwnerChanged", | ||
1420 | 85 | G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, | ||
1421 | 86 | G_TYPE_INVALID); | ||
1422 | 87 | dbus_g_proxy_connect_signal(dbus_proxy, "NameOwnerChanged", | ||
1423 | 88 | G_CALLBACK(dbus_owner_change), NULL, NULL); | ||
1426 | 89 | 100 | ||
1427 | 90 | return FALSE; | 101 | return FALSE; |
1428 | 91 | } | 102 | } |