From 0f370f9a042214453d9d92ca1daafadb0870aa9e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Jun 2008 16:45:54 +0000 Subject: [PATCH] Add g_themed_icon_prepend_name svn path=/trunk/; revision=6991 --- docs/reference/ChangeLog | 4 ++++ docs/reference/gio/gio-sections.txt | 1 + gio/ChangeLog | 8 +++++++- gio/gio.symbols | 1 + gio/gthemedicon.c | 41 ++++++++++++++++++++++++++++++++++++- gio/gthemedicon.h | 14 ++++++++----- 6 files changed, 62 insertions(+), 7 deletions(-) diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index e17838549..1d3dee204 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2008-06-10 Matthias Clasen + + * gio/gio-sections.txt: Add g_themed_icon_prepend_name + 2008-06-10 14:06:34 Tim Janik * gobject/tmpl/gtype.sgml: fixed documentation regarding type checking diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index 2bd491bb1..1c25bf4fa 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -364,6 +364,7 @@ GThemedIcon g_themed_icon_new g_themed_icon_new_from_names g_themed_icon_new_with_default_fallbacks +g_themed_icon_prepend_name g_themed_icon_append_name GThemedIconClass diff --git a/gio/ChangeLog b/gio/ChangeLog index 8bf6de99b..68ab141c3 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,6 +1,12 @@ 2008-06-10 Matthias Clasen - ug 537392 – Additional colon in xattr name + * gio.symbols: + * gthemedicon.[hc] (g_themed_icon_prepend_name): New function, + to add a name to the front of the list. + +2008-06-10 Matthias Clasen + + Bug 537392 – Additional colon in xattr name * glocalfileinfo.c (set_xattr): Skip the second colon of the prefix, too. Reported by Alessandro Morandi diff --git a/gio/gio.symbols b/gio/gio.symbols index 202645edb..6a34fd430 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -633,6 +633,7 @@ g_themed_icon_new g_themed_icon_new_with_default_fallbacks g_themed_icon_new_from_names g_themed_icon_get_names +g_themed_icon_prepend_name g_themed_icon_append_name #endif #endif diff --git a/gio/gthemedicon.c b/gio/gthemedicon.c index d59f69697..096a9004e 100644 --- a/gio/gthemedicon.c +++ b/gio/gthemedicon.c @@ -368,7 +368,8 @@ g_themed_icon_get_names (GThemedIcon *icon) * */ void -g_themed_icon_append_name (GThemedIcon *icon, const char *iconname) +g_themed_icon_append_name (GThemedIcon *icon, + const char *iconname) { guint num_names; @@ -383,6 +384,44 @@ g_themed_icon_append_name (GThemedIcon *icon, const char *iconname) g_object_notify (G_OBJECT (icon), "names"); } +/** + * g_themed_icon_prepend_name: + * @icon: a #GThemedIcon + * @iconname: name of icon to prepend to list of icons from within @icon. + * + * Prepend a name to the list of icons from within @icon. + * + * + * Note that doing so invalidates the hash computed by prior calls + * to g_icon_hash(). + * + * + * Since: 2.18 + */ +void +g_themed_icon_prepend_name (GThemedIcon *icon, + const char *iconname) +{ + guint num_names; + gchar **names; + gint i; + + g_return_if_fail (G_IS_THEMED_ICON (icon)); + g_return_if_fail (iconname != NULL); + + num_names = g_strv_length (icon->names); + names = g_new (char*, num_names + 2); + for (i = 0; icon->names[i]; i++) + names[i + 1] = icon->names[i]; + names[0] = g_strdup (iconname); + names[num_names + 1] = NULL; + + g_free (icon->names); + icon->names = names; + + g_object_notify (G_OBJECT (icon), "names"); +} + static guint g_themed_icon_hash (GIcon *icon) { diff --git a/gio/gthemedicon.h b/gio/gthemedicon.h index 5fb8a6b4e..b2b82acf5 100644 --- a/gio/gthemedicon.h +++ b/gio/gthemedicon.h @@ -48,12 +48,16 @@ typedef struct _GThemedIconClass GThemedIconClass; GType g_themed_icon_get_type (void) G_GNUC_CONST; -GIcon *g_themed_icon_new (const char *iconname); -GIcon *g_themed_icon_new_with_default_fallbacks (const char *iconname); -GIcon *g_themed_icon_new_from_names (char **iconnames, int len); -void g_themed_icon_append_name (GThemedIcon *icon, const char *iconname); +GIcon *g_themed_icon_new (const char *iconname); +GIcon *g_themed_icon_new_with_default_fallbacks (const char *iconname); +GIcon *g_themed_icon_new_from_names (char **iconnames, + int len); +void g_themed_icon_prepend_name (GThemedIcon *icon, + const char *iconname); +void g_themed_icon_append_name (GThemedIcon *icon, + const char *iconname); -const char * const *g_themed_icon_get_names (GThemedIcon *icon); +const char * const *g_themed_icon_get_names (GThemedIcon *icon); G_END_DECLS -- 2.11.4.GIT