/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007 Free Software Foundation
+ Copyright (C) 2007, 2010 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 "rank-dialog.h"
#include <gtk/gtk.h>
-#include <gtksheet/gtksheet.h>
#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 <ui/gui/helper.h>
#include <ui/gui/psppire-dialog.h>
#include <ui/gui/psppire-var-store.h>
-#include <ui/gui/syntax-editor.h>
+#include <ui/gui/psppire-var-view.h>
+#include "executor.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
GString *str = g_string_new ("RANK VARIABLES=");
- append_variable_names (str, rd->dict, GTK_TREE_VIEW (rd->rank_vars), 0);
+ psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->rank_vars), 0, str);
g_string_append_printf (str, " (%c)",
gtk_toggle_button_get_active (rd->ascending_togglebutton)
{
g_string_append (str, "\n\tBY ");
- append_variable_names (str, rd->dict, GTK_TREE_VIEW (rd->group_vars), 0);
+ psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->group_vars), 0, str);
}
g_string_append (str, "\n\t/PRINT = ");
/* Pops up the Rank dialog box */
void
-rank_dialog (GObject *o, gpointer data)
+rank_dialog (PsppireDataWindow *de)
{
gint response;
- struct data_editor *de = data;
struct rank_dialog rd;
- GladeXML *xml = XML_NEW ("rank.glade");
+ GtkBuilder * builder = builder_new ("rank.ui");
- GtkWidget *vars = get_widget_assert (xml, "dict-treeview");
- GtkWidget *selector1 = get_widget_assert (xml, "psppire-selector1");
- GtkWidget *selector2 = get_widget_assert (xml, "psppire-selector2");
+ GtkWidget *vars = get_widget_assert (builder, "dict-treeview");
+ GtkWidget *types_button = get_widget_assert (builder, "button1");
+ GtkWidget *ties_button = get_widget_assert (builder, "button2");
- GtkWidget *types_button = get_widget_assert (xml, "button1");
- GtkWidget *ties_button = get_widget_assert (xml, "button2");
+ PsppireVarStore *vs = NULL;
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+ g_object_get (de->data_editor, "var-store", &vs, NULL);
- PsppireVarStore *vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
-
-
- rd.dict = vs->dict;
- rd.rank_vars = get_widget_assert (xml, "variables-treeview");
- rd.group_vars = get_widget_assert (xml, "group-vars-treeview");
- rd.dialog = get_widget_assert (xml, "rank-dialog");
+ g_object_get (vs, "dictionary", &rd.dict, NULL);
+ rd.rank_vars = get_widget_assert (builder, "variables-treeview");
+ rd.group_vars = get_widget_assert (builder, "group-vars-treeview");
+ rd.dialog = get_widget_assert (builder, "rank-dialog");
rd.ascending_togglebutton =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "radiobutton1"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "radiobutton1"));
rd.summary_togglebutton =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "summary-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "summary-checkbutton"));
- rd.types_dialog = get_widget_assert (xml, "rank-types-dialog");
+ rd.types_dialog = get_widget_assert (builder, "rank-types-dialog");
- rd.ntiles_entry = get_widget_assert (xml, "ntiles-entry");
+ rd.ntiles_entry = get_widget_assert (builder, "ntiles-entry");
rd.func_button[RANK] =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "rank-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "rank-checkbutton"));
rd.func_button[SAVAGE] =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "savage-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "savage-checkbutton"));
rd.func_button[RFRACTION] =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "rfrac-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "rfrac-checkbutton"));
rd.func_button[PERCENT] =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "percent-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "percent-checkbutton"));
rd.func_button[N] =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "sum-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "sum-checkbutton"));
rd.func_button[NTILES] =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "ntiles-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "ntiles-checkbutton"));
rd.func_button[PROPORTION] =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "prop-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "prop-checkbutton"));
rd.func_button[NORMAL] =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "normal-checkbutton"));
+ GTK_TOGGLE_BUTTON (get_widget_assert (builder, "normal-checkbutton"));
- rd.formula_box = get_widget_assert (xml, "formula-frame");
+ rd.formula_box = get_widget_assert (builder, "formula-frame");
- rd.blom = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "blom-button"));
- rd.tukey = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "tukey-button"));
- rd.rankit = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "rankit-button"));
- rd.vw = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "vw-button"));
+ rd.blom = GTK_TOGGLE_BUTTON (get_widget_assert (builder, "blom-button"));
+ rd.tukey = GTK_TOGGLE_BUTTON (get_widget_assert (builder, "tukey-button"));
+ rd.rankit = GTK_TOGGLE_BUTTON (get_widget_assert (builder, "rankit-button"));
+ rd.vw = GTK_TOGGLE_BUTTON (get_widget_assert (builder, "vw-button"));
/* Ties dialog */
- rd.ties_dialog = PSPPIRE_DIALOG (get_widget_assert (xml, "ties-dialog"));
+ rd.ties_dialog = PSPPIRE_DIALOG (get_widget_assert (builder, "ties-dialog"));
- rd.mean = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "mean-button"));
- rd.low = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "low-button"));
- rd.high = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "high-button"));
- rd.condense = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "condense-button"));
+ rd.mean = GTK_TOGGLE_BUTTON (get_widget_assert (builder, "mean-button"));
+ rd.low = GTK_TOGGLE_BUTTON (get_widget_assert (builder, "low-button"));
+ rd.high = GTK_TOGGLE_BUTTON (get_widget_assert (builder, "high-button"));
+ rd.condense = GTK_TOGGLE_BUTTON (get_widget_assert (builder, "condense-button"));
g_signal_connect_swapped (rd.func_button[PROPORTION], "toggled",
G_CALLBACK (set_sensitivity),
G_CALLBACK (on_ntiles_toggle),
rd.ntiles_entry);
- gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), de->parent.window);
-
- attach_dictionary_to_treeview (GTK_TREE_VIEW (vars),
- vs->dict,
- GTK_SELECTION_MULTIPLE, NULL);
-
-
- set_dest_model (GTK_TREE_VIEW (rd.rank_vars), vs->dict);
-
- psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector1),
- vars,
- rd.rank_vars,
- insert_source_row_into_tree_view,
- NULL,
- NULL);
-
- set_dest_model (GTK_TREE_VIEW (rd.group_vars), vs->dict);
-
- psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector2),
- vars,
- rd.group_vars,
- insert_source_row_into_tree_view,
- NULL,
- NULL);
+ gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), GTK_WINDOW (de));
+ g_object_set (vars, "model", rd.dict, NULL);
g_signal_connect (types_button, "clicked",
G_CALLBACK (run_types_dialog), &rd);
switch (response)
{
case GTK_RESPONSE_OK:
- {
- gchar *syntax = generate_syntax (&rd);
- struct getl_interface *sss = create_syntax_string_source (syntax);
- execute_syntax (sss);
-
- g_free (syntax);
- }
+ g_free (execute_syntax_string (generate_syntax (&rd)));
break;
case PSPPIRE_RESPONSE_PASTE:
- {
- gchar *syntax = generate_syntax (&rd);
-
- struct syntax_editor *se =
- (struct syntax_editor *) window_create (WINDOW_SYNTAX, NULL);
-
- gtk_text_buffer_insert_at_cursor (se->buffer, syntax, -1);
-
- g_free (syntax);
- }
+ g_free (paste_syntax_to_window (generate_syntax (&rd)));
break;
default:
break;
}
- g_object_unref (xml);
+ g_object_unref (builder);
}