X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fsplit-file-dialog.c;h=22cdb9140483b5393010997bf40eb05f29c80961;hb=67ab7839678c0f8aa12459ce5a585a5636f20196;hp=35aaf701f9ff196b26516259c993285b229c3809;hpb=5d5b324c12dc799e6e4dc3230e93edaa7d0a0272;p=pspp
diff --git a/src/ui/gui/split-file-dialog.c b/src/ui/gui/split-file-dialog.c
index 35aaf701f9..22cdb91404 100644
--- a/src/ui/gui/split-file-dialog.c
+++ b/src/ui/gui/split-file-dialog.c
@@ -1,21 +1,18 @@
-/*
- PSPPIRE --- A Graphical User Interface for PSPP
- Copyright (C) 2007 Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2007 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
@@ -27,6 +24,7 @@
#include "dict-display.h"
#include
#include "syntax-editor.h"
+#include
#include
#include
@@ -35,29 +33,44 @@
#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;
+
+ /* The dictionary to which this dialog pertains */
+ PsppireDict *dict;
+
+ /* The treeview widget containing the list of variables
+ upon which the file should be split */
+ GtkTreeView *tv;
+
+
+ PsppireSelector *selector;
+};
+
static gchar *
-generate_syntax (GladeXML *xml, PsppireDict *dict)
+generate_syntax (const struct split_file_dialog *sfd)
{
gchar *text;
- GtkWidget *off = get_widget_assert (xml, "split-radiobutton0");
+ GtkWidget *off = get_widget_assert (sfd->xml, "split-radiobutton0");
GtkWidget *vars =
- get_widget_assert (xml, "split-file-grouping-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)))
{
GString * varlist = g_string_sized_new (80);
- GtkWidget *sort = get_widget_assert (xml, "split-radiobutton3");
- GtkWidget *layered = get_widget_assert (xml, "split-radiobutton1");
+ 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,
- dict, GTK_TREE_VIEW (vars));
+ sfd->dict, GTK_TREE_VIEW (vars), 0);
if ( n_vars > 0 )
{
@@ -113,47 +126,78 @@ on_off_toggled (GtkToggleButton *togglebutton,
}
static void
-refresh (GladeXML *xml)
+refresh (PsppireDialog *dialog, struct split_file_dialog *d)
{
- GtkWidget *off = get_widget_assert (xml, "split-radiobutton0");
+ GtkWidget *off = get_widget_assert (d->xml, "split-radiobutton0");
+ GtkWidget *on = get_widget_assert (d->xml, "split-radiobutton1");
+
+ GtkTreeModel *liststore = gtk_tree_view_get_model (d->tv);
+
+ gint n_vars = dict_get_split_cnt (d->dict->dict);
+
- g_print ("%s\n", __FUNCTION__);
+ gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+ if ( n_vars == 0 )
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(off), TRUE);
+ else
+ {
+ GtkTreeIter iter;
+ gint i;
+ const struct variable *const *vars = dict_get_split_vars (d->dict->dict);
+
+ 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_toggle_button_set_active (GTK_TOGGLE_BUTTON(on), TRUE);
+ }
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(off), TRUE);
gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON(off));
}
-/* Pops up the Weight Cases dialog box */
+/* Pops up the Split File dialog box */
void
split_file_dialog (GObject *o, gpointer data)
{
gint response;
struct data_editor *de = data;
- PsppireDict *dict;
+ struct split_file_dialog sfd;
+ PsppireVarStore *vs ;
- GladeXML *xml = XML_NEW ("psppire.glade");
+ GtkWidget *dialog ;
+ GtkWidget *source ;
+ GtkWidget *dest ;
+ GtkWidget *selector ;
+ GtkWidget *on_off ;
- GtkWidget *dialog = get_widget_assert (xml, "split-file-dialog");
- GtkWidget *source = get_widget_assert (xml, "split-file-dict-treeview");
- GtkWidget *dest = get_widget_assert (xml, "split-file-grouping-vars");
- GtkWidget *selector = get_widget_assert (xml, "split-file-selector");
- GtkWidget *on_off = get_widget_assert (xml, "split-radiobutton0");
+ sfd.xml = XML_NEW ("psppire.glade");
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+ 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");
- PsppireVarStore *vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
+ g_object_get (de->data_editor, "var-store", &vs, NULL);
- dict = vs->dict;
+ sfd.dict = vs->dict;
+ sfd.tv = GTK_TREE_VIEW (dest);
+ sfd.selector = PSPPIRE_SELECTOR (
+ get_widget_assert (sfd.xml, "split-file-selector"));
attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
vs->dict,
GTK_SELECTION_MULTIPLE, NULL);
- g_signal_connect (on_off, "toggled", G_CALLBACK(on_off_toggled), xml);
+ g_signal_connect (on_off, "toggled", G_CALLBACK(on_off_toggled), sfd.xml);
set_dest_model (GTK_TREE_VIEW (dest), vs->dict);
@@ -162,9 +206,12 @@ split_file_dialog (GObject *o, gpointer data)
source,
dest,
insert_source_row_into_tree_view,
+ NULL,
NULL);
- refresh (xml);
+ g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &sfd);
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window);
response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
@@ -173,7 +220,7 @@ split_file_dialog (GObject *o, gpointer data)
{
case GTK_RESPONSE_OK:
{
- gchar *syntax = generate_syntax (xml, dict);
+ gchar *syntax = generate_syntax (&sfd);
struct getl_interface *sss = create_syntax_string_source (syntax);
execute_syntax (sss);
@@ -182,7 +229,7 @@ split_file_dialog (GObject *o, gpointer data)
break;
case PSPPIRE_RESPONSE_PASTE:
{
- gchar *syntax = generate_syntax (xml, dict);
+ gchar *syntax = generate_syntax (&sfd);
struct syntax_editor *se =
(struct syntax_editor *) window_create (WINDOW_SYNTAX, NULL);
@@ -196,6 +243,6 @@ split_file_dialog (GObject *o, gpointer data)
break;
}
- g_object_unref (xml);
+ g_object_unref (sfd.xml);
}