New file: builder-wrapper.h and builder-wrapper.c
[pspp-builds.git] / src / ui / gui / examine-dialog.c
index 1d8944754c5ec3bc268dda14858da4bfb60a5a04..857394fb3dd6ef005c058cb7d4e0d3d988e8a616 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2008  Free Software Foundation
+   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012  Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include <config.h>
 
 #include "examine-dialog.h"
+#include "psppire-var-view.h"
 
 #include <gtk/gtk.h>
 #include <stdlib.h>
 
-#include <language/syntax-string-source.h>
 #include <ui/gui/psppire-data-window.h>
 #include <ui/gui/dialog-common.h>
 #include <ui/gui/dict-display.h>
-#include <ui/gui/helper.h>
+#include <ui/gui/builder-wrapper.h>
 #include <ui/gui/psppire-dialog.h>
 #include <ui/gui/psppire-var-store.h>
-#include <ui/gui/helper.h>
+#include "executor.h"
+#include "helper.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -96,13 +97,13 @@ generate_syntax (const struct examine_dialog *ed)
   GString *str = g_string_new ("EXAMINE ");
 
   g_string_append (str, "\n\t/VARIABLES=");
-  append_variable_names (str, ed->dict, GTK_TREE_VIEW (ed->dep_list), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ed->dep_list), 0, str);
 
   if ( 0  < gtk_tree_model_iter_n_children
        (gtk_tree_view_get_model (GTK_TREE_VIEW (ed->fct_list)), NULL))
     {
       g_string_append (str, "\n\tBY ");
-      append_variable_names (str, ed->dict, GTK_TREE_VIEW (ed->fct_list), 0);
+      psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ed->fct_list), 0, str);
     }
 
   label = gtk_entry_get_text (GTK_ENTRY (ed->id_entry));
@@ -233,10 +234,9 @@ run_opts_dialog (struct examine_dialog *ed)
 
 /* Pops up the Examine dialog box */
 void
-examine_dialog (GObject *o, gpointer data)
+examine_dialog (PsppireDataWindow *de)
 {
   gint response;
-  PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
 
   struct examine_dialog ex_d;
 
@@ -250,8 +250,6 @@ examine_dialog (GObject *o, gpointer data)
 
 
   GtkWidget *dep_selector = get_widget_assert (xml, "psppire-selector1");
-  GtkWidget *fct_selector = get_widget_assert (xml, "psppire-selector2");
-  GtkWidget *id_selector = get_widget_assert (xml, "psppire-selector3");
 
   PsppireVarStore *vs = NULL;
 
@@ -279,37 +277,12 @@ examine_dialog (GObject *o, gpointer data)
   gtk_window_set_transient_for (GTK_WINDOW (ex_d.stats_dialog), GTK_WINDOW (de));
   gtk_window_set_transient_for (GTK_WINDOW (ex_d.opts_dialog), GTK_WINDOW (de));
 
-  g_object_set (source, "dictionary", vs->dict, NULL);
-
-  set_dest_model (GTK_TREE_VIEW (ex_d.dep_list), vs->dict);
-  ex_d.dict = vs->dict;
-
-
-  psppire_selector_set_subjects (PSPPIRE_SELECTOR (dep_selector),
-                                source,
-                                ex_d.dep_list,
-                                insert_source_row_into_tree_view,
-                                NULL, NULL);
+  g_object_get (vs, "dictionary", &ex_d.dict, NULL);
+  g_object_set (source, "model", ex_d.dict, NULL);
 
   psppire_selector_set_allow (PSPPIRE_SELECTOR (dep_selector),
                              numeric_only);
 
-  set_dest_model (GTK_TREE_VIEW (ex_d.fct_list), vs->dict);
-
-
-  psppire_selector_set_subjects (PSPPIRE_SELECTOR (fct_selector),
-                                source,
-                                ex_d.fct_list,
-                                insert_source_row_into_tree_view,
-                                NULL, NULL);
-
-
-  psppire_selector_set_subjects (PSPPIRE_SELECTOR (id_selector),
-                                source,
-                                ex_d.id_entry,
-                                insert_source_row_into_entry,
-                                NULL, NULL);
-
   g_signal_connect (dialog, "refresh", G_CALLBACK (refresh),  &ex_d);
 
   psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
@@ -328,22 +301,10 @@ examine_dialog (GObject *o, gpointer data)
   switch (response)
     {
     case GTK_RESPONSE_OK:
-      {
-       gchar *syntax = generate_syntax (&ex_d);
-
-       struct getl_interface *sss = create_syntax_string_source (syntax);
-
-       execute_syntax (sss);
-
-       g_free (syntax);
-      }
+      g_free (execute_syntax_string (de, generate_syntax (&ex_d)));
       break;
     case PSPPIRE_RESPONSE_PASTE:
-      {
-       gchar *syntax = generate_syntax (&ex_d);
-       paste_syntax_in_new_window (syntax);
-       g_free (syntax);
-      }
+      g_free (paste_syntax_to_window (generate_syntax (&ex_d)));
       break;
     default:
       break;