Merge lp:~robertcarr/libindicate/custom-icon-theme into lp:libindicate/0.6

Proposed by Robert Carr
Status: Superseded
Proposed branch: lp:~robertcarr/libindicate/custom-icon-theme
Merge into: lp:libindicate/0.6
Diff against target: 299 lines (+181/-1)
8 files modified
libindicate/indicate-interface.xml (+1/-0)
libindicate/listener.c (+6/-0)
libindicate/listener.h (+4/-0)
libindicate/server.c (+49/-1)
libindicate/server.h (+2/-0)
tests/Makefile.am (+32/-0)
tests/test-icon-theme-client.c (+35/-0)
tests/test-icon-theme-server.c (+52/-0)
To merge this branch: bzr merge lp:~robertcarr/libindicate/custom-icon-theme
Reviewer Review Type Date Requested Status
Ted Gould Pending
Review via email: mp+89085@code.launchpad.net

This proposal has been superseded by a proposal from 2012-02-09.

Description of the change

This adds support for an icon theme property to IndicateServer.

Ted I believe we discussed the reasoning behind this? Essesntially Unity Webapps only wants to write out one desktop file for GMail, but wants the messaging indicator to use the favicon (while of course we wont use this in the launcher), so we need the messaging indicator to be able to load an icon theme in the users home directory.

Thanks!

To post a comment you must log in.
Revision history for this message
Robert Carr (robertcarr) wrote :

Unmerged revisions

442. By Robert Carr

Add test for icon theme properties

441. By Robert Carr

server: Server side implementation of icontheme property

440. By Robert Carr

listener: Add getter for icon theme property

439. By Robert Carr

