Blame plugins/gtk+/glade-gtk-icon-factory.c

Packit 1e8aac
/*
Packit 1e8aac
 * glade-gtk-icon-factory.c - GladeWidgetAdaptor for GtkIconFactory
Packit 1e8aac
 *
Packit 1e8aac
 * Copyright (C) 2013 Tristan Van Berkom
Packit 1e8aac
 *
Packit 1e8aac
 * Authors:
Packit 1e8aac
 *      Tristan Van Berkom <tristan.van.berkom@gmail.com>
Packit 1e8aac
 *
Packit 1e8aac
 * This library is free software; you can redistribute it and/or modify it
Packit 1e8aac
 * under the terms of the GNU Lesser General Public License as
Packit 1e8aac
 * published by the Free Software Foundation; either version 2.1 of
Packit 1e8aac
 * the License, or (at your option) any later version.
Packit 1e8aac
 *
Packit 1e8aac
 * This library is distributed in the hope that it will be useful, but
Packit 1e8aac
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1e8aac
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 1e8aac
 * Lesser General Public License for more details.
Packit 1e8aac
 *
Packit 1e8aac
 * You should have received a copy of the GNU Lesser General Public 
Packit 1e8aac
 * License along with this program; if not, write to the Free Software
Packit 1e8aac
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 1e8aac
 */
