99 |
n_COLS}; |
n_COLS}; |
100 |
|
|
101 |
|
|
|
/* Fills F with an output format specification with type TYPE, width |
|
|
W, and D decimals. Iff it's a valid format, then return true. |
|
|
*/ |
|
|
static bool |
|
|
make_output_format_try (struct fmt_spec *f, int type, int w, int d) |
|
|
{ |
|
|
f->type = type; |
|
|
f->w = w; |
|
|
f->d = d; |
|
|
return check_output_specifier (f, true); |
|
|
} |
|
|
|
|
102 |
static void psppire_var_sheet_unblock(GtkSheet *sheet); |
static void psppire_var_sheet_unblock(GtkSheet *sheet); |
103 |
|
|
104 |
static void psppire_var_sheet_block(GtkSheet *sheet); |
static void psppire_var_sheet_block(GtkSheet *sheet); |
119 |
return FALSE; |
return FALSE; |
120 |
} |
} |
121 |
|
|
|
/* Callback for when the var type dialog is closed using the OK button. |
|
|
It sets the appropriate variable accordingly. */ |
|
|
static gint |
|
|
set_var_type(GtkWidget *w, gpointer data) |
|
|
{ |
|
|
gint i; |
|
|
struct fmt_spec spec; |
|
|
gint width, decimals; |
|
|
gint new_width; |
|
|
int new_type; |
|
|
GtkSheet *sheet = data; |
|
|
gint current_row, current_column; |
|
|
|
|
|
/* Set the variable corresponding to the current row */ |
|
|
|
|
|
gtk_sheet_get_active_cell (sheet, ¤t_row, ¤t_column); |
|
|
|
|
|
struct variable *var = pspp_dict_get_var(pspp_dictionary, current_row); |
|
|
|
|
|
g_assert(var_type_dialog); |
|
|
g_assert(var); |
|
|
|
|
|
width = atoi(gtk_entry_get_text |
|
|
(GTK_ENTRY(var_type_dialog->entry_width))); |
|
|
|
|
|
decimals = atoi(gtk_entry_get_text |
|
|
(GTK_ENTRY(var_type_dialog->entry_decimals))); |
|
|
|
|
|
new_type = NUMERIC; |
|
|
new_width = 0; |
|
|
bool result = false; |
|
|
switch (var_type_dialog->active_button) |
|
|
{ |
|
|
case BUTTON_STRING: |
|
|
new_type = ALPHA; |
|
|
new_width = width; |
|
|
result = make_output_format_try(&spec, FMT_A, width, 0); |
|
|
break; |
|
|
case BUTTON_NUMERIC: |
|
|
result = make_output_format_try(&spec, FMT_F, width, decimals); |
|
|
break; |
|
|
case BUTTON_COMMA: |
|
|
result = make_output_format_try(&spec, FMT_COMMA, width, decimals); |
|
|
break; |
|
|
case BUTTON_DOT: |
|
|
result = make_output_format_try(&spec, FMT_DOT, width, decimals); |
|
|
break; |
|
|
case BUTTON_SCIENTIFIC: |
|
|
result = make_output_format_try(&spec, FMT_E, width, decimals); |
|
|
break; |
|
|
case BUTTON_DATE: |
|
|
result = make_output_format_try(&spec, FMT_DATE, 10, 0); |
|
|
break; |
|
|
case BUTTON_DOLLAR: |
|
|
result = make_output_format_try(&spec, FMT_DOLLAR, width, decimals); |
|
|
break; |
|
|
case BUTTON_CUSTOM: |
|
|
result = make_output_format_try(&spec, FMT_CCA, width, decimals); |
|
|
break; |
|
|
default: |
|
|
g_print("Unknown variable type: %d\n", |
|
|
var_type_dialog->active_button) ; |
|
|
result = false; |
|
|
break; |
|
|
} |
|
|
|
|
|
|
|
|
if ( result == true ) |
|
|
{ |
|
|
var->type = new_type; |
|
|
var->width = new_width; |
|
|
var->write = var->print = spec; |
|
|
pspp_dict_var_changed(pspp_dictionary, current_row); |
|
|
} |
|
|
|
|
|
return FALSE; |
|
|
} |
|
|
|
|
122 |
|
|
123 |
/* Returns a valid name for a new variable in DICT. |
/* Returns a valid name for a new variable in DICT. |
124 |
The return value must be freed when no longer required. */ |
The return value must be freed when no longer required. */ |
334 |
{ |
{ |
335 |
var_type_dialog = var_type_dialog_create(xml); |
var_type_dialog = var_type_dialog_create(xml); |
336 |
|
|
|
g_signal_connect(GTK_OBJECT(var_type_dialog->ok), |
|
|
"clicked", |
|
|
GTK_SIGNAL_FUNC(set_var_type), sheet); |
|
337 |
} |
} |
338 |
|
|
339 |
var_type_dialog_set_state(var_type_dialog, var); |
var_type_dialog_set_state(var_type_dialog, var); |
522 |
} |
} |
523 |
break; |
break; |
524 |
|
|
525 |
case FMT_DATE: |
case FMT_DATE: |
526 |
|
case FMT_EDATE: |
527 |
|
case FMT_SDATE: |
528 |
|
case FMT_ADATE: |
529 |
|
case FMT_JDATE: |
530 |
|
case FMT_QYR: |
531 |
|
case FMT_MOYR: |
532 |
|
case FMT_WKYR: |
533 |
|
case FMT_DATETIME: |
534 |
|
case FMT_TIME: |
535 |
|
case FMT_DTIME: |
536 |
|
case FMT_WKDAY: |
537 |
|
case FMT_MONTH: |
538 |
{ |
{ |
539 |
/* Dates don't have decimal places and the width is automatic */ |
/* Dates don't have decimal places and the width is automatic */ |
540 |
GtkSheetRange range; |
GtkSheetRange range; |