Add icontheme property to indicate interface

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libindicate/indicate-interface.xml'
2--- libindicate/indicate-interface.xml 2011-01-13 22:49:19 +0000
3+++ libindicate/indicate-interface.xml 2012-01-18 17:16:31 +0000
4@@ -35,6 +35,7 @@
5 <property name="type" type="s" access="read" />
6 <property name="count" type="u" access="read" />
7 <property name="menu" type="o" access="read" />
8+ <property name="icontheme" type="s" access="read" />
9
10 <!-- Functions -->
11 <method name="GetIndicatorCount">
12
13=== modified file 'libindicate/listener.c'
14--- libindicate/listener.c 2011-09-20 03:17:39 +0000
15+++ libindicate/listener.c 2012-01-18 17:16:31 +0000
16@@ -1384,6 +1384,12 @@
17 return get_server_property(listener, server, callback, NULL, "menu", data);
18 }
19
20+void
21+indicate_listener_server_get_icon_theme (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)
22+{
23+ return get_server_property(listener, server, callback, NULL, "icontheme", data);
24+}
25+
26 /**
27 * indicate_listener_server_get_indicators:
28 * @listener: The listener for the server
29
30=== modified file 'libindicate/listener.h'
31--- libindicate/listener.h 2011-08-15 21:21:46 +0000
32+++ libindicate/listener.h 2012-01-18 17:16:31 +0000
33@@ -193,6 +193,10 @@
34 IndicateListenerServer * server,
35 void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
36 gpointer data);
37+void indicate_listener_server_get_icon_theme (IndicateListener * listener,
38+ IndicateListenerServer * server,
39+ void (*callback) (IndicateListener *listener, IndicateListenerServer *server, const gchar *value, gpointer data),
40+ gpointer data);
41 GList * indicate_listener_server_get_indicators (IndicateListener * listener,
42 IndicateListenerServer * server);
43 const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
44
45=== modified file 'libindicate/server.c'
46--- libindicate/server.c 2011-08-10 19:13:56 +0000
47+++ libindicate/server.c 2012-01-18 17:16:31 +0000
48@@ -79,7 +79,8 @@
49 PROP_DESKTOP,
50 PROP_TYPE,
51 PROP_COUNT,
52- PROP_MENU
53+ PROP_MENU,
54+ PROP_ICON_THEME
55 };
56
57 static guint signals[LAST_SIGNAL] = { 0 };
58@@ -100,6 +101,8 @@
59
60 gchar * desktop;
61 gchar * type;
62+ gchar * icon_theme;
63+
64 guint count;
65
66 DbusmenuServer * dbusmenu;
67@@ -408,6 +411,12 @@
68 "The DBus Object path to an object with a dbusmenu interface on it.",
69 "",
70 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
71+
72+ g_object_class_install_property (gobj, PROP_ICON_THEME,
73+ g_param_spec_string("icon-theme", "Icon Theme Name",
74+ "The Custom Icon Theme Name to use when displaying this Server.",
75+ "",
76+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
77
78 class->get_indicator_count = get_indicator_count;
79 class->get_indicator_list = get_indicator_list;
80@@ -624,6 +633,12 @@
81 }
82 break;
83 }
84+ case PROP_ICON_THEME:
85+ if (priv->icon_theme != NULL) {
86+ g_free (priv->icon_theme);
87+ }
88+ priv->icon_theme = g_value_dup_string(value);
89+ break;
90 default:
91 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
92 break;
93@@ -671,6 +686,13 @@
94 g_value_set_boxed(value, g_strdup("/"));
95 }
96 break;
97+ case PROP_ICON_THEME:
98+ if (priv->icon_theme == NULL) {
99+ g_value_set_string(value, "");
100+ } else {
101+ g_value_set_string(value, priv->icon_theme);
102+ }
103+ break;
104 default:
105 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
106 break;
107@@ -823,6 +845,12 @@
108 retvariant = g_variant_new_string("/");
109 }
110
111+ } else if (g_strcmp0(property, "icontheme") == 0) {
112+ if (priv->icon_theme != NULL) {
113+ retvariant = g_variant_new_string (priv->icon_theme);
114+ } else {
115+ retvariant = g_variant_new_string ("");
116+ }
117 } else {
118 g_warning("Unknown property");
119 }
120@@ -1447,6 +1475,26 @@
121 return;
122 }
123
124+/**
125+ * indicate_server_set_icon_theme:
126+ * @server: The #IndicateServer to set the type of
127+ * @name: The name of an Icon Theme (according to the Icon Naming
128+ * Specification) to request renderers of the server to use.
129+ *
130+ * This is a convience function to set the #IndicateServer:icon-theme
131+ * property of the @server object. The property can also be set
132+ * via traditional means, but this one is easier to read.
133+*/
134+void
135+indicate_server_set_icon_theme (IndicateServer * server, const gchar * name)
136+{
137+ GValue value = {0};
138+ g_value_init(&value, G_TYPE_STRING);
139+ g_value_set_string(&value, name);
140+ g_object_set_property(G_OBJECT(server), "icon-theme", &value);
141+ return;
142+}
143+
144 static IndicateServer * default_indicate_interface_server = NULL;
145
146 /**
147
148=== modified file 'libindicate/server.h'
149--- libindicate/server.h 2011-08-10 19:13:56 +0000
150+++ libindicate/server.h 2012-01-18 17:16:31 +0000
151@@ -222,6 +222,8 @@
152 void indicate_server_set_type (IndicateServer * server, const gchar * type);
153 void indicate_server_set_count (IndicateServer * server, guint count);
154
155+void indicate_server_set_icon_theme (IndicateServer * server, const gchar * name);
156+
157 /* Show and hide the server on DBus, this allows for the server to
158 * be created, change the object, and then shown. If for some
159 * reason the app wanted to hide all it's indicators, this is a
160
161=== modified file 'tests/Makefile.am'
162--- tests/Makefile.am 2010-02-18 15:20:04 +0000
163+++ tests/Makefile.am 2012-01-18 17:16:31 +0000
164@@ -195,6 +195,38 @@
165 $(LIBINDICATE_LIBS)
166
167 ##########################
168+# test listener server icon theme
169+##########################
170+
171+TESTS += test-icon-theme
172+check_PROGRAMS += test-icon-theme-client test-icon-theme-server
173+
174+test-icon-theme: test-icon-theme-client test-icon-theme-server Makefile.am
175+ @echo "#!/bin/sh" > $@
176+ @echo "$(DBUS_RUNNER) --task ./test-icon-theme-client --task-name Client --task ./test-icon-theme-server --task-name Server" >> $@
177+ @chmod +x $@
178+
179+test_icon_theme_client_SOURCES = \
180+ test-icon-theme-client.c
181+
182+test_icon_theme_client_CFLAGS = \
183+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
184+
185+test_icon_theme_client_LDADD = \
186+ ../libindicate/libindicate.la \
187+ $(LIBINDICATE_LIBS)
188+
189+test_icon_theme_server_SOURCES = \
190+ test-icon-theme-server.c
191+
192+test_icon_theme_server_CFLAGS = \
193+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
194+
195+test_icon_theme_server_LDADD = \
196+ ../libindicate/libindicate.la \
197+ $(LIBINDICATE_LIBS)
198+
199+##########################
200 # test thousand indicators
201 ##########################
202
203
204=== added file 'tests/test-icon-theme-client.c'
205--- tests/test-icon-theme-client.c 1970-01-01 00:00:00 +0000
206+++ tests/test-icon-theme-client.c 2012-01-18 17:16:31 +0000
207@@ -0,0 +1,35 @@
208+
209+#include <glib.h>
210+#include "libindicate/indicator.h"
211+
212+static gboolean passed = TRUE;
213+static GMainLoop * mainloop = NULL;
214+
215+static gboolean
216+done_timeout_cb (gpointer data)
217+{
218+ g_debug("All done.");
219+ g_main_loop_quit(mainloop);
220+ return FALSE;
221+}
222+
223+int
224+main (int argc, char * argv)
225+{
226+ g_type_init();
227+
228+ g_debug("Starting client");
229+ IndicateIndicator * indicator = indicate_indicator_new();
230+
231+ indicate_server_set_icon_theme(indicate_indicator_get_server(indicator), "test-theme");
232+
233+ g_debug("Show indicator");
234+ indicate_indicator_show(indicator);
235+
236+ g_timeout_add_seconds(2, done_timeout_cb, indicator);
237+
238+ mainloop = g_main_loop_new(NULL, FALSE);
239+ g_main_loop_run(mainloop);
240+
241+ return !passed;
242+}
243
244=== added file 'tests/test-icon-theme-server.c'
245--- tests/test-icon-theme-server.c 1970-01-01 00:00:00 +0000
246+++ tests/test-icon-theme-server.c 2012-01-18 17:16:31 +0000
247@@ -0,0 +1,52 @@
248+
249+#include <glib.h>
250+#include "libindicate/listener.h"
251+
252+static gboolean passed = TRUE;
253+static GMainLoop * mainloop = NULL;
254+
255+void
256+cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
257+{
258+ g_debug("Got Icon Theme: %s", value);
259+ if (g_strcmp0(value, "test-theme") != 0) {
260+ passed = FALSE;
261+ }
262+ g_main_loop_quit(mainloop);
263+ return;
264+}
265+
266+static void
267+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
268+{
269+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
270+ g_debug("\tLooking for theme...");
271+ indicate_listener_server_get_icon_theme(listener, server, cb, NULL);
272+ return;
273+}
274+
275+static gboolean
276+failed_cb (gpointer data)
277+{
278+ g_debug("Failed to get a server in 5 seconds.");
279+ passed = FALSE;
280+ g_main_loop_quit(mainloop);
281+ return FALSE;
282+}
283+
284+int
285+main (int argc, char * argv)
286+{
287+ g_type_init();
288+
289+ IndicateListener * listener = indicate_listener_ref_default();
290+
291+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
292+
293+ g_timeout_add_seconds(5, failed_cb, NULL);
294+
295+ mainloop = g_main_loop_new(NULL, FALSE);
296+ g_main_loop_run(mainloop);
297+
298+ return !passed;
299+}

Subscribers

People subscribed via source and target branches