Packit 1e8aac
Packit 1e8aac
#include <config.h>
Packit 1e8aac
#include <glib/gi18n-lib.h>
Packit 1e8aac
#include <gladeui/glade.h>
Packit 1e8aac
Packit 1e8aac
#include "glade-icon-sources.h"
Packit 1e8aac
#include "glade-icon-factory-editor.h"
Packit 1e8aac
Packit 1e8aac
#define GLADE_TAG_SOURCES   "sources"
Packit 1e8aac
#define GLADE_TAG_SOURCE    "source"
Packit 1e8aac
Packit 1e8aac
#define GLADE_TAG_STOCK_ID  "stock-id"
Packit 1e8aac
#define GLADE_TAG_FILENAME  "filename"
Packit 1e8aac
#define GLADE_TAG_DIRECTION "direction"
Packit 1e8aac
#define GLADE_TAG_STATE     "state"
Packit 1e8aac
#define GLADE_TAG_SIZE      "size"
Packit 1e8aac
Packit 1e8aac
void
Packit 1e8aac
glade_gtk_icon_factory_post_create (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                    GObject * object, GladeCreateReason reason)
Packit 1e8aac
{
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
  gtk_icon_factory_add_default (GTK_ICON_FACTORY (object));
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
void
Packit 1e8aac
glade_gtk_icon_factory_destroy_object (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
				       GObject *object)
Packit 1e8aac
{
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
  gtk_icon_factory_remove_default (GTK_ICON_FACTORY (object));
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
Packit 1e8aac
  GWA_GET_CLASS (G_TYPE_OBJECT)->destroy_object (adaptor, object);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
glade_gtk_icon_factory_read_sources (GladeWidget * widget, GladeXmlNode * node)
Packit 1e8aac
{
Packit 1e8aac
  GladeIconSources *sources;
Packit 1e8aac
  GtkIconSource *source;
Packit 1e8aac
  GladeXmlNode *sources_node, *source_node;
Packit 1e8aac
  GValue *value;
Packit 1e8aac
  GList *list;
Packit 1e8aac
  gchar *current_icon_name = NULL;
Packit 1e8aac
  GdkPixbuf *pixbuf;
Packit 1e8aac
Packit 1e8aac
  if ((sources_node = glade_xml_search_child (node, GLADE_TAG_SOURCES)) == NULL)
Packit 1e8aac
    return;
Packit 1e8aac
Packit 1e8aac
  sources = glade_icon_sources_new ();
Packit 1e8aac
Packit 1e8aac
  /* Here we expect all icon sets to remain together in the list. */
Packit 1e8aac
  for (source_node = glade_xml_node_get_children (sources_node); source_node;
Packit 1e8aac
       source_node = glade_xml_node_next (source_node))
Packit 1e8aac
    {
Packit 1e8aac
      gchar *icon_name;
Packit 1e8aac
      gchar *str;
Packit 1e8aac
Packit 1e8aac
      if (!glade_xml_node_verify (source_node, GLADE_TAG_SOURCE))
Packit 1e8aac
        continue;
Packit 1e8aac
Packit 1e8aac
      if (!(icon_name =
Packit 1e8aac
            glade_xml_get_property_string_required (source_node,
Packit 1e8aac
                                                    GLADE_TAG_STOCK_ID, NULL)))
Packit 1e8aac
        continue;
Packit 1e8aac
Packit 1e8aac
      if (!
Packit 1e8aac
          (str =
Packit 1e8aac
           glade_xml_get_property_string_required (source_node,
Packit 1e8aac
                                                   GLADE_TAG_FILENAME, NULL)))
Packit 1e8aac
        {
Packit 1e8aac
          g_free (icon_name);
Packit 1e8aac
          continue;
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
      if (!current_icon_name || strcmp (current_icon_name, icon_name) != 0)
Packit 1e8aac
        current_icon_name = (g_free (current_icon_name), g_strdup (icon_name));
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      source = gtk_icon_source_new ();
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
Packit 1e8aac
      /* Deal with the filename... */
Packit 1e8aac
      value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, str, glade_widget_get_project (widget));
Packit 1e8aac
      pixbuf = g_value_dup_object (value);
Packit 1e8aac
      g_value_unset (value);
Packit 1e8aac
      g_free (value);
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      gtk_icon_source_set_pixbuf (source, pixbuf);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
      g_object_unref (G_OBJECT (pixbuf));
Packit 1e8aac
      g_free (str);
Packit 1e8aac
Packit 1e8aac
      /* Now the attributes... */
Packit 1e8aac
      if ((str =
Packit 1e8aac
           glade_xml_get_property_string (source_node,
Packit 1e8aac
                                          GLADE_TAG_DIRECTION)) != NULL)
Packit 1e8aac
        {
Packit 1e8aac
          GtkTextDirection direction =
Packit 1e8aac
              glade_utils_enum_value_from_string (GTK_TYPE_TEXT_DIRECTION, str);
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
          gtk_icon_source_set_direction_wildcarded (source, FALSE);
Packit 1e8aac
          gtk_icon_source_set_direction (source, direction);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          g_free (str);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
      if ((str =
Packit 1e8aac
           glade_xml_get_property_string (source_node, GLADE_TAG_SIZE)) != NULL)
Packit 1e8aac
        {
Packit 1e8aac
          GtkIconSize size =
Packit 1e8aac
              glade_utils_enum_value_from_string (GTK_TYPE_ICON_SIZE, str);
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
          gtk_icon_source_set_size_wildcarded (source, FALSE);
Packit 1e8aac
          gtk_icon_source_set_size (source, size);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          g_free (str);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
      if ((str =
Packit 1e8aac
           glade_xml_get_property_string (source_node,
Packit 1e8aac
                                          GLADE_TAG_STATE)) != NULL)
Packit 1e8aac
        {
Packit 1e8aac
          GtkStateType state =
Packit 1e8aac
              glade_utils_enum_value_from_string (GTK_TYPE_STATE_TYPE, str);
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
          gtk_icon_source_set_state_wildcarded (source, FALSE);
Packit 1e8aac
          gtk_icon_source_set_state (source, state);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          g_free (str);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
      if ((list =
Packit 1e8aac
           g_hash_table_lookup (sources->sources,
Packit 1e8aac
                                g_strdup (current_icon_name))) != NULL)
Packit 1e8aac
        {
Packit 1e8aac
          GList *new_list = g_list_append (list, source);
Packit 1e8aac
Packit 1e8aac
          /* Warning: if we use g_list_prepend() the returned pointer will be different
Packit 1e8aac
           * so we would have to replace the list pointer in the hash table.
Packit 1e8aac
           * But before doing that we have to steal the old list pointer otherwise
Packit 1e8aac
           * we would have to make a copy then add the new icon to finally replace the hash table
Packit 1e8aac
           * value.
Packit 1e8aac
           * Anyways if we choose to prepend we would have to reverse the list outside this loop
Packit 1e8aac
           * so its better to append.
Packit 1e8aac
           */
Packit 1e8aac
          if (new_list != list)
Packit 1e8aac
            {
Packit 1e8aac
              /* current g_list_append() returns the same pointer so this is not needed */
Packit 1e8aac
              g_hash_table_steal (sources->sources, current_icon_name);
Packit 1e8aac
              g_hash_table_insert (sources->sources,
Packit 1e8aac
                                   g_strdup (current_icon_name), new_list);
Packit 1e8aac
            }
Packit 1e8aac
        }
Packit 1e8aac
      else
Packit 1e8aac
        {
Packit 1e8aac
          list = g_list_append (NULL, source);
Packit 1e8aac
          g_hash_table_insert (sources->sources, g_strdup (current_icon_name),
Packit 1e8aac
                               list);
Packit 1e8aac
        }
Packit 1e8aac
    }
Packit 1e8aac
Packit 1e8aac
  if (g_hash_table_size (sources->sources) > 0)
Packit 1e8aac
    glade_widget_property_set (widget, "sources", sources);
Packit 1e8aac
Packit 1e8aac
  glade_icon_sources_free (sources);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
void
Packit 1e8aac
glade_gtk_icon_factory_read_widget (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                    GladeWidget * widget, GladeXmlNode * node)
Packit 1e8aac
{
Packit 1e8aac
  if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||
Packit 1e8aac
	glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))
Packit 1e8aac
    return;
Packit 1e8aac
Packit 1e8aac
  /* First chain up and read in any normal properties.. */
Packit 1e8aac
  GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
Packit 1e8aac
Packit 1e8aac
  glade_gtk_icon_factory_read_sources (widget, node);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
typedef struct
Packit 1e8aac
{
Packit 1e8aac
  GladeXmlContext *context;
Packit 1e8aac
  GladeXmlNode *node;
Packit 1e8aac
} SourceWriteTab;
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
write_icon_sources (gchar * icon_name, GList * sources, SourceWriteTab * tab)
Packit 1e8aac
{
Packit 1e8aac
  GladeXmlNode *source_node;
Packit 1e8aac
  GtkIconSource *source;
Packit 1e8aac
  GList *l;
Packit 1e8aac
  gchar *string;
Packit 1e8aac
Packit 1e8aac
  GdkPixbuf *pixbuf;
Packit 1e8aac
Packit 1e8aac
  for (l = sources; l; l = l->next)
Packit 1e8aac
    {
Packit 1e8aac
      source = l->data;
Packit 1e8aac
Packit 1e8aac
      source_node = glade_xml_node_new (tab->context, GLADE_TAG_SOURCE);
Packit 1e8aac
      glade_xml_node_append_child (tab->node, source_node);
Packit 1e8aac
Packit 1e8aac
      glade_xml_node_set_property_string (source_node, GLADE_TAG_STOCK_ID,
Packit 1e8aac
                                          icon_name);
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      if (!gtk_icon_source_get_direction_wildcarded (source))
Packit 1e8aac
        {
Packit 1e8aac
          GtkTextDirection direction = gtk_icon_source_get_direction (source);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          string =
Packit 1e8aac
              glade_utils_enum_string_from_value (GTK_TYPE_TEXT_DIRECTION,
Packit 1e8aac
                                                  direction);
Packit 1e8aac
          glade_xml_node_set_property_string (source_node, GLADE_TAG_DIRECTION,
Packit 1e8aac
                                              string);
Packit 1e8aac
          g_free (string);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      if (!gtk_icon_source_get_size_wildcarded (source))
Packit 1e8aac
        {
Packit 1e8aac
          GtkIconSize size = gtk_icon_source_get_size (source);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          string =
Packit 1e8aac
              glade_utils_enum_string_from_value (GTK_TYPE_ICON_SIZE, size);
Packit 1e8aac
          glade_xml_node_set_property_string (source_node, GLADE_TAG_SIZE,
Packit 1e8aac
                                              string);
Packit 1e8aac
          g_free (string);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      if (!gtk_icon_source_get_state_wildcarded (source))
Packit 1e8aac
        {
Packit 1e8aac
          GtkStateType state = gtk_icon_source_get_state (source);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          string =
Packit 1e8aac
              glade_utils_enum_string_from_value (GTK_TYPE_STATE_TYPE, state);
Packit 1e8aac
          glade_xml_node_set_property_string (source_node, GLADE_TAG_STATE,
Packit 1e8aac
                                              string);
Packit 1e8aac
          g_free (string);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      pixbuf = gtk_icon_source_get_pixbuf (source);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
      string = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName");
Packit 1e8aac
Packit 1e8aac
      glade_xml_node_set_property_string (source_node,
Packit 1e8aac
                                          GLADE_TAG_FILENAME, string);
Packit 1e8aac
    }
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
glade_gtk_icon_factory_write_sources (GladeWidget * widget,
Packit 1e8aac
                                      GladeXmlContext * context,
Packit 1e8aac
                                      GladeXmlNode * node)
Packit 1e8aac
{
Packit 1e8aac
  GladeXmlNode *sources_node;
Packit 1e8aac
  GladeIconSources *sources = NULL;
Packit 1e8aac
  SourceWriteTab tab;
Packit 1e8aac
Packit 1e8aac
  glade_widget_property_get (widget, "sources", &sources);
Packit 1e8aac
  if (!sources)
Packit 1e8aac
    return;
Packit 1e8aac
Packit 1e8aac
  sources_node = glade_xml_node_new (context, GLADE_TAG_SOURCES);
Packit 1e8aac
Packit 1e8aac
  tab.context = context;
Packit 1e8aac
  tab.node = sources_node;
Packit 1e8aac
  g_hash_table_foreach (sources->sources, (GHFunc) write_icon_sources, &tab;;
Packit 1e8aac
Packit 1e8aac
  if (!glade_xml_node_get_children (sources_node))
Packit 1e8aac
    glade_xml_node_delete (sources_node);
Packit 1e8aac
  else
Packit 1e8aac
    glade_xml_node_append_child (node, sources_node);
Packit 1e8aac
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
Packit 1e8aac
void
Packit 1e8aac
glade_gtk_icon_factory_write_widget (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                     GladeWidget * widget,
Packit 1e8aac
                                     GladeXmlContext * context,
Packit 1e8aac
                                     GladeXmlNode * node)
Packit 1e8aac
{
Packit 1e8aac
  if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||
Packit 1e8aac
	glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))
Packit 1e8aac
    return;
Packit 1e8aac
Packit 1e8aac
  /* First chain up and write all the normal properties.. */
Packit 1e8aac
  GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
Packit 1e8aac
Packit 1e8aac
  glade_gtk_icon_factory_write_sources (widget, context, node);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
apply_icon_sources (gchar * icon_name,
Packit 1e8aac
                    GList * sources, GtkIconFactory * factory)
Packit 1e8aac
{
Packit 1e8aac
  GtkIconSource *source;
Packit 1e8aac
  GtkIconSet *set;
Packit 1e8aac
  GList *l;
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
  set = gtk_icon_set_new ();
Packit 1e8aac
Packit 1e8aac
  for (l = sources; l; l = l->next)
Packit 1e8aac
    {
Packit 1e8aac
      source = gtk_icon_source_copy ((GtkIconSource *) l->data);
Packit 1e8aac
      gtk_icon_set_add_source (set, source);
Packit 1e8aac
    }
Packit 1e8aac
Packit 1e8aac
  gtk_icon_factory_add (factory, icon_name, set);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
glade_gtk_icon_factory_set_sources (GObject * object, const GValue * value)
Packit 1e8aac
{
Packit 1e8aac
  GladeIconSources *sources = g_value_get_boxed (value);
Packit 1e8aac
  if (sources)
Packit 1e8aac
    g_hash_table_foreach (sources->sources, (GHFunc) apply_icon_sources,
Packit 1e8aac
                          object);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
Packit 1e8aac
void
Packit 1e8aac
glade_gtk_icon_factory_set_property (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                     GObject * object,
Packit 1e8aac
                                     const gchar * property_name,
Packit 1e8aac
                                     const GValue * value)
Packit 1e8aac
{
Packit 1e8aac
  if (strcmp (property_name, "sources") == 0)
Packit 1e8aac
    {
Packit 1e8aac
      glade_gtk_icon_factory_set_sources (object, value);
Packit 1e8aac
    }
Packit 1e8aac
  else
Packit 1e8aac
    /* Chain Up */
Packit 1e8aac
    GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor,
Packit 1e8aac
                                                 object, property_name, value);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
serialize_icon_sources (gchar * icon_name, GList * sources, GString * string)
Packit 1e8aac
{
Packit 1e8aac
  GList *l;
Packit 1e8aac
Packit 1e8aac
  for (l = sources; l; l = g_list_next (l))
Packit 1e8aac
    {
Packit 1e8aac
      GtkIconSource *source = l->data;
Packit 1e8aac
      GdkPixbuf *pixbuf;
Packit 1e8aac
      gchar *str;
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      pixbuf = gtk_icon_source_get_pixbuf (source);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
      str = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName");
Packit 1e8aac
Packit 1e8aac
      g_string_append_printf (string, "%s[%s] ", icon_name, str);
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      if (!gtk_icon_source_get_direction_wildcarded (source))
Packit 1e8aac
        {
Packit 1e8aac
          GtkTextDirection direction = gtk_icon_source_get_direction (source);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          str =
Packit 1e8aac
              glade_utils_enum_string_from_value (GTK_TYPE_TEXT_DIRECTION,
Packit 1e8aac
                                                  direction);
Packit 1e8aac
          g_string_append_printf (string, "dir-%s ", str);
Packit 1e8aac
          g_free (str);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      if (!gtk_icon_source_get_size_wildcarded (source))
Packit 1e8aac
        {
Packit 1e8aac
          GtkIconSize size = gtk_icon_source_get_size (source);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          str = glade_utils_enum_string_from_value (GTK_TYPE_ICON_SIZE, size);
Packit 1e8aac
          g_string_append_printf (string, "size-%s ", str);
Packit 1e8aac
          g_free (str);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      if (!gtk_icon_source_get_state_wildcarded (source))
Packit 1e8aac
        {
Packit 1e8aac
          GtkStateType state = gtk_icon_source_get_state (source);
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
          str = glade_utils_enum_string_from_value (GTK_TYPE_STATE_TYPE, state);
Packit 1e8aac
          g_string_append_printf (string, "state-%s ", str);
Packit 1e8aac
          g_free (str);
Packit 1e8aac
        }
Packit 1e8aac
Packit 1e8aac
      g_string_append_printf (string, "| ");
Packit 1e8aac
    }
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
gchar *
Packit 1e8aac
glade_gtk_icon_factory_string_from_value (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                          GladePropertyClass * klass,
Packit 1e8aac
                                          const GValue * value)
Packit 1e8aac
{
Packit 1e8aac
  GString *string;
Packit 1e8aac
  GParamSpec *pspec;
Packit 1e8aac
Packit 1e8aac
  pspec = glade_property_class_get_pspec (klass);
Packit 1e8aac
Packit 1e8aac
  if (pspec->value_type == GLADE_TYPE_ICON_SOURCES)
Packit 1e8aac
    {
Packit 1e8aac
      GladeIconSources *sources = g_value_get_boxed (value);
Packit 1e8aac
      if (!sources)
Packit 1e8aac
        return g_strdup ("");
Packit 1e8aac
Packit 1e8aac
      string = g_string_new ("");
Packit 1e8aac
      g_hash_table_foreach (sources->sources, (GHFunc) serialize_icon_sources,
Packit 1e8aac
                            string);
Packit 1e8aac
Packit 1e8aac
      return g_string_free (string, FALSE);
Packit 1e8aac
    }
Packit 1e8aac
  else
Packit 1e8aac
    return GWA_GET_CLASS
Packit 1e8aac
        (G_TYPE_OBJECT)->string_from_value (adaptor, klass, value);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
Packit 1e8aac
GladeEditorProperty *
Packit 1e8aac
glade_gtk_icon_factory_create_eprop (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                     GladePropertyClass * klass,
Packit 1e8aac
                                     gboolean use_command)
Packit 1e8aac
{
Packit 1e8aac
  GladeEditorProperty *eprop;
Packit 1e8aac
  GParamSpec          *pspec;
Packit 1e8aac
Packit 1e8aac
  pspec = glade_property_class_get_pspec (klass);
Packit 1e8aac
Packit 1e8aac
  if (pspec->value_type == GLADE_TYPE_ICON_SOURCES)
Packit 1e8aac
    eprop = g_object_new (GLADE_TYPE_EPROP_ICON_SOURCES,
Packit 1e8aac
                          "property-class", klass,
Packit 1e8aac
                          "use-command", use_command, NULL);
Packit 1e8aac
  else
Packit 1e8aac
    eprop = GWA_GET_CLASS
Packit 1e8aac
        (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
Packit 1e8aac
  return eprop;
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
GladeEditable *
Packit 1e8aac
glade_gtk_icon_factory_create_editable (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                        GladeEditorPageType type)
Packit 1e8aac
{
Packit 1e8aac
  GladeEditable *editable;
Packit 1e8aac
Packit 1e8aac
  /* Get base editable */
Packit 1e8aac
  editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
Packit 1e8aac
Packit 1e8aac
  if (type == GLADE_PAGE_GENERAL)
Packit 1e8aac
    return (GladeEditable *) glade_icon_factory_editor_new (adaptor, editable);
Packit 1e8aac
Packit 1e8aac
  return editable;
Packit 1e8aac
}