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=b0b470bd4000029fb9b2aea14592b74e3cdf2584;hpb=48386ee68a5283653435d05a9ea4e449710fd370;p=pspp diff --git a/src/ui/gui/split-file-dialog.c b/src/ui/gui/split-file-dialog.c index b0b470bd40..2cf10d5329 100644 --- a/src/ui/gui/split-file-dialog.c +++ b/src/ui/gui/split-file-dialog.c @@ -1,49 +1,44 @@ -/* - PSPPIRE --- A Graphical User Interface for PSPP - Copyright (C) 2007 Free Software Foundation +/* PSPPIRE - a graphical user interface for PSPP. + 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + 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. + 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, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #include #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 #include "dialog-common.h" -/* FIXME: These shouldn't be here */ -#include -#include "psppire-var-store.h" - struct split_file_dialog { /* The XML that created the dialog */ - GladeXML *xml; + GtkBuilder *xml; /* The dictionary to which this dialog pertains */ PsppireDict *dict; @@ -52,7 +47,6 @@ struct split_file_dialog upon which the file should be split */ GtkTreeView *tv; - PsppireSelector *selector; }; @@ -63,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))) @@ -73,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)); + gint n_vars = psppire_var_view_append_names (PSPPIRE_VAR_VIEW (sfd->tv), 0, varlist); if ( n_vars > 0 ) { @@ -113,7 +103,7 @@ static void on_off_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - GladeXML *xml = user_data; + GtkBuilder *xml = user_data; GtkWidget *dest = get_widget_assert (xml, "split-file-grouping-vars"); GtkWidget *selector = get_widget_assert (xml, "split-file-selector"); GtkWidget *source = get_widget_assert (xml, "split-file-dict-treeview"); @@ -139,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 ) @@ -152,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); @@ -168,81 +158,47 @@ 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 ; - GtkSheet *var_sheet ; - - sfd.xml = XML_NEW ("psppire.glade"); + 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"); - var_sheet = GTK_SHEET (get_widget_assert (de->xml, "variable_sheet")); - - vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet)); + 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); - g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &sfd); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); + response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); 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;