diff options
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/dbus-menu.xml | 9 | ||||
-rw-r--r-- | libdbusmenu-glib/server.c | 89 | ||||
-rw-r--r-- | libdbusmenu-glib/server.h | 3 |
3 files changed, 100 insertions, 1 deletions
diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index b61b5ec..956844e 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="icon-theme-path" 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..14c0c53 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; } @@ -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, "icon-theme-path") == 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: 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(¶ms, G_VARIANT_TYPE_ARRAY); + g_variant_builder_add_value(¶ms, 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("icon-theme-path"), 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(¶ms, items); + g_variant_builder_add_value(¶ms, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); + GVariant * vparams = g_variant_builder_end(¶ms); + + 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 |