← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/dbusmenu/icon-theme-directories into lp:dbusmenu

 

Ted Gould has proposed merging lp:~ted/dbusmenu/icon-theme-directories into lp:dbusmenu.

Requested reviews:
  Conor Curran (cjcurran)

For more details, see:
https://code.launchpad.net/~ted/dbusmenu/icon-theme-directories/+merge/52099

Adds a property for icon theme directories.
-- 
https://code.launchpad.net/~ted/dbusmenu/icon-theme-directories/+merge/52099
Your team ayatana-commits is subscribed to branch lp:dbusmenu.
=== modified file 'libdbusmenu-glib/client-marshal.list'
--- libdbusmenu-glib/client-marshal.list	2011-02-18 17:45:57 +0000
+++ libdbusmenu-glib/client-marshal.list	2011-03-03 17:22:10 +0000
@@ -1,3 +1,4 @@
 VOID: OBJECT, UINT
 VOID: OBJECT, STRING, VARIANT, UINT, POINTER
 VOID: ENUM
+VOID: POINTER

=== modified file 'libdbusmenu-glib/client.c'
--- libdbusmenu-glib/client.c	2011-03-02 15:35:04 +0000
+++ libdbusmenu-glib/client.c	2011-03-03 17:22:10 +0000
@@ -62,6 +62,7 @@
 	NEW_MENUITEM,
 	ITEM_ACTIVATE,
 	EVENT_RESULT,
+	ICON_THEME_DIRS,
 	LAST_SIGNAL
 };
 
@@ -98,6 +99,7 @@
 
 	DbusmenuTextDirection text_direction;
 	DbusmenuStatus status;
+	GStrv icon_dirs;
 };
 
 typedef struct _newItemPropData newItemPropData;
@@ -272,6 +274,20 @@
 	                                        NULL, NULL,
 	                                        _dbusmenu_client_marshal_VOID__OBJECT_STRING_VARIANT_UINT_POINTER,
 	                                        G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_UINT, G_TYPE_POINTER);
+	/**
+		DbusmenuClient::icon-theme-dirs-changed:
+		@arg0: The #DbusmenuClient object
+		@arg1: A #GStrv of theme directories
+
+		Signaled when the theme directories are changed by the server.
+	*/
+	signals[ICON_THEME_DIRS] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED,
+	                                        G_TYPE_FROM_CLASS (klass),
+	                                        G_SIGNAL_RUN_LAST,
+	                                        G_STRUCT_OFFSET (DbusmenuClientClass, icon_theme_dirs),
+	                                        NULL, NULL,
+	                                        _dbusmenu_client_marshal_VOID__POINTER,
+	                                        G_TYPE_NONE, 1, G_TYPE_POINTER);
 
 	g_object_class_install_property (object_class, PROP_DBUSOBJECT,
 	                                 g_param_spec_string(DBUSMENU_CLIENT_PROP_DBUS_OBJECT, "DBus Object we represent",
@@ -358,6 +374,7 @@
 
 	priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE;
 	priv->status = DBUSMENU_STATUS_NORMAL;
+	priv->icon_dirs = NULL;
 
 	return;
 }
@@ -466,6 +483,11 @@
 		g_hash_table_destroy(priv->type_handlers);
 	}
 
+	if (priv->icon_dirs != NULL) {
+		g_strfreev(priv->icon_dirs);
+		priv->icon_dirs = NULL;
+	}
+
 	G_OBJECT_CLASS (dbusmenu_client_parent_class)->finalize (object);
 	return;
 }
@@ -1064,6 +1086,7 @@
 	DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data);
 	DbusmenuTextDirection olddir = priv->text_direction;
 	DbusmenuStatus oldstatus = priv->status;
+	gboolean dirs_changed = FALSE;
 
 	/* Invalidate first */
 	gchar * invalid;
@@ -1075,6 +1098,13 @@
 		if (g_strcmp0(invalid, "Status") == 0) {
 			priv->status = DBUSMENU_STATUS_NORMAL;
 		}
+		if (g_strcmp0(invalid, "IconThemePath") == 0) {
+			if (priv->icon_dirs != NULL) {
+				dirs_changed = TRUE;
+				g_strfreev(priv->icon_dirs);
+				priv->icon_dirs = NULL;
+			}
+		}
 	}
 
 	/* Check updates */
@@ -1098,6 +1128,15 @@
 
 			priv->status = dbusmenu_status_get_value_from_nick(g_variant_get_string(str, NULL));
 		}
+		if (g_strcmp0(key, "IconThemePath") == 0) {
+			if (priv->icon_dirs != NULL) {
+				g_strfreev(priv->icon_dirs);
+				priv->icon_dirs = NULL;
+			}
+
+			priv->icon_dirs = g_variant_dup_strv(value, NULL);
+			dirs_changed = TRUE;
+		}
 
 		g_variant_unref(value);
 		g_free(key);
