diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2001-01-11 02:15:13 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-01-11 02:15:13 +0800 |
commit | a1ca83afd9f3fa742d9f2c07b990b576d3867668 (patch) | |
tree | b1eedc6f181835247d45a991072458711737bafc /widgets | |
parent | 54c085cc3cec41cc3d5a77efadb98450a7c5b4b6 (diff) | |
download | gsoc2013-evolution-a1ca83afd9f3fa742d9f2c07b990b576d3867668.tar gsoc2013-evolution-a1ca83afd9f3fa742d9f2c07b990b576d3867668.tar.gz gsoc2013-evolution-a1ca83afd9f3fa742d9f2c07b990b576d3867668.tar.bz2 gsoc2013-evolution-a1ca83afd9f3fa742d9f2c07b990b576d3867668.tar.lz gsoc2013-evolution-a1ca83afd9f3fa742d9f2c07b990b576d3867668.tar.xz gsoc2013-evolution-a1ca83afd9f3fa742d9f2c07b990b576d3867668.tar.zst gsoc2013-evolution-a1ca83afd9f3fa742d9f2c07b990b576d3867668.zip |
Added expansions field and loading and saving of that field.
2001-01-10 Christopher James Lahey <clahey@helixcode.com>
* e-table-state.c, e-table-state.h: Added expansions field and
loading and saving of that field.
* e-table.c: Load and save expansion data.
svn path=/trunk/; revision=7366
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/table/e-table-state.c | 33 | ||||
-rw-r--r-- | widgets/table/e-table-state.h | 1 | ||||
-rw-r--r-- | widgets/table/e-table.c | 16 |
3 files changed, 41 insertions, 9 deletions
diff --git a/widgets/table/e-table-state.c b/widgets/table/e-table-state.c index 5bfc9c390b..9d24269322 100644 --- a/widgets/table/e-table-state.c +++ b/widgets/table/e-table-state.c @@ -41,7 +41,14 @@ etst_class_init (GtkObjectClass *klass) klass->destroy = etst_destroy; } -E_MAKE_TYPE(e_table_state, "ETableState", ETableState, etst_class_init, NULL, PARENT_TYPE); +static void +etst_init (ETableState *state) +{ + state->columns = NULL; + state->expansions = NULL; +} + +E_MAKE_TYPE(e_table_state, "ETableState", ETableState, etst_class_init, etst_init, PARENT_TYPE); ETableState * e_table_state_new (void) @@ -79,6 +86,12 @@ e_table_state_load_from_string (ETableState *state, } } +typedef struct +{ + int column; + double expansion; +} int_and_double; + void e_table_state_load_from_node (ETableState *state, const xmlNode *node) @@ -95,22 +108,27 @@ e_table_state_load_from_node (ETableState *state, state->sort_info = NULL; for (children = node->xmlChildrenNode; children; children = children->next) { if (!strcmp(children->name, "column")) { - int *column = g_new(int, 1); + int_and_double *column_info = g_new(int_and_double, 1); - *column = e_xml_get_integer_prop_by_name(children, "source"); + 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); + 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); } } g_free(state->columns); + g_free(state->expansions); 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++) { - state->columns[i] = *(int *)iterator->data; - g_free(iterator->data); + int_and_double *column_info = iterator->data; + state->columns[i] = column_info->column; + state->expansions[i] = column_info->expansion; + g_free(column_info); } g_list_free(list); } @@ -160,10 +178,13 @@ e_table_state_save_to_node (ETableState *state, for (i = 0; i < state->col_count; i++) { int column = state->columns[i]; + double expansion = state->expansions[i]; xmlNode *new_node; new_node = xmlNewChild(node, NULL, "column", NULL); e_xml_set_integer_prop_by_name (new_node, "source", column); + if (expansion >= -1) + e_xml_set_double_prop_by_name(new_node, "expansion", expansion); } diff --git a/widgets/table/e-table-state.h b/widgets/table/e-table-state.h index 0ef8471166..c699f3a1b3 100644 --- a/widgets/table/e-table-state.h +++ b/widgets/table/e-table-state.h @@ -18,6 +18,7 @@ typedef struct { ETableSortInfo *sort_info; int col_count; int *columns; + double *expansions; } ETableState; typedef struct { diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 5c7697c10a..4311005107 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -715,13 +715,21 @@ et_state_to_header (ETable *e_table, ETableHeader *full_header, ETableState *sta for (column = 0; column < state->col_count; column++) { int col; + double expansion; + ETableCol *table_col; col = state->columns[column]; + expansion = state->expansions[column]; if (col >= max_cols) continue; - e_table_header_add_column (nh, e_table_header_get_column (full_header, col), -1); + table_col = e_table_header_get_column (full_header, col); + + if (expansion >= -1) + table_col->expansion = expansion; + + e_table_header_add_column (nh, table_col, -1); } return nh; @@ -822,15 +830,17 @@ e_table_get_state_object (ETable *e_table) state->col_count = e_table_header_count (e_table->header); full_col_count = e_table_header_count (e_table->full_header); state->columns = g_new(int, state->col_count); + state->expansions = g_new(double, state->col_count); for (i = 0; i < state->col_count; i++) { - int col_idx = e_table_header_index(e_table->header, i); + ETableCol *col = e_table_header_get_column(e_table->header, i); state->columns[i] = -1; for (j = 0; j < full_col_count; j++) { - if (col_idx == e_table_header_index(e_table->full_header, j)) { + if (col->col_idx == e_table_header_index(e_table->full_header, j)) { state->columns[i] = j; break; } } + state->expansions[i] = col->expansion; } return state; |