diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-01 12:01:05 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-01 12:01:05 +0800 |
commit | eb5dc08dc91a593357a6c1b1db98fac8cdb1662e (patch) | |
tree | 95a4c1a740939467e6f179c73a13594c684e9cfc /widgets/table | |
parent | 64fbed6351453bc9e61c15cfe7267d6df4574ac0 (diff) | |
download | gsoc2013-evolution-eb5dc08dc91a593357a6c1b1db98fac8cdb1662e.tar gsoc2013-evolution-eb5dc08dc91a593357a6c1b1db98fac8cdb1662e.tar.gz gsoc2013-evolution-eb5dc08dc91a593357a6c1b1db98fac8cdb1662e.tar.bz2 gsoc2013-evolution-eb5dc08dc91a593357a6c1b1db98fac8cdb1662e.tar.lz gsoc2013-evolution-eb5dc08dc91a593357a6c1b1db98fac8cdb1662e.tar.xz gsoc2013-evolution-eb5dc08dc91a593357a6c1b1db98fac8cdb1662e.tar.zst gsoc2013-evolution-eb5dc08dc91a593357a6c1b1db98fac8cdb1662e.zip |
Made this more reentrant.
2000-04-30 Christopher James Lahey <clahey@helixcode.com>
* e-table-header-item.c: Made this more reentrant.
* e-table-sorted-variable.c, e-table-sorted-variable.h: Does a
proper resort when the sorting info changes.
* e-table.c, e-table.h: Made it so that ETable doesn't destroy and
recreate the entire table when sorting info changes.
svn path=/trunk/; revision=2704
Diffstat (limited to 'widgets/table')
-rw-r--r-- | widgets/table/e-table-header-item.c | 9 | ||||
-rw-r--r-- | widgets/table/e-table-sorted-variable.c | 49 | ||||
-rw-r--r-- | widgets/table/e-table-sorted-variable.h | 1 | ||||
-rw-r--r-- | widgets/table/e-table.c | 14 | ||||
-rw-r--r-- | widgets/table/e-table.h | 4 |
5 files changed, 67 insertions, 10 deletions
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index 65d0d3166e..f916ce447e 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -953,6 +953,7 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e) GnomeCanvas *canvas = item->canvas; const gboolean resizing = ETHI_RESIZING (ethi); int x, y, start, col; + int was_maybe_drag = 0; switch (e->type){ case GDK_ENTER_NOTIFY: @@ -1042,11 +1043,15 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e) case GDK_BUTTON_RELEASE: { gboolean needs_ungrab = FALSE; + + was_maybe_drag = ethi->maybe_drag; + + ethi->maybe_drag = FALSE; if (ethi->resize_col != -1){ needs_ungrab = (ethi->resize_guide != NULL); ethi_end_resize (ethi, ethi->resize_width); - } else if (ethi->maybe_drag && ethi->sort_info) { + } else if (was_maybe_drag && ethi->sort_info) { ETableCol *col; int model_col; int length; @@ -1090,10 +1095,10 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e) e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column); } } + if (needs_ungrab) gnome_canvas_item_ungrab (item, e->button.time); - ethi->maybe_drag = FALSE; break; } diff --git a/widgets/table/e-table-sorted-variable.c b/widgets/table/e-table-sorted-variable.c index a1a9a35a09..00b8b6af71 100644 --- a/widgets/table/e-table-sorted-variable.c +++ b/widgets/table/e-table-sorted-variable.c @@ -23,6 +23,7 @@ static ETableSubsetVariableClass *etsv_parent_class; static void etsv_proxy_model_changed (ETableModel *etm, ETableSortedVariable *etsv); static void etsv_proxy_model_row_changed (ETableModel *etm, int row, ETableSortedVariable *etsv); static void etsv_proxy_model_cell_changed (ETableModel *etm, int col, int row, ETableSortedVariable *etsv); +static void etsv_sort_info_changed (ETableSortInfo *info, ETableSortedVariable *etsv); static void etsv_add (ETableSubsetVariable *etssv, gint row); static void @@ -37,6 +38,8 @@ etsv_destroy (GtkObject *object) etsv->table_model_row_changed_id); gtk_signal_disconnect (GTK_OBJECT (etss->source), etsv->table_model_cell_changed_id); + gtk_signal_disconnect (GTK_OBJECT (etsv->sort_info), + etsv->sort_info_changed_id); etsv->table_model_changed_id = 0; etsv->table_model_row_changed_id = 0; @@ -137,6 +140,8 @@ e_table_sorted_variable_new (ETableModel *source, ETableHeader *full_header, ETa GTK_SIGNAL_FUNC (etsv_proxy_model_row_changed), etsv); etsv->table_model_cell_changed_id = gtk_signal_connect (GTK_OBJECT (source), "model_cell_changed", GTK_SIGNAL_FUNC (etsv_proxy_model_cell_changed), etsv); + etsv->sort_info_changed_id = gtk_signal_connect (GTK_OBJECT (sort_info), "sort_info_changed", + GTK_SIGNAL_FUNC (etsv_sort_info_changed), etsv); return E_TABLE_MODEL(etsv); } @@ -169,3 +174,47 @@ etsv_proxy_model_cell_changed (ETableModel *etm, int col, int row, ETableSortedV } } +static ETableSortedVariable *etsv_closure; + +static int +qsort_callback(const void *data1, const void *data2) +{ + int j; + int comp_val = 0; + int ascending = 1; + int sort_count = e_table_sort_info_sorting_get_count(etsv_closure->sort_info); + int row1 = *(int *)data1; + int row2 = *(int *)data2; + + while(gtk_events_pending()) + gtk_main_iteration(); + for (j = 0; j < sort_count; j++) { + ETableSortColumn column = e_table_sort_info_sorting_get_nth(etsv_closure->sort_info, j); + ETableCol *col; + void *val; + if (column.column > e_table_header_count (etsv_closure->full_header)) + col = e_table_header_get_columns (etsv_closure->full_header)[e_table_header_count (etsv_closure->full_header) - 1]; + else + col = e_table_header_get_columns (etsv_closure->full_header)[column.column]; + val = e_table_model_value_at (E_TABLE_SUBSET(etsv_closure)->source, col->col_idx, row1); + comp_val = (*col->compare)(val, e_table_model_value_at (E_TABLE_SUBSET(etsv_closure)->source, col->col_idx, row2)); + ascending = column.ascending; + if (comp_val != 0) + break; + } + if (((ascending && comp_val < 0) || ((!ascending) && comp_val > 0))) + return -1; + + if (comp_val == 0) + if ((ascending && row1 < row2) || ((!ascending) && row1 > row2)) + return -1; + return 1; +} + +static void +etsv_sort_info_changed (ETableSortInfo *info, ETableSortedVariable *etsv) +{ + etsv_closure = etsv; + qsort(E_TABLE_SUBSET(etsv)->map_table, E_TABLE_SUBSET(etsv)->n_map, sizeof(int), qsort_callback); + e_table_model_changed (E_TABLE_MODEL(etsv)); +} diff --git a/widgets/table/e-table-sorted-variable.h b/widgets/table/e-table-sorted-variable.h index 1a22679040..53740e85f0 100644 --- a/widgets/table/e-table-sorted-variable.h +++ b/widgets/table/e-table-sorted-variable.h @@ -24,6 +24,7 @@ typedef struct { int table_model_changed_id; int table_model_row_changed_id; int table_model_cell_changed_id; + int sort_info_changed_id; } ETableSortedVariable; typedef struct { diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 1c89a45ea9..515ca35f95 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -65,9 +65,6 @@ et_destroy (GtkObject *object) et->table_row_change_id); gtk_signal_disconnect (GTK_OBJECT (et->model), et->table_cell_change_id); - if (et->sort_info_change_id) - gtk_signal_disconnect (GTK_OBJECT (et->sort_info), - et->sort_info_change_id); if (et->group_info_change_id) gtk_signal_disconnect (GTK_OBJECT (et->sort_info), et->group_info_change_id); @@ -96,7 +93,6 @@ e_table_init (GtkObject *object) gtk_table->homogeneous = FALSE; e_table->sort_info = NULL; - e_table->sort_info_change_id = 0; e_table->group_info_change_id = 0; e_table->draw_grid = 1; @@ -149,6 +145,7 @@ e_table_setup_header (ETable *e_table) } static void + table_canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_table) { @@ -361,9 +358,6 @@ et_grouping_xml_to_sort_info (ETable *table, xmlNode *grouping) e_table_sort_info_sorting_set_nth(table->sort_info, i++, column); } - table->sort_info_change_id = - gtk_signal_connect (GTK_OBJECT (table->sort_info), "sort_info_changed", - GTK_SIGNAL_FUNC (sort_info_changed), table); table->group_info_change_id = gtk_signal_connect (GTK_OBJECT (table->sort_info), "group_info_changed", GTK_SIGNAL_FUNC (sort_info_changed), table); @@ -586,6 +580,12 @@ e_table_save_specification (ETable *e_table, gchar *filename) xmlFreeDoc (doc); } +void +e_table_select_row (ETable *e_table, int row) +{ + +} + static void et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) { diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h index 61fc5a41ae..35b9cd0002 100644 --- a/widgets/table/e-table.h +++ b/widgets/table/e-table.h @@ -33,7 +33,6 @@ typedef struct { int table_row_change_id; int table_cell_change_id; - int sort_info_change_id; int group_info_change_id; GnomeCanvas *header_canvas, *table_canvas; @@ -78,6 +77,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); +void e_table_select_row (ETable *e_table, + int row); + END_GNOME_DECLS #endif /* _E_TABLE_H_ */ |