diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-02-24 07:00:09 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-02-24 07:00:09 +0800 |
commit | 40d58afa7ce854ae8154a7f0ce32997f57d99ea4 (patch) | |
tree | 70cac56e91a6a9c056218837dc14be298f8befd6 /widgets/table/e-table.c | |
parent | 669c08181079cc48352959b829f578ea922351a6 (diff) | |
download | gsoc2013-evolution-40d58afa7ce854ae8154a7f0ce32997f57d99ea4.tar.gz gsoc2013-evolution-40d58afa7ce854ae8154a7f0ce32997f57d99ea4.tar.zst gsoc2013-evolution-40d58afa7ce854ae8154a7f0ce32997f57d99ea4.zip |
Added e-table/e-table-sorting-utils.lo.
2001-02-23 Christopher James Lahey <clahey@ximian.com>
* gal/Makefile.am (libgal_la_LIBADD): Added
e-table/e-table-sorting-utils.lo.
From gal/e-table/ChangeLog:
2001-02-23 Christopher James Lahey <clahey@ximian.com>
* Makefile.am (libetable_la_SOURCES): Added
e-table-sorting-utils.c.
(libetableinclude_HEADERS): Added e-table-sorting-utils.h.
* e-table-group-container.c: Implemented add_array method. Use
add_array to implement add_all instead of using add. Did some
general clean up.
* e-table-group-leaf.c, e-table-group-leaf.h: Implemented
add_array method. Changed everything to use an ETableSubset
variable instead of an ETableSortedVariable. Implemented it as
ETableSortedVariable if there's grouping involved and ETableSorted
if there isn't.
* e-table-group.c, e-table-group.h: Added add_array method. Added
unused get_position code.
* e-table-sorted-variable.c, e-table-sorted-variable.h: Moved a
lot of the actual implementation of sorting to
e-table-sorting-utils.c. Got rid of the signal handlers here
since we weren't using them and ETableSubset has the proxy virtual
methods.
* e-table-sorted.c, e-table-sorted.h: Completely replaced these
files with a variation on ETableSortedVariable that doesn't have
the add methods and such but instead just mimics the source
model's set of rows completely.
* e-table-sorter.c, e-table-sorter.h: Added functions to get at
the arrays here.
* e-table-sorting-utils.c, e-table-sorting-utils.h: Utility
functions for doing sorting.
* e-table-subset-variable.c, e-table-subset-variable.h: Added
add_array method.
* e-table-subset.c, e-table-subset.h: Made it so that the signal
hookups to the source model's signals are virtual methods.
* e-table.c, e-table.h: Don't call add_all and add and remove type
functions if not grouped. Don't rebuild for sort changes unless
it was either grouped before or will be grouped now.
svn path=/trunk/; revision=8374
Diffstat (limited to 'widgets/table/e-table.c')
-rw-r--r-- | widgets/table/e-table.c | 230 |
1 files changed, 122 insertions, 108 deletions
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 25922fedf7..abda473a97 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -118,13 +118,9 @@ static gint e_table_drag_source_event_cb (GtkWidget *widget, static gint et_focus (GtkContainer *container, GtkDirectionType direction); - static void -et_destroy (GtkObject *object) +et_disconnect_model (ETable *et) { - ETable *et = E_TABLE (object); - - gtk_signal_disconnect (GTK_OBJECT (et->model), et->table_model_change_id); gtk_signal_disconnect (GTK_OBJECT (et->model), @@ -135,6 +131,21 @@ et_destroy (GtkObject *object) et->table_row_inserted_id); gtk_signal_disconnect (GTK_OBJECT (et->model), et->table_row_deleted_id); + + et->table_model_change_id = 0; + et->table_row_change_id = 0; + et->table_cell_change_id = 0; + et->table_row_inserted_id = 0; + et->table_row_deleted_id = 0; +} + +static void +et_destroy (GtkObject *object) +{ + ETable *et = E_TABLE (object); + + et_disconnect_model (et); + if (et->group_info_change_id) gtk_signal_disconnect (GTK_OBJECT (et->sort_info), et->group_info_change_id); @@ -255,9 +266,12 @@ header_canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_ static void sort_info_changed (ETableSortInfo *info, ETable *et) { - et->need_rebuild = TRUE; - if (!et->rebuild_idle_id) - et->rebuild_idle_id = g_idle_add_full (20, changed_idle, et, NULL); + gboolean will_be_grouped = e_table_sort_info_grouping_get_count(info) > 0; + if (et->is_grouped || will_be_grouped) { + et->need_rebuild = TRUE; + if (!et->rebuild_idle_id) + et->rebuild_idle_id = g_idle_add_full (20, changed_idle, et, NULL); + } } static void @@ -466,58 +480,6 @@ group_key_press (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *et return return_val; } -static gboolean -changed_idle (gpointer data) -{ - ETable *et = E_TABLE (data); - - if (et->need_rebuild) { - gtk_object_destroy (GTK_OBJECT (et->group)); - et->group = e_table_group_new (GNOME_CANVAS_GROUP (et->canvas_vbox), - et->full_header, - et->header, - et->model, - et->sort_info, - 0); - e_canvas_vbox_add_item(E_CANVAS_VBOX(et->canvas_vbox), GNOME_CANVAS_ITEM(et->group)); - gnome_canvas_item_set(GNOME_CANVAS_ITEM(et->group), - "drawgrid", et->draw_grid, - "drawfocus", et->draw_focus, - "cursor_mode", et->cursor_mode, - "length_threshold", et->length_threshold, - "table_selection_model", et->selection, - NULL); - gtk_signal_connect (GTK_OBJECT (et->group), "cursor_change", - GTK_SIGNAL_FUNC (group_cursor_change), et); - gtk_signal_connect (GTK_OBJECT (et->group), "cursor_activated", - GTK_SIGNAL_FUNC (group_cursor_activated), et); - gtk_signal_connect (GTK_OBJECT (et->group), "double_click", - GTK_SIGNAL_FUNC (group_double_click), et); - gtk_signal_connect (GTK_OBJECT (et->group), "right_click", - GTK_SIGNAL_FUNC (group_right_click), et); - gtk_signal_connect (GTK_OBJECT (et->group), "click", - GTK_SIGNAL_FUNC (group_click), et); - gtk_signal_connect (GTK_OBJECT (et->group), "key_press", - GTK_SIGNAL_FUNC (group_key_press), et); - e_table_fill_table (et, et->model); - - gtk_object_set (GTK_OBJECT (et->canvas_vbox), - "width", (double) GTK_WIDGET (et->table_canvas)->allocation.width, - NULL); - - if (GTK_WIDGET_REALIZED(et->table_canvas)) - table_canvas_size_allocate (GTK_WIDGET(et->table_canvas), >K_WIDGET(et->table_canvas)->allocation, et); - } - - et->need_rebuild = 0; - et->rebuild_idle_id = 0; - - if (et->horizontal_scrolling) - e_table_header_update_horizontal(et->header); - - return FALSE; -} - static void et_table_model_changed (ETableModel *model, ETable *et) { @@ -571,6 +533,92 @@ et_table_row_deleted (ETableModel *table_model, int row, ETable *et) } static void +et_build_groups (ETable *et) +{ + gboolean was_grouped = et->is_grouped; + + et->is_grouped = e_table_sort_info_grouping_get_count(et->sort_info) > 0; + + et->group = e_table_group_new (GNOME_CANVAS_GROUP (et->canvas_vbox), + et->full_header, + et->header, + et->model, + et->sort_info, + 0); + e_canvas_vbox_add_item(E_CANVAS_VBOX(et->canvas_vbox), GNOME_CANVAS_ITEM(et->group)); + gnome_canvas_item_set(GNOME_CANVAS_ITEM(et->group), + "drawgrid", et->draw_grid, + "drawfocus", et->draw_focus, + "cursor_mode", et->cursor_mode, + "length_threshold", et->length_threshold, + "table_selection_model", et->selection, + NULL); + + gtk_signal_connect (GTK_OBJECT (et->group), "cursor_change", + GTK_SIGNAL_FUNC (group_cursor_change), et); + gtk_signal_connect (GTK_OBJECT (et->group), "cursor_activated", + GTK_SIGNAL_FUNC (group_cursor_activated), et); + gtk_signal_connect (GTK_OBJECT (et->group), "double_click", + GTK_SIGNAL_FUNC (group_double_click), et); + gtk_signal_connect (GTK_OBJECT (et->group), "right_click", + GTK_SIGNAL_FUNC (group_right_click), et); + gtk_signal_connect (GTK_OBJECT (et->group), "click", + GTK_SIGNAL_FUNC (group_click), et); + gtk_signal_connect (GTK_OBJECT (et->group), "key_press", + GTK_SIGNAL_FUNC (group_key_press), et); + + + if (!(et->is_grouped) && was_grouped) + et_disconnect_model (et); + + if (et->is_grouped && (!was_grouped)) { + et->table_model_change_id = gtk_signal_connect (GTK_OBJECT (et->model), "model_changed", + GTK_SIGNAL_FUNC (et_table_model_changed), et); + + et->table_row_change_id = gtk_signal_connect (GTK_OBJECT (et->model), "model_row_changed", + GTK_SIGNAL_FUNC (et_table_row_changed), et); + + et->table_cell_change_id = gtk_signal_connect (GTK_OBJECT (et->model), "model_cell_changed", + GTK_SIGNAL_FUNC (et_table_cell_changed), et); + + et->table_row_inserted_id = gtk_signal_connect (GTK_OBJECT (et->model), "model_row_inserted", + GTK_SIGNAL_FUNC (et_table_row_inserted), et); + + et->table_row_deleted_id = gtk_signal_connect (GTK_OBJECT (et->model), "model_row_deleted", + GTK_SIGNAL_FUNC (et_table_row_deleted), et); + + } + + if (et->is_grouped) + e_table_fill_table (et, et->model); +} + +static gboolean +changed_idle (gpointer data) +{ + ETable *et = E_TABLE (data); + + if (et->need_rebuild) { + gtk_object_destroy (GTK_OBJECT (et->group)); + et_build_groups(et); + gtk_object_set (GTK_OBJECT (et->canvas_vbox), + "width", (double) GTK_WIDGET (et->table_canvas)->allocation.width, + NULL); + + if (GTK_WIDGET_REALIZED(et->table_canvas)) + table_canvas_size_allocate (GTK_WIDGET(et->table_canvas), >K_WIDGET(et->table_canvas)->allocation, et); + } + + et->need_rebuild = 0; + et->rebuild_idle_id = 0; + + if (et->horizontal_scrolling) + e_table_header_update_horizontal(et->header); + + return FALSE; +} + +static void et_canvas_realize (GtkWidget *canvas, ETable *e_table) { gnome_canvas_item_set( @@ -676,54 +724,7 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h GTK_SIGNAL_FUNC(click_to_add_cursor_change), e_table); } - e_table->group = e_table_group_new ( - GNOME_CANVAS_GROUP (e_table->canvas_vbox), - full_header, header, - model, e_table->sort_info, 0); - e_canvas_vbox_add_item(E_CANVAS_VBOX(e_table->canvas_vbox), GNOME_CANVAS_ITEM(e_table->group)); - - gnome_canvas_item_set( - GNOME_CANVAS_ITEM(e_table->group), - "drawgrid", e_table->draw_grid, - "drawfocus", e_table->draw_focus, - "cursor_mode", e_table->cursor_mode, - "length_threshold", e_table->length_threshold, - "table_selection_model", e_table->selection, - NULL); - - gtk_signal_connect (GTK_OBJECT (e_table->group), "cursor_change", - GTK_SIGNAL_FUNC(group_cursor_change), e_table); - gtk_signal_connect (GTK_OBJECT (e_table->group), "cursor_activated", - GTK_SIGNAL_FUNC(group_cursor_activated), e_table); - gtk_signal_connect (GTK_OBJECT (e_table->group), "double_click", - GTK_SIGNAL_FUNC(group_double_click), e_table); - gtk_signal_connect (GTK_OBJECT (e_table->group), "right_click", - GTK_SIGNAL_FUNC(group_right_click), e_table); - gtk_signal_connect (GTK_OBJECT (e_table->group), "click", - GTK_SIGNAL_FUNC(group_click), e_table); - gtk_signal_connect (GTK_OBJECT (e_table->group), "key_press", - GTK_SIGNAL_FUNC(group_key_press), e_table); - - e_table->table_model_change_id = gtk_signal_connect ( - GTK_OBJECT (model), "model_changed", - GTK_SIGNAL_FUNC (et_table_model_changed), e_table); - - e_table->table_row_change_id = gtk_signal_connect ( - GTK_OBJECT (model), "model_row_changed", - GTK_SIGNAL_FUNC (et_table_row_changed), e_table); - - e_table->table_cell_change_id = gtk_signal_connect ( - GTK_OBJECT (model), "model_cell_changed", - GTK_SIGNAL_FUNC (et_table_cell_changed), e_table); - - e_table->table_row_inserted_id = gtk_signal_connect ( - GTK_OBJECT (model), "model_row_inserted", - GTK_SIGNAL_FUNC (et_table_row_inserted), e_table); - - e_table->table_row_deleted_id = gtk_signal_connect ( - GTK_OBJECT (model), "model_row_deleted", - GTK_SIGNAL_FUNC (et_table_row_deleted), e_table); - + et_build_groups(e_table); } static void @@ -1807,6 +1808,19 @@ e_table_compute_location (ETable *table, GtkWidget *widget, e_table_group_compute_location(table->group, &x, &y, row, col); } +#if 0 +void +e_table_get_position (ETable *table, GtkWidget *widget, + int *x, int *y, int row, int col) +{ + if (!(x || y)) + return; + e_table_group_get_position(table->group, x, y, &row, &col); + *x -= GTK_LAYOUT(table->table_canvas)->hadjustment->value; + *y -= GTK_LAYOUT(table->table_canvas)->vadjustment->value; +} +#endif + static void et_drag_begin (GtkWidget *widget, GdkDragContext *context, |