@@ -1111,6 +1150,10 @@
 		g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_STATUS);
 	}
 
+	if (dirs_changed) {
+		g_signal_emit(G_OBJECT(user_data), signals[ICON_THEME_DIRS], 0, priv->icon_dirs, TRUE);
+	}
+
 	return;
 }
 
@@ -2012,4 +2055,21 @@
 	return priv->status;
 }
 
+/**
+ * dbusmenu_client_get_icon_paths:
+ * @client: The #DbusmenuClient to get the icon paths from
+ * 
+ * Gets the stored and exported icon paths from the client.
+ * 
+ * Return value: (transfer none): A NULL-terminated list of icon paths with
+ *   memory managed by the client.  Duplicate if you want
+ *   to keep them.
+ */
+const GStrv
+dbusmenu_client_get_icon_paths (DbusmenuClient * client)
+{
+	g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), NULL);
+	DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
+	return priv->icon_dirs;
+}
 

=== modified file 'libdbusmenu-glib/client.h'
--- libdbusmenu-glib/client.h	2011-02-24 15:38:18 +0000
+++ libdbusmenu-glib/client.h	2011-03-03 17:22:10 +0000
@@ -75,11 +75,11 @@
  */
 #define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT    "event-result"
 /**
- * DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED:
+ * DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED:
  *
- * String to attach to signal #DbusmenuClient::text-direction-changed
+ * String to attach to signal #DbusmenuClient::icon-theme-dirs-changed
  */
-#define DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED    "text-direction-changed"
+#define DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED    "icon-theme-dirs-changed"
 
 /**
  * DBUSMENU_CLIENT_PROP_DBUS_NAME:
@@ -139,12 +139,12 @@
 	@new_menuitem: Slot for #DbusmenuClient::new-menuitem.
 	@item_activate: Slot for #DbusmenuClient::item-activate.
 	@event_result: Slot for #DbusmenuClient::event-error.
+	@icon_theme_dirs: Slot for #DbusmenuClient::icon-theme-dirs-changed.
 	@reserved1: Reserved for future use.
 	@reserved2: Reserved for future use.
 	@reserved3: Reserved for future use.
 	@reserved4: Reserved for future use.
 	@reserved5: Reserved for future use.
-	@reserved6: Reserved for future use.
 
 	A simple class that takes all of the information from a
 	#DbusmenuServer over DBus and makes the same set of 
@@ -159,6 +159,7 @@
 	void (*new_menuitem) (DbusmenuMenuitem * newitem);
 	void (*item_activate) (DbusmenuMenuitem * item, guint timestamp);
 	void (*event_result) (DbusmenuMenuitem * item, gchar * event, GVariant * data, guint timestamp, GError * error);
+	void (*icon_theme_dirs) (DbusmenuMenuitem * item, gpointer theme_dirs, GError * error);
 
 	/*< Private >*/
 	void (*reserved1) (void);
@@ -166,7 +167,6 @@
 	void (*reserved3) (void);
 	void (*reserved4) (void);
 	void (*reserved5) (void);
-	void (*reserved6) (void);
 };
 
 /**
@@ -224,6 +224,7 @@
                                                         DbusmenuClientTypeDestroyHandler destroy_func);
 DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client);
 DbusmenuStatus       dbusmenu_client_get_status        (DbusmenuClient * client);
+const GStrv          dbusmenu_client_get_icon_paths    (DbusmenuClient * client);
 
 /**
 	SECTION:client

=== modified file 'libdbusmenu-glib/dbus-menu.xml'
--- libdbusmenu-glib/dbus-menu.xml	2011-03-02 11:07:07 +0000
+++ libdbusmenu-glib/dbus-menu.xml	2011-03-03 17:22:10 +0000
@@ -189,6 +189,15 @@
 			</dox:d>
 		</property>
 
+		<property name="IconThemePath" type="as" access="read">
+			<dox:d>
+			A list of directories that should be used for finding icons using
+			the icon naming spec.  Idealy there should only be one for the icon
+			theme, but additional ones are often added by applications for
+			app specific icons.
+			</dox:d>
+		</property>
+
 <!-- Functions -->
 
 		<method name="GetLayout">

=== modified file 'libdbusmenu-glib/server.c'
--- libdbusmenu-glib/server.c	2011-03-02 11:07:07 +0000
+++ libdbusmenu-glib/server.c	2011-03-03 17:22:10 +0000
@@ -59,6 +59,7 @@
 
 	DbusmenuTextDirection text_direction;
 	DbusmenuStatus status;
+	GStrv icon_dirs;
 
 	GArray * prop_array;
 	guint property_idle;
@@ -84,7 +85,8 @@
 	PROP_ROOT_NODE,
 	PROP_VERSION,
 	PROP_TEXT_DIRECTION,
-	PROP_STATUS
+	PROP_STATUS,
+	PROP_ICON_THEME_DIRS
 };
 
 /* Errors */
