Use a more reliable way of setting the initial state of PsppireDialogAction objects.
[pspp] / src / ui / gui / psppire-dialog-action-two-sample.c
index 74612d267a8aaeef642a6a89934a6f1494fc2c29..2ad9b5ce134d17be80c19e84c2e9dfdb1da7b049 100644 (file)
@@ -68,7 +68,7 @@ dialog_state_valid (gpointer data)
 
   if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pd->nts[NT_MCNEMAR].button)))
     return TRUE;
-    
+
   return FALSE;
 }
 
@@ -134,7 +134,7 @@ select_as_pair_member (GtkTreeIter source_iter,
 
 
 static gchar *
-generate_syntax (PsppireDialogAction *pda)
+generate_syntax (const PsppireDialogAction *pda)
 {
   gint i;
 
@@ -168,48 +168,49 @@ generate_syntax (PsppireDialogAction *pda)
   return text;
 }
 
-static void
-psppire_dialog_action_two_sample_activate (GtkAction *a)
+static GtkBuilder *
+psppire_dialog_action_two_sample_activate (PsppireDialogAction *a, GVariant *param)
 {
   PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
   PsppireDialogActionTwoSample *act = PSPPIRE_DIALOG_ACTION_TWO_SAMPLE (a);
 
-  GtkBuilder *xml = builder_new ("paired-samples.ui");
-  GtkWidget *selector = get_widget_assert (xml, "psppire-selector3");
+  GtkBuilder *xml = builder_new ( "paired-samples.ui");
 
-  pda->dialog = get_widget_assert   (xml, "t-test-paired-samples-dialog");
-  pda->source = get_widget_assert   (xml, "paired-samples-t-test-treeview1");
+  /* NPAR Specific options */
+  GtkWidget *frame = gtk_frame_new (_("Test Type"));
+  GtkWidget *bb = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
+  GtkWidget *box = get_widget_assert (xml, "dynamic-populate");
 
-  gtk_window_set_title (GTK_WINDOW (pda->dialog), _("Two-Related-Samples Tests"));
 
-  act->pairs_treeview = get_widget_assert (xml, "paired-samples-t-test-treeview2");
-  act->list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (act->pairs_treeview)));
+  strcpy (act->nts[NT_WILCOXON].syntax, "/WILCOXON");
+  strcpy (act->nts[NT_SIGN].syntax, "/SIGN");
+  strcpy (act->nts[NT_MCNEMAR].syntax, "/MCNEMAR");
 
-  {
-    /* NPAR Specific options */
-    GtkWidget *frame = gtk_frame_new (_("Test Type"));
-    GtkWidget *bb = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
-    GtkWidget *box = get_widget_assert (xml, "vbox3");
+  act->nts[NT_WILCOXON].button = gtk_check_button_new_with_mnemonic (_("_Wilcoxon"));
+  act->nts[NT_SIGN].button = gtk_check_button_new_with_mnemonic (_("_Sign"));
+  act->nts[NT_MCNEMAR].button = gtk_check_button_new_with_mnemonic (_("_McNemar"));
+
+  gtk_box_pack_start (GTK_BOX (bb), act->nts[NT_WILCOXON].button, FALSE, FALSE, 5);
+  gtk_box_pack_start (GTK_BOX (bb), act->nts[NT_SIGN].button,     FALSE, FALSE, 5);
+  gtk_box_pack_start (GTK_BOX (bb), act->nts[NT_MCNEMAR].button,  FALSE, FALSE, 5);
 
+  gtk_container_add (GTK_CONTAINER (frame), bb);
 
-    strcpy (act->nts[NT_WILCOXON].syntax, "/WILCOXON");
-    strcpy (act->nts[NT_SIGN].syntax, "/SIGN");
-    strcpy (act->nts[NT_MCNEMAR].syntax, "/MCNEMAR");
+  gtk_widget_show_all (frame);
 
-    act->nts[NT_WILCOXON].button = gtk_check_button_new_with_mnemonic (_("_Wilcoxon"));
-    act->nts[NT_SIGN].button = gtk_check_button_new_with_mnemonic (_("_Sign"));
-    act->nts[NT_MCNEMAR].button = gtk_check_button_new_with_mnemonic (_("_McNemar"));
+  gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE,  5);
 
-    gtk_box_pack_start (GTK_BOX (bb), act->nts[NT_WILCOXON].button, FALSE, FALSE, 5);
-    gtk_box_pack_start (GTK_BOX (bb), act->nts[NT_SIGN].button,     FALSE, FALSE, 5);
-    gtk_box_pack_start (GTK_BOX (bb), act->nts[NT_MCNEMAR].button,  FALSE, FALSE, 5);
 
-    gtk_container_add (GTK_CONTAINER (frame), bb);
+  GtkWidget *selector = get_widget_assert (xml, "psppire-selector3");
 
-    gtk_widget_show_all (frame);
+  pda->dialog = get_widget_assert   (xml, "t-test-paired-samples-dialog");
+  pda->source = get_widget_assert   (xml, "paired-samples-t-test-treeview1");
+
+  gtk_window_set_title (GTK_WINDOW (pda->dialog), _("Two-Related-Samples Tests"));
+
+  act->pairs_treeview = get_widget_assert (xml, "paired-samples-t-test-treeview2");
+  act->list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (act->pairs_treeview)));
 
-    gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE,  5);
-  }
 
   psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
   psppire_dialog_action_set_refresh (pda, refresh);
@@ -221,17 +222,13 @@ psppire_dialog_action_two_sample_activate (GtkAction *a)
   psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
                                    select_as_pair_member,
                                    act);
-  
-  g_object_unref (xml);
-
-  if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_two_sample_parent_class)->activate)
-    PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_two_sample_parent_class)->activate (pda);
+  return xml;
 }
 
 static void
 psppire_dialog_action_two_sample_class_init (PsppireDialogActionTwoSampleClass *class)
 {
-  psppire_dialog_action_set_activation (class, psppire_dialog_action_two_sample_activate);
+  PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_two_sample_activate;
   PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
 }