Commit 6c81970c authored by Tristan Van Berkom's avatar Tristan Van Berkom

- Added property_set_save_always() functions - Introspect initial values


	* gladeui/glade-property.[ch], gladeui/glade-widget.[ch]:
	  - Added property_set_save_always() functions
	  - Introspect initial values of all properties even if they're
	    not composite children (sometimes derived widgets set a property
	    to a non-default value).

	* plugins/gtk+/glade-gtk.c: set "save-always" on the "type-hint"
	  property of GtkDialog. Bug #412848.


svn path=/trunk/; revision=1147
parent 205aa959
2006-03-03 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-property.[ch], gladeui/glade-widget.[ch]:
- Added property_set_save_always() functions
- Introspect initial values of all properties even if they're
not composite children (sometimes derived widgets set a property
to a non-default value).
* plugins/gtk+/glade-gtk.c: set "save-always" on the "type-hint"
property of GtkDialog. Bug #412848.
2007-03-01 Vincent Geddes <vincent.geddes@gmail.com>
* bindings/python/Makefile.am: Added required libraries to
libgladepython_la_LIBADD. Bug #412827.
* bindings/python/Makefile.am: Added required libraries to
libgladepython_la_LIBADD. Bug #412827.
2007-02-28 Christian Persch <chpe@svn.gnome.org>
......
......@@ -337,10 +337,11 @@ glade_property_write_impl (GladeProperty *property,
g_assert (property->klass->orig_def);
g_assert (property->klass->def);
/* Skip properties that are default
* (by original pspec default)
/* Skip properties that are default by original pspec default
* (excepting those that specified otherwise).
*/
if (glade_property_equals_value (property, property->klass->orig_def))
if (!property->save_always &&
glade_property_equals_value (property, property->klass->orig_def))
return FALSE;
/* we should change each '-' by '_' on the name of the property
......@@ -1558,6 +1559,41 @@ glade_property_get_sensitive (GladeProperty *property)
return property->sensitive;
}
/**
* glade_property_set_save_always:
* @property: A #GladeProperty
* @setting: the value to set
*
* Sets whether this property should be special cased
* to always be saved regardless of its default value.
* (used for some special cases like properties
* that are assigned initial values in composite widgets
* or derived widget code).
*/
void
glade_property_set_save_always (GladeProperty *property,
gboolean setting)
{
g_return_if_fail (GLADE_IS_PROPERTY (property));
property->save_always = setting;
}
/**
* glade_property_get_save_always:
* @property: A #GladeProperty
*
* Returns whether this property is special cased
* to always be saved regardless of its default value.
*/
gboolean
glade_property_get_save_always (GladeProperty *property)
{
g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
return property->save_always;
}
void
glade_property_set_enabled (GladeProperty *property,
gboolean enabled)
......
......@@ -47,6 +47,13 @@ struct _GladeProperty
* widget.
*/
gboolean save_always; /* Used to make a special case exception and always
* save this property regardless of what the default
* value is (used for some special cases like properties
* that are assigned initial values in composite widgets
* or derived widget code).
*/
/* Used only for translatable strings. */
gboolean i18n_translatable;
gboolean i18n_has_context;
......@@ -149,6 +156,13 @@ void glade_property_set_sensitive (GladeProperty
const gchar *reason);
LIBGLADEUI_API
gboolean glade_property_get_sensitive (GladeProperty *property);
LIBGLADEUI_API
void glade_property_set_save_always (GladeProperty *property,
gboolean setting);
LIBGLADEUI_API
gboolean glade_property_get_save_always (GladeProperty *property);
LIBGLADEUI_API
void glade_property_set_enabled (GladeProperty *property,
gboolean enabled);
......
......@@ -680,11 +680,10 @@ glade_widget_constructor (GType type,
* but only when its freshly created (depend on glade file at
* load time and copying properties at dup time).
*/
if (gwidget->internal != NULL &&
gwidget->construct_reason == GLADE_CREATE_USER)
if (gwidget->construct_reason == GLADE_CREATE_USER)
for (list = gwidget->properties; list; list = list->next)
glade_property_load (GLADE_PROPERTY (list->data));
/* We only use catalog defaults when the widget was created by the user! */
if (gwidget->construct_reason == GLADE_CREATE_USER)
glade_widget_set_catalog_defaults (gwidget->properties);
......@@ -2881,6 +2880,69 @@ glade_widget_pack_property_set_enabled (GladeWidget *widget,
return FALSE;
}
/**
* glade_widget_property_set_save_always:
* @widget: a #GladeWidget
* @id_property: a string naming a #GladeProperty
* @setting: the setting
*
* Sets whether @id_property in @widget should be special cased
* to always be saved regardless of its default value.
* (used for some special cases like properties
* that are assigned initial values in composite widgets
* or derived widget code).
*
* Returns: whether @id_property was found or not.
*/
gboolean
glade_widget_property_set_save_always (GladeWidget *widget,
const gchar *id_property,
gboolean setting)
{
GladeProperty *property;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
if ((property = glade_widget_get_property (widget, id_property)) != NULL)
{
glade_property_set_save_always (property, setting);
return TRUE;
}
return FALSE;
}
/**
* glade_widget_pack_property_set_save_always:
* @widget: a #GladeWidget
* @id_property: a string naming a #GladeProperty
* @setting: the setting
*
* Sets whether @id_property in @widget should be special cased
* to always be saved regardless of its default value.
* (used for some special cases like properties
* that are assigned initial values in composite widgets
* or derived widget code).
*
* Returns: whether @id_property was found or not.
*/
gboolean
glade_widget_pack_property_set_save_always (GladeWidget *widget,
const gchar *id_property,
gboolean setting)
{
GladeProperty *property;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
{
glade_property_set_save_always (property, setting);
return TRUE;
}
return FALSE;
}
/**
* glade_widget_property_reset:
* @widget: a #GladeWidget
......
......@@ -280,6 +280,15 @@ gboolean glade_widget_pack_property_set_enabled (GladeWidget
const gchar *id_property,
gboolean enabled);
LIBGLADEUI_API
gboolean glade_widget_property_set_save_always (GladeWidget *widget,
const gchar *id_property,
gboolean setting);
LIBGLADEUI_API
gboolean glade_widget_pack_property_set_save_always (GladeWidget *widget,
const gchar *id_property,
gboolean setting);
/*******************************************************************************
Accessors
*******************************************************************************/
......
......@@ -2985,6 +2985,8 @@ glade_gtk_dialog_post_create (GladeWidgetAdaptor *adaptor,
if (!widget)
return;
/* Mark properties that are initially modified by the dialog */
glade_widget_property_set_save_always (widget, "type-hint", TRUE);
if (reason == GLADE_CREATE_USER)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment