diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-03-06 07:15:14 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-03-06 07:15:14 +0800 |
commit | 3de981ec78d529eb1bd9b2f98f154eae91dffc6d (patch) | |
tree | e8758124523b6c534890aa80f5b918981be6ce00 /widgets/table/e-table-header.c | |
parent | 645f69dcf6d0b6162c5c7843371c559486234175 (diff) | |
download | gsoc2013-evolution-3de981ec78d529eb1bd9b2f98f154eae91dffc6d.tar gsoc2013-evolution-3de981ec78d529eb1bd9b2f98f154eae91dffc6d.tar.gz gsoc2013-evolution-3de981ec78d529eb1bd9b2f98f154eae91dffc6d.tar.bz2 gsoc2013-evolution-3de981ec78d529eb1bd9b2f98f154eae91dffc6d.tar.lz gsoc2013-evolution-3de981ec78d529eb1bd9b2f98f154eae91dffc6d.tar.xz gsoc2013-evolution-3de981ec78d529eb1bd9b2f98f154eae91dffc6d.tar.zst gsoc2013-evolution-3de981ec78d529eb1bd9b2f98f154eae91dffc6d.zip |
Added support for the sorting info. The Etable creates a sort_info object,
2000-03-05 Christopher James Lahey <clahey@helixcode.com>
* e-table.c, e-table.h: Added support for the sorting info. The
Etable creates a sort_info object, and then connects to the
signals to rearrange the rows when the sort_info changes. It also
passes the info object to the ETableHeaderItem.
* e-table-model.c: Fixed a typo where ETableModel was written as
ETableModle.
* e-table-header.c, e-table-header.h: Added some code for sorting
here, but it's not used. I don't think we want this code, but I
wanted to check it in at least once so that it's not lost.
* e-table-header-item.c, e-table-header-item.h: Added a
"sort_info" argument to ETableHeaderItem. Added display of
current sort settings. Added support for clicking to change the
sort settings.
* e-table-col.h: E_TABLE_COL_ARROW_NONE is marked as being = 0
since this is required in other places. (I think C defines this
as being the case, but it's good to have the = 0 there so that
it's obvious that it has to be first.)
* TODO: Mark sorting as done.
* e-table-sort-info.c, e-table-sort-info.h: New files for
containing the xml grouping/sorting information and for sending
signals on that information.
* Makefile.am: Added e-table-sort-info.c and e-table-sort-info.h.
svn path=/trunk/; revision=2060
Diffstat (limited to 'widgets/table/e-table-header.c')
-rw-r--r-- | widgets/table/e-table-header.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c index 527e7e22bc..8465f28567 100644 --- a/widgets/table/e-table-header.c +++ b/widgets/table/e-table-header.c @@ -350,3 +350,134 @@ e_table_header_set_frozen_columns (ETableHeader *eth, int idx) { eth->frozen_count = idx; } + +/* Forget model-view here. Really, this information belongs in the view anyway. */ +#if 0 +static void +set_arrows(ETableHeader *eth, ETableHeaderSortInfo info) +{ + ETableCol *col; + for (col = eth->columns, i = 0; i < eth->col_count; i++, col++) { + if ( col->col_idx == info.model_col ) + e_table_column_set_arrow(col, info.ascending ? E_TABLE_COL_ARROW_DOWN : E_TABLE_COL_ARROW_UP); + } +} + +static void +unset_arrows(ETableHeader *eth, ETableHeaderSortInfo info) +{ + ETableCol *col; + for (col = eth->columns, i = 0; i < eth->col_count; i++, col++) { + if ( col->col_idx == info.model_col ) + e_table_column_set_arrow(col, E_TABLE_COL_ARROW_NONE); + } +} + +ETableHeaderSortInfo +e_table_header_get_sort_info (ETableHeader *eth) +{ + ETableHeaderSortInfo dummy_info = {0, 1}; + g_return_val_if_fail (eth != NULL, dummy_info); + g_return_val_if_fail (E_IS_TABLE_HEADER (eth), dummy_info); + + return eth->sort_info; +} + +void +e_table_header_set_sort_info (ETableHeader *eth, ETableHeaderSortInfo info) +{ + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); + + unset_arrows(eth, eth->sort_info); + eth->sort_info = info; + set_arrows(eth, eth->sort_info); + + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); +} + + +int +e_table_header_get_group_count (ETableHeader *eth) +{ + g_return_val_if_fail (eth != NULL, 0); + g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); + + return eth->grouping_count; +} + +ETableHeaderSortInfo * +e_table_header_get_groups (ETableHeader *eth) +{ + ETableHeaderSortInfo *ret; + g_return_val_if_fail (eth != NULL, NULL); + g_return_val_if_fail (E_IS_TABLE_HEADER (eth), NULL); + + ret = g_new (ETableHeaderSortInfo, eth->grouping_count); + memcpy (ret, eth->grouping, sizeof (ETableHeaderSortInfo) * eth->grouping_count); + return eth->grouping; +} + +ETableHeaderSortInfo +e_table_header_get_group (ETableHeader *eth, gint index) +{ + ETableHeaderSortInfo dummy_info = {0, 1}; + g_return_val_if_fail (eth != NULL, dummy_info); + g_return_val_if_fail (E_IS_TABLE_HEADER (eth), dummy_info); + g_return_val_if_fail (index >= 0, dummy_info); + g_return_val_if_fail (index < eth->grouping_count, dummy_info); + + return eth->grouping[index]; +} + +void +e_table_header_grouping_insert (ETableHeader *eth, gint index, ETableHeaderSortInfo info) +{ + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); + + eth->grouping = g_realloc(eth->grouping, sizeof(ETableHeaderSortInfo) * (eth->grouping_count + 1)); + memmove(eth->grouping + index + 1, eth->grouping + index, sizeof(ETableHeaderSortInfo) * (eth->grouping_count - index)); + eth->grouping[index] = info; + + eth->grouping_count ++; + + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); +} + +void +e_table_header_grouping_delete (ETableHeader *eth, gint index) +{ + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); + + memmove(eth->grouping + index, eth->grouping + index + 1, sizeof(ETableHeaderSortInfo) * (eth->grouping_count - index)); + eth->grouping = g_realloc(eth->grouping, sizeof(ETableHeaderSortInfo) * (eth->grouping_count - 1)); + + eth->grouping_count --; + + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); +} + +void +e_table_header_grouping_move (ETableHeader *eth, gint old_idx, gint new_idx) +{ + ETableHeaderSortInfo info; + + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); + + if ( old_idx == new_idx ) + return; + + info = eth->grouping[old_idx]; + if ( old_idx < new_idx ) { + memmove(eth->grouping + old_idx, eth->grouping + old_idx + 1, sizeof(ETableHeaderSortInfo) * (new_idx - old_idx)); + } else { + memmove(eth->grouping + new_idx + 1, eth->grouping + new_idx, sizeof(ETableHeaderSortInfo) * (old_idx - new_idx)); + } + eth->grouping[new_idx] = info; + + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]); +} +#endif |