From 234f637779fa740ae50d1d12a76cde8cceff8fea Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sun, 18 Mar 2001 23:51:23 +0000 Subject: Use update_sort_and_group_config dialog instead of the non-implemented 2001-03-18 Miguel de Icaza * e-table-config.c (sort_entry_changed): Use update_sort_and_group_config dialog instead of the non-implemented update_group_config_dialog. (update_sort_and_group_config_dialog): Update the text correctly. (sort_entry_changed): Handle empty string as not-in-set. (group_entry_changed): Handle empty string as not-in-set. (config_class_init): Fix the signal declaration for "changed", this was sending the wrong information. (update_sort_and_group_config_dialog): Use group_info here, not sort_info * e-table-header-item.c (ethi_popup_customize_view): Changed to use the "changed" signal in the ETableConfig instead of promiscously using the "apply" from the PropertyBox * e-table-config.glade: Set Hide On Close to yes for the Group-By dialog. The groups for Radio Buttons in the Glade file are global, which caused all sorts of strange behaviour and really hard to debug problems. This should be now fixed svn path=/trunk/; revision=8801 --- widgets/table/e-table-config.c | 58 ++++---- widgets/table/e-table-config.glade | 250 ++++++++++++++++++----------------- widgets/table/e-table-config.glade.h | 4 +- widgets/table/e-table-header-item.c | 14 +- widgets/table/e-table-state.c | 3 +- 5 files changed, 166 insertions(+), 163 deletions(-) (limited to 'widgets/table') diff --git a/widgets/table/e-table-config.c b/widgets/table/e-table-config.c index f25e77245d..c249c498e8 100644 --- a/widgets/table/e-table-config.c +++ b/widgets/table/e-table-config.c @@ -49,11 +49,12 @@ config_destroy (GtkObject *object) } static void -e_table_config_changed (ETableConfig *config, ETableState *state) +e_table_config_changed (ETableConfig *config, ETableState *state) { g_return_if_fail (config != NULL); g_return_if_fail (E_IS_TABLE_CONFIG (config)); + gtk_signal_emit(GTK_OBJECT(config), e_table_config_signals [CHANGED], state); @@ -75,8 +76,8 @@ config_class_init (GtkObjectClass *object_class) GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (ETableConfigClass, changed), - gtk_marshal_NONE__OBJECT, - GTK_TYPE_NONE, 1, E_TABLE_STATE_TYPE); + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, e_table_config_signals, LAST_SIGNAL); } @@ -127,6 +128,7 @@ update_sort_and_group_config_dialog (ETableConfig *config, gboolean is_sort) for (i = 0; i < 4; i++){ gboolean sensitive = (i <= count); + char *text = ""; gtk_widget_set_sensitive (widgets [i].frames, sensitive); @@ -136,6 +138,9 @@ update_sort_and_group_config_dialog (ETableConfig *config, gboolean is_sort) gtk_signal_handler_block ( GTK_OBJECT (widgets [i].radio_ascending), widgets [i].toggled_id); + gtk_signal_handler_block ( + GTK_OBJECT (widgets [i].combo->entry), + widgets [i].changed_id); if (i < count){ GtkToggleButton *a, *d; @@ -161,18 +166,7 @@ update_sort_and_group_config_dialog (ETableConfig *config, gboolean is_sort) continue; } - /* - * Change the text - */ - gtk_signal_handler_block ( - GTK_OBJECT (widgets [i].combo->entry), - widgets [i].changed_id); - gtk_combo_text_set_text ( - widgets [i].combo, gettext ( - column->title)); - gtk_signal_handler_unblock ( - GTK_OBJECT (widgets [i].combo->entry), - widgets [i].changed_id); + text = gettext (column->title); /* * Update radio buttons @@ -189,20 +183,25 @@ update_sort_and_group_config_dialog (ETableConfig *config, gboolean is_sort) t = GTK_TOGGLE_BUTTON ( widgets [i].radio_ascending); + if (is_sort) + g_assert (widgets [i].radio_ascending != config->group [i].radio_ascending); + else + g_assert (widgets [i].radio_ascending != config->sort [i].radio_ascending); gtk_toggle_button_set_active (t, 1); } + + /* Set the text */ + gtk_combo_text_set_text (widgets [i].combo, text); + gtk_signal_handler_unblock ( GTK_OBJECT (widgets [i].radio_ascending), widgets [i].toggled_id); + gtk_signal_handler_unblock ( + GTK_OBJECT (widgets [i].combo->entry), + widgets [i].changed_id); } } -static void -update_group_config_dialog (ETableConfig *config) -{ - g_warning ("IMPLEMENT ME\n"); -} - static void config_sort_info_update (ETableConfig *config) { @@ -250,7 +249,6 @@ config_group_info_update (ETableConfig *config) int count, i; count = e_table_sort_info_grouping_get_count (info); - printf ("Count of the grouping action: %d\n", count); res = g_string_new (""); for (i = 0; i < count; i++) { @@ -310,7 +308,7 @@ do_sort_and_group_config_dialog (ETableConfig *config, gboolean is_sort) int button, running = 1; config->temp_state = e_table_state_duplicate (config->state); - + update_sort_and_group_config_dialog (config, is_sort); gtk_widget_grab_focus (GTK_WIDGET ( @@ -342,6 +340,7 @@ do_sort_and_group_config_dialog (ETableConfig *config, gboolean is_sort) case 1: gtk_object_unref (GTK_OBJECT (config->state)); config->state = config->temp_state; + config->temp_state = 0; running = 0; gnome_property_box_changed ( GNOME_PROPERTY_BOX (config->dialog_toplevel)); @@ -434,13 +433,13 @@ sort_entry_changed (GtkEntry *entry, ETableConfigSortWidgets *sort) char *s = gtk_entry_get_text (entry); - if (g_hash_table_lookup (sort->combo->elements, s)){ + if (s && s [0] && g_hash_table_lookup (sort->combo->elements, s)){ ETableSortColumn c; int col; col = find_model_column_by_name (config->source_spec, s); if (col == -1){ - g_warning ("This should not happen"); + g_warning ("sort: This should not happen (%s)", s); return; } @@ -535,16 +534,15 @@ group_entry_changed (GtkEntry *entry, ETableConfigSortWidgets *group) ETableSortInfo *sort_info = config->temp_state->sort_info; ETableConfigSortWidgets *base = &config->group[0]; int idx = group - base; - char *s = gtk_entry_get_text (entry); - if (g_hash_table_lookup (group->combo->elements, s)){ + if (s && s [0] && g_hash_table_lookup (group->combo->elements, s)){ ETableSortColumn c; int col; col = find_model_column_by_name (config->source_spec, s); if (col == -1){ - g_warning ("This should not happen"); + g_warning ("grouping: this should not happen, %s", s); return; } @@ -553,10 +551,10 @@ group_entry_changed (GtkEntry *entry, ETableConfigSortWidgets *group) c.column = col; e_table_sort_info_grouping_set_nth (sort_info, idx, c); - update_group_config_dialog (config); + update_sort_and_group_config_dialog (config, FALSE); } else { e_table_sort_info_grouping_truncate (sort_info, idx); - update_group_config_dialog (config); + update_sort_and_group_config_dialog (config, FALSE); } } diff --git a/widgets/table/e-table-config.glade b/widgets/table/e-table-config.glade index e0035daf67..b199b521a7 100644 --- a/widgets/table/e-table-config.glade +++ b/widgets/table/e-table-config.glade @@ -10,17 +10,9 @@ C True True - False False False False - True - interface.c - interface.h - callbacks.c - callbacks.h - support.c - support.h True e-table-config.glade.h @@ -51,6 +43,40 @@ True + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area3 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button20 + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + button22 + True + True + GNOME_STOCK_BUTTON_CANCEL + + + GtkVBox vbox2 @@ -188,6 +214,7 @@ table-1 True + GTK_RELIEF_NORMAL @@ -236,6 +263,7 @@ table-2 True + GTK_RELIEF_NORMAL @@ -256,6 +284,7 @@ button-up True + GTK_RELIEF_NORMAL 0 False @@ -268,6 +297,7 @@ button-down True + GTK_RELIEF_NORMAL 0 False @@ -302,6 +332,7 @@ button-add True + GTK_RELIEF_NORMAL 0 False @@ -314,6 +345,7 @@ button-remove True + GTK_RELIEF_NORMAL 0 False @@ -327,11 +359,39 @@ + + + + + GnomeDialog + dialog-group-by + False + Group + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + False + True + + + GtkVBox + GnomeDialog:vbox + dialog-vbox4 + False + 8 + + 4 + True + True + GtkHButtonBox GnomeDialog:action_area - dialog-action_area3 + dialog-action_area4 GTK_BUTTONBOX_END 8 85 @@ -347,7 +407,15 @@ GtkButton - button20 + button39 + True + True + + + + + GtkButton + button41 True True GNOME_STOCK_BUTTON_OK @@ -355,40 +423,12 @@ GtkButton - button22 + button42 True True GNOME_STOCK_BUTTON_CANCEL - - - - - GnomeDialog - dialog-group-by - False - Group - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox4 - False - 8 - - 4 - True - True - GtkVBox @@ -488,7 +528,7 @@ False True - group-1 + g-group-1 0 False @@ -503,7 +543,7 @@ False True - group-1 + g-group-1 0 False @@ -670,7 +710,7 @@ False True - group-2 + g-group-2 0 False @@ -685,7 +725,7 @@ False True - group-2 + g-group-2 0 False @@ -852,7 +892,7 @@ False True - group-3 + g-group-3 0 False @@ -867,7 +907,7 @@ False True - group-3 + g-group-3 0 False @@ -1034,7 +1074,7 @@ False True - group-4 + g-group-4 0 False @@ -1049,7 +1089,7 @@ False True - group-4 + g-group-4 0 False @@ -1061,11 +1101,39 @@ + + + + + GnomeDialog + dialog-sort + False + Sort + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + False + True + + + GtkVBox + GnomeDialog:vbox + vbox15 + False + 8 + + 4 + True + True + GtkHButtonBox GnomeDialog:action_area - dialog-action_area4 + hbuttonbox1 GTK_BUTTONBOX_END 8 85 @@ -1081,7 +1149,7 @@ GtkButton - button39 + button43 True True @@ -1089,48 +1157,21 @@ GtkButton - button41 + button44 True + True True GNOME_STOCK_BUTTON_OK GtkButton - button42 + button45 True True GNOME_STOCK_BUTTON_CANCEL - - - - - GnomeDialog - dialog-sort - False - Sort - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - False - True - - - GtkVBox - GnomeDialog:vbox - vbox15 - False - 8 - - 4 - True - True - GtkTable @@ -1524,55 +1565,17 @@ - - - GtkHButtonBox - GnomeDialog:action_area - hbuttonbox1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button43 - True - True - - - - - GtkButton - button44 - True - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button45 - True - True - GNOME_STOCK_BUTTON_CANCEL - - GnomePropertyBox e-table-config + GTK_WIN_POS_NONE + False + False + False + False GtkNotebook @@ -1698,6 +1701,7 @@ Tue, 03 Oct 2000 22:11:12 GMT + GTK_RELIEF_NORMAL 0 1 @@ -1725,6 +1729,7 @@ Tue, 03 Oct 2000 22:10:58 GMT + GTK_RELIEF_NORMAL 0 1 @@ -1752,6 +1757,7 @@ Tue, 03 Oct 2000 22:10:50 GMT + GTK_RELIEF_NORMAL 0 1 diff --git a/widgets/table/e-table-config.glade.h b/widgets/table/e-table-config.glade.h index 4218ce256a..76f2aaea31 100644 --- a/widgets/table/e-table-config.glade.h +++ b/widgets/table/e-table-config.glade.h @@ -14,6 +14,7 @@ gchar *s = N_("Move _Down"); gchar *s = N_("_Add ->"); gchar *s = N_("<- _Remove"); gchar *s = N_("Group"); +gchar *s = N_("Clear All"); gchar *s = N_("Group Items By"); gchar *s = N_("Show field in View"); gchar *s = N_("Ascending"); @@ -30,8 +31,8 @@ gchar *s = N_("Then By"); gchar *s = N_("Show field in View"); gchar *s = N_("Ascending"); gchar *s = N_("Descending"); -gchar *s = N_("Clear All"); gchar *s = N_("Sort"); +gchar *s = N_("Clear All"); gchar *s = N_("Then By"); gchar *s = N_("Ascending"); gchar *s = N_("Descending"); @@ -44,7 +45,6 @@ gchar *s = N_("Descending"); gchar *s = N_("Sort Items By"); gchar *s = N_("Ascending"); gchar *s = N_("Descending"); -gchar *s = N_("Clear All"); gchar *s = N_("Description"); gchar *s = N_("_Fields..."); gchar *s = N_("_Sort..."); diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index 70bdb3d698..c3db9e7dfc 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -1221,14 +1221,13 @@ config_destroyed (GtkObject *object, ETableHeaderItem *ethi) } static void -apply_changes (GnomePropertyBox *pbox, gint page_num, ETableHeaderItem *ethi) +apply_changes (ETableConfig *config, ETableHeaderItem *ethi) { - ETableConfig *config = E_TABLE_CONFIG (ethi->config); char *state = e_table_state_save_to_string (config->state); - if (page_num != -1) - return; - + printf ("This is the Table: %p %p\n", ethi->table, ethi); + printf ("This is the state: %s\n", state); + e_table_set_state (ethi->table, state); g_free (state); } @@ -1239,6 +1238,7 @@ ethi_popup_customize_view(GtkWidget *widget, EthiHeaderInfo *info) ETableHeaderItem *ethi = info->ethi; ETableState *state; + printf ("___This is the Table: %p %p\n", ethi->table, ethi); if (ethi->config) e_table_config_raise (E_TABLE_CONFIG (ethi->config)); else { @@ -1251,9 +1251,7 @@ ethi_popup_customize_view(GtkWidget *widget, EthiHeaderInfo *info) GTK_OBJECT (ethi->config), "destroy", GTK_SIGNAL_FUNC (config_destroyed), ethi); gtk_signal_connect ( - GTK_OBJECT ( - E_TABLE_CONFIG (ethi->config)->dialog_toplevel), - "apply", + GTK_OBJECT (ethi->config), "changed", GTK_SIGNAL_FUNC (apply_changes), ethi); } } diff --git a/widgets/table/e-table-state.c b/widgets/table/e-table-state.c index c978487368..2d7fb3b3ac 100644 --- a/widgets/table/e-table-state.c +++ b/widgets/table/e-table-state.c @@ -28,9 +28,10 @@ etst_destroy (GtkObject *object) { ETableState *etst = E_TABLE_STATE (object); + gtk_object_destroy (GTK_OBJECT (etst->sort_info)); if (etst->columns) g_free (etst->columns); - + GTK_OBJECT_CLASS (etst_parent_class)->destroy (object); } -- cgit v1.2.3