diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-12-08 07:55:56 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-12-08 07:55:56 +0800 |
commit | adf19f49fbdf0e0e69a6ed80fe0cddaf4f3978d1 (patch) | |
tree | aeb72fd07d7471fba4758833f413fd23b9687052 | |
parent | faa1509add9fc71ea4c3f206f0a05ee02d8be86c (diff) | |
download | gsoc2013-evolution-adf19f49fbdf0e0e69a6ed80fe0cddaf4f3978d1.tar.gz gsoc2013-evolution-adf19f49fbdf0e0e69a6ed80fe0cddaf4f3978d1.tar.zst gsoc2013-evolution-adf19f49fbdf0e0e69a6ed80fe0cddaf4f3978d1.zip |
set "sort_info" on our sorter when we get a new sort_info to keep things
2000-12-07 Chris Toshok <toshok@helixcode.com>
* e-table.c (e_table_set_state_object): set "sort_info" on our
sorter when we get a new sort_info to keep things in sync.
* e-table-sorter.c (ets_set_arg): new function, allowing the
setting of "sort_info".
(ets_get_arg): new function, allowing the getting of "sort_info".
(ets_class_init): fill in GtkObject::set_arg and get_arg.
(ets_sort): set ets->needs_sorting to 0 so we don't sort
unnecessarily.
(e_table_sorter_model_to_sorted): we may have ets->backsorted (and
should use it if we do) even if we didn't need to sort.
(e_table_sorter_sorted_to_model): same, except ets->sorted.
svn path=/trunk/; revision=6857
-rw-r--r-- | widgets/table/e-table-sorter.c | 60 | ||||
-rw-r--r-- | widgets/table/e-table.c | 4 |
2 files changed, 60 insertions, 4 deletions
diff --git a/widgets/table/e-table-sorter.c b/widgets/table/e-table-sorter.c index 2350e50616..2fe3966199 100644 --- a/widgets/table/e-table-sorter.c +++ b/widgets/table/e-table-sorter.c @@ -14,6 +14,12 @@ #include "gal/util/e-util.h" #include "e-table-sorter.h" +/* The arguments we take */ +enum { + ARG_0, + ARG_SORT_INFO +}; + #define PARENT_TYPE gtk_object_get_type() #define INCREMENT_AMOUNT 100 @@ -58,6 +64,41 @@ ets_destroy (GtkObject *object) } static void +ets_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + ETableSorter *ets = E_TABLE_SORTER (object); + + switch (arg_id) { + case ARG_SORT_INFO: + if (ets->sort_info) { + if (ets->sort_info_changed_id) + gtk_signal_disconnect(GTK_OBJECT(ets->sort_info), ets->sort_info_changed_id); + gtk_object_unref(GTK_OBJECT(ets->sort_info)); + } + + ets->sort_info = E_TABLE_SORT_INFO(GTK_VALUE_OBJECT (*arg)); + ets->sort_info_changed_id = gtk_signal_connect (GTK_OBJECT (ets->sort_info), "sort_info_changed", + GTK_SIGNAL_FUNC (ets_sort_info_changed), ets); + + ets_clean (ets); + break; + default: + break; + } +} + +static void +ets_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + ETableSorter *ets = E_TABLE_SORTER (object); + switch (arg_id) { + case ARG_SORT_INFO: + GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(ets->sort_info); + break; + } +} + +static void ets_class_init (ETableSorterClass *klass) { GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass); @@ -65,6 +106,11 @@ ets_class_init (ETableSorterClass *klass) parent_class = gtk_type_class (PARENT_TYPE); object_class->destroy = ets_destroy; + object_class->set_arg = ets_set_arg; + object_class->get_arg = ets_get_arg; + + gtk_object_add_arg_type ("ETableSorter::sort_info", GTK_TYPE_OBJECT, + GTK_ARG_READWRITE, ARG_SORT_INFO); } static void @@ -190,6 +236,8 @@ ets_sort(ETableSorter *ets) if (ets->sorted) return; + ets->needs_sorting = 0; + rows = e_table_model_row_count(ets->source); group_cols = e_table_sort_info_grouping_get_count(ets->sort_info); cols = e_table_sort_info_sorting_get_count(ets->sort_info) + group_cols; @@ -272,10 +320,12 @@ e_table_sorter_model_to_sorted (ETableSorter *sorter, int row) g_return_val_if_fail(row >= 0, -1); g_return_val_if_fail(row < rows, -1); - if (e_table_sorter_needs_sorting(sorter)) { + if (e_table_sorter_needs_sorting(sorter)) ets_backsort(sorter); + + if (sorter->backsorted) return sorter->backsorted[row]; - } else + else return row; } @@ -287,9 +337,11 @@ e_table_sorter_sorted_to_model (ETableSorter *sorter, int row) g_return_val_if_fail(row >= 0, -1); g_return_val_if_fail(row < rows, -1); - if (e_table_sorter_needs_sorting(sorter)) { + if (e_table_sorter_needs_sorting(sorter)) ets_sort(sorter); + + if (sorter->sorted) return sorter->sorted[row]; - } else + else return row; } diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 15e7f2d7f6..d0404525a8 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -747,6 +747,10 @@ e_table_set_state_object(ETable *e_table, ETableState *state) e_table); } + if (e_table->sorter) + gtk_object_set(GTK_OBJECT(e_table->sorter), + "sort_info", e_table->sort_info, + NULL); if (e_table->header_item) gtk_object_set(GTK_OBJECT(e_table->header_item), "ETableHeader", e_table->header, |