2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2004, 2005, 2006 Free Software Foundation
4 Written by John Darrington
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #include <glade/glade.h>
27 #include <gtksheet/gtksheet.h>
29 #include <gtksheet/gsheet-uniform-row.h>
31 #include "psppire-dict.h"
32 #include "psppire-variable.h"
33 #include "psppire-data-store.h"
36 #include <data/value-labels.h>
37 #include <data/case.h>
38 #include <data/data-in.h>
40 #include "menu-actions.h"
41 #include "data-sheet.h"
51 traverse_callback (GtkSheet * sheet,
53 gint *new_row, gint *new_column
56 PsppireDataStore *data_store = PSPPIRE_DATA_STORE(gtk_sheet_get_model(sheet));
58 const gint n_vars = psppire_dict_get_var_cnt(data_store->dict);
60 if ( *new_column >= n_vars )
68 /* Callback which occurs when the column title is double clicked */
70 click2column(GtkWidget *w, gint col, gpointer data)
72 gint current_row, current_column;
73 GtkWidget *var_sheet = get_widget_assert(xml, "variable_sheet");
75 select_sheet(PAGE_VAR_SHEET);
77 gtk_sheet_get_active_cell(GTK_SHEET(var_sheet),
78 ¤t_row, ¤t_column);
80 gtk_sheet_set_active_cell(GTK_SHEET(var_sheet), col, current_column);
86 /* Update the data_ref_entry with the reference of the active cell */
88 update_data_ref_entry(GtkSheet *sheet, gint row, gint col)
91 /* The entry where the reference to the current cell is displayed */
92 GtkEntry *cell_ref_entry;
94 PsppireDataStore *data_store = PSPPIRE_DATA_STORE(gtk_sheet_get_model(sheet));
97 const struct PsppireVariable *pv =
98 psppire_dict_get_variable(data_store->dict, col);
105 text = g_strdup_printf("%d: %s", row,
106 pv ? psppire_variable_get_name(pv) : "");
108 cell_ref_entry = GTK_ENTRY(get_widget_assert(xml, "cell_ref_entry"));
110 gtk_entry_set_text(cell_ref_entry, text);
119 extern PsppireDataStore *data_store ;
123 psppire_data_sheet_create (gchar *widget_name, gchar *string1, gchar *string2,
124 gint int1, gint int2)
128 const gint rows = 10046;
130 GObject *row_geometry = g_sheet_uniform_row_new(25, rows);
132 sheet = gtk_sheet_new(G_SHEET_ROW(row_geometry),
133 G_SHEET_COLUMN(data_store), "data sheet", 0);
136 g_signal_connect (GTK_OBJECT (sheet), "activate",
137 GTK_SIGNAL_FUNC (update_data_ref_entry),
140 g_signal_connect (GTK_OBJECT (sheet), "traverse",
141 GTK_SIGNAL_FUNC (traverse_callback), 0);
144 g_signal_connect (GTK_OBJECT (sheet), "double-click-column",
145 GTK_SIGNAL_FUNC (click2column),
148 gtk_widget_show(sheet);