diff options
author | Morten Welinder <mortenw@src.gnome.org> | 2001-10-09 02:39:28 +0800 |
---|---|---|
committer | Morten Welinder <mortenw@src.gnome.org> | 2001-10-09 02:39:28 +0800 |
commit | a191834cb1786763e75c6b32a593c0d854e06a81 (patch) | |
tree | 703e1b985828cab8fc02f206b739870e497b52b2 /widgets | |
parent | e1581b778571f2b7d52cd2c034b88b7b5d0d9083 (diff) | |
download | gsoc2013-evolution-a191834cb1786763e75c6b32a593c0d854e06a81.tar gsoc2013-evolution-a191834cb1786763e75c6b32a593c0d854e06a81.tar.gz gsoc2013-evolution-a191834cb1786763e75c6b32a593c0d854e06a81.tar.bz2 gsoc2013-evolution-a191834cb1786763e75c6b32a593c0d854e06a81.tar.lz gsoc2013-evolution-a191834cb1786763e75c6b32a593c0d854e06a81.tar.xz gsoc2013-evolution-a191834cb1786763e75c6b32a593c0d854e06a81.tar.zst gsoc2013-evolution-a191834cb1786763e75c6b32a593c0d854e06a81.zip |
Final un-bit rotting. Now actually works.
svn path=/trunk/; revision=13504
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/table/sample.table | 38 | ||||
-rw-r--r-- | widgets/table/table-test.c | 6 | ||||
-rw-r--r-- | widgets/table/test-table.c | 93 |
3 files changed, 100 insertions, 37 deletions
diff --git a/widgets/table/sample.table b/widgets/table/sample.table index 45c8ff0691..e1909a2bf7 100644 --- a/widgets/table/sample.table +++ b/widgets/table/sample.table @@ -7,5 +7,39 @@ c1.e c2.e a.e tit-1 DorkC c1.f c2.f a.f tit-2 UDork c1.g c2.g a.g tit-3 Dork--- j k k tit-1 DorkA - - +aaa1 bbb ccc ddd eee +aaa2 bbb ccc ddd eee +aaa3 bbb ccc ddd eee +aaa4 bbb ccc ddd eee +aaa5 bbb ccc ddd eee +aaa6 bbb ccc ddd eee +aaa7 bbb ccc ddd eee +aaa8 bbb ccc ddd eee +aaa9 bbb ccc ddd eee +aaa10 bbb ccc ddd eee +aaa11 bbb ccc ddd eee +aaa12 bbb ccc ddd eee +aaa13 bbb ccc ddd eee +aaa14 bbb ccc ddd eee +aaa15 bbb ccc ddd eee +aaa16 bbb ccc ddd eee +aaa17 bbb ccc ddd eee +aaa18 bbb ccc ddd eee +aaa19 bbb ccc ddd eee +aaa20 bbb ccc ddd eee +aaa21 bbb ccc ddd eee +aaa22 bbb ccc ddd eee +aaa23 bbb ccc ddd eee +aaa24 bbb ccc ddd eee +aaa25 bbb ccc ddd eee +aaa26 bbb ccc ddd eee +aaa27 bbb ccc ddd eee +aaa28 bbb ccc ddd eee +aaa29 bbb ccc ddd eee +aaa30 bbb ccc ddd eee +aaa31 bbb ccc ddd eee +aaa32 bbb ccc ddd eee +aaa33 bbb ccc ddd eee +aaa34 bbb ccc ddd eee +aaa35 bbb ccc ddd eee +aaa36 bbb ccc ddd eee diff --git a/widgets/table/table-test.c b/widgets/table/table-test.c index da60221371..73d0e3748b 100644 --- a/widgets/table/table-test.c +++ b/widgets/table/table-test.c @@ -18,7 +18,7 @@ main (int argc, char *argv []) if (isatty (0)){ int fd; - + close (0); fd = open ("sample.table", O_RDONLY); if (fd == -1){ @@ -27,7 +27,7 @@ main (int argc, char *argv []) } dup2 (fd, 0); } - + gnome_init ("TableTest", "TableTest", argc, argv); e_cursors_init (); @@ -37,7 +37,7 @@ main (int argc, char *argv []) /* check_test (); */ e_table_test (); - + gtk_main (); e_cursors_shutdown (); diff --git a/widgets/table/test-table.c b/widgets/table/test-table.c index ada98b53ef..86e1ee0b36 100644 --- a/widgets/table/test-table.c +++ b/widgets/table/test-table.c @@ -21,6 +21,8 @@ #include "table-test.h" + + char buffer [1024]; char **column_labels; char ***table_data; @@ -29,7 +31,7 @@ int lines = 0; int lines_alloc = 0; static void -parse_headers () +parse_headers (void) { char *p, *s; int in_value = 0, i; @@ -101,7 +103,7 @@ append_line (char **line) } static void -load_data () +load_data (void) { int i; @@ -154,7 +156,7 @@ row_count (ETableModel *etc, void *data) static void append_row (ETableModel *etm, ETableModel *model, int row, void *data) { - abort (); + abort (); } static void * @@ -163,6 +165,8 @@ value_at (ETableModel *etc, int col, int row, void *data) g_assert (col < cols); g_assert (row < lines); + fprintf (stderr, "value_at[%d,%d]\n", col, row); + return (void *) table_data [row][col]; } @@ -187,13 +191,13 @@ is_cell_editable (ETableModel *etc, int col, int row, void *data) static gboolean has_save_id (ETableModel *etm, void *data) { - return FALSE; + return FALSE; } static char * get_save_id (ETableModel *etm, int row, void *data) { - abort (); + abort (); } static void * @@ -226,6 +230,7 @@ value_to_string (ETableModel *etc, int col, const void *value, void *data) return g_strdup(value); } +#ifdef BIT_ROT static void set_canvas_size (GnomeCanvas *canvas, GtkAllocation *alloc) { @@ -241,6 +246,7 @@ table_browser_test (void) ECell *cell_left_just; GnomeCanvasItem *group; int i; + int priority = 20; load_data (); @@ -270,7 +276,7 @@ table_browser_test (void) i, column_labels [i], 1.0, 20, cell_left_just, g_str_compare, TRUE, - 1); + priority); e_table_header_add_column (e_table_header, ecol, i); } @@ -311,15 +317,17 @@ table_browser_test (void) #endif NULL); } +#endif static void save_spec (GtkWidget *button, ETable *e_table) { -#if 0 +#ifdef BIT_ROT e_table_save_specification (e_table, "e-table-test.xml"); #endif } +#ifdef BIT_ROT static void row_selection_test (ETable *table, int row, gboolean selected) { @@ -328,6 +336,7 @@ row_selection_test (ETable *table, int row, gboolean selected) else g_print ("Row %d unselected\n", row); } +#endif static void toggle_grid (void *nothing, ETable *etable) @@ -339,14 +348,13 @@ toggle_grid (void *nothing, ETable *etable) } static void -do_e_table_demo (const char *spec) +do_e_table_demo (const char *state) { GtkWidget *e_table, *window, *frame, *vbox, *button, *bhide; ECell *cell_left_just; ETableHeader *full_header; int i; - ETableExtras *extras = NULL; - char *state = NULL; + GString *spec; /* * Data model @@ -366,36 +374,46 @@ do_e_table_demo (const char *spec) full_header = e_table_header_new (); cell_left_just = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - for (i = 0; i < cols; i++){ - ETableCol *ecol = e_table_col_new ( - i, column_labels [i], - 1.0, 20, cell_left_just, - g_str_compare, TRUE, - 1); - - e_table_header_add_column (full_header, ecol, i); + spec = g_string_new ("\ +<ETableSpecification \ +cursor-mode=\"line\" \ +selection-mode=\"browse\" \ +draw-focus=\"true\">"); + for (i = 0; i < cols; i++) { + char *colspec = + g_strdup_printf ("\ + <ETableColumn model_col=\"%d\" \ +_title=\"%s\" \ +minimum_width=\"20\" \ +resizable=\"true\" \ +cell=\"string\" \ +compare=\"string\"/>\n", i, column_labels[i]); + g_string_append (spec, colspec); + g_free (colspec); } + g_string_append (spec, "</ETableSpecification>"); + e_table = e_table_new (e_table_model, NULL, spec->str, state); - state = "\ -<ETableState>\n\ - <column source=\"0\"/>\n\ - <column source=\"1\"/>\n\ - <column source=\"1\"/>\n\ - <column source=\"3\"/>\n\ - <grouping></grouping>\n\ -</ETableState>"; + /* This makes value_at not called just to determine row height. */ + gtk_object_set (GTK_OBJECT (e_table), + "uniform_row_height", 1, + NULL); + + g_string_free (spec, TRUE); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); frame = gtk_frame_new (NULL); - e_table = e_table_new (e_table_model, extras, spec, state); +#ifdef BIT_ROT gtk_signal_connect (GTK_OBJECT(e_table), "row_selection", - GTK_SIGNAL_FUNC(row_selection_test), NULL); + GTK_SIGNAL_FUNC(row_selection_test), NULL); +#endif vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), e_table, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_container_add (GTK_CONTAINER (window), frame); +#if 0 /* * gadgets */ @@ -408,11 +426,12 @@ do_e_table_demo (const char *spec) gtk_signal_connect (GTK_OBJECT (bhide), "clicked", GTK_SIGNAL_FUNC (toggle_grid), e_table); gtk_box_pack_start (GTK_BOX (vbox), bhide, FALSE, FALSE, 0); +#endif - gtk_widget_set_usize (window, 200, 200); + gtk_widget_set_usize (window, 400, 200); gtk_widget_show_all (window); -#if 0 +#ifdef BIT_ROT if (getenv ("TEST")){ e_table_do_gui_config (NULL, E_TABLE(e_table)); } @@ -425,9 +444,19 @@ e_table_test (void) load_data (); if (1){/*getenv ("DO")){*/ - do_e_table_demo ("<ETableSpecification> <columns-shown> <column> 0 </column> <column> 1 </column> <column> 2 </column> <column> 3 </column> <column> 4 </column> </columns-shown> <grouping> <leaf column=\"3\" ascending=\"true\"/> </grouping> </ETableSpecification>"); + do_e_table_demo ("\ +<ETableState>\n\ + <column source=\"0\"/>\n\ + <column source=\"1\"/>\n\ + <column source=\"2\"/>\n\ + <column source=\"3\"/>\n\ + <column source=\"4\"/>\n\ + <grouping></grouping>\n\ +</ETableState>"); +#if 0 do_e_table_demo ("<ETableSpecification> <columns-shown> <column> 0 </column> <column> 0 </column> <column> 1 </column> <column> 2 </column> <column> 3 </column> <column> 4 </column> </columns-shown> <grouping> <group column=\"3\" ascending=\"true\"> <group column=\"4\" ascending=\"false\"> <leaf column=\"2\" ascending=\"true\"/> </group> </group> </grouping> </ETableSpecification>"); - } do_e_table_demo ("<ETableSpecification> <columns-shown> <column> 0 </column> <column> 1 </column> <column> 2 </column> <column> 3 </column> <column> 4 </column> </columns-shown> <grouping> <group column=\"4\" ascending=\"true\"> <leaf column=\"2\" ascending=\"true\"/> </group> </grouping> </ETableSpecification>"); do_e_table_demo ("<ETableSpecification> <columns-shown> <column> 0 </column> <column> 1 </column> <column> 2 </column> <column> 3 </column> <column> 4 </column> </columns-shown> <grouping> <group column=\"3\" ascending=\"true\"> <leaf column=\"2\" ascending=\"true\"/> </group> </grouping> </ETableSpecification>"); +#endif + } } |