From 458ee7944211d03b381b02f66fdefcfbc0fa03d0 Mon Sep 17 00:00:00 2001 From: Morten Welinder Date: Wed, 6 Oct 2004 20:08:53 +0000 Subject: [PATCH] Define the group property. 2004-10-06 Morten Welinder * widgets/gtkradiobutton.xml: Define the group property. * widgets/gtk-base.xml: Load gtkradiobutton.xml * src/glade-widget.c (glade_widget_new_child_from_node): Bullet proof. * src/glade-property-class.c (glade_property_class_make_gvalue_from_string): Bullet proof. * src/glade-gtk.c (glade_gtk_radio_button_set_group, glade_gtk_radio_button_get_group): New functions. --- ChangeLog | 15 ++++++++++++++ src/glade-gtk.c | 41 ++++++++++++++++++++++++++++++++++++++ src/glade-property-class.c | 8 +++++--- src/glade-widget-class.c | 2 +- src/glade-widget.c | 41 ++++++++++++++++++++++---------------- widgets/gtk-base.xml | 2 +- widgets/gtkcheckbutton.xml | 5 +---- widgets/gtkradiobutton.xml | 10 +++++++--- 8 files changed, 95 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22ffa626..4721e3a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2004-10-06 Morten Welinder + + * widgets/gtkradiobutton.xml: Define the group property. + + * widgets/gtk-base.xml: Load gtkradiobutton.xml + + * src/glade-widget.c (glade_widget_new_child_from_node): Bullet + proof. + + * src/glade-property-class.c + (glade_property_class_make_gvalue_from_string): Bullet proof. + + * src/glade-gtk.c (glade_gtk_radio_button_set_group, + glade_gtk_radio_button_get_group): New functions. + 2004-10-06 Morten Welinder * src/glade-gtk.c (glade_gtk_widget_condition): Fix life cycle of diff --git a/src/glade-gtk.c b/src/glade-gtk.c index a648382a..28396587 100644 --- a/src/glade-gtk.c +++ b/src/glade-gtk.c @@ -1247,3 +1247,44 @@ glade_gtk_dialog_child_property_applies (GtkWidget *ancestor, return FALSE; } + + +/** + * glade_gtk_radio_button_get_group: + * @object: + * @value: + * + * TODO: write me + */ +void GLADEGTK_API +glade_gtk_radio_button_get_group (GObject *object, GValue *value) +{ + GtkRadioButton *button = GTK_RADIO_BUTTON (object); + GSList *group; + const char *name; + + group = gtk_radio_button_get_group (button); + name = group + ? gtk_widget_get_name (group->data) + : NULL; + + g_value_reset (value); + g_value_set_string (value, name); +} + + +/** + * glade_gtk_radio_button_set_group: + * @object: + * @value: + * + * TODO: write me + */ +void GLADEGTK_API +glade_gtk_radio_button_set_group (GObject *object, GValue *value) +{ + GtkRadioButton *button = GTK_RADIO_BUTTON (object); + const char *name = g_value_get_string (value); + + /* FIXME: now what? */ +} diff --git a/src/glade-property-class.c b/src/glade-property-class.c index 6f68b96c..264e952b 100644 --- a/src/glade-property-class.c +++ b/src/glade-property-class.c @@ -552,13 +552,15 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class } case GLADE_PROPERTY_TYPE_OBJECT: break; - default: + default: { + const char *typestr = glade_property_type_enum_to_string (type); g_warning ("Could not make gvalue from string ->%s<- and type %s\n", - string, - glade_property_type_enum_to_string (type)); + string ? string : "(null)", + typestr ? typestr : "(null)"); g_free (value); value = NULL; } + } return value; } diff --git a/src/glade-widget-class.c b/src/glade-widget-class.c index 0e9e63b3..6e23d221 100644 --- a/src/glade-widget-class.c +++ b/src/glade-widget-class.c @@ -121,7 +121,7 @@ glade_widget_class_list_properties (GladeWidgetClass *class) g_type_class_ref (class->type); /* hmm */ /* We count on the fact we have an instance, or else we'd have - * touse g_type_class_ref (); + * to use g_type_class_ref (); */ object_class = g_type_class_peek (class->type); diff --git a/src/glade-widget.c b/src/glade-widget.c index d4f77403..00cb1b3a 100644 --- a/src/glade-widget.c +++ b/src/glade-widget.c @@ -546,8 +546,11 @@ glade_widget_set_class (GladeWidget *widget, GladeWidgetClass *klass) { property_class = list->data; property = glade_property_new (property_class, widget); - if (!property) + if (!property) { + g_print ("Failed to create [%s] property.\n", + property_class->id); continue; + } widget->properties = g_list_prepend (widget->properties, property); } @@ -617,23 +620,19 @@ glade_widget_get_property (GladeWidget *widget, const char *id_property) g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL); g_return_val_if_fail (id_property != NULL, NULL); - list = widget->properties; - for (; list; list = list->next) - { + for (list = widget->properties; list; list = list->next) { property = list->data; if (strcmp (property->class->id, id_property) == 0) return property; } - list = widget->packing_properties; - for (; list; list = list->next) - { + for (list = widget->packing_properties; list; list = list->next) { property = list->data; if (strcmp (property->class->id, id_property) == 0) return property; } - g_warning ("Could not get property %s for widget %s\n", + g_warning ("Could not get property \"%s\" for widget %s", id_property, widget->name); return NULL; @@ -1467,9 +1466,12 @@ glade_widget_new_from_node_real (GladeXmlNode *node, return NULL; klass = glade_widget_class_get_by_name (class_name); - g_free (class_name); - if (!klass) + if (!klass) { + g_warning ("Widget class %s unknown.", class_name); + g_free (class_name); return NULL; + } + g_free (class_name); widget_gtk = g_object_new (klass->type, NULL); @@ -1542,16 +1544,21 @@ glade_widget_new_child_from_node (GladeXmlNode *node, if (internalchild) { GtkWidget *child_gtk = glade_widget_get_internal_child (parent, internalchild); - GladeWidgetClass *child_class = - glade_widget_class_get_by_name (G_OBJECT_TYPE_NAME (child_gtk)); + GladeWidgetClass *child_class; + + if (!child_gtk) { + g_warning ("Failed to locate internal child %s of %s", + internalchild, glade_widget_get_name (parent)); + return FALSE; + } + child_class = glade_widget_class_get_by_name (G_OBJECT_TYPE_NAME (child_gtk)); child = glade_widget_new_for_internal_child (child_class, parent, child_gtk, internalchild); - glade_widget_fill_from_node (child_node, child); g_free (internalchild); - } - else - { + glade_widget_fill_from_node (child_node, child); + } else { child = glade_widget_new_from_node_real (child_node, project, parent); - g_return_val_if_fail (child != NULL, FALSE); + if (!child) + return FALSE; gtk_container_add (GTK_CONTAINER (parent->widget), child->widget); } diff --git a/widgets/gtk-base.xml b/widgets/gtk-base.xml index f7bc7386..3f8c9efc 100644 --- a/widgets/gtk-base.xml +++ b/widgets/gtk-base.xml @@ -20,7 +20,7 @@ - + diff --git a/widgets/gtkcheckbutton.xml b/widgets/gtkcheckbutton.xml index e6b91183..bf4662d6 100644 --- a/widgets/gtkcheckbutton.xml +++ b/widgets/gtkcheckbutton.xml @@ -1,11 +1,8 @@ + - - - - diff --git a/widgets/gtkradiobutton.xml b/widgets/gtkradiobutton.xml index 7fc96849..1b2a7f59 100644 --- a/widgets/gtkradiobutton.xml +++ b/widgets/gtkradiobutton.xml @@ -1,9 +1,13 @@ - + - + + String + glade_gtk_radio_button_set_group + glade_gtk_radio_button_get_group + - \ No newline at end of file +