← Back to team overview

ayatana-commits team mailing list archive

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

 

Robert Carr has proposed merging lp:~robertcarr/libindicate/custom-icon-theme into lp:libindicate.

Requested reviews:
  Ted Gould (ted)

For more details, see:
https://code.launchpad.net/~robertcarr/libindicate/custom-icon-theme/+merge/89085

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!
-- 
https://code.launchpad.net/~robertcarr/libindicate/custom-icon-theme/+merge/89085
Your team ayatana-commits is subscribed to branch lp:libindicate.
=== 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 @@
 		<property name="type"    type="s" access="read" />
 		<property name="count"   type="u" access="read" />
 		<property name="menu"    type="o" access="read" />
+		<property name="icontheme" type="s" access="read" />
 
 <!-- Functions -->
 		<method name="GetIndicatorCount">

=== 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 @@
 	return get_server_property(listener, server, callback, NULL, "menu", data);
 }
 
+void
+indicate_listener_server_get_icon_theme (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)
+{
+	return get_server_property(listener, server, callback, NULL, "icontheme", data);
+}
+
 /**
  * indicate_listener_server_get_indicators:
  * @listener: The listener for the server

=== 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 @@
                                                             IndicateListenerServer * server,
                                                             void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
                                                             gpointer data);
+void                  indicate_listener_server_get_icon_theme (IndicateListener * listener,
+							       IndicateListenerServer * server,
+							       void (*callback) (IndicateListener *listener, IndicateListenerServer *server, const gchar *value, gpointer data),
+							       gpointer data);
 GList *               indicate_listener_server_get_indicators    (IndicateListener * listener,
                                                                   IndicateListenerServer * server);
 const gchar *         indicate_listener_server_get_dbusname      (IndicateListenerServer * server);

=== 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 @@
 	PROP_DESKTOP,
 	PROP_TYPE,
 	PROP_COUNT,
-	PROP_MENU
+	PROP_MENU,
+	PROP_ICON_THEME
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -100,6 +101,8 @@
 
 	gchar * desktop;
 	gchar * type;
+	gchar * icon_theme;
+
 	guint count;
 
 	DbusmenuServer * dbusmenu;
@@ -408,6 +411,12 @@
 	                                              "The DBus Object path to an object with a dbusmenu interface on it.",
 												  "",
 	                                              G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+	
+	g_object_class_install_property (gobj, PROP_ICON_THEME,
+					 g_param_spec_string("icon-theme", "Icon Theme Name",
+							     "The Custom Icon Theme Name to use when displaying this Server.",
+							     "",
+							     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
 	class->get_indicator_count = get_indicator_count;
 	class->get_indicator_list = get_indicator_list;
@@ -624,6 +633,12 @@
 		}
 		break;
 	}
+	case PROP_ICON_THEME:
+		if (priv->icon_theme != NULL) {
+			g_free (priv->icon_theme);
+		}
+		priv->icon_theme = g_value_dup_string(value);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
 		break;
@@ -671,6 +686,13 @@
 			g_value_set_boxed(value, g_strdup("/"));
 		}
 		break;
+	case PROP_ICON_THEME:
+		if (priv->icon_theme == NULL) {
+			g_value_set_string(value, "");
+		} else {
+			g_value_set_string(value, priv->icon_theme);
+		}
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
 		break;
@@ -823,6 +845,12 @@
 			retvariant = g_variant_new_string("/");
 		}
 
+	} else if (g_strcmp0(property, "icontheme") == 0) {
+		if (priv->icon_theme != NULL) {
+			retvariant = g_variant_new_string (priv->icon_theme);
+		} else {
+			retvariant = g_variant_new_string ("");
+		}
 	} else {
 		g_warning("Unknown property");
 	}
@@ -1447,6 +1475,26 @@
 	return;
 }
 
+/**
+ * indicate_server_set_icon_theme:
+ * @server: The #IndicateServer to set the type of
+ * @name: The name of an Icon Theme (according to the Icon Naming 
+ *        Specification) to request renderers of the server to use. 
+ * 
+ * This is a convience function to set the #IndicateServer:icon-theme
+ * property of the @server object.  The property can also be set
+ * via traditional means, but this one is easier to read.
+*/
+void
+indicate_server_set_icon_theme (IndicateServer * server, const gchar * name)
+{
+	GValue value = {0};
+	g_value_init(&value, G_TYPE_STRING);
+	g_value_set_string(&value, name);
+	g_object_set_property(G_OBJECT(server), "icon-theme", &value);
+	return;
+}
+
 static IndicateServer * default_indicate_interface_server = NULL;
 
 /**

=== 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 @@
 void indicate_server_set_type (IndicateServer * server, const gchar * type);
 void indicate_server_set_count (IndicateServer * server, guint count);
 
+void indicate_server_set_icon_theme (IndicateServer * server, const gchar * name);
+
 /* Show and hide the server on DBus, this allows for the server to
  * be created, change the object, and then shown.  If for some
  * reason the app wanted to hide all it's indicators, this is a

=== 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 @@
 	$(LIBINDICATE_LIBS)
 
 ##########################
+# test listener server icon theme
+##########################
+
+TESTS += test-icon-theme
+check_PROGRAMS += test-icon-theme-client test-icon-theme-server
+
+test-icon-theme: test-icon-theme-client test-icon-theme-server Makefile.am
+	@echo "#!/bin/sh" > $@
+	@echo "$(DBUS_RUNNER) --task ./test-icon-theme-client --task-name Client --task ./test-icon-theme-server --task-name Server" >> $@
+	@chmod +x $@
+
+test_icon_theme_client_SOURCES = \
+	test-icon-theme-client.c
+
+test_icon_theme_client_CFLAGS = \
+	$(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_icon_theme_client_LDADD = \
+	../libindicate/libindicate.la \
+	$(LIBINDICATE_LIBS)
+
+test_icon_theme_server_SOURCES = \
+	test-icon-theme-server.c
+
+test_icon_theme_server_CFLAGS = \
+	$(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_icon_theme_server_LDADD = \
+	../libindicate/libindicate.la \
+	$(LIBINDICATE_LIBS)
+
+##########################
 # test thousand indicators
 ##########################
 

=== 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 @@
+
+#include <glib.h>
+#include "libindicate/indicator.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static gboolean
+done_timeout_cb (gpointer data)
+{
+	g_debug("All done.");
+	g_main_loop_quit(mainloop);
+	return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+	g_type_init();
+
+	g_debug("Starting client");
+	IndicateIndicator * indicator = indicate_indicator_new();
+
+	indicate_server_set_icon_theme(indicate_indicator_get_server(indicator), "test-theme");
+
+	g_debug("Show indicator");
+	indicate_indicator_show(indicator);
+
+	g_timeout_add_seconds(2, done_timeout_cb, indicator);
+
+	mainloop = g_main_loop_new(NULL, FALSE);
+	g_main_loop_run(mainloop);
+
+	return !passed;
+}

=== 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 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+void
+cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
+{
+	g_debug("Got Icon Theme: %s", value);
+	if (g_strcmp0(value, "test-theme") != 0) {
+		passed = FALSE;
+	}
+	g_main_loop_quit(mainloop);
+	return;
+}
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+	g_debug("Indicator Server Added:   %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+	g_debug("\tLooking for theme...");
+	indicate_listener_server_get_icon_theme(listener, server, cb, NULL);
+	return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+	g_debug("Failed to get a server in 5 seconds.");
+	passed = FALSE;
+	g_main_loop_quit(mainloop);
+	return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+	g_type_init();
+
+	IndicateListener * listener = indicate_listener_ref_default();
+
+	g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+	g_timeout_add_seconds(5, failed_cb, NULL);
+
+	mainloop = g_main_loop_new(NULL, FALSE);
+	g_main_loop_run(mainloop);
+
+	return !passed;
+}


Follow ups