Commit 6d7ae493 authored by Paolo Borelli's avatar Paolo Borelli

Ifdef out the GladeProperty->child since it's unused. Use...

Ifdef out the GladeProperty->child since it's unused. Use apply_property_from_node also for packing properties.
parent 20960e6c
......@@ -2,6 +2,13 @@
* glade-3.desktop.in: minor updates from glade-2.
* Makefile.am: remove .dektop file on make clean.
* src/glade-property.[ch]: ifdef out the ->child member since it's
unused.
* src/glade-widget.[ch]: move here the get_property_by_id function and
simplify the get_property_by_class. Use apply_property_from_node also
for packing properties.
* src/glade-gtk.c: fixups for the above changes.
* src/glade-editor.c: ditto.
2003-10-31 Paolo Borelli <pborelli@katamail.com>
......
......@@ -1308,7 +1308,7 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
return;
}
property->property = glade_widget_get_property_from_class (widget, class);
property->property = glade_widget_get_property_by_class (widget, class);
g_return_if_fail (property->property != NULL);
g_return_if_fail (property->property->class == property->class);
......
......@@ -404,11 +404,8 @@ glade_gtk_button_set_stock (GObject *object, GValue *value)
glade_widget = glade_widget_get_from_gtk_widget (button);
g_return_if_fail (glade_widget != NULL);
property = glade_property_get_from_id (glade_widget->properties,
"stock");
text = glade_property_get_from_id (glade_widget->properties,
"label");
property = glade_widget_get_property_by_id (glade_widget, "stock", FALSE);
text = glade_widget_get_property_by_id (glade_widget, "label", FALSE);
g_return_if_fail (property != NULL);
g_return_if_fail (text != NULL);
......
......@@ -95,7 +95,7 @@ glade_property_init (GladeProperty *property)
property->class = NULL;
property->value = g_new0 (GValue, 1);
property->enabled = TRUE;
property->child = NULL;
// property->child = NULL;
}
GladeProperty *
......@@ -110,12 +110,14 @@ glade_property_new (GladePropertyClass *class, GladeWidget *widget)
property->class = class;
property->widget = widget;
#if 0
if (class->type == GLADE_PROPERTY_TYPE_OBJECT) {
property->child = glade_widget_new_from_class (class->child,
widget->project,
widget);
return property;
}
#endif
/* Create an empty default if the class does not specify a default value */
if (!class->def) {
......@@ -152,26 +154,6 @@ glade_property_new (GladePropertyClass *class, GladeWidget *widget)
return property;
}
GladeProperty *
glade_property_get_from_id (GList *settings_list, const gchar *id)
{
GList *list;
GladeProperty *property;
g_return_val_if_fail (id != NULL, NULL);
for (list = settings_list; list; list = list->next) {
property = list->data;
g_return_val_if_fail (property, NULL);
g_return_val_if_fail (property->class, NULL);
g_return_val_if_fail (property->class->id, NULL);
if (strcmp (property->class->id, id) == 0)
return property;
}
return NULL;
}
static void
glade_property_emit_changed (GladeProperty *property)
{
......@@ -372,8 +354,10 @@ glade_property_free (GladeProperty *property)
g_free (property->value);
property->value = NULL;
#if 0
if (property->child)
g_warning ("Implmenet free property->child\n");
#endif
g_free (property);
}
......
......@@ -38,9 +38,9 @@ struct _GladeProperty
* of the property->input state for the loaded
* widget.
*/
#if 0
GladeWidget *child; /* A GladeProperty of type object has a child */
#endif
gboolean loading;
};
......@@ -70,10 +70,6 @@ GladeChoice * glade_property_get_enum (GladeProperty *property);
void glade_property_get_from_widget (GladeProperty *property);
/* Get a GladeProperty */
GladeProperty *glade_property_get_from_id (GList *settings_list,
const gchar *id);
/* XML i/o */
GladeXmlNode *glade_property_write (GladeXmlContext *context, GladeProperty *property);
......
......@@ -464,11 +464,9 @@ glade_widget_set_contents (GladeWidget *widget)
class = widget->class;
if (glade_widget_class_has_property (class, "label"))
property = glade_property_get_from_id (widget->properties,
"label");
property = glade_widget_get_property_by_id (widget, "label", FALSE);
if (glade_widget_class_has_property (class, "title"))
property = glade_property_get_from_id (widget->properties,
"title");
property = glade_widget_get_property_by_id (widget, "title", FALSE);
if (property) {
g_value_init (value, G_TYPE_STRING);
......@@ -929,77 +927,65 @@ glade_widget_get_class (GladeWidget *widget)
}
/**
* glade_widget_get_property_from_list:
* @list: The list of GladeProperty
* @class: The Class that we are trying to match with GladeProperty
* @silent: True if we should warn when a property is not included in the list
* glade_widget_get_property_by_class:
* @widget:
* @property_class:
*
* Give a list of GladeProperties find the one that has ->class = to @class.
* This function recurses into child objects if needed.
* Given a glade Widget, it returns the property that correspons to @property_class
*
* Return Value:
**/
static GladeProperty *
glade_widget_get_property_from_list (GList *list,
GladePropertyClass *class,
gboolean silent)
GladeProperty *
glade_widget_get_property_by_class (GladeWidget *widget,
GladePropertyClass *property_class)
{
GladeProperty *property = NULL;
GladeProperty *property;
GList *list;
if (list == NULL)
return NULL;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (property_class), NULL);
if (property_class->packing)
list = widget->packing_properties;
else
list = widget->properties;
for (; list; list = list->next) {
property = list->data;
if (property->class == class)
break;
if (property->child != NULL) {
property = glade_widget_get_property_from_list (property->child->properties,
class, TRUE);
if (property != NULL)
break;
}
}
if (list == NULL) {
if (!silent)
g_warning ("Could not find the GladeProperty %s:%s",
class->id,
class->name);
return NULL;
if (property->class == property_class)
return property;
}
return property;
g_warning ("Could not get property for widget %s of %s class\n",
widget->name, property_class->name);
return NULL;
}
/**
* glade_widget_get_property_from_class:
* @widget:
* @property_class:
*
* Given a glade Widget, it returns the property that correspons to @property_class
*
* Return Value:
**/
GladeProperty *
glade_widget_get_property_from_class (GladeWidget *widget,
GladePropertyClass *property_class)
glade_widget_get_property_by_id (GladeWidget *widget,
const gchar *id,
gboolean packing)
{
GladeProperty *property;
GList *list;
GladeProperty *property;
if (property_class->packing)
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
g_return_val_if_fail (id != NULL, NULL);
if (packing)
list = widget->packing_properties;
else
list = widget->properties;
property = glade_widget_get_property_from_list (list, property_class, FALSE);
if (!property)
g_warning ("Could not get property for widget %s of %s class\n",
widget->name, widget->class->name);
for (; list; list = list->next) {
property = list->data;
if (strcmp (property->class->id, id) == 0)
return property;
}
return property;
g_warning ("Could not get property %s for widget %s\n",
id, widget->name);
return NULL;
}
/**
......@@ -1251,7 +1237,9 @@ glade_widget_write_child (GladeXmlContext *context, GtkWidget *gtk_widget)
}
static gboolean
glade_widget_apply_property_from_node (GladeXmlNode *node, GladeWidget *widget)
glade_widget_apply_property_from_node (GladeXmlNode *node,
GladeWidget *widget,
gboolean packing)
{
GladeProperty *property;
GValue *gvalue;
......@@ -1260,22 +1248,16 @@ glade_widget_apply_property_from_node (GladeXmlNode *node, GladeWidget *widget)
id = glade_xml_get_property_string_required (node, GLADE_XML_TAG_NAME, NULL);
value = glade_xml_get_content (node);
if (!value || !id)
return FALSE;
glade_util_replace (id, '_', '-');
property = glade_property_get_from_id (widget->properties, id);
if (property == NULL) {
g_warning ("Could not apply property from node. Id :%s\n",
id);
property = glade_widget_get_property_by_id (widget, id, packing);
if (!property)
return FALSE;
}
gvalue = glade_property_class_make_gvalue_from_string (property->class,
value);
glade_property_set (property, gvalue);
g_free (id);
......@@ -1344,7 +1326,7 @@ glade_widget_fill_from_node (GladeXmlNode *node, GladeWidget *widget)
if (!glade_xml_node_verify_silent (child, GLADE_XML_TAG_PROPERTY))
continue;
if (!glade_widget_apply_property_from_node (child, widget)) {
if (!glade_widget_apply_property_from_node (child, widget, FALSE)) {
g_warning ("Failed to apply property");
continue;
}
......@@ -1419,7 +1401,6 @@ glade_widget_new_child_from_node (GladeXmlNode *node,
{
gchar *internalchild;
GladeXmlNode *child_node;
GladeXmlNode *child_properties;
GladeWidget *child;
if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
......@@ -1462,44 +1443,19 @@ glade_widget_new_child_from_node (GladeXmlNode *node,
/* Get the packing properties */
child_node = glade_xml_search_child (node, GLADE_XML_TAG_PACKING);
if (child_node) {
child_properties = glade_xml_node_get_children (child_node);
GladeXmlNode *property_node;
property_node = glade_xml_node_get_children (child_node);
for (; child_properties; child_properties = glade_xml_node_next (child_properties)) {
GladeProperty *property;
char *id;
char *value;
GValue *gvalue;
for (; property_node; property_node = glade_xml_node_next (property_node)) {
/* we should be on a <property ...> tag */
if (!glade_xml_node_verify (child_properties, GLADE_XML_TAG_PROPERTY))
if (!glade_xml_node_verify (property_node, GLADE_XML_TAG_PROPERTY))
continue;
/* the tag should have the form <property name="...id...">...value...</property>*/
id = glade_xml_get_property_string_required (child_properties, GLADE_XML_TAG_NAME, NULL);
value = glade_xml_get_content (child_properties);
if (!value || !id) {
g_warning ("Invalid property %s:%s\n", value, id);
g_free (value);
g_free (id);
if (!glade_widget_apply_property_from_node (property_node, child, TRUE)) {
g_warning ("Failed to apply packing property");
continue;
}
glade_util_replace (id, '_', '-');
property = glade_property_get_from_id (child->packing_properties, id);
if (!property) {
g_warning ("Could not apply property from node. Id :%s\n",
id);
continue;
}
gvalue = glade_property_class_make_gvalue_from_string (property->class,
value);
glade_property_set (property, gvalue);
g_free (value);
g_free (id);
g_free (gvalue);
}
}
......
......@@ -82,8 +82,12 @@ const gchar *glade_widget_get_name (GladeWidget *widget);
GladeWidgetClass *glade_widget_get_class (GladeWidget *widget);
GladeProperty *glade_widget_get_property_from_class (GladeWidget *widget,
GladePropertyClass *property_class);
GladeProperty *glade_widget_get_property_by_class (GladeWidget *widget,
GladePropertyClass *property_class);
GladeProperty *glade_widget_get_property_by_id (GladeWidget *widget,
const gchar *id,
gboolean packing);
void glade_widget_set_name (GladeWidget *widget, const gchar *name);
......
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