Ejemplo n.º 1
0
/* Shared with other classes */
void
glade_gtk_write_icon_size (GladeWidget     *widget,
                           GladeXmlContext *context,
                           GladeXmlNode    *node,
                           const gchar     *prop_name)
{
  GladeXmlNode *prop_node;
  GladeProperty *size_prop;
  GtkIconSize icon_size;
  gchar *value;

  /* We have to save icon-size as an integer, the core will take care of 
   * loading the int value though.
   */
  size_prop = glade_widget_get_property (widget, prop_name);
  if (glade_property_get_enabled (size_prop) &&
      !glade_property_original_default (size_prop))
    {
      gchar *write_prop_name = g_strdup (prop_name);

      glade_util_replace (write_prop_name, '-', '_');

      prop_node = glade_xml_node_new (context, GLADE_TAG_PROPERTY);
      glade_xml_node_append_child (node, prop_node);

      glade_xml_node_set_property_string (prop_node, GLADE_TAG_NAME, write_prop_name);

      glade_property_get (size_prop, &icon_size);
      value = g_strdup_printf ("%d", icon_size);
      glade_xml_set_content (prop_node, value);
      g_free (value);
      g_free (write_prop_name);
    }
}
Ejemplo n.º 2
0
static void
glade_gtk_filter_write_strings (GladeWidget     *widget,
				GladeXmlContext *context,
				GladeXmlNode    *node,
				FilterType       type,
				const gchar     *property_name)
{
  GladeXmlNode *item_node;
  GList        *string_list = NULL, *l;
  GladeString  *string;
  const gchar  *string_tag;

  switch (type)
    {
    case FILTER_PATTERN:     string_tag = GLADE_TAG_PATTERN;     break;
    case FILTER_MIME:        string_tag = GLADE_TAG_MIME_TYPE;   break;
    case FILTER_APPLICATION: string_tag = GLADE_TAG_APPLICATION; break;
    default:
      g_assert_not_reached ();
      break;
    }

  if (!glade_widget_property_get (widget, property_name, &string_list) || !string_list)
    return;

  for (l = string_list; l; l = l->next)
    {
      string = l->data;

      item_node = glade_xml_node_new (context, string_tag);
      glade_xml_node_append_child (node, item_node);

      glade_xml_set_content (item_node, string->string);
    }
}
Ejemplo n.º 3
0
static void
glade_gtk_combo_box_text_write_items (GladeWidget     *widget,
                                      GladeXmlContext *context,
                                      GladeXmlNode    *node)
{
  GladeXmlNode *item_node;
  GList *string_list = NULL, *l;
  GladeString *string;

  if (!glade_widget_property_get (widget, "glade-items", &string_list) || !string_list)
    return;

  for (l = string_list; l; l = l->next)
    {
      string = l->data;

      item_node = glade_xml_node_new (context, GLADE_TAG_ITEM);
      glade_xml_node_append_child (node, item_node);

      glade_xml_set_content (item_node, string->string);

      if (string->id)
        glade_xml_node_set_property_string (item_node,
                                            GLADE_TAG_ID,
                                            string->id);

      if (string->translatable)
        glade_xml_node_set_property_string (item_node,
                                            GLADE_TAG_TRANSLATABLE,
                                            GLADE_XML_TAG_I18N_TRUE);

      if (string->comment)
        glade_xml_node_set_property_string (item_node,
                                            GLADE_TAG_COMMENT,
                                            string->comment);

      if (string->context)
        glade_xml_node_set_property_string (item_node,
                                            GLADE_TAG_CONTEXT,
                                            string->context);
    }
}
Ejemplo n.º 4
0
static void
glade_gtk_widget_write_atk_property (GladeProperty * property,
                                     GladeXmlContext * context,
                                     GladeXmlNode * node)
{
  GladeXmlNode *prop_node;
  GladePropertyClass *pclass;
  gchar *value;

  glade_property_get (property, &value);
  if (value && value[0])
    {
      pclass = glade_property_get_class (property);

      prop_node = glade_xml_node_new (context, GLADE_TAG_A11Y_PROPERTY);
      glade_xml_node_append_child (node, prop_node);

      glade_xml_node_set_property_string (prop_node,
                                          GLADE_TAG_NAME, glade_property_class_id (pclass));

      glade_xml_set_content (prop_node, value);

      if (glade_property_i18n_get_translatable (property))
        glade_xml_node_set_property_string (prop_node,
                                            GLADE_TAG_TRANSLATABLE,
                                            GLADE_XML_TAG_I18N_TRUE);

      if (glade_property_i18n_get_comment (property))
        glade_xml_node_set_property_string (prop_node,
                                            GLADE_TAG_COMMENT,
                                            glade_property_i18n_get_comment (property));

      if (glade_property_i18n_get_context (property))
        glade_xml_node_set_property_string (prop_node,
                                            GLADE_TAG_CONTEXT,
                                            glade_property_i18n_get_context (property));
    }
}
Ejemplo n.º 5
0
/**
 * glade_property_write:
 * @property: a #GladeProperty
 * @context: A #GladeXmlContext
 * @node: A #GladeXmlNode
 *
 * Write @property to @node
 */
void
glade_property_write (GladeProperty * property,
                      GladeXmlContext * context, GladeXmlNode * node)
{
  GladeXmlNode *prop_node;
  gchar *name, *value;
  gboolean save_always;

  g_return_if_fail (GLADE_IS_PROPERTY (property));
  g_return_if_fail (node != NULL);

  /* This code should work the same for <packing>, <widget> and <template> */
  if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_PACKING) ||
        glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||
	glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))
    return;

  /* There can be a couple of reasons to forcefully save a property */
  save_always = (glade_property_class_save_always (property->priv->klass) || property->priv->save_always);
  save_always = save_always || (glade_property_class_optional (property->priv->klass) && property->priv->enabled);

  /* Skip properties that are default by original pspec default
   * (excepting those that specified otherwise).
   */
  if (!save_always && glade_property_original_default (property))
    return;

  /* Escape our string and save with underscores */
  name = g_strdup (glade_property_class_id (property->priv->klass));
  glade_util_replace (name, '-', '_');

  /* convert the value of this property to a string */
  if (!(value = glade_widget_adaptor_string_from_value
        (glade_property_class_get_adaptor (property->priv->klass), property->priv->klass,
         property->priv->value)))
    /* make sure we keep the empty string, also... upcomming
     * funcs that may not like NULL.
     */
    value = g_strdup ("");

  /* Now dump the node values... */
  prop_node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
  glade_xml_node_append_child (node, prop_node);

  /* Name and value */
  glade_xml_node_set_property_string (prop_node, GLADE_XML_TAG_NAME, name);
  glade_xml_set_content (prop_node, value);

  /* i18n stuff */
  if (glade_property_class_translatable (property->priv->klass))
    {
      if (property->priv->i18n_translatable)
        glade_xml_node_set_property_string (prop_node,
                                            GLADE_TAG_TRANSLATABLE,
                                            GLADE_XML_TAG_I18N_TRUE);

      if (property->priv->i18n_context)
        glade_xml_node_set_property_string (prop_node,
                                            GLADE_TAG_CONTEXT,
                                            property->priv->i18n_context);

      if (property->priv->i18n_comment)
        glade_xml_node_set_property_string (prop_node,
                                            GLADE_TAG_COMMENT,
                                            property->priv->i18n_comment);
    }
  g_free (name);
  g_free (value);
}