/** * glade_property_add_object: * @property: a #GladeProperty * @object: The #GObject to add * * Adds @object to the object list in @property. * * Note: This function expects @property to be a #GladeParamSpecObjects * or #GParamSpecObject type property. */ void glade_property_add_object (GladeProperty * property, GObject * object) { GList *list = NULL, *new_list = NULL; GParamSpec *pspec; g_return_if_fail (GLADE_IS_PROPERTY (property)); g_return_if_fail (G_IS_OBJECT (object)); pspec = glade_property_class_get_pspec (property->priv->klass); g_return_if_fail (GLADE_IS_PARAM_SPEC_OBJECTS (pspec) || G_IS_PARAM_SPEC_OBJECT (pspec)); if (GLADE_IS_PARAM_SPEC_OBJECTS (pspec)) { glade_property_get (property, &list); new_list = g_list_copy (list); new_list = g_list_append (new_list, object); glade_property_set (property, new_list); /* ownership of the list is not passed * through glade_property_set() */ g_list_free (new_list); } else { glade_property_set (property, object); } }
/** * glade_property_get_va_list: * @property: a #GladeProperty * @vl: a va_list * * Retrieve the property value */ void glade_property_get_va_list (GladeProperty * property, va_list vl) { g_return_if_fail (GLADE_IS_PROPERTY (property)); glade_property_class_set_vl_from_gvalue (property->priv->klass, property->priv->value, vl); }
/** * glade_property_get_value: * @property: a #GladeProperty * @value: a #GValue * * Retrieve the property value */ void glade_property_get_value (GladeProperty * property, GValue * value) { g_return_if_fail (GLADE_IS_PROPERTY (property)); g_return_if_fail (value != NULL); GLADE_PROPERTY_GET_KLASS (property)->get_value (property, value); }
void glade_property_i18n_set_translatable (GladeProperty * property, gboolean translatable) { g_return_if_fail (GLADE_IS_PROPERTY (property)); property->priv->i18n_translatable = translatable; g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_I18N_TRANSLATABLE]); }
gchar * glade_property_make_string (GladeProperty *property) { g_return_val_if_fail (GLADE_IS_PROPERTY (property), NULL); return glade_property_class_make_string_from_gvalue (property->priv->klass, property->priv->value); }
void glade_property_set_widget (GladeProperty *property, GladeWidget *widget) { g_return_if_fail (GLADE_IS_PROPERTY (property)); property->priv->widget = widget; }
/** * glade_property_read: * @property: a #GladeProperty or #NULL * @project: the #GladeProject * @node: the #GladeXmlNode to read, will either be a 'widget' * node or a 'child' node for packing properties. * * Read the value and any attributes for @property from @node, assumes * @property is being loaded for @project * * Note that object values will only be resolved after the project is * completely loaded */ void glade_property_read (GladeProperty * property, GladeProject * project, GladeXmlNode * prop) { GValue *gvalue = NULL; gchar /* *id, *name, */ * value; gint translatable = FALSE; gchar *comment = NULL, *context = NULL; g_return_if_fail (GLADE_IS_PROPERTY (property)); g_return_if_fail (GLADE_IS_PROJECT (project)); g_return_if_fail (prop != NULL); if (!glade_xml_node_verify (prop, GLADE_XML_TAG_PROPERTY)) return; if (!(value = glade_xml_get_content (prop))) return; /* If an optional property is specified in the * glade file, its enabled */ property->priv->enabled = TRUE; if (glade_property_class_is_object (property->priv->klass)) { /* we must synchronize this directly after loading this project * (i.e. lookup the actual objects after they've been parsed and * are present). */ g_object_set_data_full (G_OBJECT (property), "glade-loaded-object", g_strdup (value), g_free); } else { gvalue = glade_property_class_make_gvalue_from_string (property->priv->klass, value, project); GLADE_PROPERTY_GET_KLASS (property)->set_value (property, gvalue); g_value_unset (gvalue); g_free (gvalue); } translatable = glade_xml_get_property_boolean (prop, GLADE_TAG_TRANSLATABLE, FALSE); comment = glade_xml_get_property_string (prop, GLADE_TAG_COMMENT); context = glade_xml_get_property_string (prop, GLADE_TAG_CONTEXT); glade_property_i18n_set_translatable (property, translatable); glade_property_i18n_set_comment (property, comment); glade_property_i18n_set_context (property, context); g_free (comment); g_free (context); g_free (value); }
gboolean glade_property_warn_usage (GladeProperty *property) { g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); if (!property->priv->support_warning) return FALSE; return ((property->priv->state & GLADE_STATE_CHANGED) != 0); }
void glade_property_i18n_set_context (GladeProperty * property, const gchar * str) { g_return_if_fail (GLADE_IS_PROPERTY (property)); if (property->priv->i18n_context) g_free (property->priv->i18n_context); property->priv->i18n_context = g_strdup (str); g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_I18N_CONTEXT]); }
/** * glade_property_get: * @property: a #GladeProperty * @...: An address to store the value * * Retrieve the property value */ void glade_property_get (GladeProperty * property, ...) { va_list vl; g_return_if_fail (GLADE_IS_PROPERTY (property)); va_start (vl, property); glade_property_get_va_list (property, vl); va_end (vl); }
/** * glade_property_get_default: * @property: a #GladeProperty * @value: a #GValue * * Retrieve the default property value */ void glade_property_get_default (GladeProperty * property, GValue * value) { GParamSpec *pspec; g_return_if_fail (GLADE_IS_PROPERTY (property)); g_return_if_fail (value != NULL); pspec = glade_property_class_get_pspec (property->priv->klass); g_value_init (value, pspec->value_type); g_value_copy (glade_property_class_get_default (property->priv->klass), value); }
/** * glade_property_set: * @property: a #GladeProperty * @...: the value to set * * Sets the property's value (in a convenient way) */ gboolean glade_property_set (GladeProperty * property, ...) { va_list vl; gboolean success; g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); va_start (vl, property); success = glade_property_set_va_list (property, vl); va_end (vl); return success; }
/** * glade_property_equals: * @property: a #GladeProperty * @...: a provided property value * * Returns: Whether this property is equal to the value provided */ gboolean glade_property_equals (GladeProperty * property, ...) { va_list vl; gboolean ret; g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); va_start (vl, property); ret = glade_property_equals_va_list (property, vl); va_end (vl); return ret; }
static void glade_property_reset_common (GladeProperty * property, gboolean original) { const GValue *value; g_return_if_fail (GLADE_IS_PROPERTY (property)); if (original) value = glade_property_class_get_original_default (property->priv->klass); else value = glade_property_class_get_default (property->priv->klass); GLADE_PROPERTY_GET_KLASS (property)->set_value (property, value); }
static gboolean glade_property_default_common (GladeProperty * property, gboolean orig) { const GValue *value; g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); if (orig) value = glade_property_class_get_original_default (property->priv->klass); else value = glade_property_class_get_default (property->priv->klass); return GLADE_PROPERTY_GET_KLASS (property)->equals_value (property, value); }
/** * glade_property_equals_va_list: * @property: a #GladeProperty * @vl: a va_list * * Returns: Whether this property is equal to the value provided */ static gboolean glade_property_equals_va_list (GladeProperty * property, va_list vl) { GValue *value; gboolean ret; g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); value = glade_property_class_make_gvalue_from_vl (property->priv->klass, vl); ret = GLADE_PROPERTY_GET_KLASS (property)->equals_value (property, value); g_value_unset (value); g_free (value); return ret; }
gboolean glade_property_i18n_get_translatable (GladeProperty * property) { g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); return property->priv->i18n_translatable; }
/** * glade_property_equals_value: * @property: a #GladeProperty * @value: a #GValue * * Returns: Whether this property is equal to the value provided */ gboolean glade_property_equals_value (GladeProperty * property, const GValue * value) { g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); return GLADE_PROPERTY_GET_KLASS (property)->equals_value (property, value); }
/** * glade_property_dup: * @template_prop: A #GladeProperty * @widget: A #GladeWidget * * Returns: A newly duplicated property based on the new widget */ GladeProperty * glade_property_dup (GladeProperty * template_prop, GladeWidget * widget) { g_return_val_if_fail (GLADE_IS_PROPERTY (template_prop), NULL); return GLADE_PROPERTY_GET_KLASS (template_prop)->dup (template_prop, widget); }
/** * glade_property_load: * @property: a #GladeProperty * * Loads the value of @property from the coresponding object instance */ void glade_property_load (GladeProperty * property) { g_return_if_fail (GLADE_IS_PROPERTY (property)); GLADE_PROPERTY_GET_KLASS (property)->load (property); }
/** * 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); }
gboolean glade_property_get_enabled (GladeProperty * property) { g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); return property->priv->enabled; }
G_CONST_RETURN gchar * glade_property_i18n_get_context (GladeProperty * property) { g_return_val_if_fail (GLADE_IS_PROPERTY (property), NULL); return property->priv->i18n_context; }
static gboolean glade_gtk_grid_configure_end (GladeFixed *fixed, GladeWidget *child, GtkWidget *grid) { GladeGridChild new_child = { child, }; glade_widget_pack_property_get (child, "left-attach", &new_child.left_attach); glade_widget_pack_property_get (child, "width", &new_child.width); glade_widget_pack_property_get (child, "top-attach", &new_child.top_attach); glade_widget_pack_property_get (child, "height", &new_child.height); /* Compare the meaningfull part of the current edit. */ if (memcmp (&new_child, &grid_edit, sizeof (GladeGridChild)) != 0) { GValue left_attach_value = { 0, }; GValue width_attach_value = { 0, }; GValue top_attach_value = { 0, }; GValue height_attach_value = { 0, }; GValue new_left_attach_value = { 0, }; GValue new_width_attach_value = { 0, }; GValue new_top_attach_value = { 0, }; GValue new_height_attach_value = { 0, }; GladeProperty *left_attach_prop, *width_attach_prop, *top_attach_prop, *height_attach_prop; left_attach_prop = glade_widget_get_pack_property (child, "left-attach"); width_attach_prop = glade_widget_get_pack_property (child, "width"); top_attach_prop = glade_widget_get_pack_property (child, "top-attach"); height_attach_prop = glade_widget_get_pack_property (child, "height"); g_return_val_if_fail (GLADE_IS_PROPERTY (left_attach_prop), FALSE); g_return_val_if_fail (GLADE_IS_PROPERTY (width_attach_prop), FALSE); g_return_val_if_fail (GLADE_IS_PROPERTY (top_attach_prop), FALSE); g_return_val_if_fail (GLADE_IS_PROPERTY (height_attach_prop), FALSE); glade_property_get_value (left_attach_prop, &new_left_attach_value); glade_property_get_value (width_attach_prop, &new_width_attach_value); glade_property_get_value (top_attach_prop, &new_top_attach_value); glade_property_get_value (height_attach_prop, &new_height_attach_value); g_value_init (&left_attach_value, G_TYPE_INT); g_value_init (&width_attach_value, G_TYPE_INT); g_value_init (&top_attach_value, G_TYPE_INT); g_value_init (&height_attach_value, G_TYPE_INT); g_value_set_int (&left_attach_value, grid_edit.left_attach); g_value_set_int (&width_attach_value, grid_edit.width); g_value_set_int (&top_attach_value, grid_edit.top_attach); g_value_set_int (&height_attach_value, grid_edit.height); glade_command_push_group (_("Placing %s inside %s"), glade_widget_get_name (child), glade_widget_get_name (GLADE_WIDGET (fixed))); glade_command_set_properties (left_attach_prop, &left_attach_value, &new_left_attach_value, width_attach_prop, &width_attach_value, &new_width_attach_value, top_attach_prop, &top_attach_value, &new_top_attach_value, height_attach_prop, &height_attach_value, &new_height_attach_value, NULL); glade_command_pop_group (); g_value_unset (&left_attach_value); g_value_unset (&width_attach_value); g_value_unset (&top_attach_value); g_value_unset (&height_attach_value); g_value_unset (&new_left_attach_value); g_value_unset (&new_width_attach_value); g_value_unset (&new_top_attach_value); g_value_unset (&new_height_attach_value); } return TRUE; }
gboolean glade_property_get_sensitive (GladeProperty * property) { g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE); return property->priv->sensitive; }