Use a more reliable way of setting the initial state of PsppireDialogAction objects.
[pspp] / src / ui / gui / psppire-dialog-action-barchart.c
index 6059c464396c2f79129c06099de0dc0830789c8c..900188fcbf7db82c4f81b0155876d2538db8ed81 100644 (file)
@@ -67,7 +67,7 @@ refresh (PsppireDialogAction *rd_)
      This ensures that the signal handler gets called.   */
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->button_summary_func), TRUE);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->button_freq_func[0]), TRUE);
-                               
+
   gtk_widget_set_sensitive (rd->combobox, FALSE);
 
   gtk_combo_box_set_active (GTK_COMBO_BOX (rd->combobox), 0);
@@ -114,51 +114,44 @@ populate_combo_model (GtkComboBox *cb)
 }
 
 
-static void
-psppire_dialog_action_barchart_activate (GtkAction *a)
+static GtkBuilder *
+psppire_dialog_action_barchart_activate (PsppireDialogAction *a, GVariant *param)
 {
   PsppireDialogActionBarchart *act = PSPPIRE_DIALOG_ACTION_BARCHART (a);
   PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
 
-  GHashTable *thing = psppire_dialog_action_get_pointer (pda);
-  GtkBuilder *xml = g_hash_table_lookup (thing, a);
-  if (!xml)
-    {
-      xml = builder_new ("barchart.ui");
-      g_hash_table_insert (thing, a, xml);
-
-      pda->dialog = get_widget_assert (xml, "barchart-dialog");
-      pda->source = get_widget_assert (xml, "dict-view");
-
-      act->variable_xaxis = get_widget_assert (xml, "entry1");
-      act->variable_cluster = get_widget_assert (xml, "entry3");
-      act->var = get_widget_assert (xml, "entry2");
-      act->button_freq_func[0] = get_widget_assert (xml, "radiobutton-count");
-      act->button_freq_func[1] = get_widget_assert (xml, "radiobutton-percent");
-      act->button_freq_func[2] = get_widget_assert (xml, "radiobutton-cum-count");
-      act->button_freq_func[3] = get_widget_assert (xml, "radiobutton-cum-percent");
-  
-      act->button_summary_func = get_widget_assert (xml, "radiobutton3");
-      act->summary_variables = get_widget_assert (xml, "hbox1");
-      act->combobox = get_widget_assert (xml, "combobox1");
-
-      populate_combo_model (GTK_COMBO_BOX(act->combobox));
-  
-      g_signal_connect_swapped (act->button_summary_func, "toggled",
-                               G_CALLBACK (on_summary_toggle), act);
-
-      psppire_dialog_action_set_refresh (pda, refresh);
-
-      psppire_dialog_action_set_valid_predicate (pda,
-                                                dialog_state_valid);
-    }
+  GtkBuilder *xml = builder_new ( "barchart.ui");
+
+  pda->dialog = get_widget_assert (xml, "barchart-dialog");
+  pda->source = get_widget_assert (xml, "dict-view");
+
+  act->variable_xaxis = get_widget_assert (xml, "entry1");
+  act->variable_cluster = get_widget_assert (xml, "entry3");
+  act->var = get_widget_assert (xml, "entry2");
+  act->button_freq_func[0] = get_widget_assert (xml, "radiobutton-count");
+  act->button_freq_func[1] = get_widget_assert (xml, "radiobutton-percent");
+  act->button_freq_func[2] = get_widget_assert (xml, "radiobutton-cum-count");
+  act->button_freq_func[3] = get_widget_assert (xml, "radiobutton-cum-percent");
 
-  if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_barchart_parent_class)->activate)
-    PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_barchart_parent_class)->activate (pda);
+  act->button_summary_func = get_widget_assert (xml, "radiobutton3");
+  act->summary_variables = get_widget_assert (xml, "hbox1");
+  act->combobox = get_widget_assert (xml, "combobox1");
+
+  populate_combo_model (GTK_COMBO_BOX(act->combobox));
+
+  g_signal_connect_swapped (act->button_summary_func, "toggled",
+                           G_CALLBACK (on_summary_toggle), act);
+
+  psppire_dialog_action_set_refresh (pda, refresh);
+
+  psppire_dialog_action_set_valid_predicate (pda,
+                                            dialog_state_valid);
+
+  return xml;
 }
 
 static char *
-generate_syntax (PsppireDialogAction *a)
+generate_syntax (const PsppireDialogAction *a)
 {
   PsppireDialogActionBarchart *rd = PSPPIRE_DIALOG_ACTION_BARCHART (a);
   gchar *text;
@@ -218,7 +211,7 @@ generate_syntax (PsppireDialogAction *a)
     g_string_append (string, " BY ");
     g_string_append (string, var_name_cluster);
   }
-  
+
   g_string_append (string, ".\n");
 
   text = string->str;
@@ -231,7 +224,7 @@ generate_syntax (PsppireDialogAction *a)
 static void
 psppire_dialog_action_barchart_class_init (PsppireDialogActionBarchartClass *class)
 {
-  psppire_dialog_action_set_activation (class, psppire_dialog_action_barchart_activate);
+  PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_barchart_activate;
 
   PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
 }