Try to find placeholder when node at given path doesn't exist

This commit is contained in:
Yevgen Muntyan 2005-11-18 13:05:59 +00:00
parent 6943242743
commit 913af05ba8
2 changed files with 29 additions and 9 deletions

View File

@ -84,7 +84,7 @@ G_STMT_START { \
} G_STMT_END
/* walking nodes stops when func returns FALSE */
/* walking nodes stops when func returns TRUE */
typedef gboolean (*NodeForeachFunc) (Node *node,
gpointer data);
@ -819,7 +819,7 @@ moo_ui_xml_add_item (MooUIXML *xml,
merge = lookup_merge (xml, merge_id);
g_return_val_if_fail (merge != NULL, NULL);
parent = moo_ui_xml_get_node (xml, parent_path);
parent = moo_ui_xml_find_node (xml, parent_path);
g_return_val_if_fail (parent != NULL, NULL);
switch (parent->type)
@ -1015,7 +1015,7 @@ moo_ui_xml_insert_markup_after (MooUIXML *xml,
if (parent_path)
{
parent = moo_ui_xml_get_node (xml, parent_path);
parent = moo_ui_xml_find_node (xml, parent_path);
g_return_if_fail (parent != NULL);
}
else
@ -1047,7 +1047,7 @@ moo_ui_xml_insert_markup_before (MooUIXML *xml,
if (parent_path)
{
parent = moo_ui_xml_get_node (xml, parent_path);
parent = moo_ui_xml_find_node (xml, parent_path);
g_return_if_fail (parent != NULL);
}
else
@ -1079,7 +1079,7 @@ moo_ui_xml_insert_markup (MooUIXML *xml,
if (parent_path)
{
parent = moo_ui_xml_get_node (xml, parent_path);
parent = moo_ui_xml_find_node (xml, parent_path);
g_return_if_fail (parent != NULL);
}
else
@ -1221,6 +1221,24 @@ moo_ui_xml_get_node (MooUIXML *xml,
}
MooUINode*
moo_ui_xml_find_node (MooUIXML *xml,
const char *path)
{
MooUINode *node;
g_return_val_if_fail (MOO_IS_UI_XML (xml), NULL);
g_return_val_if_fail (path != NULL, NULL);
node = moo_ui_xml_get_node (xml, path);
if (!node)
node = moo_ui_xml_find_placeholder (xml, path);
return node;
}
static gboolean
find_placeholder_func (Node *node,
gpointer user_data)
@ -1231,15 +1249,15 @@ find_placeholder_func (Node *node,
} *data = user_data;
if (node->type != PLACEHOLDER)
return TRUE;
return FALSE;
if (!strcmp (node->name, data->name))
{
data->found = node;
return FALSE;
return TRUE;
}
return TRUE;
return FALSE;
}
MooUINode*
@ -1409,7 +1427,7 @@ static void
xml_add_item_widget (MooUIXML *xml,
GtkWidget *widget)
{
g_signal_connect (widget, "notify::visibility",
g_signal_connect (widget, "notify::visible",
G_CALLBACK (visibility_notify), xml);
}

View File

@ -123,6 +123,8 @@ void moo_ui_xml_add_ui_from_string (MooUIXML *xml,
MooUINode *moo_ui_xml_get_node (MooUIXML *xml,
const char *path);
MooUINode *moo_ui_xml_find_node (MooUIXML *xml,
const char *path_or_placeholder);
MooUINode *moo_ui_xml_find_placeholder (MooUIXML *xml,
const char *name);
char *moo_ui_node_get_path (MooUINode *node);