From 21f2e65c7c2555bf5422920651eab07d1e8f5154 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 29 Jul 2010 16:35:56 +0200 Subject: [PATCH] Added dialog box for the aggregate command --- src/ui/gui/aggregate-dialog.c | 736 +++++++++++++++++++++++++++++++ src/ui/gui/aggregate-dialog.h | 26 ++ src/ui/gui/aggregate.ui | 534 ++++++++++++++++++++++ src/ui/gui/automake.mk | 3 + src/ui/gui/data-editor.ui | 37 +- src/ui/gui/dict-display.c | 3 +- src/ui/gui/dict-display.h | 5 +- src/ui/gui/psppire-data-window.c | 3 + src/ui/gui/psppire-selector.c | 2 - 9 files changed, 1329 insertions(+), 20 deletions(-) create mode 100644 src/ui/gui/aggregate-dialog.c create mode 100644 src/ui/gui/aggregate-dialog.h create mode 100644 src/ui/gui/aggregate.ui diff --git a/src/ui/gui/aggregate-dialog.c b/src/ui/gui/aggregate-dialog.c new file mode 100644 index 00000000..744e9cf1 --- /dev/null +++ b/src/ui/gui/aggregate-dialog.c @@ -0,0 +1,736 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include "dialog-common.h" +#include + +#include + +#include +#include + +#include "aggregate-dialog.h" +#include "psppire-selector.h" +#include "psppire-dictview.h" +#include "psppire-dialog.h" + +#include "psppire-data-window.h" +#include "psppire-var-view.h" +#include "psppire-acr.h" + +#include "dict-display.h" + +#include "executor.h" +#include "helper.h" + +#include + +#include "gettext.h" +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + + +enum + { + COMBO_MODEL_COL_DESC = 0, + COMBO_MODEL_COL_SYNTAX, + COMBO_MODEL_COL_SRC_VARS, + COMBO_MODEL_COL_ARITY + }; + + +struct aggregate +{ + GtkBuilder *xml; + PsppireDataWindow *de ; + PsppireDict *dict; + GtkWidget *break_variables; + + GtkWidget *replace_radiobutton; + GtkWidget *add_radiobutton; + GtkWidget *filename_radiobutton; + GtkWidget *filename_button; + GtkWidget *filename_box; + GtkWidget *filename_label; + + GtkWidget *function_combo; + + GtkWidget *summary_acr; + GtkWidget *summary_var_name_entry; + GtkWidget *summary_var_label_entry; + + GtkWidget *summary_sv; + GtkWidget *summary_sv_entry; + + GtkWidget *summary_arg1; + GtkWidget *summary_arg2; + + GtkWidget *summary_arg1_entry; + GtkWidget *summary_arg2_entry; + + GtkWidget *sorted_button; + GtkWidget *needs_sort_button; +}; + + +static char * generate_syntax (const struct aggregate *rd); + + +/* Makes widget W's sensitivity follow the active state of TOGGLE */ +static void +sensitive_if_active (GtkToggleButton *toggle, GtkWidget *w) +{ + gboolean active = gtk_toggle_button_get_active (toggle); + + gtk_widget_set_sensitive (w, active); +} + +static void update_arguments (struct aggregate *agg); + + +static void +refresh (struct aggregate *agg) +{ + GtkTreeModel *liststore = + gtk_tree_view_get_model (GTK_TREE_VIEW (agg->break_variables)); + gtk_list_store_clear (GTK_LIST_STORE (liststore)); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (agg->add_radiobutton), TRUE); + gtk_label_set_text (GTK_LABEL (agg->filename_label), ""); + + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (agg->needs_sort_button), TRUE); + + gtk_entry_set_text (GTK_ENTRY (agg->summary_sv_entry), ""); + gtk_entry_set_text (GTK_ENTRY (agg->summary_arg1_entry), ""); + gtk_entry_set_text (GTK_ENTRY (agg->summary_arg2_entry), ""); + gtk_entry_set_text (GTK_ENTRY (agg->summary_var_label_entry), ""); + gtk_entry_set_text (GTK_ENTRY (agg->summary_var_name_entry), ""); + + gtk_combo_box_set_active (GTK_COMBO_BOX (agg->function_combo), -1); + + gtk_list_store_clear (PSPPIRE_ACR (agg->summary_acr)->list_store); + + update_arguments (agg); +} + + +static gboolean +dialog_state_valid (gpointer data) +{ + GtkTreeIter iter; + const struct aggregate *agg = data; + + GtkTreeModel *liststore = + gtk_tree_view_get_model (GTK_TREE_VIEW (agg->break_variables)); + + if ( ! gtk_tree_model_get_iter_first (liststore, &iter)) + return FALSE; + + liststore = GTK_TREE_MODEL (PSPPIRE_ACR (agg->summary_acr)->list_store); + + if ( ! gtk_tree_model_get_iter_first (liststore, &iter)) + return FALSE; + + return TRUE; +} + + +static void +choose_filename (struct aggregate *fd) +{ + GtkFileFilter *filter; + + GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Aggregate destination file"), + GTK_WINDOW (fd->de), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); + + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("System Files (*.sav)")); + gtk_file_filter_add_pattern (filter, "*.sav"); + gtk_file_filter_add_pattern (filter, "*.SAV"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("Portable Files (*.por) ")); + gtk_file_filter_add_pattern (filter, "*.por"); + gtk_file_filter_add_pattern (filter, "*.POR"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) + { + char *filename; + + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + + gtk_label_set_text (GTK_LABEL (fd->filename_label), filename); + + g_free (filename); + } + + + gtk_widget_destroy (dialog); +} + + +static void +populate_combo_model (GtkComboBox *cb) +{ + GtkListStore *list = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); + GtkTreeIter iter; + const struct agr_func *af = agr_func_tab; + GtkCellRenderer *renderer ; + + for (af = agr_func_tab; af->name; ++af) + { + const gchar *s = af->description; + if (s == NULL) + continue; + + gtk_list_store_append (list, &iter); + gtk_list_store_set (list, &iter, + COMBO_MODEL_COL_DESC, s, + COMBO_MODEL_COL_SYNTAX, af->name, + COMBO_MODEL_COL_SRC_VARS, af->src_vars, + COMBO_MODEL_COL_ARITY, af->n_args, + -1); + } + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cb), renderer, FALSE); + + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cb), renderer, "text", 0); + + gtk_combo_box_set_model (GTK_COMBO_BOX (cb), GTK_TREE_MODEL (list)); +} + + + +/* Returns TRUE iff all the necessary controls have been set to + completely specify a summary function */ +static gboolean +summary_complete (const struct aggregate *agg) +{ + GtkTreeIter iter; + int n_args; + enum agr_src_vars src_vars; + gboolean ok; + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (agg->function_combo)); + + if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_var_name_entry)))) + return FALSE; + + ok = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (agg->function_combo), &iter); + + if (! ok) + return FALSE; + + + + gtk_tree_model_get (model, + &iter, + COMBO_MODEL_COL_ARITY, &n_args, + COMBO_MODEL_COL_SRC_VARS, &src_vars, + -1); + + if ( src_vars == AGR_SV_YES ) + { + if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_sv_entry)))) + return FALSE; + } + + if ( n_args >= 2) + { + if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_arg2_entry)))) + return FALSE; + } + + if ( n_args >= 1) + { + if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_arg1_entry)))) + return FALSE; + } + + + return TRUE; +} + + +static void +append_summary_spec (const struct aggregate *agg, GtkTreeIter *iter, GString *string); + + +static void +render_summary (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) +{ + struct aggregate *agg = data; + + GString *string = g_string_new (""); + + append_summary_spec (agg, iter, string); + + + g_object_set (cell, "text", string->str, NULL); + + g_string_free (string, TRUE); +} + + +/* Enable/Disable the summary variable ACR */ +static void +update_acr (struct aggregate *agg) +{ + gboolean ready = summary_complete (agg); + + psppire_acr_set_enabled (PSPPIRE_ACR (agg->summary_acr), ready); +} + + +/* Update the sensitivity of the summary variable argument fields */ +static void +update_arguments (struct aggregate *agg) +{ + GtkTreeIter iter; + + gboolean ok = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (agg->function_combo), &iter); + + if ( ok) + { + GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (agg->function_combo)); + int n_args; + enum agr_src_vars src_vars; + gtk_tree_model_get (model, + &iter, + COMBO_MODEL_COL_ARITY, &n_args, + COMBO_MODEL_COL_SRC_VARS, &src_vars, + -1); + + gtk_widget_set_sensitive (agg->summary_sv, src_vars != AGR_SV_NO); + gtk_widget_set_sensitive (agg->summary_arg2, n_args >= 2); + gtk_widget_set_sensitive (agg->summary_arg1, n_args >= 1); + } + else + { + gtk_widget_set_sensitive (agg->summary_sv, FALSE); + gtk_widget_set_sensitive (agg->summary_arg2, FALSE); + gtk_widget_set_sensitive (agg->summary_arg1, FALSE); + } +} + +enum + { + SUMMARY_COL_VARNAME = 0, + SUMMARY_COL_VARLABEL, + SUMMARY_COL_FUNCIDX, + SUMMARY_COL_SRCVAR, + SUMMARY_COL_ARG1, + SUMMARY_COL_ARG2 + }; + +/* Set VAL to the value appropriate for COL according to the + current state of the dialog */ +static gboolean +get_summary_spec (gint col, GValue *val, + const struct aggregate *agg) +{ + switch (col) + { + case SUMMARY_COL_VARNAME: + g_value_init (val, G_TYPE_STRING); + g_value_set_string (val, gtk_entry_get_text (GTK_ENTRY (agg->summary_var_name_entry))); + break; + case SUMMARY_COL_VARLABEL: + g_value_init (val, G_TYPE_STRING); + g_value_set_string (val, gtk_entry_get_text (GTK_ENTRY (agg->summary_var_label_entry))); + break; + case SUMMARY_COL_SRCVAR: + g_value_init (val, G_TYPE_STRING); + g_value_set_string (val, gtk_entry_get_text (GTK_ENTRY (agg->summary_sv_entry))); + break; + case SUMMARY_COL_FUNCIDX: + g_value_init (val, G_TYPE_INT); + g_value_set_int (val, gtk_combo_box_get_active (GTK_COMBO_BOX (agg->function_combo))); + break; + case SUMMARY_COL_ARG1: + { + const gchar *text = gtk_entry_get_text (GTK_ENTRY (agg->summary_arg1_entry)); + g_value_init (val, G_TYPE_DOUBLE); + g_value_set_double (val, g_strtod (text, 0)); + } + break; + case SUMMARY_COL_ARG2: + { + const gchar *text = gtk_entry_get_text (GTK_ENTRY (agg->summary_arg2_entry)); + g_value_init (val, G_TYPE_DOUBLE); + g_value_set_double (val, g_strtod (text, 0)); + } + break; + default: + g_assert_not_reached (); + break; + } + + return TRUE; +} + + +/* Update the status of the dialog box according to what row of the ACR's treeview + is selected */ +static void +on_acr_change (const struct aggregate *agg, GtkTreeView *tv) +{ + const gchar *varname; + const gchar *label; + const gchar *srcvar; + gint f_idx; + double arg1, arg2; + gchar *text = NULL; + + GtkTreeIter iter; + GtkTreePath *path = NULL; + GtkTreeModel *model = gtk_tree_view_get_model (tv); + gtk_tree_view_get_cursor (tv, &path, NULL); + + gtk_tree_model_get_iter (model, &iter, path); + + gtk_tree_model_get (model, &iter, + SUMMARY_COL_VARNAME, &varname, + SUMMARY_COL_VARLABEL, &label, + SUMMARY_COL_FUNCIDX, &f_idx, + SUMMARY_COL_SRCVAR, &srcvar, + SUMMARY_COL_ARG1, &arg1, + SUMMARY_COL_ARG2, &arg2, + -1); + + gtk_entry_set_text (GTK_ENTRY (agg->summary_var_name_entry), varname); + gtk_entry_set_text (GTK_ENTRY (agg->summary_var_label_entry), label); + gtk_entry_set_text (GTK_ENTRY (agg->summary_sv_entry), srcvar); + + text = g_strdup_printf ("%g", arg1); + gtk_entry_set_text (GTK_ENTRY (agg->summary_arg1_entry), text); + g_free (text); + + text = g_strdup_printf ("%g", arg2); + gtk_entry_set_text (GTK_ENTRY (agg->summary_arg2_entry), text); + g_free (text); + + + gtk_combo_box_set_active (GTK_COMBO_BOX (agg->function_combo), f_idx); +} + + +/* Pops up the Aggregate dialog box */ +void +aggregate_dialog (PsppireDataWindow *dw) +{ + struct aggregate fd; + gint response; + + PsppireVarStore *vs; + + GtkWidget *dialog ; + GtkWidget *source ; + + GtkWidget *break_selector ; + + fd.xml = builder_new ("aggregate.ui"); + + fd.de = dw; + + dialog = get_widget_assert (fd.xml, "psppire-dialog1"); + source = get_widget_assert (fd.xml, "dict-view"); + break_selector = get_widget_assert (fd.xml, "break-selector"); + + fd.break_variables = get_widget_assert (fd.xml, "psppire-var-view1"); + fd.filename_radiobutton = get_widget_assert (fd.xml, "filename-radiobutton"); + fd.filename_button = get_widget_assert (fd.xml, "filename-button"); + fd.filename_box = get_widget_assert (fd.xml, "filename-box"); + fd.filename_label = get_widget_assert (fd.xml, "filename-label"); + fd.replace_radiobutton = get_widget_assert (fd.xml, "replace-radiobutton"); + fd.add_radiobutton = get_widget_assert (fd.xml, "add-radiobutton"); + fd.function_combo = get_widget_assert (fd.xml, "function-combo"); + + fd.summary_acr = get_widget_assert (fd.xml, "psppire-acr1"); + fd.summary_var_name_entry = get_widget_assert (fd.xml, "summary-var-name-entry"); + + fd.summary_arg1 = get_widget_assert (fd.xml, "summary-arg1"); + fd.summary_arg2 = get_widget_assert (fd.xml, "summary-arg2"); + + fd.summary_arg1_entry = get_widget_assert (fd.xml, "summary-arg-entry1"); + fd.summary_arg2_entry = get_widget_assert (fd.xml, "summary-arg-entry2"); + + fd.summary_var_label_entry = get_widget_assert (fd.xml, "summary-var-label-entry"); + + fd.summary_sv = get_widget_assert (fd.xml, "source-var"); + fd.summary_sv_entry = get_widget_assert (fd.xml, "source-var-entry"); + + fd.sorted_button = get_widget_assert (fd.xml, "sorted-radiobutton"); + fd.needs_sort_button = get_widget_assert (fd.xml, "needs-sort-radiobutton"); + + { + GtkTreeViewColumn *column ; + + GList *l ; + + GtkCellRenderer *cell_renderer ; + + GtkListStore *list = gtk_list_store_new (6, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_DOUBLE, + G_TYPE_DOUBLE); + + psppire_acr_set_model (PSPPIRE_ACR (fd.summary_acr), list); + + psppire_acr_set_get_value_func (PSPPIRE_ACR (fd.summary_acr), + get_summary_spec, &fd); + + column = gtk_tree_view_get_column (PSPPIRE_ACR (fd.summary_acr)->tv, 0); + + l = gtk_tree_view_column_get_cell_renderers (column); + + cell_renderer = l->data; + + gtk_tree_view_column_set_cell_data_func (column, + cell_renderer, + render_summary, + &fd, + NULL); + + g_signal_connect_swapped (PSPPIRE_ACR (fd.summary_acr)->tv, + "cursor-changed", G_CALLBACK (on_acr_change), &fd); + } + + g_signal_connect_swapped (fd.summary_var_name_entry, "changed", G_CALLBACK (update_acr), &fd); + g_signal_connect_swapped (fd.function_combo, "changed", G_CALLBACK (update_acr), &fd); + g_signal_connect_swapped (fd.summary_sv_entry, "changed", G_CALLBACK (update_acr), &fd); + g_signal_connect_swapped (fd.summary_arg1_entry, "changed", G_CALLBACK (update_acr), &fd); + g_signal_connect_swapped (fd.summary_arg2_entry, "changed", G_CALLBACK (update_acr), &fd); + + g_signal_connect_swapped (fd.function_combo, "changed", + G_CALLBACK (update_arguments), &fd); + + populate_combo_model (GTK_COMBO_BOX (fd.function_combo)); + + g_signal_connect_swapped (dialog, "refresh", G_CALLBACK (refresh), &fd); + + g_object_get (fd.de->data_editor, "var-store", &vs, NULL); + + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fd.de)); + + g_object_get (vs, "dictionary", &fd.dict, NULL); + g_object_set (source, "model", fd.dict, NULL); + + + psppire_selector_set_filter_func (PSPPIRE_SELECTOR (break_selector), NULL); + + + psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog), + dialog_state_valid, &fd); + + g_signal_connect (fd.filename_radiobutton, "toggled", + G_CALLBACK (sensitive_if_active), fd.filename_box ); + + g_signal_connect_swapped (fd.filename_button, "clicked", + G_CALLBACK (choose_filename), &fd); + + + response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); + + switch (response) + { + case GTK_RESPONSE_OK: + { + gchar *syntax = generate_syntax (&fd); + + struct getl_interface *sss = create_syntax_string_source (syntax); + execute_syntax (sss); + + g_free (syntax); + } + break; + case PSPPIRE_RESPONSE_PASTE: + { + gchar *syntax = generate_syntax (&fd); + paste_syntax_to_window (syntax); + + g_free (syntax); + } + break; + default: + break; + } + + g_object_unref (fd.xml); +} + + + + +static void +append_destination_filename (const struct aggregate *agg, GString *gs) +{ + if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->filename_radiobutton))) + { + struct string ss; + const gchar *s = gtk_label_get_text (GTK_LABEL (agg->filename_label)); + ds_init_empty (&ss); + syntax_gen_string (&ss, ss_cstr (s)); + g_string_append (gs, ds_cstr (&ss)); + ds_destroy (&ss); + } + else + { + g_string_append (gs, "* "); + + if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->replace_radiobutton))) + g_string_append (gs, "MODE=REPLACE"); + else + g_string_append (gs, "MODE=ADDVARIABLES"); + } +} + +/* Append the syntax of the summary function pointed to by ITER to STRING */ +static void +append_summary_spec (const struct aggregate *agg, GtkTreeIter *iter, GString *string) +{ + GtkTreeIter combo_iter; + const char *varname; + const char *funcname; + + GtkTreeModel *acr_model = GTK_TREE_MODEL (PSPPIRE_ACR (agg->summary_acr)->list_store); + GtkTreeModel *combo_model = gtk_combo_box_get_model (GTK_COMBO_BOX (agg->function_combo)); + + + /* This is an index into the combo_model. Its used to get the function name */ + int f_idx; + double arg1, arg2; + int arity; + enum agr_src_vars has_src_vars; + const gchar *label ; + const gchar *srcvar ; + + gtk_tree_model_get (acr_model, iter, + SUMMARY_COL_VARNAME, &varname, + SUMMARY_COL_VARLABEL, &label, + SUMMARY_COL_FUNCIDX, &f_idx, + SUMMARY_COL_SRCVAR, &srcvar, + SUMMARY_COL_ARG1, &arg1, + SUMMARY_COL_ARG2, &arg2, + -1); + + gtk_tree_model_iter_nth_child (combo_model, &combo_iter, NULL, f_idx); + + gtk_tree_model_get (combo_model, &combo_iter, + COMBO_MODEL_COL_SYNTAX, &funcname, + COMBO_MODEL_COL_ARITY, &arity, + COMBO_MODEL_COL_SRC_VARS, &has_src_vars, + -1); + + g_string_append (string, varname); + + if (0 != strcmp ("", label)) + { + struct string ss; + ds_init_empty (&ss); + syntax_gen_string (&ss, ss_cstr (label)); + g_string_append (string, " "); + g_string_append (string, ds_cstr (&ss)); + ds_destroy (&ss); + } + + g_string_append_printf (string, " = %s", funcname); + + if ( has_src_vars != AGR_SV_NO) + { + g_string_append (string, " ("); + + g_string_append (string, srcvar); + + if ( arity > 0) + g_string_append_printf (string, ", %g", arg1); + + if ( arity > 1) + g_string_append_printf (string, ", %g", arg2); + + g_string_append (string, ")"); + } +} + + + +static void +append_summary_variable_syntax (const struct aggregate *agg, GString *string) +{ + GtkTreeIter iter; + GtkTreeModel *acr_model = GTK_TREE_MODEL (PSPPIRE_ACR (agg->summary_acr)->list_store); + + + gboolean ok; + + for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (acr_model), &iter); + ok ; + ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (acr_model), &iter) + ) + { + g_string_append (string, "\n\t/"); + + append_summary_spec (agg, &iter, string); + } +} + + +static char * +generate_syntax (const struct aggregate *agg) +{ + gchar *text; + + GString *string = g_string_new ("AGGREGATE OUTFILE="); + + append_destination_filename (agg, string); + + if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->sorted_button))) + g_string_append (string, "\n\t/PRESORTED"); + + g_string_append (string, "\n\t/BREAK="); + + psppire_var_view_append_names (PSPPIRE_VAR_VIEW (agg->break_variables), 0, string); + + append_summary_variable_syntax (agg, string); + + g_string_append (string, ".\n"); + + text = string->str; + + g_string_free (string, FALSE); + + return text; +} diff --git a/src/ui/gui/aggregate-dialog.h b/src/ui/gui/aggregate-dialog.h new file mode 100644 index 00000000..302e5943 --- /dev/null +++ b/src/ui/gui/aggregate-dialog.h @@ -0,0 +1,26 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef __AGGREGATE_DIALOG_H +#define __AGGREGATE_DIALOG_H + + +#include +#include "psppire-data-window.h" + +void aggregate_dialog (PsppireDataWindow * data); + +#endif diff --git a/src/ui/gui/aggregate.ui b/src/ui/gui/aggregate.ui new file mode 100644 index 00000000..193d112d --- /dev/null +++ b/src/ui/gui/aggregate.ui @@ -0,0 +1,534 @@ + + + + + + + Aggregate Data + True + Vertical + + + True + vertical + 2 + + + True + + + True + True + automatic + automatic + in + + + True + True + True + 5 + False + False + + + + + False + True + + + + + True + vertical + + + True + + + True + 0 + + + True + True + True + 5 + dict-view + psppire-var-view1 + + + + + False + 0 + + + + + True + 0 + none + + + True + 12 + + + True + True + automatic + automatic + in + + + True + True + 5 + False + False + + + + + + + + + True + _Break variable(s) + True + True + + + + + 1 + + + + + 0 + + + + + True + 0 + + + True + vertical + 5 + + + True + 4 + 2 + + + True + + + True + 1 + Variable Name: + + + 0 + + + + + True + True + + + + 1 + + + + + + + True + + + True + 1 + Variable Label: + + + 0 + + + + + True + True + + + + 1 + + + + + 1 + 2 + + + + + True + + + True + 1 + Function: + + + False + 0 + + + + + True + + + end + 1 + + + + + 2 + 1 + 2 + + + + + True + + + True + True + True + 5 + dict-view + source-var-entry + + + False + 0 + + + + + True + True + + + + 1 + + + + + 2 + 3 + + + + + True + + + True + 1 + Argument 1: + + + 0 + + + + + True + True + + + + 1 + + + + + 3 + 4 + + + + + True + + + True + 1 + Argument 2: + + + 0 + + + + + True + True + + + + 1 + + + + + 1 + 2 + 3 + 4 + + + + + + + + 0 + + + + + True + 5 + + + 1 + + + + + + + True + Aggregated variables + True + + + + + 1 + + + + + True + True + + + + + 0 + + + + + True + 0 + + + True + 12 + + + True + vertical + + + _Add aggregated variables to the active dataset + True + True + False + True + True + True + + + 0 + + + + + _Replace the current dataset with the aggregated variables + True + True + False + True + True + True + add-radiobutton + + + 1 + + + + + _Write a new data file containing only the aggregated variables + True + True + False + True + True + True + add-radiobutton + + + 2 + + + + + True + 15 + + + True + False + + + gtk-save + True + True + True + True + + + False + 0 + + + + + True + label + + + 1 + + + + + + + 3 + + + + + + + + + True + Save + True + + + + + False + 1 + + + + + True + 0 + + + True + 12 + + + True + vertical + + + File is _already sorted on break variable(s) + True + True + False + True + True + + + False + False + 0 + + + + + Sort file before a_ggregating + True + True + False + True + True + sorted-radiobutton + + + False + False + 1 + + + + + + + + + True + Options for very large datasets + True + + + + + False + 2 + + + + + True + 5 + + + False + False + end + 3 + + + + + + + diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 7f56a84b..5731ae53 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -3,6 +3,7 @@ include $(top_srcdir)/src/ui/gui/sheet/automake.mk UI_FILES = \ + src/ui/gui/aggregate.ui \ src/ui/gui/binomial.ui \ src/ui/gui/compute.ui \ src/ui/gui/correlation.ui \ @@ -116,6 +117,8 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/psppire-hbuttonbox.c \ src/ui/gui/psppire-vbuttonbox.c \ src/ui/gui/psppire-acr.c \ + src/ui/gui/aggregate-dialog.c \ + src/ui/gui/aggregate-dialog.h \ src/ui/gui/binomial-dialog.c \ src/ui/gui/binomial-dialog.h \ src/ui/gui/checkbox-treeview.c \ diff --git a/src/ui/gui/data-editor.ui b/src/ui/gui/data-editor.ui index 023b9698..69f2b413 100644 --- a/src/ui/gui/data-editor.ui +++ b/src/ui/gui/data-editor.ui @@ -14,8 +14,7 @@ - - + @@ -243,6 +242,13 @@ Transpose the cases with the variables + + + pspp-aggregate + data_aggregate + _Aggregate + + data_split-file @@ -505,6 +511,7 @@ + @@ -572,24 +579,24 @@ - - - - - - + + + + + + - - - + + + - - - + + + - + diff --git a/src/ui/gui/dict-display.c b/src/ui/gui/dict-display.c index 160cdb2a..ada7fb40 100644 --- a/src/ui/gui/dict-display.c +++ b/src/ui/gui/dict-display.c @@ -23,6 +23,7 @@ #include "dict-display.h" #include "psppire-dict.h" +#include "psppire-var-view.h" #include #include "helper.h" #include @@ -151,5 +152,3 @@ is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter, return result; } - - diff --git a/src/ui/gui/dict-display.h b/src/ui/gui/dict-display.h index f1a8a001..5586cb10 100644 --- a/src/ui/gui/dict-display.h +++ b/src/ui/gui/dict-display.h @@ -19,6 +19,9 @@ dictionary in GTK widgets. */ +#ifndef DICT_DISPLAY +#define DICT_DISPLAY 1 + #include #include "psppire-selector.h" @@ -44,4 +47,4 @@ void insert_source_row_into_entry (GtkTreeIter source_iter, gboolean is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter, PsppireSelector *selector); - +#endif diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index 92c3e599..e6d905e0 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -57,6 +57,7 @@ #include "ui/gui/t-test-paired-samples.h" #include "ui/gui/text-data-import-dialog.h" #include "ui/gui/transpose-dialog.h" +#include "ui/gui/aggregate-dialog.h" #include "ui/gui/variable-info-dialog.h" #include "ui/gui/weight-cases-dialog.h" #include "ui/syntax-gen.h" @@ -1081,6 +1082,8 @@ psppire_data_window_init (PsppireDataWindow *de) connect_action (de, "data_sort-cases", G_CALLBACK (sort_cases_dialog)); + connect_action (de, "data_aggregate", G_CALLBACK (aggregate_dialog)); + connect_action (de, "transform_compute", G_CALLBACK (compute_dialog)); connect_action (de, "edit_find", G_CALLBACK (find_dialog)); diff --git a/src/ui/gui/psppire-selector.c b/src/ui/gui/psppire-selector.c index 83fe2d82..74d2bffc 100644 --- a/src/ui/gui/psppire-selector.c +++ b/src/ui/gui/psppire-selector.c @@ -981,8 +981,6 @@ psppire_selector_set_filter_func (PsppireSelector *selector, FilterItemsFunc *filter_func) { selector->filter = filter_func ; - - set_default_filter (selector); } -- 2.30.2