22 |
/* This module creates the Variable Sheet used for inputing the |
/* This module creates the Variable Sheet used for inputing the |
23 |
variables in the dictonary */ |
variables in the dictonary */ |
24 |
|
|
25 |
|
#include <value-labels.h> |
26 |
|
#include <hacks.h> |
27 |
|
|
28 |
#include <psppire-conf.h> |
#include <psppire-conf.h> |
29 |
|
|
30 |
#include <glade/glade.h> |
#include <glade/glade.h> |
31 |
#include <gtk/gtk.h> |
#include <gtk/gtk.h> |
32 |
#include "gtksheet.h" |
#include "gtksheet.h" |
33 |
|
|
34 |
|
|
35 |
#include "callbacks.h" |
#include "callbacks.h" |
36 |
#include "pspp-dict.h" |
#include "pspp-dict.h" |
37 |
#include "var_type_dialog.h" |
#include "var_type_dialog.h" |
38 |
#include "var_sheet.h" |
#include "var_sheet.h" |
39 |
#include "customentry.h" |
#include "customentry.h" |
40 |
|
|
41 |
|
#include "val_labs_dialog.h" |
42 |
|
|
43 |
#define _(A) A |
#define _(A) A |
44 |
#define N_(A) A |
#define N_(A) A |
45 |
|
|
49 |
|
|
50 |
static gint last_populated_row = -1; |
static gint last_populated_row = -1; |
51 |
static struct var_type_dialog *var_type_dialog; |
static struct var_type_dialog *var_type_dialog; |
52 |
|
static struct val_labs_dialog *val_labs_dialog; |
53 |
static const gint n_initial_rows = 40; |
static const gint n_initial_rows = 40; |
54 |
|
|
55 |
|
|
112 |
|
|
113 |
static void psppire_var_sheet_block(GtkSheet *sheet); |
static void psppire_var_sheet_block(GtkSheet *sheet); |
114 |
|
|
115 |
|
/* Callback for when the Value Labels dialog is closed using the OK button. |
116 |
|
It sets the appropriate variable accordingly. */ |
117 |
|
static gint |
118 |
|
apply_val_labs(GtkWidget *w, gpointer data) |
119 |
|
{ |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
gboolean |
125 |
|
click2row(GtkWidget *w, gint row, gpointer data) |
126 |
|
{ |
127 |
|
gint current_row, current_column; |
128 |
|
|
129 |
|
select_sheet(PAGE_DATA_SHEET); |
130 |
|
GtkWidget *data_sheet = glade_xml_get_widget(xml, "data_sheet"); |
131 |
|
|
132 |
|
gtk_sheet_get_active_cell(GTK_SHEET(data_sheet), |
133 |
|
¤t_row, ¤t_column); |
134 |
|
|
135 |
|
gtk_sheet_set_active_cell(GTK_SHEET(data_sheet), current_row, row); |
136 |
|
|
137 |
|
return FALSE; |
138 |
|
} |
139 |
|
|
140 |
/* Callback for when the var type dialog is closed using the OK button. |
/* Callback for when the var type dialog is closed using the OK button. |
141 |
It sets the appropriate variable accordingly. */ |
It sets the appropriate variable accordingly. */ |
142 |
static gint |
static gint |
232 |
} |
} |
233 |
|
|
234 |
|
|
235 |
|
|
236 |
/* Callback whenever the cell on the var sheet is entered or left. |
/* Callback whenever the cell on the var sheet is entered or left. |
237 |
It sets the entry box type appropriately. |
It sets the entry box type appropriately. |
238 |
*/ |
*/ |
255 |
switch (column) |
switch (column) |
256 |
{ |
{ |
257 |
case COL_VALUES: |
case COL_VALUES: |
258 |
|
{ |
259 |
|
PsppireCustomEntry *customEntry; |
260 |
|
|
261 |
|
struct variable *var = pspp_dict_get_var(pspp_dictionary, row); |
262 |
|
|
263 |
|
gtk_sheet_change_entry(sheet, PSPPIRE_CUSTOM_ENTRY_TYPE); |
264 |
|
|
265 |
|
customEntry = |
266 |
|
PSPPIRE_CUSTOM_ENTRY(gtk_sheet_get_entry(sheet)); |
267 |
|
|
268 |
|
|
269 |
|
if (!val_labs_dialog ) |
270 |
|
{ |
271 |
|
val_labs_dialog = val_labs_dialog_create(xml); |
272 |
|
|
273 |
|
g_signal_connect(GTK_OBJECT(val_labs_dialog->ok), |
274 |
|
"clicked", |
275 |
|
GTK_SIGNAL_FUNC(apply_val_labs), sheet); |
276 |
|
|
277 |
|
|
278 |
|
} |
279 |
|
|
280 |
|
val_labs_dialog->target = &var->val_labs ; |
281 |
|
g_signal_connect_swapped(GTK_OBJECT(customEntry), |
282 |
|
"clicked", |
283 |
|
GTK_SIGNAL_FUNC(val_labs_dialog_show), |
284 |
|
val_labs_dialog); |
285 |
|
} |
286 |
|
break; |
287 |
case COL_MISSING: |
case COL_MISSING: |
288 |
gtk_sheet_change_entry(sheet, PSPPIRE_CUSTOM_ENTRY_TYPE); |
gtk_sheet_change_entry(sheet, PSPPIRE_CUSTOM_ENTRY_TYPE); |
289 |
break; |
break; |
591 |
else |
else |
592 |
gtk_sheet_cell_clear(sheet, row, c); |
gtk_sheet_cell_clear(sheet, row, c); |
593 |
break; |
break; |
594 |
|
case COL_VALUES: |
595 |
|
if ( ! var->val_labs || 0 == val_labs_count(var->val_labs)) |
596 |
|
gtk_sheet_set_cell_text(sheet, row, c, _("None")); |
597 |
|
else |
598 |
|
{ |
599 |
|
struct val_labs_iterator *ip=0; |
600 |
|
struct val_lab *vl = val_labs_first_sorted (var->val_labs, &ip); |
601 |
|
|
602 |
|
g_assert(vl); |
603 |
|
|
604 |
|
gchar *const text = |
605 |
|
g_strdup_printf("{%g,\"%s\"}_", vl->value.f, vl->label); |
606 |
|
|
607 |
|
gtk_sheet_set_cell_text(sheet, row, c, text); |
608 |
|
|
609 |
|
g_free(text); |
610 |
|
|
611 |
|
val_labs_done(&ip); |
612 |
|
} |
613 |
|
break; |
614 |
} |
} |
615 |
|
|
616 |
} |
} |
617 |
|
|
618 |
|
|
700 |
GTK_SIGNAL_FUNC (update_variable), |
GTK_SIGNAL_FUNC (update_variable), |
701 |
0); |
0); |
702 |
|
|
703 |
|
|
704 |
|
g_signal_connect (GTK_OBJECT (sheet), "double-click-row", |
705 |
|
GTK_SIGNAL_FUNC (click2row), |
706 |
|
0); |
707 |
|
|
708 |
for (i = 0 ; i < n_COLS ; ++i ) |
for (i = 0 ; i < n_COLS ; ++i ) |
709 |
{ |
{ |
710 |
gtk_sheet_column_button_add_label(GTK_SHEET(sheet), i, |
gtk_sheet_column_button_add_label(GTK_SHEET(sheet), i, |