From 3b296fce73d5446b67c13c3b56d74ab0b38519d9 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 30 Dec 2009 11:07:08 +0100 Subject: [PATCH] Weight cases dialog: set the sensitivity of radiobuttons. Fix the sensitivity of the dialog's radiobuttons when the the entry contains a variable. Thanks to Matej Kovacic for reporting this problem. --- src/ui/gui/weight-cases-dialog.c | 39 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/ui/gui/weight-cases-dialog.c b/src/ui/gui/weight-cases-dialog.c index 40951360..956451b1 100644 --- a/src/ui/gui/weight-cases-dialog.c +++ b/src/ui/gui/weight-cases-dialog.c @@ -34,20 +34,31 @@ #include "psppire-var-store.h" +struct weight_cases_dialog +{ + PsppireDict *dict; + GtkEntry *entry; + GtkLabel *status; + GtkToggleButton *off; + GtkToggleButton *on; +}; + static void on_select (PsppireSelector *sel, gpointer data) { - GtkRadioButton *radiobutton2 = data; + struct weight_cases_dialog *wcd = data; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton2), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wcd->on), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (wcd->on), TRUE); } static void on_deselect (PsppireSelector *sel, gpointer data) { - GtkRadioButton *radiobutton1 = data; + struct weight_cases_dialog *wcd = data; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton1), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wcd->off), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (wcd->on), FALSE); } @@ -59,15 +70,6 @@ on_toggle (GtkToggleButton *button, gpointer data) gtk_entry_set_text (entry, ""); } -struct weight_cases_dialog -{ - PsppireDict *dict; - GtkEntry *entry; - GtkLabel *status; - GtkToggleButton *off; - GtkToggleButton *on; -}; - static void refresh (PsppireDialog *dialog, const struct weight_cases_dialog *wcd) { @@ -111,12 +113,13 @@ weight_cases_dialog (GObject *o, gpointer data) GtkWidget *dialog = get_widget_assert (xml, "weight-cases-dialog"); GtkWidget *source = get_widget_assert (xml, "weight-cases-treeview"); GtkWidget *entry = get_widget_assert (xml, "weight-cases-entry"); - GtkWidget *selector = get_widget_assert (xml, "weight-cases-selector"); GtkWidget *radiobutton1 = get_widget_assert (xml, "weight-cases-radiobutton1"); GtkWidget *radiobutton2 = get_widget_assert (xml, "radiobutton2"); GtkWidget *status = get_widget_assert (xml, "weight-status-label"); + GtkWidget *selector = get_widget_assert (xml, "weight-cases-selector"); + PsppireVarStore *vs = NULL; g_object_get (de->data_editor, "var-store", &vs, NULL); @@ -125,12 +128,9 @@ weight_cases_dialog (GObject *o, gpointer data) gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); g_signal_connect (radiobutton1, "toggled", G_CALLBACK (on_toggle), entry); - g_signal_connect (selector, "selected", G_CALLBACK (on_select), - radiobutton2); - - g_signal_connect (selector, "de-selected", G_CALLBACK (on_deselect), - radiobutton1); + g_signal_connect (selector, "selected", G_CALLBACK (on_select), &wcd); + g_signal_connect (selector, "de-selected", G_CALLBACK (on_deselect), &wcd); g_object_set (source, "model", wcd.dict, "selection-mode", GTK_SELECTION_SINGLE, @@ -140,7 +140,6 @@ weight_cases_dialog (GObject *o, gpointer data) psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector), is_currently_in_entry); - wcd.entry = GTK_ENTRY (entry); wcd.status = GTK_LABEL (status); wcd.off = GTK_TOGGLE_BUTTON (radiobutton1); -- 2.30.2