Refactor common code in dialog implementations
[pspp-builds.git] / src / ui / gui / t-test-independent-samples-dialog.c
index d5f9eaa6406c7908f96f8f55f35269642f5d13e6..4ceab4d8e8cfa91840c359f866d97e5a62460ae1 100644 (file)
 #include "psppire-dict.h"
 #include "psppire-var-store.h"
 #include "helper.h"
-#include "data-editor.h"
+#include "psppire-data-window.h"
 #include "psppire-dialog.h"
 #include "dialog-common.h"
 #include "dict-display.h"
 #include "widget-io.h"
 #include "t-test-options.h"
-#include <libpspp/syntax-gen.h>
+#include <ui/syntax-gen.h>
 
 #include <language/syntax-string-source.h>
-#include "syntax-editor.h"
+#include "helper.h"
 
 #include <gl/xalloc.h>
 
@@ -177,9 +177,8 @@ generate_syntax (const struct tt_indep_samples_dialog *d)
 
       if ( var_is_alpha (group_variable))
        {
-         struct string s;
-         ds_init_cstr (&s, d->grps->val[0]);
-         gen_quoted_string (&s);
+         struct string s = DS_EMPTY_INITIALIZER;
+         syntax_gen_string (&s, ss_cstr (d->grps->val[0]));
          g_string_append (str, ds_cstr (&s));
          ds_destroy (&s);
        }
@@ -194,9 +193,8 @@ generate_syntax (const struct tt_indep_samples_dialog *d)
 
          if ( var_is_alpha (group_variable))
            {
-             struct string s;
-             ds_init_cstr (&s, d->grps->val[1]);
-             gen_quoted_string (&s);
+             struct string s = DS_EMPTY_INITIALIZER;
+             syntax_gen_string (&s, ss_cstr (d->grps->val[1]));
              g_string_append (str, ds_cstr (&s));
              ds_destroy (&s);
            }
@@ -394,7 +392,7 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
 {
   struct tt_indep_samples_dialog tt_d;
   gint response;
-  struct data_editor *de = data;
+  PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
 
   PsppireVarStore *vs = NULL;
 
@@ -423,11 +421,11 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
 
   tt_d.define_groups_button = get_widget_assert (xml, "define-groups-button");
   tt_d.groups_entry = get_widget_assert (xml, "indep-samples-t-test-entry");
-  tt_d.opts = tt_options_dialog_create (xml, de->parent.window);
-  tt_d.grps = tt_groups_dialog_create (xml, de->parent.window);
+  tt_d.opts = tt_options_dialog_create (xml, GTK_WINDOW (de));
+  tt_d.grps = tt_groups_dialog_create (xml, GTK_WINDOW (de));
 
 
-  gtk_window_set_transient_for (GTK_WINDOW (tt_d.dialog), de->parent.window);
+  gtk_window_set_transient_for (GTK_WINDOW (tt_d.dialog), GTK_WINDOW (de));
 
   attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view),
                                 vs->dict,
@@ -477,6 +475,7 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
     case GTK_RESPONSE_OK:
       {
        gchar *syntax = generate_syntax (&tt_d);
+
        struct getl_interface *sss = create_syntax_string_source (syntax);
        execute_syntax (sss);
 
@@ -486,12 +485,7 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
     case PSPPIRE_RESPONSE_PASTE:
       {
        gchar *syntax = generate_syntax (&tt_d);
-
-       struct syntax_editor *se =
-         (struct syntax_editor *) window_create (WINDOW_SYNTAX, NULL);
-
-       gtk_text_buffer_insert_at_cursor (se->buffer, syntax, -1);
-
+        paste_syntax_in_new_window (syntax);
        g_free (syntax);
       }
       break;