X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgthemedicon.c;h=3d72bc25ffce9acea65323a0fc1b3ee3173bf6a1;hb=d9ad40b4eaf1a9197ab363de4346a8d84f45f5c1;hp=e723a493e9e1326753d824665c5a2a742bfcb36f;hpb=5a8d012d296ab6eba4e26c59cfe06d3f8d582e70;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gthemedicon.c b/gio/gthemedicon.c index e723a49..3d72bc2 100644 --- a/gio/gthemedicon.c +++ b/gio/gthemedicon.c @@ -13,9 +13,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Author: Alexander Larsson */ @@ -155,8 +153,17 @@ g_themed_icon_constructed (GObject *object) const char *p; char *dashp; char *last; + gboolean is_symbolic; + char *name; + char **names; + + is_symbolic = g_str_has_suffix (themed->names[0], "-symbolic"); + if (is_symbolic) + name = g_strndup (themed->names[0], strlen (themed->names[0]) - 9); + else + name = g_strdup (themed->names[0]); - p = themed->names[0]; + p = name; while (*p) { if (*p == '-') @@ -164,17 +171,34 @@ g_themed_icon_constructed (GObject *object) p++; } - last = g_strdup (themed->names[0]); + last = name; g_strfreev (themed->names); - themed->names = g_new (char *, dashes + 1 + 1); - themed->names[i++] = last; + names = g_new (char *, dashes + 1 + 1); + names[i++] = last; while ((dashp = strrchr (last, '-')) != NULL) - themed->names[i++] = last = g_strndup (last, dashp - last); + names[i++] = last = g_strndup (last, dashp - last); + + names[i++] = NULL; - themed->names[i++] = NULL; + if (is_symbolic) + { + themed->names = g_new (char *, 2 * dashes + 3); + for (i = 0; names[i] != NULL; i++) + { + themed->names[i] = g_strconcat (names[i], "-symbolic", NULL); + themed->names[dashes + 1 + i] = names[i]; + } + + themed->names[dashes + 1 + i] = NULL; + g_free (names); + } + else + { + themed->names = names; + } } } @@ -233,7 +257,7 @@ g_themed_icon_class_init (GThemedIconClass *klass) * * For example, if the icon name was "gnome-dev-cdrom-audio", the array * would become - * |[ + * |[ * { * "gnome-dev-cdrom-audio", * "gnome-dev-cdrom", @@ -263,7 +287,7 @@ g_themed_icon_init (GThemedIcon *themed) * * Creates a new themed icon for @iconname. * - * Returns: (transfer full): a new #GThemedIcon. + * Returns: (transfer full) (type GThemedIcon): a new #GThemedIcon. **/ GIcon * g_themed_icon_new (const char *iconname) @@ -281,7 +305,7 @@ g_themed_icon_new (const char *iconname) * * Creates a new themed icon for @iconnames. * - * Returns: (transfer full): a new #GThemedIcon + * Returns: (transfer full) (type GThemedIcon): a new #GThemedIcon **/ GIcon * g_themed_icon_new_from_names (char **iconnames, @@ -321,7 +345,7 @@ g_themed_icon_new_from_names (char **iconnames, * that can be created by shortening @iconname at '-' characters. * * In the following example, @icon1 and @icon2 are equivalent: - * |[ + * |[ * const char *names[] = { * "gnome-dev-cdrom-audio", * "gnome-dev-cdrom", @@ -333,7 +357,7 @@ g_themed_icon_new_from_names (char **iconnames, * icon2 = g_themed_icon_new_with_default_fallbacks ("gnome-dev-cdrom-audio"); * ]| * - * Returns: (transfer full): a new #GThemedIcon. + * Returns: (transfer full) (type GThemedIcon): a new #GThemedIcon. */ GIcon * g_themed_icon_new_with_default_fallbacks (const char *iconname) @@ -366,10 +390,8 @@ g_themed_icon_get_names (GThemedIcon *icon) * * Append 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(). - * */ void g_themed_icon_append_name (GThemedIcon *icon, @@ -395,10 +417,8 @@ g_themed_icon_append_name (GThemedIcon *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 */ @@ -512,6 +532,14 @@ g_themed_icon_from_tokens (gchar **tokens, return icon; } +static GVariant * +g_themed_icon_serialize (GIcon *icon) +{ + GThemedIcon *themed_icon = G_THEMED_ICON (icon); + + return g_variant_new ("(sv)", "themed", g_variant_new ("^as", themed_icon->names)); +} + static void g_themed_icon_icon_iface_init (GIconIface *iface) { @@ -519,4 +547,5 @@ g_themed_icon_icon_iface_init (GIconIface *iface) iface->equal = g_themed_icon_equal; iface->to_tokens = g_themed_icon_to_tokens; iface->from_tokens = g_themed_icon_from_tokens; + iface->serialize = g_themed_icon_serialize; }