From 8c5325bc09ba0d4ffa953ff9a909c324bcf31841 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 24 Jul 2007 06:24:01 +0000 Subject: [PATCH] Tidied up the way that value-labels button and menu item interact. --- src/ui/gui/data-editor.c | 71 +++++++++++++----------------------- src/ui/gui/data-editor.glade | 2 +- src/ui/gui/data-editor.h | 2 + 3 files changed, 28 insertions(+), 47 deletions(-) diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index 28f15e01..16c85d9d 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -71,6 +71,7 @@ static void insert_case (GtkAction *a, gpointer data); static void delete_cases (GtkAction *a, gpointer data); static void delete_variables (GtkAction *a, gpointer data); +static void toggle_value_labels (GtkToggleAction *a, gpointer data); /* Switch between the VAR SHEET and the DATA SHEET */ @@ -102,10 +103,6 @@ static void variable_sheet_activate (GtkCheckMenuItem *, gpointer ); static void fonts_activate (GtkMenuItem *, gpointer); -static void value_labels_activate (GtkCheckMenuItem *, gpointer); -static void value_labels_toggled (GtkToggleToolButton *, gpointer); - - static void file_quit (GtkCheckMenuItem *, gpointer ); static void @@ -244,6 +241,24 @@ new_data_editor (void) register_data_editor_actions (de); + de->toggle_value_labels = + gtk_toggle_action_new ("toggle-value-labels", + _("Labels"), + _("Show (hide) value labels"), + "pspp-value-labels"); + + g_signal_connect (de->toggle_value_labels, "activate", + G_CALLBACK (toggle_value_labels), de); + + + gtk_action_connect_proxy (GTK_ACTION (de->toggle_value_labels), + get_widget_assert (de->xml, + "togglebutton-value-labels")); + + + gtk_action_connect_proxy (GTK_ACTION (de->toggle_value_labels), + get_widget_assert (de->xml, + "view_value-labels")); de->delete_cases = gtk_action_new ("clear-cases", @@ -579,14 +594,6 @@ new_data_editor (void) - g_signal_connect (get_widget_assert (de->xml, "view_valuelabels"), - "activate", - G_CALLBACK (value_labels_activate), de); - - - g_signal_connect (get_widget_assert (de->xml, "togglebutton-value-labels"), - "toggled", - G_CALLBACK (value_labels_toggled), de); gtk_action_connect_proxy (de->action_data_open, get_widget_assert (de->xml, "button-open") @@ -828,50 +835,20 @@ fonts_activate (GtkMenuItem *menuitem, gpointer data) } -/* The next two callbacks are mutually co-operative */ - -/* Callback for the value labels menu item */ -static void -value_labels_activate (GtkCheckMenuItem *menuitem, gpointer data) -{ - struct data_editor *de = data; - - GtkSheet *data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet")); - - GtkToggleToolButton *tb = - GTK_TOGGLE_TOOL_BUTTON (get_widget_assert (de->xml, - "togglebutton-value-labels")); - - PsppireDataStore *ds = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet)); - - gboolean show_value_labels = gtk_check_menu_item_get_active (menuitem); - - gtk_toggle_tool_button_set_active (tb, show_value_labels); - psppire_data_store_show_labels (ds, show_value_labels); -} - - -/* Callback for the value labels tooglebutton */ +/* Callback for the value labels action */ static void -value_labels_toggled (GtkToggleToolButton *toggle_tool_button, - gpointer data) +toggle_value_labels (GtkToggleAction *ta, gpointer data) { struct data_editor *de = data; GtkSheet *data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet")); - GtkCheckMenuItem *item = - GTK_CHECK_MENU_ITEM (get_widget_assert (de->xml, "view_valuelabels")); - PsppireDataStore *ds = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet)); - gboolean show_value_labels = - gtk_toggle_tool_button_get_active (toggle_tool_button); - gtk_check_menu_item_set_active (item, show_value_labels); - - psppire_data_store_show_labels (ds, show_value_labels); + psppire_data_store_show_labels (ds, + gtk_toggle_action_get_active (ta)); } @@ -1684,3 +1661,5 @@ popup_cases_menu (GtkSheet *sheet, gint row, event->button, event->time); } } + + diff --git a/src/ui/gui/data-editor.glade b/src/ui/gui/data-editor.glade index c7ba83e5..18e34001 100644 --- a/src/ui/gui/data-editor.glade +++ b/src/ui/gui/data-editor.glade @@ -243,7 +243,7 @@ - + True Value Labels True diff --git a/src/ui/gui/data-editor.h b/src/ui/gui/data-editor.h index 930423ee..2186d4cf 100644 --- a/src/ui/gui/data-editor.h +++ b/src/ui/gui/data-editor.h @@ -47,6 +47,8 @@ struct data_editor GtkAction *delete_variables; GtkAction *delete_cases; + GtkToggleAction *toggle_value_labels; + GladeXML *xml; GtkMenu *data_sheet_variable_popup_menu; -- 2.30.2