diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-08-01 06:32:36 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-08-01 06:32:36 +0800 |
commit | 1ad76125efe77fe8237c8bdf6dde4f0bacf92f38 (patch) | |
tree | 1ef4c64668fa495ae871f27efeb20e5ea6bb870b | |
parent | 4b87fc9067e02f1925bc834e6cbd4b96165b53e3 (diff) | |
download | gsoc2013-evolution-1ad76125efe77fe8237c8bdf6dde4f0bacf92f38.tar gsoc2013-evolution-1ad76125efe77fe8237c8bdf6dde4f0bacf92f38.tar.gz gsoc2013-evolution-1ad76125efe77fe8237c8bdf6dde4f0bacf92f38.tar.bz2 gsoc2013-evolution-1ad76125efe77fe8237c8bdf6dde4f0bacf92f38.tar.lz gsoc2013-evolution-1ad76125efe77fe8237c8bdf6dde4f0bacf92f38.tar.xz gsoc2013-evolution-1ad76125efe77fe8237c8bdf6dde4f0bacf92f38.tar.zst gsoc2013-evolution-1ad76125efe77fe8237c8bdf6dde4f0bacf92f38.zip |
Added an argument to set a column so that you can't sort by that column.
2000-07-31 Christopher James Lahey <clahey@helixcode.com>
* e-table-col.c, e-table-col.h: Added an argument to set a column
so that you can't sort by that column.
* e-table-header-item.c: Obey the sortable column of ETableCol.
svn path=/trunk/; revision=4439
-rw-r--r-- | widgets/e-table/ChangeLog | 7 | ||||
-rw-r--r-- | widgets/e-table/e-table-col.c | 43 | ||||
-rw-r--r-- | widgets/e-table/e-table-col.h | 2 | ||||
-rw-r--r-- | widgets/e-table/e-table-header-item.c | 50 | ||||
-rw-r--r-- | widgets/table/e-table-col.c | 43 | ||||
-rw-r--r-- | widgets/table/e-table-col.h | 2 | ||||
-rw-r--r-- | widgets/table/e-table-header-item.c | 50 |
7 files changed, 151 insertions, 46 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog index 08775273c7..002a67617c 100644 --- a/widgets/e-table/ChangeLog +++ b/widgets/e-table/ChangeLog @@ -1,3 +1,10 @@ +2000-07-31 Christopher James Lahey <clahey@helixcode.com> + + * e-table-col.c, e-table-col.h: Added an argument to set a column + so that you can't sort by that column. + + * e-table-header-item.c: Obey the sortable column of ETableCol. + 2000-07-29 Christopher James Lahey <clahey@helixcode.com> * e-table-click-to-add.c: Made enter key destroy and recreate the diff --git a/widgets/e-table/e-table-col.c b/widgets/e-table/e-table-col.c index 5a167a8940..e767aa5567 100644 --- a/widgets/e-table/e-table-col.c +++ b/widgets/e-table/e-table-col.c @@ -17,6 +17,12 @@ static GtkObjectClass *parent_class; + +enum { + ARG_0, + ARG_SORTABLE, +}; + static void etc_destroy (GtkObject *object) { @@ -31,18 +37,53 @@ etc_destroy (GtkObject *object) (*parent_class->destroy)(object); } - + + +static void +etc_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + ETableCol *etc = E_TABLE_COL (o); + + switch (arg_id){ + case ARG_SORTABLE: + etc->sortable = GTK_VALUE_BOOL(*arg); + break; + } +} + +static void +etc_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + ETableCol *etc = E_TABLE_COL (o); + + switch (arg_id){ + case ARG_SORTABLE: + GTK_VALUE_BOOL(*arg) = etc->sortable; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + static void e_table_col_class_init (GtkObjectClass *object_class) { parent_class = gtk_type_class (PARENT_TYPE); object_class->destroy = etc_destroy; + object_class->get_arg = etc_get_arg; + object_class->set_arg = etc_set_arg; + + gtk_object_add_arg_type ("ETableCol::sortable", + GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SORTABLE); } static void e_table_col_init (ETableCol *etc) { etc->width = 0; + etc->sortable = 1; + etc->groupable = 1; } E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, e_table_col_init, PARENT_TYPE); diff --git a/widgets/e-table/e-table-col.h b/widgets/e-table/e-table-col.h index a7878fe4d7..39aeb26ba9 100644 --- a/widgets/e-table/e-table-col.h +++ b/widgets/e-table/e-table-col.h @@ -36,6 +36,8 @@ struct _ETableCol { unsigned int is_pixbuf:1; unsigned int selected:1; unsigned int resizeable:1; + unsigned int sortable:1; + unsigned int groupable:1; int col_idx; ETableColArrow arrow; diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c index 173256c8bd..fc4947293e 100644 --- a/widgets/e-table/e-table-header-item.c +++ b/widgets/e-table/e-table-header-item.c @@ -1150,9 +1150,11 @@ ethi_popup_customize_view(GtkWidget *widget, EthiHeaderInfo *info) { } +/* Bit 1 is always disabled. */ +/* Bit 2 is disabled if not "sortable". */ static EPopupMenu ethi_context_menu [] = { - { "Sort Ascending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_ascending), 0}, - { "Sort Descending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_descending), 0}, + { "Sort Ascending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_ascending), 2}, + { "Sort Descending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_descending), 2}, { "Unsort", NULL, GTK_SIGNAL_FUNC(ethi_popup_unsort), 0}, { "", NULL, GTK_SIGNAL_FUNC(NULL), 0}, { "Group By This Field", NULL, GTK_SIGNAL_FUNC(ethi_popup_group_field), 0}, @@ -1173,9 +1175,11 @@ static void ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event) { EthiHeaderInfo *info = g_new(EthiHeaderInfo, 1); + ETableCol *col; info->ethi = ethi; info->col = ethi_find_col_by_x (ethi, event->x); - e_popup_menu_run (ethi_context_menu, event, 1, info); + col = e_table_header_get_column (ethi->eth, info->col); + e_popup_menu_run (ethi_context_menu, event, 1 + (col->sortable ? 0 : 2), info); } static void @@ -1310,29 +1314,31 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e) break; } } - 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){ - int ascending = column.ascending; - ascending = ! ascending; - column.ascending = ascending; - e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column); - found = 1; - break; + if(col->sortable) { + 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){ + int ascending = column.ascending; + ascending = ! ascending; + column.ascending = ascending; + e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column); + found = 1; + break; + } } } - } - if (!found) { - ETableSortColumn column = { model_col, 1 }; - length = e_table_sort_info_sorting_get_count(ethi->sort_info); - if (length == 0) - length++; - e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column); + if (!found) { + ETableSortColumn column = { model_col, 1 }; + length = e_table_sort_info_sorting_get_count(ethi->sort_info); + if (length == 0) + length++; + e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column); + } } } - + if (needs_ungrab) gnome_canvas_item_ungrab (item, e->button.time); diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c index 5a167a8940..e767aa5567 100644 --- a/widgets/table/e-table-col.c +++ b/widgets/table/e-table-col.c @@ -17,6 +17,12 @@ static GtkObjectClass *parent_class; + +enum { + ARG_0, + ARG_SORTABLE, +}; + static void etc_destroy (GtkObject *object) { @@ -31,18 +37,53 @@ etc_destroy (GtkObject *object) (*parent_class->destroy)(object); } - + + +static void +etc_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + ETableCol *etc = E_TABLE_COL (o); + + switch (arg_id){ + case ARG_SORTABLE: + etc->sortable = GTK_VALUE_BOOL(*arg); + break; + } +} + +static void +etc_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + ETableCol *etc = E_TABLE_COL (o); + + switch (arg_id){ + case ARG_SORTABLE: + GTK_VALUE_BOOL(*arg) = etc->sortable; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + static void e_table_col_class_init (GtkObjectClass *object_class) { parent_class = gtk_type_class (PARENT_TYPE); object_class->destroy = etc_destroy; + object_class->get_arg = etc_get_arg; + object_class->set_arg = etc_set_arg; + + gtk_object_add_arg_type ("ETableCol::sortable", + GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SORTABLE); } static void e_table_col_init (ETableCol *etc) { etc->width = 0; + etc->sortable = 1; + etc->groupable = 1; } E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, e_table_col_init, PARENT_TYPE); diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h index a7878fe4d7..39aeb26ba9 100644 --- a/widgets/table/e-table-col.h +++ b/widgets/table/e-table-col.h @@ -36,6 +36,8 @@ struct _ETableCol { unsigned int is_pixbuf:1; unsigned int selected:1; unsigned int resizeable:1; + unsigned int sortable:1; + unsigned int groupable:1; int col_idx; ETableColArrow arrow; diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index 173256c8bd..fc4947293e 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -1150,9 +1150,11 @@ ethi_popup_customize_view(GtkWidget *widget, EthiHeaderInfo *info) { } +/* Bit 1 is always disabled. */ +/* Bit 2 is disabled if not "sortable". */ static EPopupMenu ethi_context_menu [] = { - { "Sort Ascending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_ascending), 0}, - { "Sort Descending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_descending), 0}, + { "Sort Ascending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_ascending), 2}, + { "Sort Descending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_descending), 2}, { "Unsort", NULL, GTK_SIGNAL_FUNC(ethi_popup_unsort), 0}, { "", NULL, GTK_SIGNAL_FUNC(NULL), 0}, { "Group By This Field", NULL, GTK_SIGNAL_FUNC(ethi_popup_group_field), 0}, @@ -1173,9 +1175,11 @@ static void ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event) { EthiHeaderInfo *info = g_new(EthiHeaderInfo, 1); + ETableCol *col; info->ethi = ethi; info->col = ethi_find_col_by_x (ethi, event->x); - e_popup_menu_run (ethi_context_menu, event, 1, info); + col = e_table_header_get_column (ethi->eth, info->col); + e_popup_menu_run (ethi_context_menu, event, 1 + (col->sortable ? 0 : 2), info); } static void @@ -1310,29 +1314,31 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e) break; } } - 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){ - int ascending = column.ascending; - ascending = ! ascending; - column.ascending = ascending; - e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column); - found = 1; - break; + if(col->sortable) { + 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){ + int ascending = column.ascending; + ascending = ! ascending; + column.ascending = ascending; + e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column); + found = 1; + break; + } } } - } - if (!found) { - ETableSortColumn column = { model_col, 1 }; - length = e_table_sort_info_sorting_get_count(ethi->sort_info); - if (length == 0) - length++; - e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column); + if (!found) { + ETableSortColumn column = { model_col, 1 }; + length = e_table_sort_info_sorting_get_count(ethi->sort_info); + if (length == 0) + length++; + e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column); + } } } - + if (needs_ungrab) gnome_canvas_item_ungrab (item, e->button.time); |