| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | /* GIO - GLib Input, Output and Streaming Library
 | 
					
						
							|  |  |  |  |  *  | 
					
						
							|  |  |  |  |  * Copyright (C) 2006-2007 Red Hat, Inc. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  |  * version 2 of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * This library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * You should have received a copy of the GNU Lesser General | 
					
						
							| 
									
										
										
										
											2014-01-23 12:58:29 +01:00
										 |  |  |  |  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * Author: Alexander Larsson <alexl@redhat.com> | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-22 15:10:51 +00:00
										 |  |  |  | #include "config.h"
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-09 15:20:49 +00:00
										 |  |  |  | #include <string.h>
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | #include "gthemedicon.h"
 | 
					
						
							| 
									
										
										
										
											2008-07-01 06:32:35 +00:00
										 |  |  |  | #include "gicon.h"
 | 
					
						
							| 
									
										
										
										
											2008-10-21 11:51:48 +00:00
										 |  |  |  | #include "gioerror.h"
 | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | #include "glibintl.h"
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-28 12:39:07 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-27 14:00:13 +00:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * SECTION:gthemedicon | 
					
						
							| 
									
										
										
										
											2007-12-01 04:38:29 +00:00
										 |  |  |  |  * @short_description: Icon theming support | 
					
						
							| 
									
										
										
										
											2008-02-21 18:20:17 +00:00
										 |  |  |  |  * @include: gio/gio.h | 
					
						
							| 
									
										
										
										
											2007-11-28 06:43:33 +00:00
										 |  |  |  |  * @see_also: #GIcon, #GLoadableIcon | 
					
						
							| 
									
										
										
										
											2007-11-27 14:00:13 +00:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2007-11-29 10:18:55 +00:00
										 |  |  |  |  * #GThemedIcon is an implementation of #GIcon that supports icon themes. | 
					
						
							|  |  |  |  |  * #GThemedIcon contains a list of all of the icons present in an icon | 
					
						
							|  |  |  |  |  * theme, so that icons can be looked up quickly. #GThemedIcon does | 
					
						
							|  |  |  |  |  * not provide actual pixmaps for icons, just the icon names. | 
					
						
							| 
									
										
										
										
											2007-12-12 12:19:02 +00:00
										 |  |  |  |  * Ideally something like gtk_icon_theme_choose_icon() should be used to | 
					
						
							|  |  |  |  |  * resolve the list of names so that fallback icons work nicely with | 
					
						
							|  |  |  |  |  * themes that inherit other themes. | 
					
						
							| 
									
										
										
										
											2007-11-27 14:00:13 +00:00
										 |  |  |  |  **/ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-30 05:11:25 +00:00
										 |  |  |  | static void g_themed_icon_icon_iface_init (GIconIface *iface); | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | struct _GThemedIcon | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GObject parent_instance; | 
					
						
							|  |  |  |  |    | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |   char     **names; | 
					
						
							|  |  |  |  |   gboolean   use_default_fallbacks; | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | struct _GThemedIconClass | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GObjectClass parent_class; | 
					
						
							|  |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | enum | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   PROP_0, | 
					
						
							|  |  |  |  |   PROP_NAME, | 
					
						
							|  |  |  |  |   PROP_NAMES, | 
					
						
							|  |  |  |  |   PROP_USE_DEFAULT_FALLBACKS | 
					
						
							|  |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | G_DEFINE_TYPE_WITH_CODE (GThemedIcon, g_themed_icon, G_TYPE_OBJECT, | 
					
						
							|  |  |  |  | 			 G_IMPLEMENT_INTERFACE (G_TYPE_ICON, | 
					
						
							|  |  |  |  | 						g_themed_icon_icon_iface_init)) | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | static void | 
					
						
							|  |  |  |  | g_themed_icon_get_property (GObject    *object, | 
					
						
							|  |  |  |  |                             guint       prop_id, | 
					
						
							|  |  |  |  |                             GValue     *value, | 
					
						
							|  |  |  |  |                             GParamSpec *pspec) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GThemedIcon *icon = G_THEMED_ICON (object); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   switch (prop_id) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |       case PROP_NAMES: | 
					
						
							|  |  |  |  |         g_value_set_boxed (value, icon->names); | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-06 19:43:31 +00:00
										 |  |  |  |       case PROP_USE_DEFAULT_FALLBACKS: | 
					
						
							|  |  |  |  |         g_value_set_boolean (value, icon->use_default_fallbacks); | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |       default: | 
					
						
							|  |  |  |  |         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | static void | 
					
						
							|  |  |  |  | g_themed_icon_set_property (GObject      *object, | 
					
						
							|  |  |  |  |                             guint         prop_id, | 
					
						
							|  |  |  |  |                             const GValue *value, | 
					
						
							|  |  |  |  |                             GParamSpec   *pspec) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GThemedIcon *icon = G_THEMED_ICON (object); | 
					
						
							| 
									
										
										
										
											2008-03-11 00:14:11 +00:00
										 |  |  |  |   gchar **names; | 
					
						
							|  |  |  |  |   const gchar *name; | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   switch (prop_id) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |       case PROP_NAME: | 
					
						
							| 
									
										
										
										
											2008-03-11 00:14:11 +00:00
										 |  |  |  |         name = g_value_get_string (value); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!name) | 
					
						
							|  |  |  |  |           break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |         if (icon->names) | 
					
						
							|  |  |  |  |           g_strfreev (icon->names); | 
					
						
							| 
									
										
										
										
											2008-03-11 00:14:11 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |         icon->names = g_new (char *, 2); | 
					
						
							| 
									
										
										
										
											2008-03-11 00:14:11 +00:00
										 |  |  |  |         icon->names[0] = g_strdup (name); | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |         icon->names[1] = NULL; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       case PROP_NAMES: | 
					
						
							| 
									
										
										
										
											2008-03-11 00:14:11 +00:00
										 |  |  |  |         names = g_value_dup_boxed (value); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!names) | 
					
						
							|  |  |  |  |           break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |         if (icon->names) | 
					
						
							|  |  |  |  |           g_strfreev (icon->names); | 
					
						
							| 
									
										
										
										
											2008-03-11 00:14:11 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         icon->names = names; | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |         break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       case PROP_USE_DEFAULT_FALLBACKS: | 
					
						
							|  |  |  |  |         icon->use_default_fallbacks = g_value_get_boolean (value); | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       default: | 
					
						
							|  |  |  |  |         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | static void | 
					
						
							|  |  |  |  | g_themed_icon_constructed (GObject *object) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GThemedIcon *themed = G_THEMED_ICON (object); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   g_return_if_fail (themed->names != NULL && themed->names[0] != NULL); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (themed->use_default_fallbacks) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |       int i = 0, dashes = 0; | 
					
						
							|  |  |  |  |       const char *p; | 
					
						
							|  |  |  |  |       char *dashp; | 
					
						
							|  |  |  |  |       char *last; | 
					
						
							| 
									
										
										
										
											2013-08-13 15:16:48 +02:00
										 |  |  |  |       gboolean is_symbolic; | 
					
						
							|  |  |  |  |       char *name; | 
					
						
							|  |  |  |  |       char **names; | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-13 15:16:48 +02:00
										 |  |  |  |       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 = name; | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |       while (*p) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |           if (*p == '-') | 
					
						
							|  |  |  |  |             dashes++; | 
					
						
							|  |  |  |  |           p++; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-13 15:16:48 +02:00
										 |  |  |  |       last = name; | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |       g_strfreev (themed->names); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-13 15:16:48 +02:00
										 |  |  |  |       names = g_new (char *, dashes + 1 + 1); | 
					
						
							|  |  |  |  |       names[i++] = last; | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |       while ((dashp = strrchr (last, '-')) != NULL) | 
					
						
							| 
									
										
										
										
											2013-08-13 15:16:48 +02:00
										 |  |  |  |         names[i++] = last = g_strndup (last, dashp - last); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       names[i++] = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       if (is_symbolic) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2013-10-08 16:11:44 +02:00
										 |  |  |  |           themed->names = g_new (char *, 2 * dashes + 3); | 
					
						
							| 
									
										
										
										
											2013-08-13 15:16:48 +02:00
										 |  |  |  |           for (i = 0; names[i] != NULL; i++) | 
					
						
							| 
									
										
										
										
											2013-10-08 16:11:44 +02:00
										 |  |  |  |             { | 
					
						
							|  |  |  |  |               themed->names[i] = g_strconcat (names[i], "-symbolic", NULL); | 
					
						
							|  |  |  |  |               themed->names[dashes + 1 + i] = names[i]; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-08 16:11:44 +02:00
										 |  |  |  |           themed->names[dashes + 1 + i] = NULL; | 
					
						
							|  |  |  |  |           g_free (names); | 
					
						
							| 
									
										
										
										
											2013-08-13 15:16:48 +02:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |       else | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |           themed->names = names; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | static void | 
					
						
							|  |  |  |  | g_themed_icon_finalize (GObject *object) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GThemedIcon *themed; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   themed = G_THEMED_ICON (object); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   g_strfreev (themed->names); | 
					
						
							| 
									
										
										
										
											2008-06-16 09:54:04 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   G_OBJECT_CLASS (g_themed_icon_parent_class)->finalize (object); | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | static void | 
					
						
							|  |  |  |  | g_themed_icon_class_init (GThemedIconClass *klass) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | 
					
						
							|  |  |  |  |    | 
					
						
							|  |  |  |  |   gobject_class->finalize = g_themed_icon_finalize; | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |   gobject_class->constructed = g_themed_icon_constructed; | 
					
						
							|  |  |  |  |   gobject_class->set_property = g_themed_icon_set_property; | 
					
						
							|  |  |  |  |   gobject_class->get_property = g_themed_icon_get_property; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   /**
 | 
					
						
							|  |  |  |  |    * GThemedIcon:name: | 
					
						
							|  |  |  |  |    * | 
					
						
							|  |  |  |  |    * The icon name. | 
					
						
							|  |  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2008-03-11 00:14:11 +00:00
										 |  |  |  |   g_object_class_install_property (gobject_class, PROP_NAME, | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |                                    g_param_spec_string ("name", | 
					
						
							| 
									
										
										
										
											2009-04-22 15:12:37 +02:00
										 |  |  |  |                                                         P_("name"), | 
					
						
							|  |  |  |  |                                                         P_("The name of the icon"), | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |                                                         NULL, | 
					
						
							|  |  |  |  |                                                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NICK)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   /**
 | 
					
						
							|  |  |  |  |    * GThemedIcon:names: | 
					
						
							|  |  |  |  |    * | 
					
						
							|  |  |  |  |    * A %NULL-terminated array of icon names. | 
					
						
							|  |  |  |  |    */ | 
					
						
							|  |  |  |  |   g_object_class_install_property (gobject_class, PROP_NAMES, | 
					
						
							|  |  |  |  |                                    g_param_spec_boxed ("names", | 
					
						
							| 
									
										
										
										
											2009-04-22 15:12:37 +02:00
										 |  |  |  |                                                        P_("names"), | 
					
						
							|  |  |  |  |                                                        P_("An array containing the icon names"), | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |                                                        G_TYPE_STRV, | 
					
						
							|  |  |  |  |                                                        G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NICK)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   /**
 | 
					
						
							|  |  |  |  |    * GThemedIcon:use-default-fallbacks: | 
					
						
							|  |  |  |  |    * | 
					
						
							|  |  |  |  |    * Whether to use the default fallbacks found by shortening the icon name  | 
					
						
							|  |  |  |  |    * at '-' characters. If the "names" array has more than one element,  | 
					
						
							|  |  |  |  |    * ignores any past the first. | 
					
						
							|  |  |  |  |    * | 
					
						
							|  |  |  |  |    * For example, if the icon name was "gnome-dev-cdrom-audio", the array  | 
					
						
							|  |  |  |  |    * would become | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:49 -05:00
										 |  |  |  |    * |[<!-- language="C" --> | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |    * { | 
					
						
							|  |  |  |  |    *   "gnome-dev-cdrom-audio", | 
					
						
							|  |  |  |  |    *   "gnome-dev-cdrom", | 
					
						
							|  |  |  |  |    *   "gnome-dev", | 
					
						
							|  |  |  |  |    *   "gnome", | 
					
						
							|  |  |  |  |    *   NULL | 
					
						
							|  |  |  |  |    * }; | 
					
						
							|  |  |  |  |    * ]| | 
					
						
							|  |  |  |  |    */ | 
					
						
							|  |  |  |  |   g_object_class_install_property (gobject_class, PROP_USE_DEFAULT_FALLBACKS, | 
					
						
							|  |  |  |  |                                    g_param_spec_boolean ("use-default-fallbacks", | 
					
						
							| 
									
										
										
										
											2009-04-22 15:12:37 +02:00
										 |  |  |  |                                                          P_("use default fallbacks"), | 
					
						
							| 
									
										
										
										
											2016-09-30 05:47:15 +02:00
										 |  |  |  |                                                          P_("Whether to use default fallbacks found by shortening the name at “-” characters. Ignores names after the first if multiple names are given."), | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |                                                          FALSE, | 
					
						
							| 
									
										
										
										
											2008-08-06 19:43:31 +00:00
										 |  |  |  |                                                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NICK)); | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | static void | 
					
						
							|  |  |  |  | g_themed_icon_init (GThemedIcon *themed) | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |   themed->names = NULL; | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_themed_icon_new: | 
					
						
							| 
									
										
										
										
											2007-11-27 14:00:13 +00:00
										 |  |  |  |  * @iconname: a string containing an icon name. | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  |  *  | 
					
						
							| 
									
										
										
										
											2007-11-27 14:00:13 +00:00
										 |  |  |  |  * Creates a new themed icon for @iconname. | 
					
						
							|  |  |  |  |  *  | 
					
						
							| 
									
										
										
										
											2012-01-07 09:54:53 -08:00
										 |  |  |  |  * Returns: (transfer full) (type GThemedIcon): a new #GThemedIcon. | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  |  **/ | 
					
						
							|  |  |  |  | GIcon * | 
					
						
							|  |  |  |  | g_themed_icon_new (const char *iconname) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   g_return_val_if_fail (iconname != NULL, NULL); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |   return G_ICON (g_object_new (G_TYPE_THEMED_ICON, "name", iconname, NULL)); | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_themed_icon_new_from_names: | 
					
						
							| 
									
										
										
										
											2010-12-27 16:08:46 +01:00
										 |  |  |  |  * @iconnames: (array length=len): an array of strings containing icon names. | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |  * @len: the length of the @iconnames array, or -1 if @iconnames is  | 
					
						
							|  |  |  |  |  *     %NULL-terminated | 
					
						
							| 
									
										
										
										
											2007-11-27 14:00:13 +00:00
										 |  |  |  |  *  | 
					
						
							|  |  |  |  |  * Creates a new themed icon for @iconnames. | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  |  *  | 
					
						
							| 
									
										
										
										
											2012-01-07 09:54:53 -08:00
										 |  |  |  |  * Returns: (transfer full) (type GThemedIcon): a new #GThemedIcon | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  |  **/ | 
					
						
							|  |  |  |  | GIcon * | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | g_themed_icon_new_from_names (char **iconnames, | 
					
						
							| 
									
										
										
										
											2007-11-30 05:11:25 +00:00
										 |  |  |  |                               int    len) | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-07 03:14:15 -04:00
										 |  |  |  |   GIcon *icon; | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   g_return_val_if_fail (iconnames != NULL, NULL); | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (len >= 0) | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |       char **names; | 
					
						
							|  |  |  |  |       int i; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-11 00:14:11 +00:00
										 |  |  |  |       names = g_new (char *, len + 1); | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  |       for (i = 0; i < len; i++) | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |         names[i] = iconnames[i]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       names[i] = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       icon = G_ICON (g_object_new (G_TYPE_THEMED_ICON, "names", names, NULL)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       g_free (names); | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |   else | 
					
						
							|  |  |  |  |     icon = G_ICON (g_object_new (G_TYPE_THEMED_ICON, "names", iconnames, NULL)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   return icon; | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-21 03:49:20 +00:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_themed_icon_new_with_default_fallbacks: | 
					
						
							|  |  |  |  |  * @iconname: a string containing an icon name | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Creates a new themed icon for @iconname, and all the names | 
					
						
							|  |  |  |  |  * that can be created by shortening @iconname at '-' characters. | 
					
						
							|  |  |  |  |  *  | 
					
						
							|  |  |  |  |  * In the following example, @icon1 and @icon2 are equivalent: | 
					
						
							| 
									
										
										
										
											2014-02-01 15:11:49 -05:00
										 |  |  |  |  * |[<!-- language="C" --> | 
					
						
							| 
									
										
										
										
											2008-01-21 03:49:20 +00:00
										 |  |  |  |  * const char *names[] = {  | 
					
						
							|  |  |  |  |  *   "gnome-dev-cdrom-audio", | 
					
						
							|  |  |  |  |  *   "gnome-dev-cdrom", | 
					
						
							|  |  |  |  |  *   "gnome-dev", | 
					
						
							|  |  |  |  |  *   "gnome" | 
					
						
							|  |  |  |  |  * }; | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * icon1 = g_themed_icon_new_from_names (names, 4); | 
					
						
							|  |  |  |  |  * icon2 = g_themed_icon_new_with_default_fallbacks ("gnome-dev-cdrom-audio"); | 
					
						
							|  |  |  |  |  * ]| | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-01-07 09:54:53 -08:00
										 |  |  |  |  * Returns: (transfer full) (type GThemedIcon): a new #GThemedIcon. | 
					
						
							| 
									
										
										
										
											2008-01-21 03:49:20 +00:00
										 |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-01-09 15:20:49 +00:00
										 |  |  |  | GIcon * | 
					
						
							|  |  |  |  | g_themed_icon_new_with_default_fallbacks (const char *iconname) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   g_return_val_if_fail (iconname != NULL, NULL); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |   return G_ICON (g_object_new (G_TYPE_THEMED_ICON, "name", iconname, "use-default-fallbacks", TRUE, NULL)); | 
					
						
							| 
									
										
										
										
											2008-01-09 15:20:49 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_themed_icon_get_names: | 
					
						
							| 
									
										
										
										
											2007-11-27 14:00:13 +00:00
										 |  |  |  |  * @icon: a #GThemedIcon. | 
					
						
							| 
									
										
										
										
											2009-05-18 13:02:11 +02:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2007-11-27 14:00:13 +00:00
										 |  |  |  |  * Gets the names of icons from within @icon. | 
					
						
							| 
									
										
										
										
											2009-05-18 13:02:11 +02:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-10-12 12:54:36 -04:00
										 |  |  |  |  * Returns: (transfer none): a list of icon names. | 
					
						
							| 
									
										
										
										
											2009-05-18 13:02:11 +02:00
										 |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | const char * const * | 
					
						
							|  |  |  |  | g_themed_icon_get_names (GThemedIcon *icon) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   g_return_val_if_fail (G_IS_THEMED_ICON (icon), NULL); | 
					
						
							|  |  |  |  |   return (const char * const *)icon->names; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Implement this function by moving bits from glocalfileinfo.c
2008-02-21  David Zeuthen  <davidz@redhat.com>
	* glocalfileinfo.c: (_g_local_file_info_get):
	* gcontenttype.c:
	(g_content_type_get_icon): Implement this function by
	moving bits from glocalfileinfo.c
	(g_content_type_get_description): Unalias before getting
	description (#517687)
	* gfile.c: (g_file_class_init),
	(g_file_query_filesystem_info_async),
	(g_file_query_filesystem_info_finish),
	(query_filesystem_info_data_free),
	(query_filesystem_info_async_thread),
	(g_file_real_query_filesystem_info_async),
	(g_file_real_query_filesystem_info_finish):
	* gfile.h: Implement async version of
	g_file_query_filesystem_info()
	* gfileinfo.h: Add new attributes for filesystem::use-preview
	* gio.symbols: Update
	* gthemedicon.c: (g_themed_icon_append_name):
	* gthemedicon.h: Add new new convenience function.
	* gunionvolumemonitor.c: (g_union_volume_monitor_dispose),
	(get_mounts), (get_volumes), (get_connected_drives),
	(get_volume_for_uuid), (get_mount_for_uuid),
	(g_union_volume_monitor_init), (populate_union_monitor),
	(g_volume_monitor_get), (_g_mount_get_for_mount_path),
	(g_volume_monitor_adopt_orphan_mount):
	* gvolumemonitor.c:
	* gvolumemonitor.h: Use recursive locks so it's safe for volume
	monitor implementations to call into the main volume monitor. Also
	separate object initialization and volume monitor initialization
	such that non-native volume monitors can properly adopt their
	mounts away.
svn path=/trunk/; revision=6550
											
										 
											2008-02-21 12:35:05 +00:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_themed_icon_append_name: | 
					
						
							|  |  |  |  |  * @icon: a #GThemedIcon | 
					
						
							|  |  |  |  |  * @iconname: name of icon to append to list of icons from within @icon. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Append a name to the list of icons from within @icon. | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * Note that doing so invalidates the hash computed by prior calls | 
					
						
							|  |  |  |  |  * to g_icon_hash(). | 
					
						
							| 
									
										
											  
											
												Implement this function by moving bits from glocalfileinfo.c
2008-02-21  David Zeuthen  <davidz@redhat.com>
	* glocalfileinfo.c: (_g_local_file_info_get):
	* gcontenttype.c:
	(g_content_type_get_icon): Implement this function by
	moving bits from glocalfileinfo.c
	(g_content_type_get_description): Unalias before getting
	description (#517687)
	* gfile.c: (g_file_class_init),
	(g_file_query_filesystem_info_async),
	(g_file_query_filesystem_info_finish),
	(query_filesystem_info_data_free),
	(query_filesystem_info_async_thread),
	(g_file_real_query_filesystem_info_async),
	(g_file_real_query_filesystem_info_finish):
	* gfile.h: Implement async version of
	g_file_query_filesystem_info()
	* gfileinfo.h: Add new attributes for filesystem::use-preview
	* gio.symbols: Update
	* gthemedicon.c: (g_themed_icon_append_name):
	* gthemedicon.h: Add new new convenience function.
	* gunionvolumemonitor.c: (g_union_volume_monitor_dispose),
	(get_mounts), (get_volumes), (get_connected_drives),
	(get_volume_for_uuid), (get_mount_for_uuid),
	(g_union_volume_monitor_init), (populate_union_monitor),
	(g_volume_monitor_get), (_g_mount_get_for_mount_path),
	(g_volume_monitor_adopt_orphan_mount):
	* gvolumemonitor.c:
	* gvolumemonitor.h: Use recursive locks so it's safe for volume
	monitor implementations to call into the main volume monitor. Also
	separate object initialization and volume monitor initialization
	such that non-native volume monitors can properly adopt their
	mounts away.
svn path=/trunk/; revision=6550
											
										 
											2008-02-21 12:35:05 +00:00
										 |  |  |  |  */ | 
					
						
							|  |  |  |  | void | 
					
						
							| 
									
										
										
										
											2008-06-10 16:45:54 +00:00
										 |  |  |  | g_themed_icon_append_name (GThemedIcon *icon,  | 
					
						
							|  |  |  |  |                            const char  *iconname) | 
					
						
							| 
									
										
											  
											
												Implement this function by moving bits from glocalfileinfo.c
2008-02-21  David Zeuthen  <davidz@redhat.com>
	* glocalfileinfo.c: (_g_local_file_info_get):
	* gcontenttype.c:
	(g_content_type_get_icon): Implement this function by
	moving bits from glocalfileinfo.c
	(g_content_type_get_description): Unalias before getting
	description (#517687)
	* gfile.c: (g_file_class_init),
	(g_file_query_filesystem_info_async),
	(g_file_query_filesystem_info_finish),
	(query_filesystem_info_data_free),
	(query_filesystem_info_async_thread),
	(g_file_real_query_filesystem_info_async),
	(g_file_real_query_filesystem_info_finish):
	* gfile.h: Implement async version of
	g_file_query_filesystem_info()
	* gfileinfo.h: Add new attributes for filesystem::use-preview
	* gio.symbols: Update
	* gthemedicon.c: (g_themed_icon_append_name):
	* gthemedicon.h: Add new new convenience function.
	* gunionvolumemonitor.c: (g_union_volume_monitor_dispose),
	(get_mounts), (get_volumes), (get_connected_drives),
	(get_volume_for_uuid), (get_mount_for_uuid),
	(g_union_volume_monitor_init), (populate_union_monitor),
	(g_volume_monitor_get), (_g_mount_get_for_mount_path),
	(g_volume_monitor_adopt_orphan_mount):
	* gvolumemonitor.c:
	* gvolumemonitor.h: Use recursive locks so it's safe for volume
	monitor implementations to call into the main volume monitor. Also
	separate object initialization and volume monitor initialization
	such that non-native volume monitors can properly adopt their
	mounts away.
svn path=/trunk/; revision=6550
											
										 
											2008-02-21 12:35:05 +00:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |   guint num_names; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   g_return_if_fail (G_IS_THEMED_ICON (icon)); | 
					
						
							|  |  |  |  |   g_return_if_fail (iconname != NULL); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   num_names = g_strv_length (icon->names); | 
					
						
							|  |  |  |  |   icon->names = g_realloc (icon->names, sizeof (char*) * (num_names + 2)); | 
					
						
							|  |  |  |  |   icon->names[num_names] = g_strdup (iconname); | 
					
						
							|  |  |  |  |   icon->names[num_names + 1] = NULL; | 
					
						
							| 
									
										
										
										
											2008-03-10 16:08:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   g_object_notify (G_OBJECT (icon), "names"); | 
					
						
							| 
									
										
											  
											
												Implement this function by moving bits from glocalfileinfo.c
2008-02-21  David Zeuthen  <davidz@redhat.com>
	* glocalfileinfo.c: (_g_local_file_info_get):
	* gcontenttype.c:
	(g_content_type_get_icon): Implement this function by
	moving bits from glocalfileinfo.c
	(g_content_type_get_description): Unalias before getting
	description (#517687)
	* gfile.c: (g_file_class_init),
	(g_file_query_filesystem_info_async),
	(g_file_query_filesystem_info_finish),
	(query_filesystem_info_data_free),
	(query_filesystem_info_async_thread),
	(g_file_real_query_filesystem_info_async),
	(g_file_real_query_filesystem_info_finish):
	* gfile.h: Implement async version of
	g_file_query_filesystem_info()
	* gfileinfo.h: Add new attributes for filesystem::use-preview
	* gio.symbols: Update
	* gthemedicon.c: (g_themed_icon_append_name):
	* gthemedicon.h: Add new new convenience function.
	* gunionvolumemonitor.c: (g_union_volume_monitor_dispose),
	(get_mounts), (get_volumes), (get_connected_drives),
	(get_volume_for_uuid), (get_mount_for_uuid),
	(g_union_volume_monitor_init), (populate_union_monitor),
	(g_volume_monitor_get), (_g_mount_get_for_mount_path),
	(g_volume_monitor_adopt_orphan_mount):
	* gvolumemonitor.c:
	* gvolumemonitor.h: Use recursive locks so it's safe for volume
	monitor implementations to call into the main volume monitor. Also
	separate object initialization and volume monitor initialization
	such that non-native volume monitors can properly adopt their
	mounts away.
svn path=/trunk/; revision=6550
											
										 
											2008-02-21 12:35:05 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-10 16:45:54 +00:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * 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"); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | static guint | 
					
						
							|  |  |  |  | g_themed_icon_hash (GIcon *icon) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GThemedIcon *themed = G_THEMED_ICON (icon); | 
					
						
							|  |  |  |  |   guint hash; | 
					
						
							|  |  |  |  |   int i; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   hash = 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   for (i = 0; themed->names[i] != NULL; i++) | 
					
						
							|  |  |  |  |     hash ^= g_str_hash (themed->names[i]); | 
					
						
							|  |  |  |  |    | 
					
						
							|  |  |  |  |   return hash; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | static gboolean | 
					
						
							|  |  |  |  | g_themed_icon_equal (GIcon *icon1, | 
					
						
							| 
									
										
										
										
											2007-11-30 05:11:25 +00:00
										 |  |  |  |                      GIcon *icon2) | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |   GThemedIcon *themed1 = G_THEMED_ICON (icon1); | 
					
						
							|  |  |  |  |   GThemedIcon *themed2 = G_THEMED_ICON (icon2); | 
					
						
							|  |  |  |  |   int i; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   for (i = 0; themed1->names[i] != NULL && themed2->names[i] != NULL; i++) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |       if (!g_str_equal (themed1->names[i], themed2->names[i])) | 
					
						
							|  |  |  |  | 	return FALSE; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   return themed1->names[i] == NULL && themed2->names[i] == NULL; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-21 11:51:48 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | static gboolean | 
					
						
							|  |  |  |  | g_themed_icon_to_tokens (GIcon *icon, | 
					
						
							|  |  |  |  | 			 GPtrArray *tokens, | 
					
						
							|  |  |  |  |                          gint  *out_version) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GThemedIcon *themed_icon = G_THEMED_ICON (icon); | 
					
						
							|  |  |  |  |   int n; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   g_return_val_if_fail (out_version != NULL, FALSE); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   *out_version = 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   for (n = 0; themed_icon->names[n] != NULL; n++) | 
					
						
							|  |  |  |  |     g_ptr_array_add (tokens, | 
					
						
							|  |  |  |  | 		     g_strdup (themed_icon->names[n])); | 
					
						
							|  |  |  |  |    | 
					
						
							|  |  |  |  |   return TRUE; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | static GIcon * | 
					
						
							|  |  |  |  | g_themed_icon_from_tokens (gchar  **tokens, | 
					
						
							|  |  |  |  |                            gint     num_tokens, | 
					
						
							|  |  |  |  |                            gint     version, | 
					
						
							|  |  |  |  |                            GError **error) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   GIcon *icon; | 
					
						
							|  |  |  |  |   gchar **names; | 
					
						
							|  |  |  |  |   int n; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-17 16:57:10 -04:00
										 |  |  |  |   icon = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (version != 0) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |       g_set_error (error, | 
					
						
							|  |  |  |  |                    G_IO_ERROR, | 
					
						
							|  |  |  |  |                    G_IO_ERROR_INVALID_ARGUMENT, | 
					
						
							| 
									
										
										
										
											2016-09-30 05:47:15 +02:00
										 |  |  |  |                    _("Can’t handle version %d of GThemedIcon encoding"), | 
					
						
							| 
									
										
										
										
											2013-10-17 16:57:10 -04:00
										 |  |  |  |                    version); | 
					
						
							|  |  |  |  |       goto out; | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-10-21 11:51:48 +00:00
										 |  |  |  |    | 
					
						
							|  |  |  |  |   names = g_new0 (gchar *, num_tokens + 1); | 
					
						
							|  |  |  |  |   for (n = 0; n < num_tokens; n++) | 
					
						
							|  |  |  |  |     names[n] = tokens[n]; | 
					
						
							|  |  |  |  |   names[n] = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   icon = g_themed_icon_new_from_names (names, num_tokens); | 
					
						
							|  |  |  |  |   g_free (names); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-17 16:57:10 -04:00
										 |  |  |  |  out: | 
					
						
							| 
									
										
										
										
											2008-10-21 11:51:48 +00:00
										 |  |  |  |   return icon; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-20 18:50:21 -04:00
										 |  |  |  | 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)); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | static void | 
					
						
							|  |  |  |  | g_themed_icon_icon_iface_init (GIconIface *iface) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   iface->hash = g_themed_icon_hash; | 
					
						
							|  |  |  |  |   iface->equal = g_themed_icon_equal; | 
					
						
							| 
									
										
										
										
											2008-10-21 11:51:48 +00:00
										 |  |  |  |   iface->to_tokens = g_themed_icon_to_tokens; | 
					
						
							|  |  |  |  |   iface->from_tokens = g_themed_icon_from_tokens; | 
					
						
							| 
									
										
										
										
											2013-04-20 18:50:21 -04:00
										 |  |  |  |   iface->serialize = g_themed_icon_serialize; | 
					
						
							| 
									
										
										
										
											2007-11-26 16:13:05 +00:00
										 |  |  |  | } |