Remove unused code
[pspp-builds.git] / src / ui / gui / t-test-paired-samples.c
index 6b5a6e9e20c92b2320cae84a4a28c656ed816d14..95e212aff7e21e12e95912a9ab46f9fd3824b9a0 100644 (file)
 
 #include <config.h>
 #include <gtk/gtk.h>
-#include <glade/glade.h>
 #include <language/syntax-string-source.h>
-#include <gtksheet/gtksheet.h>
 
-#include "data-editor.h"
+#include "psppire-data-window.h"
+#include "psppire-selector.h"
+#include "psppire-var-view.h"
 
 #include "psppire-dict.h"
 #include "psppire-var-store.h"
 #include "t-test-paired-samples.h"
 #include "t-test-options.h"
 
-#include "dict-display.h"
 #include "dialog-common.h"
 #include "psppire-dialog.h"
 
-#include "syntax-editor.h"
+#include "executor.h"
 
 #include "helper.h"
 
@@ -58,11 +57,11 @@ generate_syntax (const struct tt_paired_samples_dialog *d)
   gchar *text = NULL;
   GString *str =   g_string_new ("T-TEST \n\tPAIRS = ");
 
-  append_variable_names (str, d->dict, GTK_TREE_VIEW (d->pairs_treeview), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (d->pairs_treeview), 0, str);
 
   g_string_append (str, " WITH ");
 
-  append_variable_names (str, d->dict, GTK_TREE_VIEW (d->pairs_treeview), 1);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (d->pairs_treeview), 1, str);
 
   g_string_append (str, " (PAIRED)");
   g_string_append (str, "\n");
@@ -153,94 +152,47 @@ select_as_pair_member (GtkTreeIter source_iter,
     }
 }
 
-
-/* Append a new column to TV at position C, and heading TITLE */
-static void
-add_new_column (GtkTreeView *tv, const gchar *title, gint c)
-{
-  GtkTreeViewColumn *col = gtk_tree_view_column_new ();
-  GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
-
-  gtk_tree_view_column_set_min_width (col, 100);
-  gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-  gtk_tree_view_column_set_resizable (col, TRUE);
-
-
-  gtk_tree_view_column_set_title (col, title);
-
-  gtk_tree_view_column_pack_start (col, renderer, TRUE);
-
-  gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
-
-  gtk_tree_view_append_column (tv, col);
-
-  gtk_tree_view_column_add_attribute  (col, renderer, "text", c);
-}
-
-
 /* Pops up the dialog box */
 void
 t_test_paired_samples_dialog (GObject *o, gpointer data)
 {
   struct tt_paired_samples_dialog tt_d;
   gint response;
-  struct data_editor *de = data;
-
-  PsppireVarStore *vs;
+  PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
 
-  GladeXML *xml = XML_NEW ("t-test.glade");
+  PsppireVarStore *vs = NULL;
 
-  GtkSheet *var_sheet =
-    GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+  GtkBuilder *xml = builder_new ("t-test.ui");
 
   GtkWidget *dict_view =
     get_widget_assert (xml, "paired-samples-t-test-treeview1");
 
-  GtkWidget *options_button = get_widget_assert (xml, "options-button");
+  GtkWidget *options_button = get_widget_assert (xml, "paired-samples-t-test-options-button");
 
   GtkWidget *selector = get_widget_assert (xml, "psppire-selector3");
 
   GtkWidget *dialog = get_widget_assert (xml, "t-test-paired-samples-dialog");
 
-  vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
+  g_object_get (de->data_editor, "var-store", &vs, NULL);
 
-  tt_d.dict = vs->dict;
+  g_object_get (vs, "dictionary", &tt_d.dict, NULL);
   tt_d.pairs_treeview =
    get_widget_assert (xml, "paired-samples-t-test-treeview2");
-  tt_d.opt = tt_options_dialog_create (xml, de->parent.window);
-
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window);
-
-
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE,
-                                var_is_numeric);
-
-  {
-    tt_d.list_store =
-      GTK_TREE_MODEL (
-                     gtk_list_store_new (2,
-                                         PSPPIRE_VAR_PTR_TYPE,
-                                         PSPPIRE_VAR_PTR_TYPE));
+  tt_d.opt = tt_options_dialog_create (xml, GTK_WINDOW (de));
 
+  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-    gtk_tree_view_set_model (GTK_TREE_VIEW (tt_d.pairs_treeview),
-                            GTK_TREE_MODEL (tt_d.list_store));
 
+  g_object_set (dict_view, "model", tt_d.dict,
+               "predicate",
+               var_is_numeric, NULL);
 
-    add_new_column (GTK_TREE_VIEW (tt_d.pairs_treeview), _("Var 1"), 0);
-    add_new_column (GTK_TREE_VIEW (tt_d.pairs_treeview), _("Var 2"), 1);
-  }
-
-
-  psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector),
-                                dict_view,
-                                tt_d.pairs_treeview,
-                                select_as_pair_member,
-                                NULL,
-                                &tt_d);
+  
+  tt_d.list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (tt_d.pairs_treeview));
 
+  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
+                                   select_as_pair_member,
+                                   &tt_d);
 
   g_signal_connect_swapped (dialog, "refresh",
                            G_CALLBACK (refresh),  &tt_d);
@@ -259,6 +211,7 @@ t_test_paired_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);
 
@@ -268,11 +221,7 @@ t_test_paired_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);
       }