aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt5
-rw-r--r--libdbusmenu-glib/client-marshal.list1
-rw-r--r--libdbusmenu-glib/client.c60
-rw-r--r--libdbusmenu-glib/client.h11
-rw-r--r--libdbusmenu-glib/dbus-menu.xml9
-rw-r--r--libdbusmenu-glib/server.c93
-rw-r--r--libdbusmenu-glib/server.h3
7 files changed, 173 insertions, 9 deletions
diff --git a/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt b/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt
index 2a8aa90..84d8257 100644
--- a/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt
+++ b/docs/libdbusmenu-glib/reference/libdbusmenu-glib-sections.txt
@@ -6,7 +6,7 @@ DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED
DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM
DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT
DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE
-DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED
+DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED
DBUSMENU_CLIENT_PROP_DBUS_NAME
DBUSMENU_CLIENT_PROP_DBUS_OBJECT
DBUSMENU_CLIENT_PROP_STATUS
@@ -18,6 +18,7 @@ DbusmenuClient
DbusmenuClientClass
DbusmenuClientTypeHandler
dbusmenu_client_new
+dbusmenu_client_get_icon_paths
dbusmenu_client_get_root
dbusmenu_client_get_status
dbusmenu_client_get_text_direction
@@ -151,6 +152,8 @@ DBUSMENU_SERVER_GET_CLASS
<SUBSECTION Private>
DbusmenuServerPrivate
dbusmenu_server_get_type
+dbusmenu_server_get_icon_paths
+dbusmenu_server_set_icon_paths
</SECTION>
<SECTION>
diff --git a/libdbusmenu-glib/client-marshal.list b/libdbusmenu-glib/client-marshal.list
index 96f9302..980c5c3 100644
--- a/libdbusmenu-glib/client-marshal.list
+++ b/libdbusmenu-glib/client-marshal.list
@@ -1,3 +1,4 @@
VOID: OBJECT, UINT
VOID: OBJECT, STRING, VARIANT, UINT, POINTER
VOID: ENUM
+VOID: POINTER
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 8415b95..c95b161 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -62,6 +62,7 @@ enum {
NEW_MENUITEM,
ITEM_ACTIVATE,
EVENT_RESULT,
+ ICON_THEME_DIRS,
LAST_SIGNAL
};
@@ -98,6 +99,7 @@ struct _DbusmenuClientPrivate
DbusmenuTextDirection text_direction;
DbusmenuStatus status;
+ GStrv icon_dirs;
};
typedef struct _newItemPropData newItemPropData;
@@ -272,6 +274,20 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass)
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 @@ dbusmenu_client_init (DbusmenuClient *self)
priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE;
priv->status = DBUSMENU_STATUS_NORMAL;
+ priv->icon_dirs = NULL;
return;
}
@@ -466,6 +483,11 @@ dbusmenu_client_finalize (GObject *object)
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 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva
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 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva
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 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva
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 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva
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 @@ dbusmenu_client_get_status (DbusmenuClient * client)
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;
+}
diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h
index 1deed56..1cb9ee5 100644
--- a/libdbusmenu-glib/client.h
+++ b/libdbusmenu-glib/client.h
@@ -75,11 +75,11 @@ G_BEGIN_DECLS
*/
#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 @@ typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate;
@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 @@ struct _DbusmenuClientClass {
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 @@ struct _DbusmenuClientClass {
void (*reserved3) (void);
void (*reserved4) (void);
void (*reserved5) (void);
- void (*reserved6) (void);
};
/**
@@ -212,6 +212,7 @@ gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * cli
GDestroyNotify 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
diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml
index b61b5ec..efb55d4 100644
--- a/libdbusmenu-glib/dbus-menu.xml
+++ b/libdbusmenu-glib/dbus-menu.xml
@@ -189,6 +189,15 @@ License version 3 and version 2.1 along with this program. If not, see
</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">
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index ebd9193..ca39ea3 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -59,6 +59,7 @@ struct _DbusmenuServerPrivate
DbusmenuTextDirection text_direction;
DbusmenuStatus status;
+ GStrv icon_dirs;
GArray * prop_array;
guint property_idle;
@@ -84,7 +85,8 @@ enum {
PROP_ROOT_NODE,
PROP_VERSION,
PROP_TEXT_DIRECTION,
- PROP_STATUS
+ PROP_STATUS,
+ PROP_ICON_THEME_DIRS
};
/* Errors */
@@ -368,6 +370,7 @@ dbusmenu_server_init (DbusmenuServer *self)
default_text_direction(self);
priv->status = DBUSMENU_STATUS_NORMAL;
+ priv->icon_dirs = NULL;
return;
}
@@ -425,6 +428,13 @@ dbusmenu_server_dispose (GObject *object)
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;
}
@@ -499,7 +509,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
/* If the value has changed we need to signal that on DBus */
if (priv->text_direction != olddir && priv->bus != NULL && priv->dbusobject != NULL) {
GVariantBuilder params;
- g_variant_builder_init(&params, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value(&params, g_variant_new_string(DBUSMENU_INTERFACE));
GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("TextDirection"), g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction)));
g_variant_builder_add_value(&params, g_variant_new_array(NULL, &dict, 1));
@@ -523,7 +533,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
/* If the value has changed we need to signal that on DBus */
if (priv->status != instatus && priv->bus != NULL && priv->dbusobject != NULL) {
GVariantBuilder params;
- g_variant_builder_init(&params, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value(&params, g_variant_new_string(DBUSMENU_INTERFACE));
GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("Status"), g_variant_new_string(dbusmenu_status_get_nick(instatus)));
g_variant_builder_add_value(&params, g_variant_new_array(NULL, &dict, 1));
@@ -744,6 +754,16 @@ bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar *
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 @@ dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status)
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;
+}
diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h
index 80b7abb..5feb09b 100644
--- a/libdbusmenu-glib/server.h
+++ b/libdbusmenu-glib/server.h
@@ -167,6 +167,9 @@ void dbusmenu_server_set_text_direction (DbusmenuServer *
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