X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Ft-test-paired-samples.c;h=1b1cfbc87f7ac7f29b7248596e7537bd2212252d;hb=bea8b007855970c07083dbec5b5cc90f33990957;hp=5f226d4e194a2963881d5ac05c09f3835ca04558;hpb=4d7bacdd25f6404e10e8e5de894e875235e43cfa;p=pspp diff --git a/src/ui/gui/t-test-paired-samples.c b/src/ui/gui/t-test-paired-samples.c index 5f226d4e19..1b1cfbc87f 100644 --- a/src/ui/gui/t-test-paired-samples.c +++ b/src/ui/gui/t-test-paired-samples.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008, 2010 Free Software Foundation + Copyright (C) 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 @@ -17,16 +17,15 @@ #include #include -#include + +#include "t-test-options.h" +#include "t-test-paired-samples.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 "dialog-common.h" #include "psppire-dialog.h" @@ -37,22 +36,27 @@ #include "psppire-var-ptr.h" +#include "paired-dialog.h" #include #define _(msgid) gettext (msgid) #define N_(msgid) msgid -struct tt_paired_samples_dialog +static void +refresh (void *aux) { - PsppireDict *dict; - GtkWidget *pairs_treeview; - GtkTreeModel *list_store; - struct tt_options_dialog *opt; -}; +} + + +static gboolean +valid (void *aux) +{ + return TRUE; +} static gchar * -generate_syntax (const struct tt_paired_samples_dialog *d) +generate_syntax (const struct paired_samples_dialog *d, const struct tt_options_dialog *opt) { gchar *text = NULL; GString *str = g_string_new ("T-TEST \n\tPAIRS = "); @@ -66,7 +70,7 @@ generate_syntax (const struct tt_paired_samples_dialog *d) g_string_append (str, " (PAIRED)"); g_string_append (str, "\n"); - tt_options_dialog_append_syntax (d->opt, str); + tt_options_dialog_append_syntax (opt, str); g_string_append (str, ".\n"); @@ -76,165 +80,43 @@ generate_syntax (const struct tt_paired_samples_dialog *d) return text; } -static void -refresh (struct tt_paired_samples_dialog *tt_d) -{ - gtk_list_store_clear (GTK_LIST_STORE (tt_d->list_store)); -} - -static gboolean -dialog_state_valid (gpointer data) -{ - struct variable *v = NULL; - struct tt_paired_samples_dialog *tt_d = data; - GtkTreeIter dest_iter; - - gint n_rows = gtk_tree_model_iter_n_children (tt_d->list_store, NULL); - - if ( n_rows == 0 ) - return FALSE; - - /* Get the last row */ - gtk_tree_model_iter_nth_child (tt_d->list_store, &dest_iter, - NULL, n_rows - 1); - - /* Get the last (2nd) column */ - gtk_tree_model_get (tt_d->list_store, &dest_iter, 1, &v, -1); - - - return (v != NULL); -} - - - -static void -select_as_pair_member (GtkTreeIter source_iter, - GtkWidget *dest, - GtkTreeModel *source_model, - gpointer data) -{ - struct variable *v; - struct variable *v1; - gint n_rows; - GtkTreeIter dest_iter; - struct tt_paired_samples_dialog *tt_d = data; - - - gtk_tree_model_get (source_model, &source_iter, - DICT_TVM_COL_VAR, &v, -1); - - n_rows = gtk_tree_model_iter_n_children (tt_d->list_store, NULL); - - if ( n_rows > 0 ) - { - - gtk_tree_model_iter_nth_child (tt_d->list_store, - &dest_iter, NULL, n_rows - 1); - - gtk_tree_model_get (tt_d->list_store, &dest_iter, 1, &v1, -1); - } - else - v1 = NULL; - - if ( n_rows == 0 || v1 != NULL) - { - gtk_list_store_append (GTK_LIST_STORE (tt_d->list_store), &dest_iter); - - gtk_list_store_set (GTK_LIST_STORE (tt_d->list_store), &dest_iter, - 0, v, - 1, NULL, - -1); - } - else - { - gtk_list_store_set (GTK_LIST_STORE (tt_d->list_store), &dest_iter, - 1, v, - -1); - - } -} - /* Pops up the dialog box */ void t_test_paired_samples_dialog (PsppireDataWindow *de) { - struct tt_paired_samples_dialog tt_d; gint response; + struct paired_samples_dialog *tt_d = two_sample_dialog_create (de); + struct tt_options_dialog *opts = tt_options_dialog_create (GTK_WINDOW (de)); - PsppireVarStore *vs = NULL; - - 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, "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"); - - g_object_get (de->data_editor, "var-store", &vs, NULL); - - 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, GTK_WINDOW (de)); - - gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); - - - g_object_set (dict_view, "model", tt_d.dict, - "predicate", - var_is_numeric, NULL); + GtkWidget *bb = gtk_hbutton_box_new (); + GtkWidget *opt = gtk_button_new_with_mnemonic (_("_Options")); + gtk_box_pack_start (GTK_BOX (bb), opt, TRUE, TRUE, 5); + gtk_widget_show_all (bb); + two_sample_dialog_add_widget (tt_d, bb); - 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); + g_signal_connect_swapped (opt, "clicked", G_CALLBACK (tt_options_dialog_run), opts); + tt_d->refresh = refresh; + tt_d->valid = valid; + tt_d->aux = opts; - g_signal_connect_swapped (options_button, "clicked", - G_CALLBACK (tt_options_dialog_run), tt_d.opt); + gtk_window_set_title (GTK_WINDOW (tt_d->dialog), _("Paired Samples T Test")); - psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog), - dialog_state_valid, &tt_d); - - response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); + response = psppire_dialog_run (PSPPIRE_DIALOG (tt_d->dialog)); switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&tt_d); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (de, generate_syntax (tt_d, opts))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&tt_d); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (tt_d, opts))); break; default: break; } - - g_object_unref (xml); - - tt_options_dialog_destroy (tt_d.opt); + two_sample_dialog_destroy (tt_d); + tt_options_dialog_destroy (opts); } - -