21 |
#include <psppire-conf.h> |
#include <psppire-conf.h> |
22 |
|
|
23 |
#include <gtk/gtk.h> |
#include <gtk/gtk.h> |
24 |
#include "gtksheet.h" |
#include <glade/glade.h> |
25 |
|
|
26 |
|
#include "gtksheet.h" |
27 |
#include "pspp-dict.h" |
#include "pspp-dict.h" |
28 |
#include "sfm-write.h" |
#include "sfm-write.h" |
29 |
#include "case.h" |
#include "case.h" |
34 |
#define N_(A) A |
#define N_(A) A |
35 |
|
|
36 |
|
|
37 |
|
extern GladeXML *xml; |
38 |
|
|
39 |
|
|
40 |
static PSPP_Dict *pspp_dictionary ; |
static PSPP_Dict *pspp_dictionary ; |
41 |
|
|
42 |
static gint last_populated_row = -1; |
static gint last_populated_row = -1; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
/* The entry where the reference to the current cell is displayed */ |
48 |
|
static GtkEntry *cell_ref_entry; |
49 |
|
|
50 |
|
|
51 |
/* Return the width that an 'M' character would occupy when typeset at |
/* Return the width that an 'M' character would occupy when typeset at |
52 |
row, col */ |
row, col */ |
53 |
static guint |
static guint |
80 |
} |
} |
81 |
|
|
82 |
|
|
83 |
|
/* Update the data_ref_entry with the reference of the active cell */ |
84 |
|
static gint |
85 |
|
update_data_ref_entry(GtkSheet *sheet, gint row, gint col) |
86 |
|
{ |
87 |
|
if ( !xml) |
88 |
|
return FALSE; |
89 |
|
|
90 |
|
const struct variable *var = pspp_dict_get_var(pspp_dictionary, col); |
91 |
|
|
92 |
|
gchar *text = g_strdup_printf("%d: %s", row, var?var->name:""); |
93 |
|
|
94 |
|
if ( !cell_ref_entry ) |
95 |
|
cell_ref_entry = glade_xml_get_widget(xml,"cell_ref_entry"); |
96 |
|
|
97 |
|
|
98 |
|
gtk_entry_set_text(cell_ref_entry, text); |
99 |
|
|
100 |
|
g_free(text); |
101 |
|
|
102 |
|
return FALSE; |
103 |
|
} |
104 |
|
|
105 |
static gint |
static gint |
106 |
data_sheet_set_cell(GtkSheet *sheet, gint row, gint col) |
data_sheet_set_cell(GtkSheet *sheet, gint row, gint col) |
107 |
{ |
{ |
118 |
} |
} |
119 |
if ( row > last_populated_row) |
if ( row > last_populated_row) |
120 |
last_populated_row = row; |
last_populated_row = row; |
121 |
|
|
122 |
|
return FALSE; |
123 |
} |
} |
124 |
|
|
125 |
/* Update COLUMN of the data sheet */ |
/* Update COLUMN of the data sheet */ |
269 |
const gint columns=10; |
const gint columns=10; |
270 |
const gint rows=46; |
const gint rows=46; |
271 |
|
|
|
|
|
|
|
|
272 |
GtkSheetRange entire_sheet= {0,0,0,0}; |
GtkSheetRange entire_sheet= {0,0,0,0}; |
273 |
entire_sheet.rowi = rows - 1; |
entire_sheet.rowi = rows - 1; |
274 |
entire_sheet.coli = columns - 1; |
entire_sheet.coli = columns - 1; |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
sheet = gtk_sheet_new(rows, columns, "data sheet"); |
sheet = gtk_sheet_new(rows, columns, "data sheet"); |
279 |
|
|
280 |
g_signal_connect(sheet, "new_column_width", |
g_signal_connect(sheet, "new_column_width", |
296 |
GTK_SIGNAL_FUNC (data_sheet_set_cell), |
GTK_SIGNAL_FUNC (data_sheet_set_cell), |
297 |
0); |
0); |
298 |
|
|
299 |
|
g_signal_connect (GTK_OBJECT (sheet), "activate", |
300 |
|
GTK_SIGNAL_FUNC (update_data_ref_entry), |
301 |
|
0); |
302 |
|
|
303 |
|
|
304 |
|
|
305 |
gtk_widget_show(sheet); |
gtk_widget_show(sheet); |
306 |
|
|
307 |
return sheet; |
return sheet; |