41 |
#define N_(A) A |
#define N_(A) A |
42 |
|
|
43 |
|
|
44 |
|
/* Fills F with an output format specification with type TYPE, width |
45 |
|
W, and D decimals. Iff it's a valid format, then return true. |
46 |
|
*/ |
47 |
|
static bool |
48 |
|
make_output_format_try (struct fmt_spec *f, int type, int w, int d) |
49 |
|
{ |
50 |
|
f->type = type; |
51 |
|
f->w = w; |
52 |
|
f->d = d; |
53 |
|
return check_output_specifier (f, true); |
54 |
|
} |
55 |
|
|
56 |
|
|
57 |
/* The dictionary associated with this var sheet */ |
/* The dictionary associated with this var sheet */ |
58 |
static PSPP_Dict *pspp_dictionary; |
static PSPP_Dict *pspp_dictionary; |
59 |
|
|
114 |
gint i; |
gint i; |
115 |
struct fmt_spec spec; |
struct fmt_spec spec; |
116 |
gint width, decimals; |
gint width, decimals; |
117 |
|
gint new_width; |
118 |
|
int new_type; |
119 |
GtkSheet *sheet = data; |
GtkSheet *sheet = data; |
120 |
gint current_row, current_column; |
gint current_row, current_column; |
121 |
|
|
131 |
width = atoi(gtk_entry_get_text |
width = atoi(gtk_entry_get_text |
132 |
(GTK_ENTRY(var_type_dialog->entry_width))); |
(GTK_ENTRY(var_type_dialog->entry_width))); |
133 |
|
|
134 |
decimals =atoi(gtk_entry_get_text |
decimals = atoi(gtk_entry_get_text |
135 |
(GTK_ENTRY(var_type_dialog->entry_decimals))); |
(GTK_ENTRY(var_type_dialog->entry_decimals))); |
136 |
|
|
137 |
var->type = NUMERIC; |
new_type = NUMERIC; |
138 |
var->width = 0; |
new_width = 0; |
139 |
|
bool result = false; |
140 |
switch (var_type_dialog->active_button) |
switch (var_type_dialog->active_button) |
141 |
{ |
{ |
142 |
case BUTTON_STRING: |
case BUTTON_STRING: |
143 |
var->type = ALPHA; |
new_type = ALPHA; |
144 |
var->width = width; |
new_width = width; |
145 |
spec = make_output_format(FMT_A, width, 0); |
result = make_output_format_try(&spec, FMT_A, width, 0); |
146 |
break; |
break; |
147 |
case BUTTON_NUMERIC: |
case BUTTON_NUMERIC: |
148 |
spec = make_output_format(FMT_F, width, decimals); |
result = make_output_format_try(&spec, FMT_F, width, decimals); |
149 |
break; |
break; |
150 |
case BUTTON_COMMA: |
case BUTTON_COMMA: |
151 |
spec = make_output_format(FMT_COMMA, width, decimals); |
result = make_output_format_try(&spec, FMT_COMMA, width, decimals); |
152 |
break; |
break; |
153 |
case BUTTON_DOT: |
case BUTTON_DOT: |
154 |
spec = make_output_format(FMT_DOT, width, decimals); |
result = make_output_format_try(&spec, FMT_DOT, width, decimals); |
155 |
break; |
break; |
156 |
case BUTTON_SCIENTIFIC: |
case BUTTON_SCIENTIFIC: |
157 |
spec = make_output_format(FMT_E, width, decimals); |
result = make_output_format_try(&spec, FMT_E, width, decimals); |
158 |
break; |
break; |
159 |
case BUTTON_DATE: |
case BUTTON_DATE: |
160 |
spec = make_output_format(FMT_DATE, 10, 0); |
result = make_output_format_try(&spec, FMT_DATE, 10, 0); |
161 |
break; |
break; |
162 |
case BUTTON_DOLLAR: |
case BUTTON_DOLLAR: |
163 |
spec = make_output_format(FMT_DOLLAR, width, decimals); |
result = make_output_format_try(&spec, FMT_DOLLAR, width, decimals); |
164 |
break; |
break; |
165 |
case BUTTON_CUSTOM: |
case BUTTON_CUSTOM: |
166 |
spec = make_output_format(FMT_CCA, width, decimals); |
result = make_output_format_try(&spec, FMT_CCA, width, decimals); |
167 |
break; |
break; |
168 |
default: |
default: |
169 |
g_print("Unknown variable type: %d\n", |
g_print("Unknown variable type: %d\n", |
170 |
var_type_dialog->active_button) ; |
var_type_dialog->active_button) ; |
171 |
|
result = false; |
172 |
break; |
break; |
173 |
} |
} |
174 |
|
|
175 |
var->write = var->print = spec; |
|
176 |
|
if ( result == true ) |
177 |
pspp_dict_var_changed(pspp_dictionary, current_row); |
{ |
178 |
|
var->type = new_type; |
179 |
|
var->width = new_width; |
180 |
|
var->write = var->print = spec; |
181 |
|
pspp_dict_var_changed(pspp_dictionary, current_row); |
182 |
|
} |
183 |
|
|
184 |
return FALSE; |
return FALSE; |
185 |
} |
} |
493 |
|
|
494 |
/* Set the enabled colour to the default foreground colour */ |
/* Set the enabled colour to the default foreground colour */ |
495 |
GtkSheetCellAttr attributes; |
GtkSheetCellAttr attributes; |
496 |
g_assert(gtk_sheet_get_attributes (sheet,0,0, &attributes)); |
g_assert(gtk_sheet_get_attributes (GTK_SHEET(sheet), 0, 0, &attributes)); |
497 |
enabled = attributes.foreground; |
enabled = attributes.foreground; |
498 |
|
|
499 |
|
|
523 |
|
|
524 |
struct variable *old_var = pspp_dict_get_var(pspp_dictionary, row); |
struct variable *old_var = pspp_dict_get_var(pspp_dictionary, row); |
525 |
|
|
526 |
struct fmt_spec *fmt_write ; |
struct fmt_spec fmt; |
|
struct fmt_spec *fmt_print ; |
|
527 |
|
|
528 |
if ( old_var) |
if ( old_var) |
529 |
{ |
fmt = old_var->write; |
|
fmt_write = &old_var->write; |
|
|
fmt_print = &old_var->print; |
|
|
} |
|
530 |
|
|
531 |
switch (col) |
switch (col) |
532 |
{ |
{ |
568 |
pspp_dict_var_changed(pspp_dictionary, row); |
pspp_dict_var_changed(pspp_dictionary, row); |
569 |
break; |
break; |
570 |
case COL_WIDTH: |
case COL_WIDTH: |
571 |
fmt_write->w = fmt_print->w = |
fmt.w = atoi(gtk_sheet_cell_get_text(sheet, row, col)); |
572 |
atoi(gtk_sheet_cell_get_text(sheet, row, col)); |
if ( old_var && old_var->type == ALPHA ) |
573 |
pspp_dict_var_changed(pspp_dictionary, row); |
old_var->width = fmt.w ; |
574 |
break; |
break; |
575 |
case COL_DECIMALS: |
case COL_DECIMALS: |
576 |
fmt_write->d = fmt_print->d = |
fmt.d = atoi(gtk_sheet_cell_get_text(sheet, row, col)); |
|
atoi(gtk_sheet_cell_get_text(sheet, row, col)); |
|
|
pspp_dict_var_changed(pspp_dictionary, row); |
|
577 |
break; |
break; |
578 |
case COL_LABEL: |
case COL_LABEL: |
579 |
{ |
{ |
590 |
|
|
591 |
if ( old_var ) |
if ( old_var ) |
592 |
{ |
{ |
593 |
check_output_specifier(fmt_write,true); |
if ( check_output_specifier(&fmt, true) |
594 |
check_output_specifier(fmt_print,true); |
&& |
595 |
|
check_specifier_type(&fmt, old_var->type, true) |
596 |
|
&& |
597 |
|
check_specifier_width(&fmt, old_var->width, true) |
598 |
|
) |
599 |
|
{ |
600 |
|
old_var->write = old_var->print = fmt; |
601 |
|
} |
602 |
|
pspp_dict_var_changed(pspp_dictionary, row); |
603 |
} |
} |
604 |
|
|
605 |
|
|
606 |
|
|
607 |
if ( row > last_populated_row ) |
if ( row > last_populated_row ) |
608 |
last_populated_row = row ; |
last_populated_row = row ; |
609 |
|
|