static void glade_property_fix_state (GladeProperty * property) { property->priv->state = GLADE_STATE_NORMAL; /* Properties are 'changed' state if they are not default, or if * they are optional and enabled, optional enabled properties * are saved regardless of default value */ if (glade_property_class_optional (property->priv->klass)) { if (glade_property_get_enabled (property)) property->priv->state |= GLADE_STATE_CHANGED; } else if (!glade_property_original_default (property)) property->priv->state |= GLADE_STATE_CHANGED; if (property->priv->support_warning) property->priv->state |= GLADE_STATE_UNSUPPORTED; if (property->priv->support_disabled) property->priv->state |= GLADE_STATE_SUPPORT_DISABLED; g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_STATE]); }
/* 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); } }
/** * 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); }