Merge lp://staging/~ted/indicator-applet/gtk-split-out into lp://staging/indicator-applet/0.4
- gtk-split-out
- Merge into applet
Proposed by
Ted Gould
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp://staging/~ted/indicator-applet/gtk-split-out |
Merge into: | lp://staging/indicator-applet/0.4 |
Diff against target: | None lines |
To merge this branch: | bzr merge lp://staging/~ted/indicator-applet/gtk-split-out |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aurélien Gâteau (community) | Approve | ||
Review via email: mp+9607@code.staging.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote : | # |
Revision history for this message
Aurélien Gâteau (agateau) wrote : | # |
Looks good, thanks!
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2009-08-03 17:08:22 +0000 |
3 | +++ .bzrignore 2009-08-03 23:18:10 +0000 |
4 | @@ -82,3 +82,20 @@ |
5 | libindicate_la-server-marshal.lo |
6 | server-marshal.c |
7 | server-marshal.h |
8 | +libindicate-gtk.la |
9 | +libindicate_gtk_la-indicator.lo |
10 | +libindicate_gtk_la-indicator.o |
11 | +libindicate_gtk_la-listener.lo |
12 | +libindicate_gtk_la-listener.o |
13 | +indicate-gtk.pc |
14 | +.deps |
15 | +.libs |
16 | +indicator-applet-*.tar.gz |
17 | +docs/reference/tmpl/indicator-message.sgml |
18 | +docs/reference/tmpl/indicator-message.sgml.bak |
19 | +docs/reference/tmpl/indicator.sgml.bak |
20 | +docs/reference/tmpl/libindicate-unused.sgml.bak |
21 | +docs/reference/tmpl/listener.sgml |
22 | +docs/reference/tmpl/listener.sgml.bak |
23 | +docs/reference/tmpl/server.sgml |
24 | +docs/reference/tmpl/server.sgml.bak |
25 | |
26 | === modified file 'Makefile.am' |
27 | --- Makefile.am 2009-04-27 15:42:39 +0000 |
28 | +++ Makefile.am 2009-08-03 18:10:34 +0000 |
29 | @@ -2,6 +2,7 @@ |
30 | SUBDIRS = \ |
31 | src \ |
32 | libindicate \ |
33 | + libindicate-gtk \ |
34 | libindicator \ |
35 | examples \ |
36 | tests \ |
37 | |
38 | === modified file 'configure.ac' |
39 | --- configure.ac 2009-07-03 19:41:48 +0000 |
40 | +++ configure.ac 2009-08-03 23:08:51 +0000 |
41 | @@ -23,7 +23,7 @@ |
42 | # Libindicate versioning |
43 | ########################### |
44 | |
45 | -LIBINDICATE_CURRENT=1 |
46 | +LIBINDICATE_CURRENT=2 |
47 | LIBINDICATE_REVISION=0 |
48 | LIBINDICATE_AGE=0 |
49 | |
50 | @@ -32,6 +32,18 @@ |
51 | AC_SUBST(LIBINDICATE_AGE) |
52 | |
53 | ########################### |
54 | +# Libindicate versioning |
55 | +########################### |
56 | + |
57 | +LIBINDICATEGTK_CURRENT=0 |
58 | +LIBINDICATEGTK_REVISION=0 |
59 | +LIBINDICATEGTK_AGE=0 |
60 | + |
61 | +AC_SUBST(LIBINDICATEGTK_CURRENT) |
62 | +AC_SUBST(LIBINDICATEGTK_REVISION) |
63 | +AC_SUBST(LIBINDICATEGTK_AGE) |
64 | + |
65 | +########################### |
66 | # Dependencies |
67 | ########################### |
68 | |
69 | @@ -50,17 +62,25 @@ |
70 | |
71 | GLIB_REQUIRED_VERSION=2.18 |
72 | GIO_REQUIRED_VERSION=2.18 |
73 | -GDK_PIXBUF_REQUIRED_VERSION=2.12 |
74 | XML_REQUIRED_VERSION=2.6 |
75 | |
76 | PKG_CHECK_MODULES(LIBINDICATE, glib-2.0 >= $GLIB_REQUIRED_VERSION |
77 | gio-2.0 >= $GIO_REQUIRED_VERSION |
78 | - gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED_VERSION |
79 | dbus-glib-1 >= $DBUS_REQUIRED_VERSION |
80 | libxml-2.0 >= $XML_REQUIRED_VERSION) |
81 | AC_SUBST(LIBINDICATE_CFLAGS) |
82 | AC_SUBST(LIBINDICATE_LIBS) |
83 | |
84 | +GDK_PIXBUF_REQUIRED_VERSION=2.12 |
85 | + |
86 | +PKG_CHECK_MODULES(LIBINDICATEGTK, glib-2.0 >= $GLIB_REQUIRED_VERSION |
87 | + gio-2.0 >= $GIO_REQUIRED_VERSION |
88 | + gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED_VERSION |
89 | + gtk+-2.0 >= $GTK_REQUIRED_VERSION |
90 | + dbus-glib-1 >= $DBUS_REQUIRED_VERSION) |
91 | +AC_SUBST(LIBINDICATEGTK_CFLAGS) |
92 | +AC_SUBST(LIBINDICATEGTK_LIBS) |
93 | + |
94 | ########################### |
95 | # GObject Introspection |
96 | ########################### |
97 | @@ -162,6 +182,8 @@ |
98 | src/Makefile |
99 | libindicate/Makefile |
100 | libindicate/indicate.pc |
101 | +libindicate-gtk/Makefile |
102 | +libindicate-gtk/indicate-gtk.pc |
103 | libindicator/Makefile |
104 | libindicator/indicator.pc |
105 | examples/Makefile |
106 | |
107 | === modified file 'docs/reference/tmpl/libindicate-unused.sgml' |
108 | --- docs/reference/tmpl/libindicate-unused.sgml 2009-05-01 03:30:15 +0000 |
109 | +++ docs/reference/tmpl/libindicate-unused.sgml 2009-08-03 22:53:40 +0000 |
110 | @@ -1,3 +1,12 @@ |
111 | +<!-- ##### FUNCTION indicate_indicator_set_property_icon ##### --> |
112 | +<para> |
113 | + |
114 | +</para> |
115 | + |
116 | +@indicator: |
117 | +@key: |
118 | +@data: |
119 | + |
120 | <!-- ##### FUNCTION indicate_server_new ##### --> |
121 | <para> |
122 | |
123 | |
124 | === modified file 'examples/Makefile.am' |
125 | --- examples/Makefile.am 2009-04-07 22:34:45 +0000 |
126 | +++ examples/Makefile.am 2009-08-03 22:49:42 +0000 |
127 | @@ -33,22 +33,28 @@ |
128 | |
129 | listen_and_print_CFLAGS = \ |
130 | -I $(srcdir)/.. \ |
131 | - $(LIBINDICATE_CFLAGS) |
132 | + $(LIBINDICATE_CFLAGS) \ |
133 | + $(LIBINDICATEGTK_CFLAGS) |
134 | |
135 | listen_and_print_LDADD = \ |
136 | ../libindicate/libindicate.la \ |
137 | - $(LIBINDICATE_LIBS) |
138 | + ../libindicate-gtk/libindicate-gtk.la \ |
139 | + $(LIBINDICATE_LIBS) \ |
140 | + $(LIBINDICATEGTK_LIBS) |
141 | |
142 | im_client_SOURCES = \ |
143 | im-client.c |
144 | |
145 | im_client_CFLAGS = \ |
146 | -I $(srcdir)/.. \ |
147 | - $(LIBINDICATE_CFLAGS) |
148 | + $(LIBINDICATE_CFLAGS) \ |
149 | + $(LIBINDICATEGTK_CFLAGS) |
150 | |
151 | im_client_LDADD = \ |
152 | ../libindicate/libindicate.la \ |
153 | - $(LIBINDICATE_LIBS) |
154 | + ../libindicate-gtk/libindicate-gtk.la \ |
155 | + $(LIBINDICATE_LIBS) \ |
156 | + $(LIBINDICATEGTK_LIBS) |
157 | |
158 | show_hide_server_SOURCES = \ |
159 | show-hide-server.c |
160 | |
161 | === modified file 'examples/im-client.c' |
162 | --- examples/im-client.c 2009-04-02 21:11:34 +0000 |
163 | +++ examples/im-client.c 2009-08-03 22:49:42 +0000 |
164 | @@ -22,6 +22,7 @@ |
165 | #include <glib.h> |
166 | #include "libindicate/server.h" |
167 | #include "libindicate/indicator-message.h" |
168 | +#include "libindicate-gtk/indicator.h" |
169 | |
170 | gchar * patha = "/usr/share/icons/hicolor/16x16/apps/empathy.png"; |
171 | gchar * pathb = "/usr/share/icons/hicolor/22x22/apps/empathy.png"; |
172 | |
173 | === modified file 'examples/listen-and-print.c' |
174 | --- examples/listen-and-print.c 2009-04-03 15:36:10 +0000 |
175 | +++ examples/listen-and-print.c 2009-08-03 23:01:06 +0000 |
176 | @@ -21,6 +21,7 @@ |
177 | |
178 | #include <glib.h> |
179 | #include "libindicate/listener.h" |
180 | +#include "libindicate-gtk/listener.h" |
181 | |
182 | static void |
183 | show_property_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data) |
184 | |
185 | === added directory 'libindicate-gtk' |
186 | === added file 'libindicate-gtk/Makefile.am' |
187 | --- libindicate-gtk/Makefile.am 1970-01-01 00:00:00 +0000 |
188 | +++ libindicate-gtk/Makefile.am 2009-08-03 23:08:51 +0000 |
189 | @@ -0,0 +1,71 @@ |
190 | + |
191 | +INCLUDES= \ |
192 | + -DG_LOG_DOMAIN=\"libindicate-gtk\" |
193 | + |
194 | +EXTRA_DIST = \ |
195 | + indicate-gtk.pc.in |
196 | + |
197 | +lib_LTLIBRARIES = \ |
198 | + libindicate-gtk.la |
199 | + |
200 | +libindicate_gtkincludedir=$(includedir)/libindicate-0.1/libindicate-gtk |
201 | + |
202 | +indicate_gtk_headers = \ |
203 | + indicator.h \ |
204 | + listener.h |
205 | + |
206 | +libindicate_gtkinclude_HEADERS = \ |
207 | + $(indicate_gtk_headers) |
208 | + |
209 | +libindicate_gtk_la_SOURCES = \ |
210 | + $(indicate_gtk_headers) \ |
211 | + indicator.c \ |
212 | + listener.c |
213 | + |
214 | +libindicate_gtk_la_LDFLAGS = \ |
215 | + -version-info $(LIBINDICATEGTK_CURRENT):$(LIBINDICATEGTK_REVISION):$(LIBINDICATEGTK_AGE) \ |
216 | + -no-undefined \ |
217 | + -export-symbols-regex "^[^_d].*" |
218 | + |
219 | +libindicate_gtk_la_CFLAGS = \ |
220 | + -I $(srcdir)/.. \ |
221 | + $(LIBINDICATEGTK_CFLAGS) |
222 | + |
223 | +libindicate_gtk_la_LIBADD = \ |
224 | + $(LIBINDICATEGTK_LIBS) |
225 | + |
226 | +pkgconfig_DATA = indicate-gtk.pc |
227 | +pkgconfigdir = $(libdir)/pkgconfig |
228 | + |
229 | +if USE_GIR |
230 | + |
231 | +gobjectintrospection_gir_DATA = \ |
232 | + Indicate-gtk-0.1.gir |
233 | +gobjectintrospection_girdir = $(datadir)/gir |
234 | + |
235 | +gobjectintrospection_type_DATA = \ |
236 | + Indicate-gtk-0.1.typelib |
237 | +gobjectintrospection_typedir = $(libdir)/girepository |
238 | + |
239 | +irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_headers)) |
240 | +Indicate-gtk-0.1.gir: $(irscanner_headers) |
241 | + $(G_IR_SCANNER) \ |
242 | + -v --namespace IndicateGtk \ |
243 | + --nsversion=0.1 \ |
244 | + --add-include-path=$(srcdir) \ |
245 | + --include=GObject-2.0 \ |
246 | + --include=GLib-2.0 \ |
247 | + --include=GdkPixbuf-2.0 \ |
248 | + --library=indicate --pkg indicate \ |
249 | + --output Indicate-gtk-0.1.gir $(irscanner_headers) |
250 | + |
251 | +Indicate-gtk-0.1.typelib: Indicate-gtk-0.1.gir |
252 | + $(G_IR_COMPILER) \ |
253 | + --includedir=$(srcdir) Indicate-gtk-0.1.gir \ |
254 | + -o Indicate-gtk-0.1.typelib |
255 | + |
256 | +DISTCLEANFILES = \ |
257 | + Indicate-gtk-0.1.gir \ |
258 | + Indicate-gtk-0.1.typelib |
259 | + |
260 | +endif |
261 | |
262 | === added file 'libindicate-gtk/indicate-gtk.pc.in' |
263 | --- libindicate-gtk/indicate-gtk.pc.in 1970-01-01 00:00:00 +0000 |
264 | +++ libindicate-gtk/indicate-gtk.pc.in 2009-08-03 18:10:34 +0000 |
265 | @@ -0,0 +1,14 @@ |
266 | +prefix=@prefix@ |
267 | +exec_prefix=@exec_prefix@ |
268 | +libdir=@libdir@ |
269 | +bindir=@bindir@ |
270 | +includedir=@includedir@ |
271 | + |
272 | +Cflags: -I${includedir}/libindicate-0.1 |
273 | +Requires: gtk+-2.0 indicate |
274 | +Libs: -L${libdir} -lindicate-gtk |
275 | + |
276 | +Name: libindicate-gtk |
277 | +Description: libindicate GTK stuff. |
278 | +Version: @VERSION@ |
279 | + |
280 | |
281 | === added file 'libindicate-gtk/indicator.c' |
282 | --- libindicate-gtk/indicator.c 1970-01-01 00:00:00 +0000 |
283 | +++ libindicate-gtk/indicator.c 2009-08-03 18:25:05 +0000 |
284 | @@ -0,0 +1,74 @@ |
285 | +/* |
286 | +A library to allow applictions to provide simple indications of |
287 | +information to be displayed to users of the application through the |
288 | +interface shell. |
289 | + |
290 | +Copyright 2009 Canonical Ltd. |
291 | + |
292 | +Authors: |
293 | + Ted Gould <ted@canonical.com> |
294 | + |
295 | +This program is free software: you can redistribute it and/or modify it |
296 | +under the terms of either or both of the following licenses: |
297 | + |
298 | +1) the GNU Lesser General Public License version 3, as published by the |
299 | +Free Software Foundation; and/or |
300 | +2) the GNU Lesser General Public License version 2.1, as published by |
301 | +the Free Software Foundation. |
302 | + |
303 | +This program is distributed in the hope that it will be useful, but |
304 | +WITHOUT ANY WARRANTY; without even the implied warranties of |
305 | +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
306 | +PURPOSE. See the applicable version of the GNU Lesser General Public |
307 | +License for more details. |
308 | + |
309 | +You should have received a copy of both the GNU Lesser General Public |
310 | +License version 3 and version 2.1 along with this program. If not, see |
311 | +<http://www.gnu.org/licenses/> |
312 | +*/ |
313 | + |
314 | +#include "indicator.h" |
315 | + |
316 | +/** |
317 | + indicate_indicator_set_property_icon: |
318 | + @indicator: a #IndicateIndicator to act on |
319 | + @key: name of the property |
320 | + @data: icon to set property with |
321 | + |
322 | + This is a helper function that wraps around #indicate_indicator_set_property |
323 | + but takes an #GdkPixbuf parameter. It then takes the @data |
324 | + parameter, turns it into a PNG, base64 encodes it and then |
325 | + uses that data to call #indicate_indicator_set_property. |
326 | +*/ |
327 | +void |
328 | +indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data) |
329 | +{ |
330 | + if (!GDK_IS_PIXBUF(data)) { |
331 | + g_warning("Invalide GdkPixbuf"); |
332 | + return; |
333 | + } |
334 | + |
335 | + GError * error = NULL; |
336 | + gchar * png_data; |
337 | + gsize png_data_len; |
338 | + |
339 | + if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)data, &png_data, &png_data_len, "png", &error, NULL)) { |
340 | + if (error == NULL) { |
341 | + g_warning("Unable to create pixbuf data stream: %d", png_data_len); |
342 | + } else { |
343 | + g_warning("Unable to create pixbuf data stream: %s", error->message); |
344 | + g_error_free(error); |
345 | + error = NULL; |
346 | + } |
347 | + |
348 | + return; |
349 | + } |
350 | + |
351 | + gchar * prop_str = g_base64_encode((guchar *)png_data, png_data_len); |
352 | + indicate_indicator_set_property(indicator, key, prop_str); |
353 | + |
354 | + g_free(prop_str); |
355 | + g_free(png_data); |
356 | + |
357 | + return; |
358 | +} |
359 | |
360 | === added file 'libindicate-gtk/indicator.h' |
361 | --- libindicate-gtk/indicator.h 1970-01-01 00:00:00 +0000 |
362 | +++ libindicate-gtk/indicator.h 2009-08-03 18:25:05 +0000 |
363 | @@ -0,0 +1,44 @@ |
364 | +/* |
365 | +A library to allow applictions to provide simple indications of |
366 | +information to be displayed to users of the application through the |
367 | +interface shell. |
368 | + |
369 | +Copyright 2009 Canonical Ltd. |
370 | + |
371 | +Authors: |
372 | + Ted Gould <ted@canonical.com> |
373 | + |
374 | +This program is free software: you can redistribute it and/or modify it |
375 | +under the terms of either or both of the following licenses: |
376 | + |
377 | +1) the GNU Lesser General Public License version 3, as published by the |
378 | +Free Software Foundation; and/or |
379 | +2) the GNU Lesser General Public License version 2.1, as published by |
380 | +the Free Software Foundation. |
381 | + |
382 | +This program is distributed in the hope that it will be useful, but |
383 | +WITHOUT ANY WARRANTY; without even the implied warranties of |
384 | +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
385 | +PURPOSE. See the applicable version of the GNU Lesser General Public |
386 | +License for more details. |
387 | + |
388 | +You should have received a copy of both the GNU Lesser General Public |
389 | +License version 3 and version 2.1 along with this program. If not, see |
390 | +<http://www.gnu.org/licenses/> |
391 | +*/ |
392 | + |
393 | +#ifndef INDICATE_GTK_INDICATOR_H_INCLUDED__ |
394 | +#define INDICATE_GTK_INDICATOR_H_INCLUDED__ 1 |
395 | + |
396 | +#include <glib.h> |
397 | +#include <gdk-pixbuf/gdk-pixbuf.h> |
398 | +#include "libindicate/indicator.h" |
399 | + |
400 | +G_BEGIN_DECLS |
401 | + |
402 | +/* Properties handling */ |
403 | +void indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data); |
404 | + |
405 | +G_END_DECLS |
406 | + |
407 | +#endif /* INDICATE_GTK_INDICATOR_H_INCLUDED__ */ |
408 | |
409 | === added file 'libindicate-gtk/listener.c' |
410 | --- libindicate-gtk/listener.c 1970-01-01 00:00:00 +0000 |
411 | +++ libindicate-gtk/listener.c 2009-08-03 22:43:37 +0000 |
412 | @@ -0,0 +1,148 @@ |
413 | +/* |
414 | +A library to allow applictions to provide simple indications of |
415 | +information to be displayed to users of the application through the |
416 | +interface shell. |
417 | + |
418 | +Copyright 2009 Canonical Ltd. |
419 | + |
420 | +Authors: |
421 | + Ted Gould <ted@canonical.com> |
422 | + |
423 | +This program is free software: you can redistribute it and/or modify it |
424 | +under the terms of either or both of the following licenses: |
425 | + |
426 | +1) the GNU Lesser General Public License version 3, as published by the |
427 | +Free Software Foundation; and/or |
428 | +2) the GNU Lesser General Public License version 2.1, as published by |
429 | +the Free Software Foundation. |
430 | + |
431 | +This program is distributed in the hope that it will be useful, but |
432 | +WITHOUT ANY WARRANTY; without even the implied warranties of |
433 | +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
434 | +PURPOSE. See the applicable version of the GNU Lesser General Public |
435 | +License for more details. |
436 | + |
437 | +You should have received a copy of both the GNU Lesser General Public |
438 | +License version 3 and version 2.1 along with this program. If not, see |
439 | +<http://www.gnu.org/licenses/> |
440 | +*/ |
441 | + |
442 | +#include "listener.h" |
443 | +#include <dbus/dbus-glib-bindings.h> |
444 | + |
445 | +#include "../libindicate/dbus-indicate-client.h" |
446 | +#include "../libindicate/listener-private.h" |
447 | + |
448 | +typedef enum _get_property_type get_property_type; |
449 | +enum _get_property_type { |
450 | + PROPERTY_TYPE_STRING, |
451 | + PROPERTY_TYPE_TIME, |
452 | + PROPERTY_TYPE_ICON |
453 | +}; |
454 | + |
455 | +typedef struct _get_property_t get_property_t; |
456 | +struct _get_property_t { |
457 | + GCallback cb; |
458 | + gpointer data; |
459 | + IndicateListener * listener; |
460 | + IndicateListenerServer * server; |
461 | + IndicateListenerIndicator * indicator; |
462 | + gchar * property; |
463 | + get_property_type type; |
464 | +}; |
465 | + |
466 | +static void |
467 | +get_property_cb (DBusGProxy *proxy, char * OUT_value, GError *error, gpointer userdata) |
468 | +{ |
469 | + get_property_t * get_property_data = (get_property_t *)userdata; |
470 | + |
471 | + if (error != NULL) { |
472 | + g_warning("Unable to get property data: %s", error->message); |
473 | + g_error_free(error); |
474 | + return; |
475 | + } |
476 | + |
477 | + switch (get_property_data->type) { |
478 | + case PROPERTY_TYPE_STRING: { |
479 | + indicate_listener_get_property_cb cb = (indicate_listener_get_property_cb)get_property_data->cb; |
480 | + cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, OUT_value, get_property_data->data); |
481 | + break; |
482 | + } |
483 | + case PROPERTY_TYPE_ICON: { |
484 | + indicate_listener_get_property_icon_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb; |
485 | + |
486 | + /* There is no icon */ |
487 | + if (OUT_value == NULL || OUT_value[0] == '\0') { |
488 | + break; |
489 | + } |
490 | + |
491 | + gsize length = 0; |
492 | + guchar * icondata = g_base64_decode(OUT_value, &length); |
493 | + |
494 | + GInputStream * input = g_memory_input_stream_new_from_data(icondata, length, NULL); |
495 | + if (input == NULL) { |
496 | + g_warning("Cound not create input stream from icon property data"); |
497 | + g_free(icondata); |
498 | + break; |
499 | + } |
500 | + |
501 | + GError * error = NULL; |
502 | + GdkPixbuf * icon = gdk_pixbuf_new_from_stream(input, NULL, &error); |
503 | + if (icon != NULL) { |
504 | + cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, icon, get_property_data->data); |
505 | + } |
506 | + |
507 | + if (error != NULL) { |
508 | + g_warning("Unable to build Pixbuf from icon data: %s", error->message); |
509 | + g_error_free(error); |
510 | + } |
511 | + |
512 | + error = NULL; |
513 | + g_input_stream_close(input, NULL, &error); |
514 | + if (error != NULL) { |
515 | + g_warning("Unable to close input stream: %s", error->message); |
516 | + g_error_free(error); |
517 | + } |
518 | + g_free(icondata); |
519 | + break; |
520 | + } |
521 | + case PROPERTY_TYPE_TIME: { |
522 | + indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_time_cb)get_property_data->cb; |
523 | + GTimeVal time; |
524 | + if (g_time_val_from_iso8601(OUT_value, &time)) { |
525 | + cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, &time, get_property_data->data); |
526 | + } |
527 | + break; |
528 | + } |
529 | + } |
530 | + |
531 | + g_free(get_property_data->property); |
532 | + g_free(get_property_data); |
533 | + |
534 | + return; |
535 | +}; |
536 | + |
537 | +static void |
538 | +get_property_helper (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GCallback callback, gpointer data, get_property_type prop_type) |
539 | +{ |
540 | + /* g_debug("get_property_helper: %s %d", property, prop_type); */ |
541 | + /* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */ |
542 | + get_property_t * get_property_data = g_new(get_property_t, 1); |
543 | + get_property_data->cb = callback; |
544 | + get_property_data->data = data; |
545 | + get_property_data->listener = listener; |
546 | + get_property_data->server = server; |
547 | + get_property_data->indicator = indicator; |
548 | + get_property_data->property = g_strdup(property); |
549 | + get_property_data->type = prop_type; |
550 | + |
551 | + org_freedesktop_indicator_get_indicator_property_async (server->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data); |
552 | + return; |
553 | +} |
554 | + |
555 | +void |
556 | +indicate_listener_get_property_icon (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_icon_cb callback, gpointer data) |
557 | +{ |
558 | + return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_ICON); |
559 | +} |
560 | + |
561 | |
562 | === added file 'libindicate-gtk/listener.h' |
563 | --- libindicate-gtk/listener.h 1970-01-01 00:00:00 +0000 |
564 | +++ libindicate-gtk/listener.h 2009-08-03 22:43:37 +0000 |
565 | @@ -0,0 +1,57 @@ |
566 | +/* |
567 | +A library to allow applictions to provide simple indications of |
568 | +information to be displayed to users of the application through the |
569 | +interface shell. |
570 | + |
571 | +Copyright 2009 Canonical Ltd. |
572 | + |
573 | +Authors: |
574 | + Ted Gould <ted@canonical.com> |
575 | + |
576 | +This program is free software: you can redistribute it and/or modify it |
577 | +under the terms of either or both of the following licenses: |
578 | + |
579 | +1) the GNU Lesser General Public License version 3, as published by the |
580 | +Free Software Foundation; and/or |
581 | +2) the GNU Lesser General Public License version 2.1, as published by |
582 | +the Free Software Foundation. |
583 | + |
584 | +This program is distributed in the hope that it will be useful, but |
585 | +WITHOUT ANY WARRANTY; without even the implied warranties of |
586 | +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
587 | +PURPOSE. See the applicable version of the GNU Lesser General Public |
588 | +License for more details. |
589 | + |
590 | +You should have received a copy of both the GNU Lesser General Public |
591 | +License version 3 and version 2.1 along with this program. If not, see |
592 | +<http://www.gnu.org/licenses/> |
593 | +*/ |
594 | + |
595 | +#ifndef INDICATE_GTK_LISTENER_H_INCLUDED__ |
596 | +#define INDICATE_GTK_LISTENER_H_INCLUDED__ 1 |
597 | + |
598 | +#include <glib.h> |
599 | +#include <gdk-pixbuf/gdk-pixbuf.h> |
600 | + |
601 | +#include "libindicate/listener.h" |
602 | + |
603 | +G_BEGIN_DECLS |
604 | + |
605 | +typedef void (*indicate_listener_get_property_icon_cb) (IndicateListener * listener, |
606 | + IndicateListenerServer * server, |
607 | + IndicateListenerIndicator * indicator, |
608 | + gchar * property, |
609 | + GdkPixbuf * propertydata, |
610 | + gpointer data); |
611 | + |
612 | +void indicate_listener_get_property_icon (IndicateListener * listener, |
613 | + IndicateListenerServer * server, |
614 | + IndicateListenerIndicator * indicator, |
615 | + gchar * property, |
616 | + indicate_listener_get_property_icon_cb callback, |
617 | + gpointer data); |
618 | + |
619 | +G_END_DECLS |
620 | + |
621 | +#endif /* INDICATE_GTK_LISTENER_H_INCLUDED__ */ |
622 | + |
623 | |
624 | === modified file 'libindicate/Makefile.am' |
625 | --- libindicate/Makefile.am 2009-07-21 16:37:51 +0000 |
626 | +++ libindicate/Makefile.am 2009-08-03 22:31:00 +0000 |
627 | @@ -53,6 +53,7 @@ |
628 | listener.c \ |
629 | listener-marshal.c \ |
630 | listener-marshal.h \ |
631 | + listener-private.h \ |
632 | indicator.c \ |
633 | indicator-message.c \ |
634 | interests-priv.h |
635 | |
636 | === modified file 'libindicate/indicator.c' |
637 | --- libindicate/indicator.c 2009-08-03 17:50:57 +0000 |
638 | +++ libindicate/indicator.c 2009-08-03 22:31:00 +0000 |
639 | @@ -381,50 +381,6 @@ |
640 | } |
641 | |
642 | /** |
643 | - indicate_indicator_set_property_icon: |
644 | - @indicator: a #IndicateIndicator to act on |
645 | - @key: name of the property |
646 | - @data: icon to set property with |
647 | - |
648 | - This is a helper function that wraps around #indicate_indicator_set_property |
649 | - but takes an #GdkPixbuf parameter. It then takes the @data |
650 | - parameter, turns it into a PNG, base64 encodes it and then |
651 | - uses that data to call #indicate_indicator_set_property. |
652 | -*/ |
653 | -void |
654 | -indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data) |
655 | -{ |
656 | - if (!GDK_IS_PIXBUF(data)) { |
657 | - g_warning("Invalide GdkPixbuf"); |
658 | - return; |
659 | - } |
660 | - |
661 | - GError * error = NULL; |
662 | - gchar * png_data; |
663 | - gsize png_data_len; |
664 | - |
665 | - if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)data, &png_data, &png_data_len, "png", &error, NULL)) { |
666 | - if (error == NULL) { |
667 | - g_warning("Unable to create pixbuf data stream: %d", png_data_len); |
668 | - } else { |
669 | - g_warning("Unable to create pixbuf data stream: %s", error->message); |
670 | - g_error_free(error); |
671 | - error = NULL; |
672 | - } |
673 | - |
674 | - return; |
675 | - } |
676 | - |
677 | - gchar * prop_str = g_base64_encode((guchar *)png_data, png_data_len); |
678 | - indicate_indicator_set_property(indicator, key, prop_str); |
679 | - |
680 | - g_free(prop_str); |
681 | - g_free(png_data); |
682 | - |
683 | - return; |
684 | -} |
685 | - |
686 | -/** |
687 | indicate_indicator_set_property_time: |
688 | @indicator: a #IndicateIndicator to act on |
689 | @key: name of the property |
690 | |
691 | === modified file 'libindicate/indicator.h' |
692 | --- libindicate/indicator.h 2009-08-03 17:50:57 +0000 |
693 | +++ libindicate/indicator.h 2009-08-03 22:31:00 +0000 |
694 | @@ -33,8 +33,6 @@ |
695 | #include <glib.h> |
696 | #include <glib-object.h> |
697 | |
698 | -#include <gdk-pixbuf/gdk-pixbuf.h> |
699 | - |
700 | G_BEGIN_DECLS |
701 | |
702 | /* Boilerplate */ |
703 | @@ -132,7 +130,6 @@ |
704 | |
705 | /* Properties handling */ |
706 | void indicate_indicator_set_property (IndicateIndicator * indicator, const gchar * key, const gchar * data); |
707 | -void indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data); |
708 | void indicate_indicator_set_property_time (IndicateIndicator * indicator, const gchar * key, GTimeVal * time); |
709 | const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key); |
710 | GPtrArray * indicate_indicator_list_properties (IndicateIndicator * indicator); |
711 | |
712 | === added file 'libindicate/listener-private.h' |
713 | --- libindicate/listener-private.h 1970-01-01 00:00:00 +0000 |
714 | +++ libindicate/listener-private.h 2009-08-03 22:31:00 +0000 |
715 | @@ -0,0 +1,63 @@ |
716 | +/* |
717 | +A library to allow applictions to provide simple indications of |
718 | +information to be displayed to users of the application through the |
719 | +interface shell. |
720 | + |
721 | +Copyright 2009 Canonical Ltd. |
722 | + |
723 | +Authors: |
724 | + Ted Gould <ted@canonical.com> |
725 | + |
726 | +This program is free software: you can redistribute it and/or modify it |
727 | +under the terms of either or both of the following licenses: |
728 | + |
729 | +1) the GNU Lesser General Public License version 3, as published by the |
730 | +Free Software Foundation; and/or |
731 | +2) the GNU Lesser General Public License version 2.1, as published by |
732 | +the Free Software Foundation. |
733 | + |
734 | +This program is distributed in the hope that it will be useful, but |
735 | +WITHOUT ANY WARRANTY; without even the implied warranties of |
736 | +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
737 | +PURPOSE. See the applicable version of the GNU Lesser General Public |
738 | +License for more details. |
739 | + |
740 | +You should have received a copy of both the GNU Lesser General Public |
741 | +License version 3 and version 2.1 along with this program. If not, see |
742 | +<http://www.gnu.org/licenses/> |
743 | +*/ |
744 | + |
745 | +#ifndef INDICATE_LISTENER_PRIVATE_H__ |
746 | +#define INDICATE_LISTENER_PRIVATE_H__ 1 |
747 | + |
748 | +struct _IndicateListenerServer { |
749 | + gchar * name; |
750 | + DBusGProxy * proxy; |
751 | + DBusGConnection * connection; |
752 | + gboolean interests[INDICATE_INTEREST_LAST]; |
753 | +}; |
754 | + |
755 | +struct _IndicateListenerIndicator { |
756 | + guint id; |
757 | +}; |
758 | + |
759 | +typedef struct _IndicateListenerPrivate IndicateListenerPrivate; |
760 | +struct _IndicateListenerPrivate |
761 | +{ |
762 | + DBusGConnection * session_bus; |
763 | + DBusGConnection * system_bus; |
764 | + |
765 | + DBusGProxy * dbus_proxy_session; |
766 | + DBusGProxy * dbus_proxy_system; |
767 | + |
768 | + GList * proxies_working; |
769 | + GList * proxies_possible; |
770 | + |
771 | + GArray * proxy_todo; |
772 | + guint todo_idle; |
773 | +}; |
774 | + |
775 | +#define INDICATE_LISTENER_GET_PRIVATE(o) \ |
776 | + (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_LISTENER, IndicateListenerPrivate)) |
777 | + |
778 | +#endif /* INDICATE_LISTENER_PRIVATE_H__ */ |
779 | |
780 | === modified file 'libindicate/listener.c' |
781 | --- libindicate/listener.c 2009-07-27 15:20:24 +0000 |
782 | +++ libindicate/listener.c 2009-08-03 22:31:00 +0000 |
783 | @@ -54,35 +54,7 @@ |
784 | |
785 | static guint signals[LAST_SIGNAL] = { 0 }; |
786 | |
787 | -struct _IndicateListenerServer { |
788 | - gchar * name; |
789 | - DBusGProxy * proxy; |
790 | - DBusGConnection * connection; |
791 | - gboolean interests[INDICATE_INTEREST_LAST]; |
792 | -}; |
793 | - |
794 | -struct _IndicateListenerIndicator { |
795 | - guint id; |
796 | -}; |
797 | - |
798 | -typedef struct _IndicateListenerPrivate IndicateListenerPrivate; |
799 | -struct _IndicateListenerPrivate |
800 | -{ |
801 | - DBusGConnection * session_bus; |
802 | - DBusGConnection * system_bus; |
803 | - |
804 | - DBusGProxy * dbus_proxy_session; |
805 | - DBusGProxy * dbus_proxy_system; |
806 | - |
807 | - GList * proxies_working; |
808 | - GList * proxies_possible; |
809 | - |
810 | - GArray * proxy_todo; |
811 | - guint todo_idle; |
812 | -}; |
813 | - |
814 | -#define INDICATE_LISTENER_GET_PRIVATE(o) \ |
815 | - (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_LISTENER, IndicateListenerPrivate)) |
816 | +#include "listener-private.h" |
817 | |
818 | typedef struct { |
819 | DBusGProxy * proxy; |
820 | @@ -718,8 +690,7 @@ |
821 | typedef enum _get_property_type get_property_type; |
822 | enum _get_property_type { |
823 | PROPERTY_TYPE_STRING, |
824 | - PROPERTY_TYPE_TIME, |
825 | - PROPERTY_TYPE_ICON |
826 | + PROPERTY_TYPE_TIME |
827 | }; |
828 | |
829 | typedef struct _get_property_t get_property_t; |
830 | @@ -750,44 +721,6 @@ |
831 | cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, OUT_value, get_property_data->data); |
832 | break; |
833 | } |
834 | - case PROPERTY_TYPE_ICON: { |
835 | - indicate_listener_get_property_icon_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb; |
836 | - |
837 | - /* There is no icon */ |
838 | - if (OUT_value == NULL || OUT_value[0] == '\0') { |
839 | - break; |
840 | - } |
841 | - |
842 | - gsize length = 0; |
843 | - guchar * icondata = g_base64_decode(OUT_value, &length); |
844 | - |
845 | - GInputStream * input = g_memory_input_stream_new_from_data(icondata, length, NULL); |
846 | - if (input == NULL) { |
847 | - g_warning("Cound not create input stream from icon property data"); |
848 | - g_free(icondata); |
849 | - break; |
850 | - } |
851 | - |
852 | - GError * error = NULL; |
853 | - GdkPixbuf * icon = gdk_pixbuf_new_from_stream(input, NULL, &error); |
854 | - if (icon != NULL) { |
855 | - cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, icon, get_property_data->data); |
856 | - } |
857 | - |
858 | - if (error != NULL) { |
859 | - g_warning("Unable to build Pixbuf from icon data: %s", error->message); |
860 | - g_error_free(error); |
861 | - } |
862 | - |
863 | - error = NULL; |
864 | - g_input_stream_close(input, NULL, &error); |
865 | - if (error != NULL) { |
866 | - g_warning("Unable to close input stream: %s", error->message); |
867 | - g_error_free(error); |
868 | - } |
869 | - g_free(icondata); |
870 | - break; |
871 | - } |
872 | case PROPERTY_TYPE_TIME: { |
873 | indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_time_cb)get_property_data->cb; |
874 | GTimeVal time; |
875 | @@ -834,12 +767,6 @@ |
876 | return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_TIME); |
877 | } |
878 | |
879 | -void |
880 | -indicate_listener_get_property_icon (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_icon_cb callback, gpointer data) |
881 | -{ |
882 | - return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_ICON); |
883 | -} |
884 | - |
885 | gboolean |
886 | _indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers) |
887 | { |
888 | |
889 | === modified file 'libindicate/listener.h' |
890 | --- libindicate/listener.h 2009-04-10 10:16:39 +0000 |
891 | +++ libindicate/listener.h 2009-08-03 22:53:17 +0000 |
892 | @@ -33,8 +33,6 @@ |
893 | #include <glib.h> |
894 | #include <glib-object.h> |
895 | |
896 | -#include <gdk-pixbuf/gdk-pixbuf.h> |
897 | - |
898 | #include "indicator.h" |
899 | #include "server.h" |
900 | #include "interests.h" |
901 | @@ -88,7 +86,6 @@ |
902 | |
903 | typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data); |
904 | typedef void (*indicate_listener_get_property_time_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GTimeVal * propertydata, gpointer data); |
905 | -typedef void (*indicate_listener_get_property_icon_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GdkPixbuf * propertydata, gpointer data); |
906 | typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data); |
907 | |
908 | /* Create a new listener */ |
909 | @@ -106,12 +103,6 @@ |
910 | gchar * property, |
911 | indicate_listener_get_property_time_cb callback, |
912 | gpointer data); |
913 | -void indicate_listener_get_property_icon (IndicateListener * listener, |
914 | - IndicateListenerServer * server, |
915 | - IndicateListenerIndicator * indicator, |
916 | - gchar * property, |
917 | - indicate_listener_get_property_icon_cb callback, |
918 | - gpointer data); |
919 | void indicate_listener_display (IndicateListener * listener, |
920 | IndicateListenerServer * server, |
921 | IndicateListenerIndicator * indicator); |
922 | |
923 | === modified file 'src/Makefile.am' |
924 | --- src/Makefile.am 2009-04-21 19:35:49 +0000 |
925 | +++ src/Makefile.am 2009-08-03 23:01:06 +0000 |
926 | @@ -6,6 +6,7 @@ |
927 | -DG_LOG_DOMAIN=\""Indicator-Applet"\" \ |
928 | -DDATADIR=\""$(datadir)"\" \ |
929 | -DINDICATOR_DIR=\""$(libdir)/indicators/2"\" \ |
930 | + -I$(srcdir)/.. \ |
931 | $(APPLET_CFLAGS) |
932 | |
933 | indicator_applet_SOURCES = \ |
A branch splitting out the GTK parts of libindicate into a libindicate-gtk.