diff options
author | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-06-12 13:05:48 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-06-12 13:05:48 +0800 |
commit | d3e8fc316941aba4d04ee1f1eee999ec5781f14b (patch) | |
tree | ce2c337562fed2a0ed85f2ad01e1ed088d3183d8 /widgets/table/e-table-header-item.c | |
parent | 4dbdaf99b9eaf4b2672e4ae66c8f4d05bc5e6aa3 (diff) | |
download | gsoc2013-evolution-d3e8fc316941aba4d04ee1f1eee999ec5781f14b.tar.gz gsoc2013-evolution-d3e8fc316941aba4d04ee1f1eee999ec5781f14b.tar.zst gsoc2013-evolution-d3e8fc316941aba4d04ee1f1eee999ec5781f14b.zip |
Committing a fix for sorting in the vertical view message list.
svn path=/trunk/; revision=32105
Diffstat (limited to 'widgets/table/e-table-header-item.c')
-rw-r--r-- | widgets/table/e-table-header-item.c | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index 74332dc61c..1e6d9bad29 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -1236,14 +1236,15 @@ static void ethi_popup_sort_ascending(GtkWidget *widget, EthiHeaderInfo *info) { ETableCol *col; - int model_col; + int model_col = -1; int length; int i; int found = FALSE; ETableHeaderItem *ethi = info->ethi; col = e_table_header_get_column (ethi->eth, info->col); - model_col = col->col_idx; + if (col->sortable) + model_col = col->col_idx; length = e_table_sort_info_grouping_get_count(ethi->sort_info); for (i = 0; i < length; i++) { @@ -1265,12 +1266,13 @@ ethi_popup_sort_ascending(GtkWidget *widget, EthiHeaderInfo *info) ETableSortColumn column = e_table_sort_info_sorting_get_nth( ethi->sort_info, i); - if (model_col == column.column){ + if (model_col == column.column || model_col == -1){ column.ascending = 1; e_table_sort_info_sorting_set_nth ( ethi->sort_info, i, column); found = 1; - break; + if (model_col != -1) + break; } } } @@ -1289,14 +1291,15 @@ static void ethi_popup_sort_descending(GtkWidget *widget, EthiHeaderInfo *info) { ETableCol *col; - int model_col; + int model_col=-1; int length; int i; int found = FALSE; ETableHeaderItem *ethi = info->ethi; col = e_table_header_get_column (ethi->eth, info->col); - model_col = col->col_idx; + if (col->sortable) + model_col = col->col_idx; length = e_table_sort_info_grouping_get_count(ethi->sort_info); for (i = 0; i < length; i++) { @@ -1317,12 +1320,13 @@ ethi_popup_sort_descending(GtkWidget *widget, EthiHeaderInfo *info) e_table_sort_info_sorting_get_nth( ethi->sort_info, i); - if (model_col == column.column){ + if (model_col == column.column || model_col == -1){ column.ascending = 0; e_table_sort_info_sorting_set_nth ( ethi->sort_info, i, column); found = 1; - break; + if (model_col != -1) + break; } } } @@ -1533,6 +1537,7 @@ ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event) GtkWidget *menu_item; GSList *group = NULL; ETableSortColumn column; + gboolean ascending; info->ethi = ethi; info->col = ethi_find_col_by_x (ethi, event->x); @@ -1540,7 +1545,7 @@ ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event) popup = e_popup_menu_create_with_domain (ethi_context_menu, 1 + - (col->sortable ? 0 : 2) + + 0 + ((ethi->table || ethi->tree) ? 0 : 4) + ((e_table_header_count (ethi->eth) > 1) ? 0 : 8), ((e_table_sort_info_get_can_group (ethi->sort_info)) ? 0 : 16) + @@ -1560,6 +1565,7 @@ ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event) else { column = e_table_sort_info_sorting_get_nth(ethi->sort_info, 0); sort_col = column.column; + ascending = column.ascending; } /* Custom */ @@ -1578,14 +1584,25 @@ ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event) /* Headers */ for (ncol = 0; ncol<ethi->full_header->col_count; ncol++) { - menu_item = gtk_radio_menu_item_new_with_label (group, ethi->full_header->columns[ncol]->text); + char *text=NULL; + + if (!ethi->full_header->columns[ncol]->sortable) + continue; + + if (ncol == sort_col) { + text = g_strdup_printf("%s (%s)", ethi->full_header->columns[ncol]->text, ascending ? _("Ascending"):_("Descending")); + menu_item = gtk_radio_menu_item_new_with_label (group, text); + g_free (text); + } else + menu_item = gtk_radio_menu_item_new_with_label (group, ethi->full_header->columns[ncol]->text); + gtk_widget_show (menu_item); gtk_menu_shell_prepend (GTK_MENU_SHELL (sub_menu), menu_item); if (ncol == sort_col) gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE); g_object_set_data (menu_item, "col-number", GINT_TO_POINTER (ncol)); - g_signal_connect (menu_item, "toggled", G_CALLBACK (sort_by_id), ethi); + g_signal_connect (menu_item, "activate", G_CALLBACK (sort_by_id), ethi); } g_object_ref (popup); @@ -1605,7 +1622,7 @@ ethi_button_pressed (ETableHeaderItem *ethi, GdkEventButton *event) void ethi_change_sort_state (ETableHeaderItem *ethi, ETableCol *col) { - int model_col; + int model_col = -1; int length; int i; int found = FALSE; @@ -1613,33 +1630,32 @@ ethi_change_sort_state (ETableHeaderItem *ethi, ETableCol *col) if (col == NULL) return; - model_col = col->col_idx; + if (col->sortable) + model_col = col->col_idx; length = e_table_sort_info_grouping_get_count(ethi->sort_info); for (i = 0; i < length; i++) { ETableSortColumn column = e_table_sort_info_grouping_get_nth(ethi->sort_info, i); - if (model_col == column.column){ + if (model_col == column.column || model_col == -1){ int ascending = column.ascending; ascending = ! ascending; column.ascending = ascending; e_table_sort_info_grouping_set_nth(ethi->sort_info, i, column); found = 1; - break; + if (model_col != -1) + break; } } - if (!col->sortable) - return; - if (!found) { length = e_table_sort_info_sorting_get_count(ethi->sort_info); for (i = 0; i < length; i++) { ETableSortColumn column = e_table_sort_info_sorting_get_nth(ethi->sort_info, i); - if (model_col == column.column){ + if (model_col == column.column || model_col == -1){ int ascending = column.ascending; - if (ascending == 0){ + if (ascending == 0 && model_col != -1){ /* * This means the user has clicked twice * already, lets kill sorting now. @@ -1651,7 +1667,8 @@ ethi_change_sort_state (ETableHeaderItem *ethi, ETableCol *col) e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column); } found = 1; - break; + if (model_col != -1) + break; } } } |