diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-10-09 20:24:54 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-10-09 20:24:54 +0800 |
commit | 3012f7b1f28abda4cb15c50d061af165889bc08b (patch) | |
tree | 696b48556a677f51aadfb517bc89c3ddf32d83f3 /widgets | |
parent | a2821bc528a4968d67a8e587ec31d6d69abcfbc6 (diff) | |
download | gsoc2013-evolution-3012f7b1f28abda4cb15c50d061af165889bc08b.tar gsoc2013-evolution-3012f7b1f28abda4cb15c50d061af165889bc08b.tar.gz gsoc2013-evolution-3012f7b1f28abda4cb15c50d061af165889bc08b.tar.bz2 gsoc2013-evolution-3012f7b1f28abda4cb15c50d061af165889bc08b.tar.lz gsoc2013-evolution-3012f7b1f28abda4cb15c50d061af165889bc08b.tar.xz gsoc2013-evolution-3012f7b1f28abda4cb15c50d061af165889bc08b.tar.zst gsoc2013-evolution-3012f7b1f28abda4cb15c50d061af165889bc08b.zip |
Removed the assertion that there must be at least 1 column. No way to
2000-10-06 Not Zed <NotZed@HelixCode.com>
* e-table-item.c (eti_header_structure_changed): Removed the
assertion that there must be at least 1 column. No way to remove
all columns otherwise (which the header allows).
* e-table.c (et_xml_config_header): Reconfigure header based on
xml nodes for header.
(et_real_set_specification): Just configure the header only, dont
try to recreate everything.
2000-10-05 Not Zed <NotZed@HelixCode.com>
* e-table-scrolled.c (e_table_scrolled_set_specification): Set the
spec on a scrolled etable.
(e_table_scrolled_load_specification): Likewise for load.
* e-table.c (et_real_set_specification): Allow you to set the
specification after the widget was created.
(et_real_construct): Changed to use et_real_set_specification to
set the spec.
(e_table_load_specification): New frunction, load the
speficication from a specific file.
(e_table_set_specification): NEw function to set the specification
from a string.
svn path=/trunk/; revision=5795
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/table/e-table-item.c | 3 | ||||
-rw-r--r-- | widgets/table/e-table-scrolled.c | 20 | ||||
-rw-r--r-- | widgets/table/e-table-scrolled.h | 2 | ||||
-rw-r--r-- | widgets/table/e-table.c | 82 | ||||
-rw-r--r-- | widgets/table/e-table.h | 3 |
5 files changed, 108 insertions, 2 deletions
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index 0e329486b4..070b55b9da 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -811,8 +811,9 @@ eti_header_structure_changed (ETableHeader *eth, ETableItem *eti) /* * There should be at least one column + * BUT: then you can't remove all columns from a header and add new ones. */ - g_assert (eti->cols != 0); + /*g_assert (eti->cols != 0);*/ if (eti->cell_views){ eti_unrealize_cell_views (eti); diff --git a/widgets/table/e-table-scrolled.c b/widgets/table/e-table-scrolled.c index 50cb01a440..16a99bbcb0 100644 --- a/widgets/table/e-table-scrolled.c +++ b/widgets/table/e-table-scrolled.c @@ -216,6 +216,26 @@ e_table_scrolled_save_specification (ETableScrolled *ets, gchar *filename) e_table_save_specification(ets->table, filename); } +int +e_table_scrolled_set_specification(ETableScrolled *ets, const char *spec) +{ + g_return_val_if_fail(ets != NULL, -1); + g_return_val_if_fail(E_IS_TABLE_SCROLLED(ets), -1); + g_return_val_if_fail(spec != NULL, -1); + + return e_table_set_specification(ets->table, spec); +} + +int +e_table_scrolled_load_specification(ETableScrolled *ets, gchar *filename) +{ + g_return_val_if_fail(ets != NULL, -1); + g_return_val_if_fail(E_IS_TABLE_SCROLLED(ets), -1); + g_return_val_if_fail(filename != NULL, -1); + + return e_table_load_specification(ets->table, filename); +} + void e_table_scrolled_set_cursor_row (ETableScrolled *ets, int row) { diff --git a/widgets/table/e-table-scrolled.h b/widgets/table/e-table-scrolled.h index 0dd9168803..8543f59d2f 100644 --- a/widgets/table/e-table-scrolled.h +++ b/widgets/table/e-table-scrolled.h @@ -48,6 +48,8 @@ GtkWidget *e_table_scrolled_new_from_spec_file (ETableHeader *full_he gchar *e_table_scrolled_get_specification (ETableScrolled *e_table_scrolled); void e_table_scrolled_save_specification (ETableScrolled *e_table_scrolled, gchar *filename); +int e_table_scrolled_set_specification (ETableScrolled *e_table_scrolled, const char *spec); +int e_table_scrolled_load_specification (ETableScrolled *e_table_scrolled, gchar *filename); void e_table_scrolled_set_cursor_row (ETableScrolled *e_table_scrolled, int row); diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 294cfa9968..a9598c214f 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -625,6 +625,32 @@ et_xml_to_header (ETable *e_table, ETableHeader *full_header, xmlNode *xmlColumn } static void +et_xml_config_header (ETable *e_table, xmlNode *xmlColumns) +{ + xmlNode *column; + const int max_cols = e_table_header_count(e_table->full_header); + int i; + + for (i=e_table_header_count(e_table->header)-1;i>=0;i--) { + e_table_header_remove(e_table->header, i); + } + + for (column = xmlColumns->childs; column; column = column->next) { + char *content; + int col; + + content = xmlNodeListGetString (column->doc, column->childs, 1); + col = atoi (content); + xmlFree (content); + + if (col >= max_cols) + continue; + + e_table_header_add_column (e_table->header, e_table_header_get_column (e_table->full_header, col), -1); + } +} + +static void et_grouping_xml_to_sort_info (ETable *table, xmlNode *grouping) { int i; @@ -657,6 +683,25 @@ et_grouping_xml_to_sort_info (ETable *table, xmlNode *grouping) GTK_SIGNAL_FUNC (sort_info_changed), table); } +static int +et_real_set_specification (ETable *e_table, xmlDoc *xmlSpec) +{ + xmlNode *xmlRoot; + xmlNode *xmlColumns; + xmlNode *xmlGrouping; + + xmlRoot = xmlDocGetRootElement (xmlSpec); + xmlColumns = e_xml_get_child_by_name (xmlRoot, "columns-shown"); + xmlGrouping = e_xml_get_child_by_name (xmlRoot, "grouping"); + + if ((xmlColumns == NULL) || (xmlGrouping == NULL)) + return -1; + + et_xml_config_header(e_table, xmlColumns); + + return 0; +} + static ETable * et_real_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm, xmlDoc *xmlSpec) @@ -676,7 +721,6 @@ et_real_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm, no_header = e_xml_get_integer_prop_by_name(xmlRoot, "no-header"); e_table->use_click_to_add = e_xml_get_integer_prop_by_name(xmlRoot, "click-to-add"); - e_table->full_header = full_header; gtk_object_ref (GTK_OBJECT (full_header)); @@ -901,6 +945,24 @@ e_table_get_specification (ETable *e_table) return buffer; } +int +e_table_set_specification (ETable *e_table, const char *spec) +{ + xmlDoc *xmlSpec; + int ret; + + g_return_val_if_fail(e_table != NULL, -1); + g_return_val_if_fail(E_IS_TABLE(e_table), -1); + g_return_val_if_fail(spec != NULL, -1); + + /* doesn't work yet, sigh */ + xmlSpec = xmlParseMemory ((char *)spec, strlen(spec)); + ret = et_real_set_specification(e_table, xmlSpec); + xmlFreeDoc (xmlSpec); + + return ret; +} + void e_table_save_specification (ETable *e_table, gchar *filename) { @@ -914,6 +976,24 @@ e_table_save_specification (ETable *e_table, gchar *filename) xmlFreeDoc (doc); } +int +e_table_load_specification (ETable *e_table, gchar *filename) +{ + xmlDoc *xmlSpec; + int ret; + + g_return_val_if_fail(e_table != NULL, -1); + g_return_val_if_fail(E_IS_TABLE(e_table), -1); + g_return_val_if_fail(filename != NULL, -1); + + /* doesn't work yet, yay */ + xmlSpec = xmlParseFile (filename); + ret = et_real_set_specification(e_table, xmlSpec); + xmlFreeDoc (xmlSpec); + + return ret; +} + void e_table_set_cursor_row (ETable *e_table, int row) { diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h index 5b71fa82c2..d5462ce65c 100644 --- a/widgets/table/e-table.h +++ b/widgets/table/e-table.h @@ -173,6 +173,9 @@ GtkWidget *e_table_new_from_spec_file (ETableHeader *full_header, gchar *e_table_get_specification (ETable *e_table); void e_table_save_specification (ETable *e_table, gchar *filename); +/* note that it is more efficient to provide the spec at creation time */ +int e_table_set_specification (ETable *e_table, const char *spec); +int e_table_load_specification (ETable *e_table, gchar *filename); void e_table_set_cursor_row (ETable *e_table, int row); |