Add "dictionary" property to PsppireVarStore and use it.
[pspp-builds.git] / src / ui / gui / crosstabs-dialog.c
index 2c50b461844d38de4587e1bcc9fcad01212b4d04..019d8c361dffe49c35b58b2f2799f701abd392b8 100644 (file)
 #include <stdlib.h>
 
 #include <language/syntax-string-source.h>
-#include <ui/gui/data-editor.h>
+#include <ui/gui/psppire-data-window.h>
 #include <ui/gui/dialog-common.h>
 #include <ui/gui/dict-display.h>
-#include "helper.h"
+#include "executor.h"
 #include <ui/gui/psppire-dialog.h>
 #include <ui/gui/psppire-var-store.h>
-#include <ui/gui/syntax-editor.h>
+#include <ui/gui/helper.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -385,12 +385,14 @@ void
 crosstabs_dialog (GObject *o, gpointer data)
 {
   gint response;
-  struct data_editor *de = data;
-
   struct crosstabs_dialog cd;
 
   GtkBuilder *xml = builder_new ("crosstabs.ui");
   PsppireVarStore *vs = NULL;
+  PsppireDict *dict = NULL;
+
+  PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
+
 
   GtkWidget *dialog = get_widget_assert   (xml, "crosstabs-dialog");
   GtkWidget *source = get_widget_assert   (xml, "dict-treeview");
@@ -419,14 +421,13 @@ crosstabs_dialog (GObject *o, gpointer data)
                                  cells
                                  );
 
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window);
+  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+  g_object_get (vs, "dictionary", &dict, NULL);
+  g_object_set (source, "dictionary", dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (dest_rows), vs->dict);
-  set_dest_model (GTK_TREE_VIEW (dest_cols), vs->dict);
+  set_dest_model (GTK_TREE_VIEW (dest_rows), dict);
+  set_dest_model (GTK_TREE_VIEW (dest_cols), dict);
 
   psppire_selector_set_subjects (PSPPIRE_SELECTOR (row_selector),
                                 source,
@@ -444,7 +445,7 @@ crosstabs_dialog (GObject *o, gpointer data)
 
   cd.row_vars = GTK_TREE_VIEW (dest_rows);
   cd.col_vars = GTK_TREE_VIEW (dest_cols);
-  cd.dict = vs->dict;
+  g_object_get (vs, "dictionary", &cd.dict, NULL);
   cd.format_dialog = get_widget_assert (xml, "format-dialog");
   cd.table_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "print-tables"));
   cd.pivot_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "pivot"));
@@ -461,9 +462,9 @@ crosstabs_dialog (GObject *o, gpointer data)
   cd.current_opts.table = TRUE;
   cd.current_opts.pivot = TRUE;
 
-  gtk_window_set_transient_for (GTK_WINDOW (cd.format_dialog), de->parent.window);
-  gtk_window_set_transient_for (GTK_WINDOW (cd.cell_dialog), de->parent.window);
-  gtk_window_set_transient_for (GTK_WINDOW (cd.stat_dialog), de->parent.window);
+  gtk_window_set_transient_for (GTK_WINDOW (cd.format_dialog), GTK_WINDOW (de));
+  gtk_window_set_transient_for (GTK_WINDOW (cd.cell_dialog), GTK_WINDOW (de));
+  gtk_window_set_transient_for (GTK_WINDOW (cd.stat_dialog), GTK_WINDOW (de));
 
   g_signal_connect (dialog, "refresh", G_CALLBACK (refresh),  &cd);
 
@@ -485,6 +486,7 @@ crosstabs_dialog (GObject *o, gpointer data)
     case GTK_RESPONSE_OK:
       {
        gchar *syntax = generate_syntax (&cd);
+
        struct getl_interface *sss = create_syntax_string_source (syntax);
        execute_syntax (sss);
 
@@ -495,10 +497,7 @@ crosstabs_dialog (GObject *o, gpointer data)
       {
        gchar *syntax = generate_syntax (&cd);
 
-       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);
       }