aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-table.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-03-04 04:05:57 +0800
committerChris Lahey <clahey@src.gnome.org>2000-03-04 04:05:57 +0800
commit626f63df0b18cc891b7995a0b7202303efede45d (patch)
tree9a963dfa708abf113b067bf1a11c7592f13cb565 /widgets/table/e-table.c
parentbc0d854e93fa0dd9ca596d1663f389f31f458439 (diff)
downloadgsoc2013-evolution-626f63df0b18cc891b7995a0b7202303efede45d.tar
gsoc2013-evolution-626f63df0b18cc891b7995a0b7202303efede45d.tar.gz
gsoc2013-evolution-626f63df0b18cc891b7995a0b7202303efede45d.tar.bz2
gsoc2013-evolution-626f63df0b18cc891b7995a0b7202303efede45d.tar.lz
gsoc2013-evolution-626f63df0b18cc891b7995a0b7202303efede45d.tar.xz
gsoc2013-evolution-626f63df0b18cc891b7995a0b7202303efede45d.tar.zst
gsoc2013-evolution-626f63df0b18cc891b7995a0b7202303efede45d.zip
Added a bunch of stuff to the TODO list. Put +s before a few of the items
2000-03-04 Christopher James Lahey <clahey@helixcode.com> * TODO: Added a bunch of stuff to the TODO list. Put +s before a few of the items that are finished. * test-table.c: Add a button to save the spec file. * e-table.c, e-table.h: Add loading configurations from files as well as the ability to get the current configuration out of the widget. svn path=/trunk/; revision=2025
Diffstat (limited to 'widgets/table/e-table.c')
-rw-r--r--widgets/table/e-table.c118
1 files changed, 107 insertions, 11 deletions
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 074ed3c2ae..7d1d9afd14 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -58,6 +58,8 @@ et_destroy (GtkObject *object)
g_source_remove(et->rebuild_idle_id);
et->rebuild_idle_id = 0;
}
+
+ xmlFreeDoc (et->specification);
(*e_table_parent_class->destroy)(object);
}
@@ -623,7 +625,7 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
gtk_signal_connect (
GTK_OBJECT (e_table->table_canvas), "size_allocate",
GTK_SIGNAL_FUNC (table_canvas_size_allocate), e_table);
-
+
gtk_widget_show (GTK_WIDGET (e_table->table_canvas));
gtk_table_attach (
GTK_TABLE (e_table), GTK_WIDGET (e_table->table_canvas),
@@ -665,18 +667,14 @@ e_table_fill_table (ETable *e_table, ETableModel *model)
NULL);
}
-void
-e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
- const char *spec)
+static void
+et_real_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
+ xmlDoc *xmlSpec)
{
- xmlDoc *xmlSpec;
xmlNode *xmlRoot;
xmlNode *xmlColumns;
xmlNode *xmlGrouping;
- char *copy;
- copy = g_strdup(spec);
-
GTK_TABLE (e_table)->homogeneous = FALSE;
gtk_table_resize (GTK_TABLE (e_table), 1, 2);
@@ -686,9 +684,6 @@ e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
e_table->model = etm;
gtk_object_ref (GTK_OBJECT (etm));
-
- xmlSpec = xmlParseMemory(copy, strlen(copy) + 1);
- e_table->specification = xmlSpec;
xmlRoot = xmlDocGetRootElement(xmlSpec);
xmlColumns = e_xml_get_child_by_name(xmlRoot, "columns-shown");
@@ -701,6 +696,29 @@ e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
e_table_fill_table (e_table, etm);
}
+void
+e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
+ const char *spec)
+{
+ xmlDoc *xmlSpec;
+ char *copy;
+ copy = g_strdup(spec);
+
+ xmlSpec = xmlParseMemory(copy, strlen(copy));
+ et_real_construct(e_table, full_header, etm, xmlSpec);
+ g_free(copy);
+}
+
+void
+e_table_construct_from_spec_file (ETable *e_table, ETableHeader *full_header, ETableModel *etm,
+ const char *filename)
+{
+ xmlDoc *xmlSpec;
+
+ xmlSpec = xmlParseFile(filename);
+ et_real_construct(e_table, full_header, etm, xmlSpec);
+}
+
GtkWidget *
e_table_new (ETableHeader *full_header, ETableModel *etm, const char *spec)
{
@@ -713,6 +731,84 @@ e_table_new (ETableHeader *full_header, ETableModel *etm, const char *spec)
return (GtkWidget *) e_table;
}
+GtkWidget *
+e_table_new_from_spec_file (ETableHeader *full_header, ETableModel *etm, const char *filename)
+{
+ ETable *e_table;
+
+ e_table = gtk_type_new (e_table_get_type ());
+
+ e_table_construct (e_table, full_header, etm, filename);
+
+ return (GtkWidget *) e_table;
+}
+
+static xmlNode *
+et_build_column_spec(ETable *e_table)
+{
+ xmlNode *columns_shown;
+ gint i;
+ gint col_count;
+
+ columns_shown = xmlNewNode(NULL, "columns-shown");
+
+ col_count = e_table_header_count(e_table->header);
+ for ( i = 0; i < col_count; i++ ) {
+ gchar *text = g_strdup_printf("%d", e_table_header_index(e_table->header, i));
+ xmlNewChild(columns_shown, NULL, "column", text);
+ g_free(text);
+ }
+ return columns_shown;
+}
+
+static xmlNode *
+et_build_grouping_spec(ETable *e_table)
+{
+ xmlNode *grouping;
+ xmlNode *root;
+
+ root = xmlDocGetRootElement(e_table->specification);
+ grouping = xmlCopyNode(e_xml_get_child_by_name(root, "grouping"), TRUE);
+ return grouping;
+}
+
+static xmlDoc *
+et_build_tree (ETable *e_table)
+{
+ xmlDoc *doc;
+ xmlNode *root;
+ doc = xmlNewDoc( "1.0" );
+ if ( doc == NULL )
+ return NULL;
+ root = xmlNewDocNode(doc, NULL, "ETableSpecification", NULL);
+ xmlDocSetRootElement(doc, root);
+ xmlAddChild(root, et_build_column_spec(e_table));
+ xmlAddChild(root, et_build_grouping_spec(e_table));
+ return doc;
+}
+
+gchar *
+e_table_get_specification (ETable *e_table)
+{
+ xmlDoc *doc = et_build_tree (e_table);
+ xmlChar *buffer;
+ gint size;
+ xmlDocDumpMemory(doc,
+ &buffer,
+ &size);
+ xmlFreeDoc(doc);
+ return buffer;
+}
+
+void
+e_table_save_specification (ETable *e_table, gchar *filename)
+{
+ xmlDoc *doc = et_build_tree (e_table);
+ xmlSaveFile(filename, doc);
+ xmlFreeDoc(doc);
+}
+
+
static void
e_table_class_init (GtkObjectClass *object_class)
{