PsppireDialogAction (generate_syntax): Change signature.
[pspp] / src / ui / gui / psppire-dialog-action-roc.c
index babd4b306aa65dab3ab14b8c9c81340b5b1f3686..a01942c6701d304ead0587544daf3819285a0325 100644 (file)
@@ -105,10 +105,9 @@ refresh (PsppireDialogAction *rd_)
 }
 
 static void
-on_state_var_changed (GtkAction *a)
+on_state_var_changed (PsppireDialogAction *a)
 {
   PsppireDialogActionRoc *act = PSPPIRE_DIALOG_ACTION_ROC (a);
-  PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
 
   const gchar *var_name = gtk_entry_get_text (GTK_ENTRY(act->state_variable));
 
@@ -122,12 +121,20 @@ on_state_var_changed (GtkAction *a)
 }
 
 static void
-psppire_dialog_action_roc_activate (GtkAction *a)
+psppire_dialog_action_roc_activate (PsppireDialogAction *a)
 {
   PsppireDialogActionRoc *act = PSPPIRE_DIALOG_ACTION_ROC (a);
   PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
 
-  GtkBuilder *xml = builder_new ("roc.ui");
+  GHashTable *thing = psppire_dialog_action_get_hash_table (pda);
+  GtkBuilder *xml = g_hash_table_lookup (thing, a);
+  if (!xml)
+    {
+      xml = builder_new ("roc.ui");
+      g_hash_table_insert (thing, a, xml);
+    }
+
+
   pda->dialog = get_widget_assert   (xml, "roc-dialog");
   pda->source = get_widget_assert   (xml, "dict-view");
 
@@ -143,8 +150,6 @@ psppire_dialog_action_roc_activate (GtkAction *a)
   g_signal_connect_swapped (act->state_variable, "changed",
                            G_CALLBACK (on_state_var_changed), act);
 
-  g_object_unref (xml);
-
   g_signal_connect (act->curve, "toggled",
                    G_CALLBACK (on_curve_button_toggle), act);
 
@@ -160,7 +165,7 @@ psppire_dialog_action_roc_activate (GtkAction *a)
 
 
 static char *
-generate_syntax (PsppireDialogAction *a)
+generate_syntax (const PsppireDialogAction *a)
 {
   PsppireDialogActionRoc *rd = PSPPIRE_DIALOG_ACTION_ROC (a);
   gchar *text;
@@ -239,9 +244,7 @@ generate_syntax (PsppireDialogAction *a)
 static void
 psppire_dialog_action_roc_class_init (PsppireDialogActionRocClass *class)
 {
-  GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
-  action_class->activate = psppire_dialog_action_roc_activate;
+  psppire_dialog_action_set_activation (class, psppire_dialog_action_roc_activate);
 
   PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
 }