Commit 7011d381 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

make glade_property_new() always return instrospected value

* gladeui/glade-property.[ch]: make glade_property_new() always
  return instrospected value (catalog_default parameter removed)

* gladeui/glade-widget.c: added glade_widget_set_catalog_defaults()
  to set catalog default values in glade_widget_constructor() when
  the widget is created by the user.

* plugins/gtk+/glade-gtk.c: glade_gtk_menu_item_get_children()
  added GtkImageMenuItem support. fix bug #404322

* plugins/gtk+/gtk+.xml.in: GtkMenuItem get-children function
 renamed to glade_gtk_menu_item_get_children

svn path=/trunk/; revision=1124
parent 75085f54
2007-02-15 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* gladeui/glade-property.[ch]: make glade_property_new() always
return instrospected value (catalog_default parameter removed)
* gladeui/glade-widget.c: added glade_widget_set_catalog_defaults()
to set catalog default values in glade_widget_constructor() when
the widget is created by the user.
* plugins/gtk+/glade-gtk.c: glade_gtk_menu_item_get_children()
added GtkImageMenuItem support.
* plugins/gtk+/gtk+.xml.in: GtkMenuItem get-children function
renamed to glade_gtk_menu_item_get_children()
2007-02-20 Vincent Geddes <vincent.geddes@gmail.com>
* src/glade-utils.c: Remove redundant call to `gtk_window_set_position()'
......
......@@ -961,30 +961,19 @@ glade_property_read_accel_prop (GladeProperty *property,
* @widget: The #GladeWidget this property is created for
* @value: The initial #GValue of the property or %NULL
* (the #GladeProperty will assume ownership of @value)
* @catalog_default: if specified; use any default value supplied
* by the catalog; otherwise use the introspected default.
*
*
* Creates a #GladeProperty of type @klass for @widget with @value; if
* @value is %NULL, then the introspected default value for that property
* will be used; unless otherwise specified by @catalog_default.
*
* Note that we want to use catalog defaults when creating properties for
* any newly created #GladeWidget; but we want to stay with the introspected
* defaults at load time (since the absence of the property who's default
* has been overridden; is interpreted as explicitly set to the default
* by the user).
* will be used.
*
* Returns: The newly created #GladeProperty
*/
GladeProperty *
glade_property_new (GladePropertyClass *klass,
GladeWidget *widget,
GValue *value,
gboolean catalog_default)
GValue *value)
{
GladeProperty *property;
GValue *def;
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), NULL);
......@@ -999,12 +988,11 @@ glade_property_new (GladePropertyClass *klass,
if (property->value == NULL)
{
def = catalog_default ? klass->def : klass->orig_def;
g_assert (def);
g_assert (klass->orig_def);
property->value = g_new0 (GValue, 1);
g_value_init (property->value, def->g_type);
g_value_copy (def, property->value);
g_value_init (property->value, klass->orig_def->g_type);
g_value_copy (klass->orig_def, property->value);
}
return property;
}
......
......@@ -82,8 +82,7 @@ GType glade_property_get_type (void) G_GNUC_CONST
LIBGLADEUI_API
GladeProperty *glade_property_new (GladePropertyClass *klass,
GladeWidget *widget,
GValue *value,
gboolean catalog_default);
GValue *value);
LIBGLADEUI_API
GladeProperty *glade_property_dup (GladeProperty *template_prop,
GladeWidget *widget);
......
......@@ -566,6 +566,20 @@ glade_widget_remove_property (GladeWidget *widget,
id_property, widget->name);
}
static void
glade_widget_set_catalog_defaults (GList *list)
{
GList *l;
for (l = list; l && l->data; l = l->next)
{
GladeProperty *prop = l->data;
GladePropertyClass *klass = prop->klass;
if (glade_property_equals_value (prop, klass->orig_def) &&
g_param_values_cmp (klass->pspec, klass->orig_def, klass->def))
glade_property_reset (prop);
}
}
static void
glade_widget_sync_custom_props (GladeWidget *widget)
......@@ -671,6 +685,10 @@ glade_widget_constructor (GType type,
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);
/* Only call this once the GladeWidget is completely built
* (but before calling custom handlers...)
*/
......@@ -685,7 +703,7 @@ glade_widget_constructor (GType type,
if (gwidget->parent && gwidget->packing_properties == NULL)
glade_widget_set_packing_properties (gwidget, gwidget->parent);
if (GTK_IS_WIDGET (gwidget->object) && !GTK_WIDGET_TOPLEVEL (gwidget->object))
{
gwidget->visible = TRUE;
......@@ -1630,7 +1648,7 @@ glade_widget_set_adaptor (GladeWidget *widget, GladeWidgetAdaptor *adaptor)
{
property_class = GLADE_PROPERTY_CLASS(list->data);
if ((property = glade_property_new (property_class,
widget, NULL, TRUE)) == NULL)
widget, NULL)) == NULL)
{
g_warning ("Failed to create [%s] property",
property_class->id);
......@@ -1708,8 +1726,7 @@ glade_widget_create_packing_properties (GladeWidget *container, GladeWidget *wid
list && list->data; list = list->next)
{
property_class = list->data;
property = glade_property_new
(property_class, widget, NULL, TRUE);
property = glade_property_new (property_class, widget, NULL);
packing_props = g_list_prepend (packing_props, property);
}
......@@ -1890,7 +1907,7 @@ glade_widget_properties_from_widget_info (GladeWidgetAdaptor *klass,
/* If there is a value in the XML, initialize property with it,
* otherwise initialize property to default.
*/
property = glade_property_new (pclass, NULL, NULL, FALSE);
property = glade_property_new (pclass, NULL, NULL);
glade_property_original_reset (property);
......
......@@ -4137,7 +4137,7 @@ glade_gtk_menu_shell_launch_editor (GObject *object, gchar *title)
/* ----------------------------- GtkMenuItem(s) ------------------------------ */
GList * GLADEGTK_API
glade_gtk_menu_item_get_submenu (GladeWidgetAdaptor *adaptor,
glade_gtk_menu_item_get_children (GladeWidgetAdaptor *adaptor,
GObject *object)
{
GList *list = NULL;
......@@ -4145,10 +4145,13 @@ glade_gtk_menu_item_get_submenu (GladeWidgetAdaptor *adaptor,
g_return_val_if_fail (GTK_IS_MENU_ITEM (object), NULL);
child = gtk_menu_item_get_submenu (GTK_MENU_ITEM (object));
if (child) list = g_list_append (list, child);
if ((child = gtk_menu_item_get_submenu (GTK_MENU_ITEM (object))))
list = g_list_append (list, child);
if (GTK_IS_IMAGE_MENU_ITEM (object) &&
(child = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (object))))
list = g_list_append (list, child);
return list;
}
......
......@@ -212,7 +212,7 @@
<glade-widget-class name="GtkMenuItem" generic-name="menuitem" _title="Menu Item" use-placeholders="False">
<post-create-function>glade_gtk_menu_item_post_create</post-create-function>
<get-children-function>glade_gtk_menu_item_get_submenu</get-children-function>
<get-children-function>glade_gtk_menu_item_get_children</get-children-function>
<set-property-function>glade_gtk_menu_item_set_property</set-property-function>
<add-child-function>glade_gtk_menu_item_add_submenu</add-child-function>
<remove-child-function>glade_gtk_menu_item_remove_submenu</remove-child-function>
......
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