X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fcrosstabs-dialog.c;h=acac2b67494849a5ff42cb342c25a7627821fb78;hb=c95342af39690092058967093bfa08117cdf05e7;hp=2c50b461844d38de4587e1bcc9fcad01212b4d04;hpb=e2c69e2706b5e6ed05ff865ab7b3aca04817fc99;p=pspp-builds.git diff --git a/src/ui/gui/crosstabs-dialog.c b/src/ui/gui/crosstabs-dialog.c index 2c50b461..acac2b67 100644 --- a/src/ui/gui/crosstabs-dialog.c +++ b/src/ui/gui/crosstabs-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008 Free Software Foundation + Copyright (C) 2008, 2010, 2011 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 @@ -18,18 +18,18 @@ #include "checkbox-treeview.h" #include "crosstabs-dialog.h" +#include "psppire-var-view.h" #include #include -#include -#include +#include #include #include -#include "helper.h" +#include "executor.h" #include #include -#include +#include #include "gettext.h" #define _(msgid) gettext (msgid) @@ -108,12 +108,6 @@ static const struct checkbox_entry_item cells[] = #undef CS }; -enum - { - LABEL, - NO_LABEL, - NO_VAL_LABEL, - }; struct format_options { gboolean avalue; @@ -140,9 +134,6 @@ struct crosstabs_dialog GtkWidget *stat_view; GtkWidget *cell_view; - GtkToggleButton *label; - GtkToggleButton *no_label; - GtkToggleButton *no_val_label; struct format_options current_opts; }; @@ -159,9 +150,6 @@ static void on_format_clicked (struct crosstabs_dialog *cd) { int ret; - gboolean lab; - gboolean no_lab; - gboolean no_val_lab; if (cd->current_opts.avalue) { @@ -175,14 +163,6 @@ on_format_clicked (struct crosstabs_dialog *cd) { gtk_toggle_button_set_active (cd->pivot_button, TRUE); } - lab = gtk_toggle_button_get_active (cd->label); - no_lab = gtk_toggle_button_get_active (cd->no_label); - no_val_lab = gtk_toggle_button_get_active (cd->no_val_label); - if (!lab) - if (!no_lab) - if (!no_val_lab) - gtk_toggle_button_set_active (cd->label, TRUE); - ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->format_dialog)); @@ -195,12 +175,6 @@ on_format_clicked (struct crosstabs_dialog *cd) cd->current_opts.pivot = (gtk_toggle_button_get_active (cd->pivot_button) == TRUE) ? TRUE : FALSE; } - else - { - gtk_toggle_button_set_active (cd->label, lab); - gtk_toggle_button_set_active (cd->no_label, no_lab); - gtk_toggle_button_set_active (cd->no_val_label, no_val_lab); - } } static void @@ -259,9 +233,9 @@ generate_syntax (const struct crosstabs_dialog *cd) GString *string = g_string_new ("CROSSTABS"); g_string_append (string, "\n\t/TABLES="); - append_variable_names (string, cd->dict, GTK_TREE_VIEW (cd->row_vars), 0); + psppire_var_view_append_names (PSPPIRE_VAR_VIEW (cd->row_vars), 0, string); g_string_append (string, "\tBY\t"); - append_variable_names (string, cd->dict, GTK_TREE_VIEW (cd->col_vars), 0); + psppire_var_view_append_names (PSPPIRE_VAR_VIEW (cd->col_vars), 0, string); g_string_append (string, "\n\t/FORMAT="); @@ -274,19 +248,6 @@ generate_syntax (const struct crosstabs_dialog *cd) g_string_append (string, "DVALUE"); } g_string_append (string, " "); - if (gtk_toggle_button_get_active (cd->label)) - { - g_string_append (string, "LABELS"); - } - else if (gtk_toggle_button_get_active (cd->no_label)) - { - g_string_append (string, "NOLABELS"); - } - else if (gtk_toggle_button_get_active (cd->no_val_label)) - { - g_string_append (string, "NOVALLABS"); - } - g_string_append (string, " "); if (cd->current_opts.table) g_string_append (string, "TABLES"); else @@ -382,22 +343,20 @@ dialog_state_valid (gpointer data) /* Pops up the Crosstabs dialog box */ void -crosstabs_dialog (GObject *o, gpointer data) +crosstabs_dialog (PsppireDataWindow *de) { gint response; - struct data_editor *de = data; - struct crosstabs_dialog cd; GtkBuilder *xml = builder_new ("crosstabs.ui"); PsppireVarStore *vs = NULL; + PsppireDict *dict = NULL; + GtkWidget *dialog = get_widget_assert (xml, "crosstabs-dialog"); GtkWidget *source = get_widget_assert (xml, "dict-treeview"); GtkWidget *dest_rows = get_widget_assert (xml, "rows"); GtkWidget *dest_cols = get_widget_assert (xml, "cols"); - GtkWidget *row_selector = get_widget_assert (xml, "row-selector"); - GtkWidget *col_selector = get_widget_assert (xml, "col-selector"); GtkWidget *format_button = get_widget_assert (xml, "format-button"); GtkWidget *stat_button = get_widget_assert (xml, "stats-button"); GtkWidget *cell_button = get_widget_assert (xml, "cell-button"); @@ -419,38 +378,17 @@ crosstabs_dialog (GObject *o, gpointer data) cells ); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); - - attach_dictionary_to_treeview (GTK_TREE_VIEW (source), - vs->dict, - GTK_SELECTION_MULTIPLE, NULL); - - set_dest_model (GTK_TREE_VIEW (dest_rows), vs->dict); - set_dest_model (GTK_TREE_VIEW (dest_cols), vs->dict); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); - psppire_selector_set_subjects (PSPPIRE_SELECTOR (row_selector), - source, - dest_rows, - insert_source_row_into_tree_view, - NULL, - NULL); - - psppire_selector_set_subjects (PSPPIRE_SELECTOR (col_selector), - source, - dest_cols, - insert_source_row_into_tree_view, - NULL, - NULL); + g_object_get (vs, "dictionary", &dict, NULL); + g_object_set (source, "model", dict, NULL); cd.row_vars = GTK_TREE_VIEW (dest_rows); cd.col_vars = GTK_TREE_VIEW (dest_cols); - cd.dict = vs->dict; + g_object_get (vs, "dictionary", &cd.dict, NULL); cd.format_dialog = get_widget_assert (xml, "format-dialog"); cd.table_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "print-tables")); cd.pivot_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "pivot")); - cd.label = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "radiobutton1")); - cd.no_label = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "radiobutton2")); - cd.no_val_label = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "radiobutton3")); cd.stat_dialog = get_widget_assert (xml, "stat-dialog"); cd.cell_dialog = get_widget_assert (xml, "cell-dialog"); @@ -461,9 +399,9 @@ crosstabs_dialog (GObject *o, gpointer data) cd.current_opts.table = TRUE; cd.current_opts.pivot = TRUE; - gtk_window_set_transient_for (GTK_WINDOW (cd.format_dialog), de->parent.window); - gtk_window_set_transient_for (GTK_WINDOW (cd.cell_dialog), de->parent.window); - gtk_window_set_transient_for (GTK_WINDOW (cd.stat_dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (cd.format_dialog), GTK_WINDOW (de)); + gtk_window_set_transient_for (GTK_WINDOW (cd.cell_dialog), GTK_WINDOW (de)); + gtk_window_set_transient_for (GTK_WINDOW (cd.stat_dialog), GTK_WINDOW (de)); g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &cd); @@ -483,25 +421,10 @@ crosstabs_dialog (GObject *o, gpointer data) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&cd); - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (de, generate_syntax (&cd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&cd); - - 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 (&cd))); break; default: break;