Commit a9feef66 authored by Joaquín Cuenca Abela's avatar Joaquín Cuenca Abela

load xml files fixes

parent e828db55
2003-05-08 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
* src/glade-placeholder.c, src/glade-property.c,
src/glade-utils.[ch], src/glade-widget.c, src/glade-xml-utils.[ch]:
fix a bunch of memleaks on error conditions, change the name
of the properties from '_' to '-' when read from the xml file
(and when we write it to a xml file), remove the need of a packing
property on each child node.
2003-05-04 Paolo Borelli <pborelli@katamail.com>
* src/glade-editor.[ch]: gtk_object -> g_object conversion
* src/glade-project.[ch]: remove glade_project_get_active
* src/glade-editor.c: ditto
* src/glade-palette.c: update for the above & remove deprecated function
* src/glade-project-window.c: update for the above
* src/glade-menu-editor.c: on delete event hide the keys dialog
instad of destroying it
2003-05-01 Paolo Borelli <pborelli@katamail.com>
* src/glade-keys-dialog.[ch]: init of the keys dialog.
* src/glade-menu-editor.c: idem.
2003-05-01 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
* src/glade-editor.[ch]: changes to undo & redo on changes to the widget
name.
* src/glade-command.[ch]: Idem.
* src/glade-project-window.c: Idem.
* src/glade-property.c: Idem.
2003-05-01 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
......@@ -39,9 +39,7 @@
2003-05-01 Paolo Borelli <pborelli@katamail.com>
* src/glade-palette.[ch]: fix GLADE_PALETTE macro and misc cleanups.
* src/glade-project-window.c: cleanups.
* src/glade-placeholder.c: add missing include and some cleanups.
2003-04-25 Archit Baweja <bighead@users.sourceforge.net>
......@@ -132,9 +130,7 @@
* src/glade-project-window.c (gpw_cut_cb): use glade_command_cut().
(gpw_paste_cb): use glade_command_paste().
* src/glade-placeholder.c (glade_placeholder_paste_cb): likewise.
* src/glade-widget.c (glade_widget_cut): likewise.
2002-05-26 Archit Baweja <bighead@users.sourceforge.net>
......
......@@ -536,13 +536,28 @@ glade_placeholder_get_from_properties (GladeWidget *parent,
list = gtk_container_children (GTK_CONTAINER (parent->widget));
val = g_hash_table_lookup (properties, "position");
if (!val)
return NULL;
box_child = (GtkBoxChild *) g_list_nth (list, atoi (val));
placeholder = box_child->widget;
g_assert (placeholder);
} else if (glade_widget_class_is (parent->class, "GtkTable")) {
GtkTableChild *child;
gint col = atoi (g_hash_table_lookup (properties, "cell_x"));
gint row = atoi (g_hash_table_lookup (properties, "cell_y"));
const char *val;
int col;
int row;
val = g_hash_table_lookup (properties, "cell_x");
if (!val)
return NULL;
col = atoi (val);
val = g_hash_table_lookup (properties, "cell_y");
if (!val)
return NULL;
row = atoi (val);
list = GTK_TABLE (parent->widget)->children;
for (; list; list = list->next) {
......
......@@ -622,18 +622,44 @@ GladeXmlNode *
glade_property_write (GladeXmlContext *context, GladeProperty *property)
{
GladeXmlNode *node;
gchar *temp;
gchar *tmp;
if (!property->enabled)
return NULL;
/* create a new node <property ...> */
node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
glade_xml_node_set_property_string (node, GLADE_XML_TAG_NAME, property->class->id);
temp = glade_property_class_make_string_from_gvalue (property->class,
if (!node)
return NULL;
/* we should change each '-' by '_' on the name of the property (<property name="...">) */
tmp = g_strdup(property->class->id);
if (tmp == NULL) {
glade_xml_node_delete (node);
return NULL;
}
glade_util_replace (tmp, '-', '_');
/* put the name="..." part on the <property ...> tag */
glade_xml_node_set_property_string (node, GLADE_XML_TAG_NAME, tmp);
g_free (tmp);
/* convert the value of this property to a string, and put it between
* the openning and the closing of the property tag */
tmp = glade_property_class_make_string_from_gvalue (property->class,
property->value);
glade_xml_set_content (node, temp);
g_free (temp);
if (tmp == NULL)
{
glade_xml_node_delete (node);
return NULL;
}
glade_xml_set_content (node, tmp);
g_free (tmp);
/* return the created node */
return node;
}
......
......@@ -338,4 +338,19 @@ glade_util_file_selection_new (const gchar *title, GtkWindow *parent)
return filesel;
}
/**
* changes each occurence of the character a on the string str by the character b.
*/
void
glade_util_replace (char *str, char a, char b)
{
g_return_if_fail (str != NULL);
while (*str != 0) {
if (*str == a)
*str = b;
str = g_utf8_next_char (str);
}
}
......@@ -17,21 +17,22 @@ typedef enum
GladeEscDestroys
} GladeEscAction;
void glade_util_widget_set_tooltip (GtkWidget *widget, const gchar *str);
GType glade_util_get_type_from_name (const gchar *name);
void glade_util_ui_warn (const gchar *warning);
void glade_util_flash_message (guint context_id, gchar *format, ...);
void glade_util_widget_set_tooltip (GtkWidget *widget, const gchar *str);
GType glade_util_get_type_from_name (const gchar *name);
void glade_util_ui_warn (const gchar *warning);
void glade_util_flash_message (guint context_id, gchar *format, ...);
/* This is a GCompareFunc for comparing the labels of 2 stock items, ignoring
any '_' characters. It isn't particularly efficient. */
gint glade_util_compare_stock_labels (gconstpointer a, gconstpointer b);
gint glade_util_compare_stock_labels (gconstpointer a, gconstpointer b);
void glade_util_hide_window (GtkWindow *window);
gint glade_util_check_key_is_esc (GtkWidget *widget, GdkEventKey *event, gpointer data);
gchar *glade_util_gtk_combo_func (gpointer data);
gpointer glade_util_gtk_combo_find (GtkCombo *combo);
void glade_util_hide_window (GtkWindow *window);
gint glade_util_check_key_is_esc (GtkWidget *widget, GdkEventKey *event, gpointer data);
gchar *glade_util_gtk_combo_func (gpointer data);
gpointer glade_util_gtk_combo_find (GtkCombo *combo);
GtkWidget *glade_util_file_selection_new (const gchar *title, GtkWindow *parent);
GtkWidget *glade_util_file_selection_new (const gchar *title, GtkWindow *parent);
void glade_util_replace (char *str, char a, char b);
G_END_DECLS
......
......@@ -1381,7 +1381,8 @@ glade_widget_apply_property_from_node (GladeXmlNode *node, GladeWidget *widget)
gchar *value;
gchar *id;
id = glade_xml_get_property_string_required (node, GLADE_XML_TAG_NAME, NULL);
id = glade_xml_get_property_string_required (node, GLADE_XML_TAG_NAME, NULL);
glade_util_replace (id, '_', '-');
value = glade_xml_get_content (node);
if (!value || !id)
......@@ -1478,6 +1479,7 @@ glade_widget_properties_hash_from_node (GladeXmlNode *node)
child = glade_xml_node_get_children (node);
for (; child != NULL; child = glade_xml_node_next (child)) {
if (!glade_xml_node_verify (child, GLADE_XML_TAG_PROPERTY)) {
g_hash_table_destroy (hash);
return NULL;
}
......@@ -1486,9 +1488,13 @@ glade_widget_properties_hash_from_node (GladeXmlNode *node)
if (!value || !id) {
g_warning ("Invalid property %s:%s\n", value, id);
g_hash_table_destroy (hash);
g_free (value);
g_free (id);
return NULL;
}
glade_util_replace (id, '_', '-');
g_hash_table_insert (hash, id, value);
}
......@@ -1531,19 +1537,31 @@ glade_widget_new_child_from_node (GladeXmlNode *node, GladeProject *project, Gla
return FALSE;
/* Get the packing properties */
child_node = glade_xml_search_child_required (node, GLADE_XML_TAG_PACKING);
if (!child_node)
return FALSE;
packing_properties = glade_widget_properties_hash_from_node (child_node);
child_node = glade_xml_search_child (node, GLADE_XML_TAG_PACKING);
if (child_node)
packing_properties = glade_widget_properties_hash_from_node (child_node);
else
packing_properties = g_hash_table_new (NULL, NULL);
if (packing_properties == NULL)
return FALSE;
/* Get and create the widget */
child_node = glade_xml_search_child_required (node, GLADE_XML_TAG_WIDGET);
if (!child_node)
{
g_hash_table_destroy (packing_properties);
return FALSE;
}
child = glade_widget_new_from_node_real (child_node, project, parent);
g_assert (child);
if (!child)
{
/* not enough memory... and now, how can I signal it and not make the caller believe that
* it was a parsing problem? */
g_hash_table_destroy (packing_properties);
return FALSE;
}
/* Get the placeholder and replace it with the widget */
placeholder = glade_placeholder_get_from_properties (parent, packing_properties);
......
......@@ -599,6 +599,12 @@ glade_xml_node_new (GladeXmlContext *context, const gchar *name)
return (GladeXmlNode *) xmlNewDocNode ((xmlDocPtr) context->doc, context->ns, name, NULL);
}
void
glade_xml_node_delete (GladeXmlNode *node)
{
xmlFreeNode ((xmlDocPtr) node);
}
GladeXmlDoc *
glade_xml_context_get_doc (GladeXmlContext *context)
{
......
......@@ -50,6 +50,7 @@ GladeXmlNode * glade_xml_utils_hash_write (GladeXmlContext *context,
/* Node operations */
GladeXmlNode * glade_xml_node_new (GladeXmlContext *context, const gchar *name);
void glade_xml_node_delete (GladeXmlNode *node);
GladeXmlNode * glade_xml_node_get_children (GladeXmlNode *node);
GladeXmlNode * glade_xml_node_next (GladeXmlNode *node_in);
gboolean glade_xml_node_verify (GladeXmlNode * node, 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