mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-09-24 00:04:33 -04:00
Added "catalog_default" arg to glade_property_new() and adjusted callers.
* src/glade-property.[ch], src/glade-widget.[ch]: Added "catalog_default" arg to glade_property_new() and adjusted callers. * src/glade-property-class.[ch]: Ensure that there are always ->def and ->orig_def members resolved. * src/glade-gtk.c: o GtkBox loading issues fixed. o Removed unused code from: glade_gtk_table_has_child and glade_gtk_table_refresh_placeholders. * src/glade-widget.c: o Ignore properties properly when creating the object. (glade_widget_params_from_widget_info and glade_widget_build_object functions) o Use the introspected default value for properties when loading a project. glade_widget_properties_from_widget_info * widgets/gtk+.xml.in: Avoid warnings. o Ignore GtkWidget has-default property. o Ignore GtkComboBox active, column-span-column and row-span-column properties.
This commit is contained in:
parent
3cab166c89
commit
47fd7cd57a
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
||||
2006-03-01 Tristan Van Berkom <tvb@gnome.org>
|
||||
|
||||
* src/glade-property.[ch], src/glade-widget.[ch]: Added
|
||||
"catalog_default" arg to glade_property_new() and adjusted callers.
|
||||
|
||||
* src/glade-property-class.[ch]: Ensure that there are always
|
||||
->def and ->orig_def members resolved.
|
||||
|
||||
2006-03-01 Juan Pablo Ugarte <juanpablougarte@gmail.com>
|
||||
|
||||
* src/glade-gtk.c:
|
||||
o GtkBox loading issues fixed.
|
||||
o Removed unused code from: glade_gtk_table_has_child and
|
||||
glade_gtk_table_refresh_placeholders.
|
||||
|
||||
* src/glade-widget.c:
|
||||
o Ignore properties properly when creating the object.
|
||||
(glade_widget_params_from_widget_info and
|
||||
glade_widget_build_object functions)
|
||||
o Use the introspected default value for properties when
|
||||
loading a project. glade_widget_properties_from_widget_info
|
||||
|
||||
* widgets/gtk+.xml.in: Avoid warnings.
|
||||
o Ignore GtkWidget has-default property.
|
||||
o Ignore GtkComboBox active, column-span-column and row-span-column properties.
|
||||
|
||||
2006-02-27 Vincent Geddes <vgeddes@metroweb.co.za>
|
||||
|
||||
* src/glade-utils.c: Added file filters "All Files" and "Glade Files"
|
||||
|
@ -353,14 +353,14 @@ glade_gtk_box_verify_size (GObject *object, GValue *value)
|
||||
void GLADEGTK_API
|
||||
glade_gtk_box_add_child (GObject *object, GObject *child)
|
||||
{
|
||||
gint num_children, position;
|
||||
GladeWidget *gbox, *gchild;
|
||||
GladeWidget *gbox;
|
||||
GladeProject *project;
|
||||
|
||||
g_return_if_fail (GTK_IS_BOX (object));
|
||||
g_return_if_fail (GTK_IS_WIDGET (child));
|
||||
|
||||
gbox = glade_widget_get_from_gobject (object);
|
||||
gchild = glade_widget_get_from_gobject (child);
|
||||
project = glade_widget_get_project (gbox);
|
||||
|
||||
/*
|
||||
Try to remove the last placeholder if any, this way GtkBox`s size
|
||||
@ -383,17 +383,20 @@ glade_gtk_box_add_child (GObject *object, GObject *child)
|
||||
}
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
|
||||
|
||||
num_children = g_list_length (GTK_BOX (object)->children);
|
||||
|
||||
glade_widget_property_set (gbox, "size", num_children);
|
||||
|
||||
/* Packing props arent around when parenting during a glade_widget_dup() */
|
||||
if (gchild && gchild->packing_properties)
|
||||
|
||||
if (glade_project_is_loading (project))
|
||||
{
|
||||
if (!glade_widget_pack_property_get (gchild, "position", &position))
|
||||
position = num_children - 1;
|
||||
glade_widget_pack_property_set (gchild, "position", position);
|
||||
GladeWidget *gchild;
|
||||
gint num_children;
|
||||
|
||||
num_children = g_list_length (GTK_BOX (object)->children);
|
||||
glade_widget_property_set (gbox, "size", num_children);
|
||||
|
||||
gchild = glade_widget_get_from_gobject (child);
|
||||
|
||||
/* Packing props arent around when parenting during a glade_widget_dup() */
|
||||
if (gchild && gchild->packing_properties)
|
||||
glade_widget_pack_property_set (gchild, "position", num_children - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1800,10 +1803,7 @@ glade_gtk_expander_add_child (GObject *object, GObject *child)
|
||||
/* GtkTable */
|
||||
|
||||
static gboolean
|
||||
glade_gtk_table_has_child (GtkTable *table,
|
||||
gboolean skip_placeholders,
|
||||
guint left_attach,
|
||||
guint top_attach)
|
||||
glade_gtk_table_has_child (GtkTable *table, guint left_attach, guint top_attach)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
@ -1811,9 +1811,6 @@ glade_gtk_table_has_child (GtkTable *table,
|
||||
{
|
||||
GtkTableChild *child = list->data;
|
||||
|
||||
if (skip_placeholders && GLADE_IS_PLACEHOLDER (child->widget))
|
||||
continue;
|
||||
|
||||
if (left_attach >= child->left_attach && left_attach < child->right_attach &&
|
||||
top_attach >= child->top_attach && top_attach < child->bottom_attach)
|
||||
return TRUE;
|
||||
@ -1847,21 +1844,7 @@ glade_gtk_table_refresh_placeholders (GtkTable *table)
|
||||
GtkTableChild *child = list->data;
|
||||
|
||||
if (GLADE_IS_PLACEHOLDER (child->widget))
|
||||
{
|
||||
guint left_attach, top_attach;
|
||||
|
||||
gtk_container_child_get (GTK_CONTAINER (table), child->widget,
|
||||
"left-attach", &left_attach,
|
||||
"top-attach", &top_attach, NULL);
|
||||
|
||||
gtk_container_child_set (GTK_CONTAINER (table), child->widget,
|
||||
"right-attach", left_attach + 1,
|
||||
"bottom-attach", top_attach + 1, NULL);
|
||||
|
||||
if (glade_gtk_table_has_child (table, TRUE,
|
||||
left_attach, top_attach))
|
||||
toremove = g_list_prepend (toremove, child->widget);
|
||||
}
|
||||
toremove = g_list_prepend (toremove, child->widget);
|
||||
}
|
||||
|
||||
if (toremove)
|
||||
@ -1874,7 +1857,7 @@ glade_gtk_table_refresh_placeholders (GtkTable *table)
|
||||
|
||||
for (i = 0; i < table->ncols; i++)
|
||||
for (j = 0; j < table->nrows; j++)
|
||||
if (glade_gtk_table_has_child (table, FALSE, i, j) == FALSE)
|
||||
if (glade_gtk_table_has_child (table, i, j) == FALSE)
|
||||
gtk_table_attach_defaults (table,
|
||||
glade_placeholder_new (),
|
||||
i, i + 1, j, j + 1);
|
||||
@ -2543,7 +2526,7 @@ glade_gtk_radio_menu_item_set_group (GObject *object, GValue *value)
|
||||
static GladeWidget *
|
||||
glade_gtk_menu_bar_append_new_submenu (GladeWidget *parent, GladeProject *project)
|
||||
{
|
||||
GladeWidgetClass *submenu_class = NULL;
|
||||
static GladeWidgetClass *submenu_class = NULL;
|
||||
GladeWidget *gsubmenu;
|
||||
|
||||
if (submenu_class == NULL)
|
||||
|
@ -1177,6 +1177,11 @@ glade_property_class_update_from_node (GladeXmlNode *node,
|
||||
g_free (class->def);
|
||||
}
|
||||
class->def = glade_property_class_get_default_from_spec (class->pspec);
|
||||
|
||||
if (class->orig_def == NULL)
|
||||
class->orig_def =
|
||||
glade_property_class_get_default_from_spec (class->pspec);
|
||||
|
||||
}
|
||||
|
||||
g_free (buff);
|
||||
|
@ -57,11 +57,14 @@ struct _GladePropertyClass
|
||||
*/
|
||||
gchar *tooltip; /* The default tooltip for the property editor rows.
|
||||
*/
|
||||
GValue *def; /* The default value for this property */
|
||||
GValue *def; /* The default value for this property (this will exist
|
||||
* as a copy of orig_def if not specified by the catalog)
|
||||
*/
|
||||
|
||||
GValue *orig_def; /* The real default value obtained through introspection.
|
||||
* (used to decide whether we should write to the
|
||||
* glade file or not).
|
||||
* glade file or not, or to restore the loaded property
|
||||
* correctly); all property classes have and orig_def.
|
||||
*/
|
||||
|
||||
GList *parameters; /* list of GladeParameter objects. This list
|
||||
|
@ -586,17 +586,31 @@ glade_property_get_type (void)
|
||||
* @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.
|
||||
*
|
||||
* Returns: A newly created #GladeProperty based on the
|
||||
* given criteria
|
||||
*
|
||||
* Creates a #GladeProperty of type @class 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).
|
||||
*
|
||||
* Returns: The newly created #GladeProperty
|
||||
*/
|
||||
GladeProperty *
|
||||
glade_property_new (GladePropertyClass *class,
|
||||
GladeWidget *widget,
|
||||
GValue *value)
|
||||
GValue *value,
|
||||
gboolean catalog_default)
|
||||
{
|
||||
GladeProperty *property;
|
||||
|
||||
GValue *def;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (class), NULL);
|
||||
|
||||
property =
|
||||
@ -610,10 +624,12 @@ glade_property_new (GladePropertyClass *class,
|
||||
|
||||
if (property->value == NULL)
|
||||
{
|
||||
g_assert (class->def);
|
||||
def = catalog_default ? class->def : class->orig_def;
|
||||
g_assert (def);
|
||||
|
||||
property->value = g_new0 (GValue, 1);
|
||||
g_value_init (property->value, class->def->g_type);
|
||||
g_value_copy (class->def, property->value);
|
||||
g_value_init (property->value, def->g_type);
|
||||
g_value_copy (def, property->value);
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
@ -83,7 +83,8 @@ GType glade_property_get_type (void);
|
||||
LIBGLADEUI_API
|
||||
GladeProperty *glade_property_new (GladePropertyClass *class,
|
||||
GladeWidget *widget,
|
||||
GValue *value);
|
||||
GValue *value,
|
||||
gboolean catalog_default);
|
||||
LIBGLADEUI_API
|
||||
GladeProperty *glade_property_dup (GladeProperty *template,
|
||||
GladeWidget *widget);
|
||||
|
@ -556,7 +556,9 @@ glade_widget_build_object (GladeWidgetClass *klass, GladeWidget *widget)
|
||||
glade_property_class =
|
||||
glade_widget_class_get_property_class (klass,
|
||||
pspec[i]->name);
|
||||
if (!glade_property_class)
|
||||
if (glade_property_class == NULL ||
|
||||
glade_property_class->set_function ||
|
||||
glade_property_class->ignore)
|
||||
/* Ignore properties that are not accounted for
|
||||
* by the GladeWidgetClass
|
||||
*/
|
||||
@ -1374,22 +1376,25 @@ glade_widget_set_class (GladeWidget *widget, GladeWidgetClass *klass)
|
||||
|
||||
widget->widget_class = klass;
|
||||
|
||||
/* If we have no properties; we are not in the process of loading
|
||||
*/
|
||||
if (!widget->properties)
|
||||
{
|
||||
for (list = klass->properties; list; list = list->next)
|
||||
{
|
||||
property_class = GLADE_PROPERTY_CLASS(list->data);
|
||||
property = glade_property_new (property_class,
|
||||
widget, NULL);
|
||||
if (!property) {
|
||||
if ((property = glade_property_new (property_class,
|
||||
widget, NULL, TRUE)) == NULL)
|
||||
{
|
||||
g_warning ("Failed to create [%s] property",
|
||||
property_class->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
widget->properties = g_list_prepend (widget->properties, property);
|
||||
if (property_class->query) widget->query_user = TRUE;
|
||||
|
||||
/* Mark the widget for query dialogs */
|
||||
if (property_class->query) widget->query_user = TRUE;
|
||||
}
|
||||
widget->properties = g_list_reverse (widget->properties);
|
||||
}
|
||||
@ -2286,7 +2291,8 @@ glade_widget_create_packing_properties (GladeWidget *container, GladeWidget *wid
|
||||
for (list = support->properties; list && list->data; list = list->next)
|
||||
{
|
||||
property_class = list->data;
|
||||
property = glade_property_new (property_class, widget, NULL);
|
||||
property = glade_property_new
|
||||
(property_class, widget, NULL, TRUE);
|
||||
packing_props = g_list_prepend (packing_props, property);
|
||||
}
|
||||
}
|
||||
@ -2559,7 +2565,7 @@ glade_widget_write_child (GArray *children,
|
||||
child_widget = glade_widget_get_from_gobject (object);
|
||||
if (!child_widget)
|
||||
return FALSE;
|
||||
|
||||
|
||||
if (child_widget->internal)
|
||||
info.internal_child = alloc_string(interface, child_widget->internal);
|
||||
|
||||
@ -2801,7 +2807,7 @@ glade_widget_properties_from_widget_info (GladeWidgetClass *class,
|
||||
(class, info, pclass->id,
|
||||
&translatable, &has_context, &comment);
|
||||
|
||||
property = glade_property_new (pclass, NULL, value);
|
||||
property = glade_property_new (pclass, NULL, value, FALSE);
|
||||
property->enabled = value ? TRUE : property->enabled;
|
||||
|
||||
if (glade_property_class_is_object (pclass))
|
||||
@ -2881,9 +2887,14 @@ glade_widget_params_from_widget_info (GladeWidgetClass *widget_class,
|
||||
}
|
||||
/* Now try filling the parameter with the default on the GladeWidgetClass.
|
||||
*/
|
||||
else if (g_value_type_compatible (G_VALUE_TYPE (glade_property_class->def),
|
||||
else if (g_value_type_compatible (G_VALUE_TYPE (glade_property_class->orig_def),
|
||||
G_VALUE_TYPE (¶meter.value)))
|
||||
g_value_copy (glade_property_class->def, ¶meter.value);
|
||||
{
|
||||
if (g_type_is_a (G_VALUE_TYPE (glade_property_class->orig_def), G_TYPE_OBJECT))
|
||||
if (g_value_get_object (glade_property_class->orig_def) == NULL)
|
||||
continue;
|
||||
g_value_copy (glade_property_class->orig_def, ¶meter.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_critical ("Type mismatch on %s property of %s",
|
||||
|
@ -52,6 +52,7 @@
|
||||
<property id="parent" disabled="True"/>
|
||||
<property id="style" disabled="True"/>
|
||||
<property id="sensitive" ignore="True"/>
|
||||
<property id="has-default" ignore="True" common="True"/>
|
||||
</properties>
|
||||
</glade-widget-class>
|
||||
|
||||
@ -481,6 +482,9 @@
|
||||
<glade-widget-class name="GtkComboBox" generic-name="combobox" _title="Combo Box">
|
||||
<post-create-function>glade_gtk_combo_box_post_create</post-create-function>
|
||||
<properties>
|
||||
<property id="active" ignore="True"/>
|
||||
<property id="column-span-column" ignore="True"/>
|
||||
<property id="row-span-column" ignore="True"/>
|
||||
<property id="items" _name="Items" translatable="True">
|
||||
<spec>glade_standard_strv_spec</spec>
|
||||
<_tooltip>The items in this combo box</_tooltip>
|
||||
|
Loading…
x
Reference in New Issue
Block a user