From: John Darrington Date: Wed, 30 Dec 2009 10:07:08 +0000 (+0100) Subject: Weight cases dialog: set the sensitivity of radiobuttons. X-Git-Tag: fc11-i386-build69^0 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b296fce73d5446b67c13c3b56d74ab0b38519d9;p=pspp-builds.git 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. --- 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);