aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2006-06-12 13:05:48 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2006-06-12 13:05:48 +0800
commitd3e8fc316941aba4d04ee1f1eee999ec5781f14b (patch)
treece2c337562fed2a0ed85f2ad01e1ed088d3183d8 /widgets
parent4dbdaf99b9eaf4b2672e4ae66c8f4d05bc5e6aa3 (diff)
downloadgsoc2013-evolution-d3e8fc316941aba4d04ee1f1eee999ec5781f14b.tar
gsoc2013-evolution-d3e8fc316941aba4d04ee1f1eee999ec5781f14b.tar.gz
gsoc2013-evolution-d3e8fc316941aba4d04ee1f1eee999ec5781f14b.tar.bz2
gsoc2013-evolution-d3e8fc316941aba4d04ee1f1eee999ec5781f14b.tar.lz
gsoc2013-evolution-d3e8fc316941aba4d04ee1f1eee999ec5781f14b.tar.xz
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')
-rw-r--r--widgets/table/ChangeLog12
-rw-r--r--widgets/table/e-table-column-specification.c1
-rw-r--r--widgets/table/e-table-column-specification.h1
-rw-r--r--widgets/table/e-table-header-item.c59
-rw-r--r--widgets/table/e-table-utils.c5
5 files changed, 56 insertions, 22 deletions
diff --git a/widgets/table/ChangeLog b/widgets/table/ChangeLog
index c9b68fd40b..35f0a8e4ae 100644
--- a/widgets/table/ChangeLog
+++ b/widgets/table/ChangeLog
@@ -1,3 +1,15 @@
+2006-06-12 Srinivasa Ragavan <sragavan@novell.com>
+
+ Committing a fix for sorting in the vertical view.
+
+ * e-table-column-specification.c:
+ (e_table_column_specification_load_from_node):
+ * e-table-column-specification.h:
+ * e-table-header-item.c: (ethi_popup_sort_ascending),
+ (ethi_popup_sort_descending), (ethi_header_context_menu),
+ (ethi_change_sort_state):
+ * e-table-utils.c: (et_col_spec_to_col):
+
2006-06-08 Carlos Garcia Campos <carlosgc@gnome.org>
** Fixes bug #343764
diff --git a/widgets/table/e-table-column-specification.c b/widgets/table/e-table-column-specification.c
index 1d4d1d218a..a563248735 100644
--- a/widgets/table/e-table-column-specification.c
+++ b/widgets/table/e-table-column-specification.c
@@ -116,6 +116,7 @@ e_table_column_specification_load_from_node (ETableColumnSpecification *etcs,
etcs->cell = e_xml_get_string_prop_by_name (node, "cell");
etcs->compare = e_xml_get_string_prop_by_name (node, "compare");
etcs->search = e_xml_get_string_prop_by_name (node, "search");
+ etcs->sortable = e_xml_get_string_prop_by_name (node, "sortable");
etcs->priority = e_xml_get_integer_prop_by_name_with_default (node, "priority", 0);
if (etcs->title == NULL)
diff --git a/widgets/table/e-table-column-specification.h b/widgets/table/e-table-column-specification.h
index 6bf5623398..87d538a542 100644
--- a/widgets/table/e-table-column-specification.h
+++ b/widgets/table/e-table-column-specification.h
@@ -52,6 +52,7 @@ typedef struct {
char *cell;
char *compare;
char *search;
+ char *sortable;
int priority;
} ETableColumnSpecification;
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;
}
}
}
diff --git a/widgets/table/e-table-utils.c b/widgets/table/e-table-utils.c
index fb05326573..178842cd84 100644
--- a/widgets/table/e-table-utils.c
+++ b/widgets/table/e-table-utils.c
@@ -113,7 +113,10 @@ et_col_spec_to_col (ETableColumnSpecification *col_spec,
cell, compare, col_spec->resizable, col_spec->disabled, col_spec->priority);
}
col->search = search;
-
+ if (col_spec->sortable && !strcmp(col_spec->sortable, "false"))
+ col->sortable = FALSE;
+ else
+ col->sortable = TRUE;
g_free (title);
}
if (col && col_spec->compare_col != col_spec->model_col)