X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Foneway-anova-dialog.c;h=d656366cf06bade3e0a578ca33e2dadb0a38c472;hb=refs%2Fbuilds%2F20130214032106%2Fpspp;hp=4db1e5ff6bccf8ea484c568f06f774bdfb9806eb;hpb=d43a876351d94acce0e8d565ad2cb4d690727fe9;p=pspp
diff --git a/src/ui/gui/oneway-anova-dialog.c b/src/ui/gui/oneway-anova-dialog.c
index 4db1e5ff6b..d656366cf0 100644
--- a/src/ui/gui/oneway-anova-dialog.c
+++ b/src/ui/gui/oneway-anova-dialog.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007 Free Software Foundation
+ Copyright (C) 2007, 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
@@ -15,24 +15,21 @@
along with this program. If not, see .
*/
-
#include
-#include
#include
#include "oneway-anova-dialog.h"
#include "psppire-dict.h"
-#include "psppire-var-store.h"
-#include "helper.h"
-#include "data-editor.h"
+#include "psppire-var-view.h"
+#include "builder-wrapper.h"
+#include "psppire-data-window.h"
#include "psppire-dialog.h"
#include "dialog-common.h"
-#include "dict-display.h"
#include "psppire-acr.h"
+#include "psppire-selector.h"
+#include "dict-display.h"
-
-#include
-#include "psppire-syntax-window.h"
-
+#include "executor.h"
+#include "helper.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
@@ -121,75 +118,53 @@ refresh (struct oneway_anova_dialog *ow)
}
+
/* Pops up the dialog box */
void
-oneway_anova_dialog (GObject *o, gpointer data)
+oneway_anova_dialog (PsppireDataWindow *de)
{
gint response;
- struct data_editor *de = data;
-
- PsppireVarStore *vs = NULL;
-
- GladeXML *xml = XML_NEW ("oneway.glade");
struct oneway_anova_dialog ow;
+ GtkBuilder *builder = builder_new ("oneway.ui");
+
GtkWidget *dict_view =
- get_widget_assert (xml, "oneway-anova-treeview1");
+ get_widget_assert (builder, "oneway-anova-treeview1");
GtkWidget *selector2 =
- get_widget_assert (xml, "oneway-anova-selector2");
-
- GtkWidget *selector1 =
- get_widget_assert (xml, "oneway-anova-selector1");
+ get_widget_assert (builder, "oneway-anova-selector2");
GtkWidget *contrasts_button =
- get_widget_assert (xml, "contrasts-button");
+ get_widget_assert (builder, "contrasts-button");
g_signal_connect_swapped (contrasts_button, "clicked",
G_CALLBACK (run_contrasts_dialog), &ow);
- ow.factor_entry = get_widget_assert (xml, "oneway-anova-entry");
+ ow.factor_entry = get_widget_assert (builder, "oneway-anova-entry");
ow.vars_treeview =
- get_widget_assert (xml, "oneway-anova-treeview2");
+ get_widget_assert (builder, "oneway-anova-treeview2");
ow.descriptives =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "checkbutton1"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "checkbutton1"));
ow.homogeneity =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "checkbutton2"));
-
- g_object_get (de->data_editor, "var-store", &vs, NULL);
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "checkbutton2"));
- ow.dict = vs->dict;
+ g_object_get (de->data_editor, "dictionary", &ow.dict, NULL);
ow.dialog =
- GTK_WINDOW (get_widget_assert (xml, "oneway-anova-dialog"));
-
- gtk_window_set_transient_for (ow.dialog, de->parent.window);
-
- attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view),
- vs->dict,
- GTK_SELECTION_MULTIPLE, NULL);
-
- set_dest_model (GTK_TREE_VIEW (ow.vars_treeview), vs->dict);
-
+ GTK_WINDOW (get_widget_assert (builder, "oneway-anova-dialog"));
- psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector1),
- dict_view, ow.vars_treeview,
- insert_source_row_into_tree_view,
- NULL,
- NULL);
+ gtk_window_set_transient_for (ow.dialog, GTK_WINDOW (de));
+ g_object_set (dict_view, "model", ow.dict, NULL);
- psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector2),
- dict_view, ow.factor_entry,
- insert_source_row_into_entry,
- is_currently_in_entry,
- NULL);
+ psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector2),
+ is_currently_in_entry);
g_signal_connect_swapped (ow.dialog, "refresh", G_CALLBACK (refresh), &ow);
@@ -202,16 +177,16 @@ oneway_anova_dialog (GObject *o, gpointer data)
{
struct contrasts_subdialog *cd = &ow.contrasts;
- GtkEntry *entry = GTK_ENTRY (get_widget_assert (xml, "entry1"));
+ GtkEntry *entry = GTK_ENTRY (get_widget_assert (builder, "entry1"));
- cd->acr = PSPPIRE_ACR (get_widget_assert (xml, "psppire-acr1"));
- cd->contrasts_dialog = get_widget_assert (xml, "contrasts-dialog");
+ cd->acr = PSPPIRE_ACR (get_widget_assert (builder, "psppire-acr1"));
+ cd->contrasts_dialog = get_widget_assert (builder, "contrasts-dialog");
- cd->next = get_widget_assert (xml, "next-button");
- cd->prev = get_widget_assert (xml, "prev-button");
- cd->ctotal = get_widget_assert (xml, "entry2");
+ cd->next = get_widget_assert (builder, "next-button");
+ cd->prev = get_widget_assert (builder, "prev-button");
+ cd->ctotal = get_widget_assert (builder, "entry2");
- cd->stack_label = get_widget_assert (xml, "contrast-stack-label");
+ cd->stack_label = get_widget_assert (builder, "contrast-stack-label");
/* Contrasts */
ow.contrasts_array = g_array_new (FALSE, FALSE, sizeof (GtkListStore *));
@@ -222,7 +197,7 @@ oneway_anova_dialog (GObject *o, gpointer data)
psppire_acr_set_entry (cd->acr, entry);
gtk_window_set_transient_for (GTK_WINDOW (cd->contrasts_dialog),
- de->parent.window);
+ GTK_WINDOW (de));
}
response = psppire_dialog_run (PSPPIRE_DIALOG (ow.dialog));
@@ -230,26 +205,10 @@ oneway_anova_dialog (GObject *o, gpointer data)
switch (response)
{
case GTK_RESPONSE_OK:
- {
- gchar *syntax = generate_syntax (&ow);
- struct getl_interface *sss = create_syntax_string_source (syntax);
- execute_syntax (sss);
-
- g_free (syntax);
- }
+ g_free (execute_syntax_string (de, generate_syntax (&ow)));
break;
case PSPPIRE_RESPONSE_PASTE:
- {
- gchar *syntax = generate_syntax (&ow);
-
- GtkWidget *se = psppire_syntax_window_new ();
-
- gtk_text_buffer_insert_at_cursor (PSPPIRE_SYNTAX_WINDOW (se)->buffer, syntax, -1);
-
- gtk_widget_show (se);
-
- g_free (syntax);
- }
+ g_free (paste_syntax_to_window (generate_syntax (&ow)));
break;
default:
break;
@@ -257,7 +216,7 @@ oneway_anova_dialog (GObject *o, gpointer data)
g_array_free (ow.contrasts_array, FALSE);
- g_object_unref (xml);
+ g_object_unref (builder);
}
@@ -267,22 +226,23 @@ static gchar * generate_syntax (const struct oneway_anova_dialog *ow)
gint i;
gboolean descriptives = gtk_toggle_button_get_active (ow->descriptives);
gboolean homogeneity = gtk_toggle_button_get_active (ow->homogeneity);
+ struct string dss;
- GString *str = g_string_new ("ONEWAY /VARIABLES=");
+ ds_init_cstr (&dss, "ONEWAY /VARIABLES=");
- append_variable_names (str, ow->dict, GTK_TREE_VIEW (ow->vars_treeview), 0);
+ psppire_var_view_append_names_str (PSPPIRE_VAR_VIEW (ow->vars_treeview), 0, &dss);
- g_string_append (str, " BY ");
+ ds_put_cstr (&dss, " BY ");
- g_string_append (str, gtk_entry_get_text (GTK_ENTRY (ow->factor_entry)));
+ ds_put_cstr (&dss, gtk_entry_get_text (GTK_ENTRY (ow->factor_entry)));
if (descriptives || homogeneity )
{
- g_string_append (str, "\n\t/STATISTICS=");
+ ds_put_cstr (&dss, "\n\t/STATISTICS=");
if (descriptives)
- g_string_append (str, "DESCRIPTIVES ");
+ ds_put_cstr (&dss, "DESCRIPTIVES ");
if (homogeneity)
- g_string_append (str, "HOMOGENEITY ");
+ ds_put_cstr (&dss, "HOMOGENEITY ");
}
for (i = 0 ; i < ow->contrasts_array->len ; ++i )
@@ -291,7 +251,7 @@ static gchar * generate_syntax (const struct oneway_anova_dialog *ow)
GtkTreeIter iter;
gboolean ok;
- g_string_append (str, "\n\t/CONTRAST=");
+ ds_put_cstr (&dss, "\n\t/CONTRAST=");
for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(ls),
&iter);
@@ -302,14 +262,14 @@ static gchar * generate_syntax (const struct oneway_anova_dialog *ow)
gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 0, &v, -1);
- g_string_append_printf (str, " %g", v);
+ ds_put_c_format (&dss, " %g", v);
}
}
- g_string_append (str, ".\n");
+ ds_put_cstr (&dss, ".\n");
- text = str->str;
- g_string_free (str, FALSE);
+ text = ds_steal_cstr (&dss);
+ ds_destroy (&dss);
return text;
}