X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fsplit-file-dialog.c;h=2cf10d532945d837965b4861a837ec3a86e5f39d;hb=64c3106b6b4900aa3515fb3ebc930ce80b59bb1e;hp=00f30c627080d53f96848d96c1c7ba4aca128ea7;hpb=21f8b80b93df013ab921fbb4adeadd7e3424262f;p=pspp diff --git a/src/ui/gui/split-file-dialog.c b/src/ui/gui/split-file-dialog.c index 00f30c6270..2cf10d5329 100644 --- a/src/ui/gui/split-file-dialog.c +++ b/src/ui/gui/split-file-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 @@ -19,21 +19,21 @@ #include "split-file-dialog.h" #include "psppire-selector.h" #include "psppire-dialog.h" -#include "helper.h" -#include "data-editor.h" +#include "executor.h" +#include "psppire-data-window.h" #include "dict-display.h" -#include -#include "syntax-editor.h" +#include "builder-wrapper.h" +#include "helper.h" + #include +#include "psppire-var-view.h" + #include #include "dialog-common.h" -/* FIXME: These shouldn't be here */ -#include "psppire-var-store.h" - struct split_file_dialog { @@ -47,7 +47,6 @@ struct split_file_dialog upon which the file should be split */ GtkTreeView *tv; - PsppireSelector *selector; }; @@ -58,9 +57,6 @@ generate_syntax (const struct split_file_dialog *sfd) gchar *text; GtkWidget *off = get_widget_assert (sfd->xml, "split-radiobutton0"); - GtkWidget *vars = - get_widget_assert (sfd->xml, "split-file-grouping-vars"); - GString *string = g_string_new ("SPLIT FILE OFF."); if ( ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (off))) @@ -68,8 +64,7 @@ generate_syntax (const struct split_file_dialog *sfd) GString * varlist = g_string_sized_new (80); GtkWidget *sort = get_widget_assert (sfd->xml, "split-radiobutton3"); GtkWidget *layered = get_widget_assert (sfd->xml, "split-radiobutton1"); - gint n_vars = append_variable_names (varlist, - sfd->dict, GTK_TREE_VIEW (vars), 0); + gint n_vars = psppire_var_view_append_names (PSPPIRE_VAR_VIEW (sfd->tv), 0, varlist); if ( n_vars > 0 ) { @@ -134,7 +129,6 @@ refresh (PsppireDialog *dialog, struct split_file_dialog *d) gint n_vars = dict_get_split_cnt (d->dict->dict); - gtk_list_store_clear (GTK_LIST_STORE (liststore)); if ( n_vars == 0 ) @@ -147,10 +141,11 @@ refresh (PsppireDialog *dialog, struct split_file_dialog *d) for (i = 0 ; i < n_vars; ++i ) { - gint idx = var_get_dict_index (vars[i]); - gtk_list_store_append (GTK_LIST_STORE (liststore), &iter); - gtk_list_store_set (GTK_LIST_STORE (liststore), &iter, 0, idx, -1); + + gtk_list_store_set (GTK_LIST_STORE (liststore), &iter, + 0, vars[i], + -1); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(on), TRUE); @@ -163,54 +158,36 @@ refresh (PsppireDialog *dialog, struct split_file_dialog *d) /* Pops up the Split File dialog box */ void -split_file_dialog (GObject *o, gpointer data) +split_file_dialog (PsppireDataWindow *de) { gint response; - struct data_editor *de = data; struct split_file_dialog sfd; - PsppireVarStore *vs ; GtkWidget *dialog ; GtkWidget *source ; - GtkWidget *dest ; GtkWidget *selector ; GtkWidget *on_off ; - sfd.xml = builder_new ("psppire.ui"); + sfd.xml = builder_new ("split-file.ui"); dialog = get_widget_assert (sfd.xml, "split-file-dialog"); source = get_widget_assert (sfd.xml, "split-file-dict-treeview"); - dest = get_widget_assert (sfd.xml, "split-file-grouping-vars"); selector = get_widget_assert (sfd.xml, "split-file-selector"); on_off = get_widget_assert (sfd.xml, "split-radiobutton0"); - g_object_get (de->data_editor, "var-store", &vs, NULL); + sfd.tv = GTK_TREE_VIEW (get_widget_assert (sfd.xml, "split-file-grouping-vars")); - sfd.dict = vs->dict; - sfd.tv = GTK_TREE_VIEW (dest); - sfd.selector = PSPPIRE_SELECTOR ( - get_widget_assert (sfd.xml, "split-file-selector")); + g_object_get (de->data_editor, "dictionary", &sfd.dict, NULL); - attach_dictionary_to_treeview (GTK_TREE_VIEW (source), - vs->dict, - GTK_SELECTION_MULTIPLE, NULL); + sfd.selector = PSPPIRE_SELECTOR (selector); + g_object_set (source, "model", sfd.dict, NULL); g_signal_connect (on_off, "toggled", G_CALLBACK(on_off_toggled), sfd.xml); - - set_dest_model (GTK_TREE_VIEW (dest), vs->dict); - - psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector), - source, - dest, - insert_source_row_into_tree_view, - NULL, - NULL); - g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &sfd); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); @@ -218,25 +195,10 @@ split_file_dialog (GObject *o, gpointer data) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&sfd); - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (de, generate_syntax (&sfd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&sfd); - - 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 (&sfd))); break; default: break;