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
This commit is contained in:
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -624,6 +624,32 @@ et_xml_to_header (ETable *e_table, ETableHeader *full_header, xmlNode *xmlColumn
|
||||
return nh;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user