diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-08-11 04:49:24 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-08-11 04:49:24 +0800 |
commit | 1580b0527cab9b93c15a899dd83031ee65fc64d2 (patch) | |
tree | ff9f876c3028b9d18e0ef916bb561550c7767b86 | |
parent | acdfbcd161c23f9b5b043e3dd6829e5dbd48a2f0 (diff) | |
download | gsoc2013-evolution-1580b0527cab9b93c15a899dd83031ee65fc64d2.tar.gz gsoc2013-evolution-1580b0527cab9b93c15a899dd83031ee65fc64d2.tar.zst gsoc2013-evolution-1580b0527cab9b93c15a899dd83031ee65fc64d2.zip |
If the sort_info can't group, hide the grouping button and label.
2001-08-10 Christopher James Lahey <clahey@ximian.com>
* e-table-config.c (setup_gui): If the sort_info can't group, hide
the grouping button and label.
* e-table-header-item.c (ethi_header_context_menu): Removed the
Group By This Field menu item if the sort_info doesn't support
grouping.
* e-table-sort-info.c, e-table-sort-info.h
(e_table_sort_info_get_can_group,
e_table_sort_info_set_can_group): Added these functions.
* e-tree.c (e_tree_set_state_object, et_real_construct): Set
can_group to FALSE for all our sort infos.
(e_tree_get_state_object): Fixed a potential gtk_object_ref (NULL)
here.
svn path=/trunk/; revision=11896
-rw-r--r-- | widgets/table/e-table-config.c | 6 | ||||
-rw-r--r-- | widgets/table/e-table-header-item.c | 11 | ||||
-rw-r--r-- | widgets/table/e-table-sort-info.c | 25 | ||||
-rw-r--r-- | widgets/table/e-table-sort-info.h | 5 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 10 |
5 files changed, 47 insertions, 10 deletions
diff --git a/widgets/table/e-table-config.c b/widgets/table/e-table-config.c index c33290b227..93dd0d31cf 100644 --- a/widgets/table/e-table-config.c +++ b/widgets/table/e-table-config.c @@ -726,6 +726,12 @@ setup_gui (ETableConfig *config) gtk_signal_connect ( GTK_OBJECT (config->dialog_toplevel), "apply", GTK_SIGNAL_FUNC (dialog_apply), config); + + if (!e_table_sort_info_get_can_group (config->state->sort_info)) { + GtkWidget *button = glade_xml_get_widget (gui, "button-group"); + gtk_widget_hide (button); + gtk_widget_hide (config->group_label); + } gtk_object_unref (GTK_OBJECT (gui)); } diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index d3a28c8f69..e089cb5fa6 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -1277,15 +1277,15 @@ static EPopupMenu ethi_context_menu [] = { { N_("Sort Descending"), NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_descending), NULL, 2}, { N_("Unsort"), NULL, GTK_SIGNAL_FUNC(ethi_popup_unsort), NULL, 0}, { "", NULL, GTK_SIGNAL_FUNC(NULL), NULL, 0}, - { N_("Group By This Field"), NULL, GTK_SIGNAL_FUNC(ethi_popup_group_field), NULL, 0}, - { N_("Group By Box"), NULL, GTK_SIGNAL_FUNC(ethi_popup_group_box), NULL, 16}, + { N_("Group By This Field"), NULL, GTK_SIGNAL_FUNC(ethi_popup_group_field), NULL, 16}, + { N_("Group By Box"), NULL, GTK_SIGNAL_FUNC(ethi_popup_group_box), NULL, 128}, { "", NULL, GTK_SIGNAL_FUNC(NULL), NULL, 1}, { N_("Remove This Column"), NULL, GTK_SIGNAL_FUNC(ethi_popup_remove_column), NULL, 8}, { N_("Add a Column..."), NULL, GTK_SIGNAL_FUNC(ethi_popup_field_chooser), NULL, 0}, { "", NULL, GTK_SIGNAL_FUNC(NULL), NULL, 1}, - { N_("Alignment"), NULL, GTK_SIGNAL_FUNC(ethi_popup_alignment), NULL, 16}, + { N_("Alignment"), NULL, GTK_SIGNAL_FUNC(ethi_popup_alignment), NULL, 128}, { N_("Best Fit"), NULL, GTK_SIGNAL_FUNC(ethi_popup_best_fit), NULL, 2}, - { N_("Format Columns..."), NULL, GTK_SIGNAL_FUNC(ethi_popup_format_columns), NULL, 16}, + { N_("Format Columns..."), NULL, GTK_SIGNAL_FUNC(ethi_popup_format_columns), NULL, 128}, { "", NULL, GTK_SIGNAL_FUNC(NULL), NULL, 1}, { N_("Customize Current View..."), NULL, GTK_SIGNAL_FUNC(ethi_popup_customize_view), NULL, 4}, { NULL, NULL, NULL, NULL, 0 } @@ -1304,7 +1304,8 @@ ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event) (col->sortable ? 0 : 2) + (ethi->table ? 0 : 4) + ((e_table_header_count (ethi->eth) > 1) ? 0 : 8), - 16, info); + ((e_table_sort_info_get_can_group (ethi->sort_info)) ? 0 : 16) + + 128, info); } static void diff --git a/widgets/table/e-table-sort-info.c b/widgets/table/e-table-sort-info.c index 32477cbf4b..ed10e6c73b 100644 --- a/widgets/table/e-table-sort-info.c +++ b/widgets/table/e-table-sort-info.c @@ -59,6 +59,7 @@ e_table_sort_info_init (ETableSortInfo *info) info->frozen = 0; info->sort_info_changed = 0; info->group_info_changed = 0; + info->can_group = 1; } static void @@ -179,7 +180,10 @@ e_table_sort_info_thaw (ETableSortInfo *info) guint e_table_sort_info_grouping_get_count (ETableSortInfo *info) { - return info->group_count; + if (info->can_group) + return info->group_count; + else + return 0; } static void @@ -219,7 +223,7 @@ e_table_sort_info_grouping_truncate (ETableSortInfo *info, int length) ETableSortColumn e_table_sort_info_grouping_get_nth (ETableSortInfo *info, int n) { - if (n < info->group_count) { + if (info->can_group && n < info->group_count) { return info->groupings[n]; } else { ETableSortColumn fake = {0, 0}; @@ -450,5 +454,22 @@ e_table_sort_info_duplicate (ETableSortInfo *info) new_info->sortings = g_new(ETableSortColumn, new_info->sort_count); memmove(new_info->sortings, info->sortings, sizeof (ETableSortColumn) * new_info->sort_count); + new_info->can_group = info->can_group; + return new_info; } + +void +e_table_sort_info_set_can_group (ETableSortInfo *info, + gboolean can_group) +{ + info->can_group = can_group; +} + +gboolean +e_table_sort_info_get_can_group (ETableSortInfo *info) +{ + return info->can_group; +} + + diff --git a/widgets/table/e-table-sort-info.h b/widgets/table/e-table-sort-info.h index a2cd4f43a0..09a2b16d4b 100644 --- a/widgets/table/e-table-sort-info.h +++ b/widgets/table/e-table-sort-info.h @@ -33,6 +33,8 @@ typedef struct { guint frozen : 1; guint sort_info_changed : 1; guint group_info_changed : 1; + + guint can_group : 1; } ETableSortInfo; typedef struct { @@ -75,6 +77,9 @@ void e_table_sort_info_load_from_node (ETableSortInfo *info, xmlNode *e_table_sort_info_save_to_node (ETableSortInfo *info, xmlNode *parent); ETableSortInfo *e_table_sort_info_duplicate (ETableSortInfo *info); +void e_table_sort_info_set_can_group (ETableSortInfo *info, + gboolean can_group); +gboolean e_table_sort_info_get_can_group (ETableSortInfo *info); #ifdef __cplusplus } diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 97153b95be..753188a831 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -751,9 +751,10 @@ e_tree_set_state_object(ETree *e_tree, ETableState *state) if (e_tree->priv->sort_info) gtk_object_unref(GTK_OBJECT(e_tree->priv->sort_info)); - if (state->sort_info) + if (state->sort_info) { e_tree->priv->sort_info = e_table_sort_info_duplicate(state->sort_info); - else + e_table_sort_info_set_can_group (e_tree->priv->sort_info, FALSE); + } else e_tree->priv->sort_info = NULL; if (e_tree->priv->header_item) @@ -843,7 +844,8 @@ e_tree_get_state_object (ETree *e_tree) state = e_table_state_new(); state->sort_info = e_tree->priv->sort_info; - gtk_object_ref(GTK_OBJECT(state->sort_info)); + if (state->sort_info) + gtk_object_ref(GTK_OBJECT(state->sort_info)); state->col_count = e_table_header_count (e_tree->priv->header); full_col_count = e_table_header_count (e_tree->priv->full_header); @@ -969,6 +971,8 @@ et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, e_tree->priv->sort_info = state->sort_info; gtk_object_ref (GTK_OBJECT (e_tree->priv->sort_info)); + e_table_sort_info_set_can_group (e_tree->priv->sort_info, FALSE); + gtk_object_set(GTK_OBJECT(e_tree->priv->header), "sort_info", e_tree->priv->sort_info, NULL); |