@@ -368,6 +370,7 @@
 
 	default_text_direction(self);
 	priv->status = DBUSMENU_STATUS_NORMAL;
+	priv->icon_dirs = NULL;
 
 	return;
 }
@@ -425,6 +428,13 @@
 static void
 dbusmenu_server_finalize (GObject *object)
 {
+	DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(object);
+
+	if (priv->icon_dirs != NULL) {
+		g_strfreev(priv->icon_dirs);
+		priv->icon_dirs = NULL;
+	}
+
 	G_OBJECT_CLASS (dbusmenu_server_parent_class)->finalize (object);
 	return;
 }
@@ -744,6 +754,16 @@
 		return g_variant_new_uint32(DBUSMENU_VERSION_NUMBER);
 	} else if (g_strcmp0(property, "TextDirection") == 0) {
 		return g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction));
+	} else if (g_strcmp0(property, "IconThemePath") == 0) {
+		GVariant * dirs = NULL;
+
+		if (priv->icon_dirs != NULL) {
+			dirs = g_variant_new_strv((const gchar * const *)priv->icon_dirs, -1);
+		} else {
+			dirs = g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0);
+		}
+
+		return dirs;
 	} else if (g_strcmp0(property, "Status") == 0) {
 		return g_variant_new_string(dbusmenu_status_get_nick(priv->status));
 	} else {
@@ -1706,3 +1726,70 @@
 
 	return;
 }
+
+/**
+ * dbusmenu_server_get_icon_paths:
+ * @server: The #DbusmenuServer to get the icon paths from
+ * 
+ * Gets the stored and exported icon paths from the server.
+ * 
+ * Return value: (transfer none): A NULL-terminated list of icon paths with
+ *   memory managed by the server.  Duplicate if you want
+ *   to keep them.
+ */
+const GStrv
+dbusmenu_server_get_icon_paths (DbusmenuServer * server)
+{
+	g_return_val_if_fail(DBUSMENU_IS_SERVER(server), NULL);
+	DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
+	return priv->icon_dirs;
+}
+
+/**
+	dbusmenu_server_set_icon_paths:
+	@server: The #DbusmenuServer to set the icon paths on
+
+	Sets the icon paths for the server.  This will replace previously
+	set icon theme paths.
+*/
+void
+dbusmenu_server_set_icon_paths (DbusmenuServer * server, GStrv icon_paths)
+{
+	g_return_if_fail(DBUSMENU_IS_SERVER(server));
+	DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
+
+	if (priv->icon_dirs != NULL) {
+		g_strfreev(priv->icon_dirs);
+		priv->icon_dirs = NULL;
+	}
+
+	if (icon_paths != NULL) {
+		priv->icon_dirs = g_strdupv(icon_paths);
+	}
+
+	if (priv->bus != NULL && priv->dbusobject != NULL) {
+		GVariantBuilder params;
+		g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);
+		g_variant_builder_add_value(&params, g_variant_new_string(DBUSMENU_INTERFACE));
+		GVariant * items = NULL;
+		if (priv->icon_dirs != NULL) {
+			GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("IconThemePath"), g_variant_new_strv((const gchar * const *)priv->icon_dirs, -1));
+			items = g_variant_new_array(NULL, &dict, 1);
+		} else {
+			items = g_variant_new_array(G_VARIANT_TYPE("{sv}"), NULL, 0);
+		}
+		g_variant_builder_add_value(&params, items);
+		g_variant_builder_add_value(&params, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0));
+		GVariant * vparams = g_variant_builder_end(&params);
+
+		g_dbus_connection_emit_signal(priv->bus,
+		                              NULL,
+		                              priv->dbusobject,
+		                              "org.freedesktop.DBus.Properties",
+		                              "PropertiesChanged",
+		                              vparams,
+		                              NULL);
+	}
+
+	return;
+}

=== modified file 'libdbusmenu-glib/server.h'
--- libdbusmenu-glib/server.h	2011-02-24 15:38:18 +0000
+++ libdbusmenu-glib/server.h	2011-03-03 17:22:10 +0000
@@ -167,6 +167,9 @@
 DbusmenuStatus          dbusmenu_server_get_status          (DbusmenuServer *       server);
 void                    dbusmenu_server_set_status          (DbusmenuServer *       server,
                                                              DbusmenuStatus         status);
+const GStrv             dbusmenu_server_get_icon_paths      (DbusmenuServer *       server);
+void                    dbusmenu_server_set_icon_paths      (DbusmenuServer *       server,
+                                                             GStrv                  icon_paths);
 
 /**
 	SECTION:server


References