aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-table-state.c
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/table/e-table-state.c')
-rw-r--r--widgets/table/e-table-state.c65
1 files changed, 41 insertions, 24 deletions
diff --git a/widgets/table/e-table-state.c b/widgets/table/e-table-state.c
index c9049b7a18..c978487368 100644
--- a/widgets/table/e-table-state.c
+++ b/widgets/table/e-table-state.c
@@ -2,8 +2,9 @@
/*
* E-table-state.c: Savable state of a table.
*
- * Author:
+ * Authors:
* Chris Lahey <clahey@ximian.com>
+ * Miguel de Icaza (miguel@ximian.com)
*
* (C) 2000 Ximian, Inc.
*/
@@ -87,37 +88,44 @@ e_table_state_load_from_string (ETableState *state,
}
}
-typedef struct
-{
+typedef struct {
int column;
double expansion;
} int_and_double;
void
-e_table_state_load_from_node (ETableState *state,
- const xmlNode *node)
+e_table_state_load_from_node (ETableState *state,
+ const xmlNode *node)
{
xmlNode *children;
GList *list = NULL, *iterator;
gdouble state_version;
int i;
- state_version = e_xml_get_double_prop_by_name_with_default(node, "state-version", STATE_VERSION);
+ state_version = e_xml_get_double_prop_by_name_with_default (
+ node, "state-version", STATE_VERSION);
if (state->sort_info)
- gtk_object_unref(GTK_OBJECT(state->sort_info));
+ gtk_object_unref (GTK_OBJECT(state->sort_info));
+
state->sort_info = NULL;
- for (children = node->xmlChildrenNode; children; children = children->next) {
- if (!strcmp(children->name, "column")) {
+ children = node->xmlChildrenNode;
+ for (; children; children = children->next) {
+ if (!strcmp (children->name, "column")) {
int_and_double *column_info = g_new(int_and_double, 1);
- column_info->column = e_xml_get_integer_prop_by_name(children, "source");
- column_info->expansion = e_xml_get_double_prop_by_name_with_default(children, "expansion", -2);
+ column_info->column = e_xml_get_integer_prop_by_name(
+ children, "source");
+ column_info->expansion =
+ e_xml_get_double_prop_by_name_with_default(
+ children, "expansion", -2);
- list = g_list_append(list, column_info);
- } else if (state->sort_info == NULL && !strcmp(children->name, "grouping")) {
+ list = g_list_append (list, column_info);
+ } else if (state->sort_info == NULL &&
+ !strcmp (children->name, "grouping")) {
state->sort_info = e_table_sort_info_new();
- e_table_sort_info_load_from_node(state->sort_info, children, state_version);
+ e_table_sort_info_load_from_node(
+ state->sort_info, children, state_version);
}
}
g_free(state->columns);
@@ -125,11 +133,14 @@ e_table_state_load_from_node (ETableState *state,
state->col_count = g_list_length(list);
state->columns = g_new(int, state->col_count);
state->expansions = g_new(double, state->col_count);
- for (iterator = list, i = 0; iterator; iterator = g_list_next(iterator), i++) {
+
+ for (iterator = list, i = 0; iterator; i++) {
int_and_double *column_info = iterator->data;
- state->columns[i] = column_info->column;
- state->expansions[i] = column_info->expansion;
- g_free(column_info);
+
+ state->columns [i] = column_info->column;
+ state->expansions [i] = column_info->expansion;
+ g_free (column_info);
+ iterator = g_list_next (iterator);
}
g_list_free(list);
}
@@ -196,7 +207,7 @@ e_table_state_save_to_node (ETableState *state,
/**
* e_table_state_duplicate:
- * @state: state to duplicate
+ * @state: The ETableState to duplicate
*
* This creates a copy of the %ETableState @state
*
@@ -205,11 +216,17 @@ e_table_state_save_to_node (ETableState *state,
ETableState *
e_table_state_duplicate (ETableState *state)
{
- ETableState *new_state = e_table_state_new ();
- char *state_str = e_table_state_save_to_string (state);
-
- printf ("This is the state: \n%s\n", state_str);
- e_table_state_load_from_string (new_state, state_str);
+ ETableState *new_state;
+ char *copy;
+ g_return_val_if_fail (state != NULL, NULL);
+ g_return_val_if_fail (E_IS_TABLE_STATE (state), NULL);
+
+ new_state = e_table_state_new ();
+ copy = e_table_state_save_to_string (state);
+ e_table_state_load_from_string (new_state, copy);
+ g_free (copy);
+
return new_state;
}
+