diff src/rcfile.c @ 1466:6e020d3ab168

added possibility to update existing layout window from config
author nadvornik
date Fri, 20 Mar 2009 14:36:59 +0000
parents 1b3751ac4743
children 607c60506863
line wrap: on
line diff
--- a/src/rcfile.c	Fri Mar 20 11:52:29 2009 +0000
+++ b/src/rcfile.c	Fri Mar 20 14:36:59 2009 +0000
@@ -777,6 +777,19 @@
 	gboolean startup; /* reading config for the first time - add commandline and defaults */
 };
 
+static const gchar *options_get_id(const gchar **attribute_names, const gchar **attribute_values)
+{
+	while (*attribute_names)
+		{
+		const gchar *option = *attribute_names++;
+		const gchar *value = *attribute_values++;
+		
+		if (strcmp(option, "id") == 0) return value;
+
+		}
+	return NULL;
+}
+
 
 void options_parse_leaf(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error)
 {
@@ -1001,7 +1014,15 @@
 	if (g_ascii_strcasecmp(element_name, "layout") == 0)
 		{
 		LayoutWindow *lw;
-		lw = layout_new_from_config(attribute_names, attribute_values, parser_data->startup);
+		lw = layout_find_by_layout_id(options_get_id(attribute_names, attribute_values));
+		if (lw) 
+			{
+			layout_update_from_config(lw, attribute_names, attribute_values);
+			}
+		else
+			{
+			lw = layout_new_from_config(attribute_names, attribute_values, parser_data->startup);
+			}
 		options_parse_func_push(parser_data, options_parse_layout, options_parse_layout_end, lw);
 		}
 	else