Weight cases dialog: set the sensitivity of radiobuttons. fc11-i386-build69 fc11-x64-build66 lenny-x64-build90 sid-i386-build136
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 30 Dec 2009 10:07:08 +0000 (11:07 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 30 Dec 2009 10:07:08 +0000 (11:07 +0100)
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

index 40951360d70186658642ec2a99c701ed8e9e042c..956451b13702fe2097a0a4f05c416a8d4201dffb 100644 (file)
 
 #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);