From 51284ee84a6e135df27c957701bb6c580d5ecb73 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sat, 23 Dec 2000 05:55:20 +0000 Subject: Destroy text and pixbuf if they exist whether or not is_pixbuf is set. 2000-12-23 Christopher James Lahey * e-table-col.c, e-table-col.h (etc_destroy): Destroy text and pixbuf if they exist whether or not is_pixbuf is set. (e_table_col_new_with_pixbuf): Make new_with_pixbuf take a title argument which is for when you can't display pixmaps. * e-table-column-specification.c (e_table_column_specification_load_from_node): Don't translate the pixbuf string attribute. * e-table-sort-info.c, e-table-sort-info.h (e_table_sort_info_load_from_node): Added a state_version parameter to the load_from_node function. This lets the loader specify which version of ETableState is being processed. If it's less than .05, use the old nested version. If it's greater, use the new flat version. (e_table_sort_info_save_to_node): Changed this to store a list of group and leaf nodes instead of nesting the group nodes and leaf nodes one inside the other. This is much easier to understand and requires less typing when creating a new ETableSpecification's initial ETableState. * e-table-state.c: Changed the state-version parameter to 0.1. (e_table_state_load_from_node): Use e_xml_get_double_prop_by_name_with_default so that we can specify a state-version default of 0.1 for people writing ETableStates by hand. Pass the state-version to e_table_sort_info_load_from_node. * e-table.c (et_col_spec_to_col): Pass the title from the ETableColumnSpecification to the ETableCol even if it's a pixbuf column. svn path=/trunk/; revision=7138 --- widgets/table/e-table-sort-info.c | 51 ++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 17 deletions(-) (limited to 'widgets/table/e-table-sort-info.c') diff --git a/widgets/table/e-table-sort-info.c b/widgets/table/e-table-sort-info.c index bea5bde0eb..c7f5f12525 100644 --- a/widgets/table/e-table-sort-info.c +++ b/widgets/table/e-table-sort-info.c @@ -240,24 +240,42 @@ e_table_sort_info_new (void) void e_table_sort_info_load_from_node (ETableSortInfo *info, - xmlNode *node) + xmlNode *node, + gdouble state_version) { int i; xmlNode *grouping; - i = 0; - for (grouping = node->childs; grouping && !strcmp (grouping->name, "group"); grouping = grouping->childs) { - ETableSortColumn column; - column.column = e_xml_get_integer_prop_by_name (grouping, "column"); - column.ascending = e_xml_get_bool_prop_by_name (grouping, "ascending"); - e_table_sort_info_grouping_set_nth(info, i++, column); - } - i = 0; - for (; grouping && !strcmp (grouping->name, "leaf"); grouping = grouping->childs) { - ETableSortColumn column; - column.column = e_xml_get_integer_prop_by_name (grouping, "column"); - column.ascending = e_xml_get_bool_prop_by_name (grouping, "ascending"); - e_table_sort_info_sorting_set_nth(info, i++, column); + if (state_version <= 0.05) { + i = 0; + for (grouping = node->childs; grouping && !strcmp (grouping->name, "group"); grouping = grouping->childs) { + ETableSortColumn column; + column.column = e_xml_get_integer_prop_by_name (grouping, "column"); + column.ascending = e_xml_get_bool_prop_by_name (grouping, "ascending"); + e_table_sort_info_grouping_set_nth(info, i++, column); + } + i = 0; + for (; grouping && !strcmp (grouping->name, "leaf"); grouping = grouping->childs) { + ETableSortColumn column; + column.column = e_xml_get_integer_prop_by_name (grouping, "column"); + column.ascending = e_xml_get_bool_prop_by_name (grouping, "ascending"); + e_table_sort_info_sorting_set_nth(info, i++, column); + } + } else { + i = 0; + for (grouping = node->childs; grouping && !strcmp (grouping->name, "group"); grouping = grouping->next) { + ETableSortColumn column; + column.column = e_xml_get_integer_prop_by_name (grouping, "column"); + column.ascending = e_xml_get_bool_prop_by_name (grouping, "ascending"); + e_table_sort_info_grouping_set_nth(info, i++, column); + } + i = 0; + for (; grouping && !strcmp (grouping->name, "leaf"); grouping = grouping->next) { + ETableSortColumn column; + column.column = e_xml_get_integer_prop_by_name (grouping, "column"); + column.ascending = e_xml_get_bool_prop_by_name (grouping, "ascending"); + e_table_sort_info_sorting_set_nth(info, i++, column); + } } } @@ -272,11 +290,10 @@ e_table_sort_info_save_to_node (ETableSortInfo *info, const int group_count = e_table_sort_info_grouping_get_count (info); grouping = xmlNewChild (parent, NULL, "grouping", NULL); - node = grouping; for (i = 0; i < group_count; i++) { ETableSortColumn column = e_table_sort_info_grouping_get_nth(info, i); - xmlNode *new_node = xmlNewChild(node, NULL, "group", NULL); + xmlNode *new_node = xmlNewChild(grouping, NULL, "group", NULL); e_xml_set_integer_prop_by_name (new_node, "column", column.column); e_xml_set_bool_prop_by_name (new_node, "ascending", column.ascending); @@ -285,7 +302,7 @@ e_table_sort_info_save_to_node (ETableSortInfo *info, for (i = 0; i < sort_count; i++) { ETableSortColumn column = e_table_sort_info_sorting_get_nth(info, i); - xmlNode *new_node = xmlNewChild(node, NULL, "leaf", NULL); + xmlNode *new_node = xmlNewChild(grouping, NULL, "leaf", NULL); e_xml_set_integer_prop_by_name (new_node, "column", column.column); e_xml_set_bool_prop_by_name (new_node, "ascending", column.ascending); -- cgit v1.2.3