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
=== modified file 'libindicate/indicate-interface.xml'
--- libindicate/indicate-interface.xml 2011-01-13 22:49:19 +0000
+++ libindicate/indicate-interface.xml 2012-01-18 17:16:31 +0000
@@ -35,6 +35,7 @@
35 <property name="type" type="s" access="read" />35 <property name="type" type="s" access="read" />
36 <property name="count" type="u" access="read" />36 <property name="count" type="u" access="read" />
37 <property name="menu" type="o" access="read" />37 <property name="menu" type="o" access="read" />
38 <property name="icontheme" type="s" access="read" />
3839
39<!-- Functions -->40<!-- Functions -->
40 <method name="GetIndicatorCount">41 <method name="GetIndicatorCount">
4142
=== modified file 'libindicate/listener.c'
--- libindicate/listener.c 2011-09-20 03:17:39 +0000
+++ libindicate/listener.c 2012-01-18 17:16:31 +0000
@@ -1384,6 +1384,12 @@
1384 return get_server_property(listener, server, callback, NULL, "menu", data);1384 return get_server_property(listener, server, callback, NULL, "menu", data);
1385}1385}
13861386
1387void
1388indicate_listener_server_get_icon_theme (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)
1389{
1390 return get_server_property(listener, server, callback, NULL, "icontheme", data);
1391}
1392
1387/**1393/**
1388 * indicate_listener_server_get_indicators:1394 * indicate_listener_server_get_indicators:
1389 * @listener: The listener for the server1395 * @listener: The listener for the server
13901396
=== modified file 'libindicate/listener.h'
--- libindicate/listener.h 2011-08-15 21:21:46 +0000
+++ libindicate/listener.h 2012-01-18 17:16:31 +0000
@@ -193,6 +193,10 @@
193 IndicateListenerServer * server,193 IndicateListenerServer * server,
194 void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),194 void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
195 gpointer data);195 gpointer data);
196void indicate_listener_server_get_icon_theme (IndicateListener * listener,
197 IndicateListenerServer * server,
198 void (*callback) (IndicateListener *listener, IndicateListenerServer *server, const gchar *value, gpointer data),
199 gpointer data);
196GList * indicate_listener_server_get_indicators (IndicateListener * listener,200GList * indicate_listener_server_get_indicators (IndicateListener * listener,
197 IndicateListenerServer * server);201 IndicateListenerServer * server);
198const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);202const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
199203
=== modified file 'libindicate/server.c'
--- libindicate/server.c 2011-08-10 19:13:56 +0000
+++ libindicate/server.c 2012-01-18 17:16:31 +0000
@@ -79,7 +79,8 @@
79 PROP_DESKTOP,79 PROP_DESKTOP,
80 PROP_TYPE,80 PROP_TYPE,
81 PROP_COUNT,81 PROP_COUNT,
82 PROP_MENU82 PROP_MENU,
83 PROP_ICON_THEME
83};84};
8485
85static guint signals[LAST_SIGNAL] = { 0 };86static guint signals[LAST_SIGNAL] = { 0 };
@@ -100,6 +101,8 @@
100101
101 gchar * desktop;102 gchar * desktop;
102 gchar * type;103 gchar * type;
104 gchar * icon_theme;
105
103 guint count;106 guint count;
104107
105 DbusmenuServer * dbusmenu;108 DbusmenuServer * dbusmenu;
@@ -408,6 +411,12 @@
408 "The DBus Object path to an object with a dbusmenu interface on it.",411 "The DBus Object path to an object with a dbusmenu interface on it.",
409 "",412 "",
410 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));413 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
414
415 g_object_class_install_property (gobj, PROP_ICON_THEME,
416 g_param_spec_string("icon-theme", "Icon Theme Name",
417 "The Custom Icon Theme Name to use when displaying this Server.",
418 "",
419 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
411420
412 class->get_indicator_count = get_indicator_count;421 class->get_indicator_count = get_indicator_count;
413 class->get_indicator_list = get_indicator_list;422 class->get_indicator_list = get_indicator_list;
@@ -624,6 +633,12 @@
624 }633 }
625 break;634 break;
626 }635 }
636 case PROP_ICON_THEME:
637 if (priv->icon_theme != NULL) {
638 g_free (priv->icon_theme);
639 }
640 priv->icon_theme = g_value_dup_string(value);
641 break;
627 default:642 default:
628 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);643 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
629 break;644 break;
@@ -671,6 +686,13 @@
671 g_value_set_boxed(value, g_strdup("/"));686 g_value_set_boxed(value, g_strdup("/"));
672 }687 }
673 break;688 break;
689 case PROP_ICON_THEME:
690 if (priv->icon_theme == NULL) {
691 g_value_set_string(value, "");
692 } else {
693 g_value_set_string(value, priv->icon_theme);
694 }
695 break;
674 default:696 default:
675 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);697 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
676 break;698 break;
@@ -823,6 +845,12 @@
823 retvariant = g_variant_new_string("/");845 retvariant = g_variant_new_string("/");
824 }846 }
825847
848 } else if (g_strcmp0(property, "icontheme") == 0) {
849 if (priv->icon_theme != NULL) {
850 retvariant = g_variant_new_string (priv->icon_theme);
851 } else {
852 retvariant = g_variant_new_string ("");
853 }
826 } else {854 } else {
827 g_warning("Unknown property");855 g_warning("Unknown property");
828 }856 }
@@ -1447,6 +1475,26 @@
1447 return;1475 return;
1448}1476}
14491477
1478/**
1479 * indicate_server_set_icon_theme:
1480 * @server: The #IndicateServer to set the type of
1481 * @name: The name of an Icon Theme (according to the Icon Naming
1482 * Specification) to request renderers of the server to use.
1483 *
1484 * This is a convience function to set the #IndicateServer:icon-theme
1485 * property of the @server object. The property can also be set
1486 * via traditional means, but this one is easier to read.
1487*/
1488void
1489indicate_server_set_icon_theme (IndicateServer * server, const gchar * name)
1490{
1491 GValue value = {0};
1492 g_value_init(&value, G_TYPE_STRING);
1493 g_value_set_string(&value, name);
1494 g_object_set_property(G_OBJECT(server), "icon-theme", &value);
1495 return;
1496}
1497
1450static IndicateServer * default_indicate_interface_server = NULL;1498static IndicateServer * default_indicate_interface_server = NULL;
14511499
1452/**1500/**
14531501
=== modified file 'libindicate/server.h'
--- libindicate/server.h 2011-08-10 19:13:56 +0000
+++ libindicate/server.h 2012-01-18 17:16:31 +0000
@@ -222,6 +222,8 @@
222void indicate_server_set_type (IndicateServer * server, const gchar * type);222void indicate_server_set_type (IndicateServer * server, const gchar * type);
223void indicate_server_set_count (IndicateServer * server, guint count);223void indicate_server_set_count (IndicateServer * server, guint count);
224224
225void indicate_server_set_icon_theme (IndicateServer * server, const gchar * name);
226
225/* Show and hide the server on DBus, this allows for the server to227/* Show and hide the server on DBus, this allows for the server to
226 * be created, change the object, and then shown. If for some228 * be created, change the object, and then shown. If for some
227 * reason the app wanted to hide all it's indicators, this is a229 * reason the app wanted to hide all it's indicators, this is a
228230
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2010-02-18 15:20:04 +0000
+++ tests/Makefile.am 2012-01-18 17:16:31 +0000
@@ -195,6 +195,38 @@
195 $(LIBINDICATE_LIBS)195 $(LIBINDICATE_LIBS)
196196
197##########################197##########################
198# test listener server icon theme
199##########################
200
201TESTS += test-icon-theme
202check_PROGRAMS += test-icon-theme-client test-icon-theme-server
203
204test-icon-theme: test-icon-theme-client test-icon-theme-server Makefile.am
205 @echo "#!/bin/sh" > $@
206 @echo "$(DBUS_RUNNER) --task ./test-icon-theme-client --task-name Client --task ./test-icon-theme-server --task-name Server" >> $@
207 @chmod +x $@
208
209test_icon_theme_client_SOURCES = \
210 test-icon-theme-client.c
211
212test_icon_theme_client_CFLAGS = \
213 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
214
215test_icon_theme_client_LDADD = \
216 ../libindicate/libindicate.la \
217 $(LIBINDICATE_LIBS)
218
219test_icon_theme_server_SOURCES = \
220 test-icon-theme-server.c
221
222test_icon_theme_server_CFLAGS = \
223 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
224
225test_icon_theme_server_LDADD = \
226 ../libindicate/libindicate.la \
227 $(LIBINDICATE_LIBS)
228
229##########################
198# test thousand indicators230# test thousand indicators
199##########################231##########################
200232
201233
=== added file 'tests/test-icon-theme-client.c'
--- tests/test-icon-theme-client.c 1970-01-01 00:00:00 +0000
+++ tests/test-icon-theme-client.c 2012-01-18 17:16:31 +0000
@@ -0,0 +1,35 @@
1
2#include <glib.h>
3#include "libindicate/indicator.h"
4
5static gboolean passed = TRUE;
6static GMainLoop * mainloop = NULL;
7
8static gboolean
9done_timeout_cb (gpointer data)
10{
11 g_debug("All done.");
12 g_main_loop_quit(mainloop);
13 return FALSE;
14}
15
16int
17main (int argc, char * argv)
18{
19 g_type_init();
20
21 g_debug("Starting client");
22 IndicateIndicator * indicator = indicate_indicator_new();
23
24 indicate_server_set_icon_theme(indicate_indicator_get_server(indicator), "test-theme");
25
26 g_debug("Show indicator");
27 indicate_indicator_show(indicator);
28
29 g_timeout_add_seconds(2, done_timeout_cb, indicator);
30
31 mainloop = g_main_loop_new(NULL, FALSE);
32 g_main_loop_run(mainloop);
33
34 return !passed;
35}
036
=== added file 'tests/test-icon-theme-server.c'
--- tests/test-icon-theme-server.c 1970-01-01 00:00:00 +0000
+++ tests/test-icon-theme-server.c 2012-01-18 17:16:31 +0000
@@ -0,0 +1,52 @@
1
2#include <glib.h>
3#include "libindicate/listener.h"
4
5static gboolean passed = TRUE;
6static GMainLoop * mainloop = NULL;
7
8void
9cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
10{
11 g_debug("Got Icon Theme: %s", value);
12 if (g_strcmp0(value, "test-theme") != 0) {
13 passed = FALSE;
14 }
15 g_main_loop_quit(mainloop);
16 return;
17}
18
19static void
20server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
21{
22 g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
23 g_debug("\tLooking for theme...");
24 indicate_listener_server_get_icon_theme(listener, server, cb, NULL);
25 return;
26}
27
28static gboolean
29failed_cb (gpointer data)
30{
31 g_debug("Failed to get a server in 5 seconds.");
32 passed = FALSE;
33 g_main_loop_quit(mainloop);
34 return FALSE;
35}
36
37int
38main (int argc, char * argv)
39{
40 g_type_init();
41
42 IndicateListener * listener = indicate_listener_ref_default();
43
44 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
45
46 g_timeout_add_seconds(5, failed_cb, NULL);
47
48 mainloop = g_main_loop_new(NULL, FALSE);
49 g_main_loop_run(mainloop);
50
51 return !passed;
52}

Subscribers

People subscribed via source and target branches