X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-var-sheet.c;h=b02a0a03ec613b4b272b9d323bfb170be440f192;hb=640b8c52426647f73714c35c2f4281e0479c4fa3;hp=3ebea2ea182a23b2e0dab2324127f434b42555d7;hpb=04d2c99833753252b724dd9d4f15cc3a80b6bec8;p=pspp diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index 3ebea2ea18..b02a0a03ec 100644 --- a/src/ui/gui/psppire-var-sheet.c +++ b/src/ui/gui/psppire-var-sheet.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2011, 2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,11 +18,15 @@ #include "psppire-var-sheet.h" #include +#include "builder-wrapper.h" #include "helper.h" #include "customentry.h" #include +#include "data/value-labels.h" #include "psppire-var-store.h" +#include "ui/gui/val-labs-dialog.h" +#include "ui/gui/var-type-dialog.h" #include #define _(msgid) gettext (msgid) @@ -31,8 +35,6 @@ static void psppire_var_sheet_class_init (PsppireVarSheetClass *klass); static void psppire_var_sheet_init (PsppireVarSheet *vs); -static void psppire_var_sheet_realize (GtkWidget *w); -static void psppire_var_sheet_unrealize (GtkWidget *w); enum @@ -183,15 +185,12 @@ static void psppire_var_sheet_class_init (PsppireVarSheetClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GParamSpec *pspec; parent_class = g_type_class_peek_parent (klass); object_class->dispose = psppire_var_sheet_dispose; object_class->finalize = psppire_var_sheet_finalize; - widget_class->realize = psppire_var_sheet_realize; - widget_class->unrealize = psppire_var_sheet_unrealize; object_class->set_property = psppire_var_sheet_set_property; object_class->get_property = psppire_var_sheet_get_property; @@ -251,6 +250,9 @@ traverse_cell_callback (PsppireSheet *sheet, gint n_vars = psppire_var_store_get_var_cnt (var_store); + if (new_cell->col >= PSPPIRE_VAR_STORE_n_COLS) + return TRUE; + if (new_cell->row >= n_vars && !var_sheet->may_create_vars) return TRUE; @@ -260,10 +262,10 @@ traverse_cell_callback (PsppireSheet *sheet, const gchar *name = gtk_entry_get_text (entry); - if (! psppire_dict_check_name (var_store->dict, name, TRUE)) + if (! psppire_dict_check_name (var_store->dictionary, name, TRUE)) return TRUE; - psppire_dict_insert_variable (var_store->dict, existing_cell->row, name); + psppire_dict_insert_variable (var_store->dictionary, existing_cell->row, name); return FALSE; } @@ -278,13 +280,75 @@ traverse_cell_callback (PsppireSheet *sheet, { gint i; for ( i = n_vars ; i <= new_cell->row; ++i ) - psppire_dict_insert_variable (var_store->dict, i, NULL); + psppire_dict_insert_variable (var_store->dictionary, i, NULL); } return FALSE; } +static void +var_sheet_show_var_type_dialog (PsppireVarSheet *vs) +{ + PsppireVarStore *var_store; + struct fmt_spec format; + struct variable *var; + gint row; + + var_store = PSPPIRE_VAR_STORE (psppire_sheet_get_model (PSPPIRE_SHEET (vs))); + + psppire_sheet_get_active_cell (PSPPIRE_SHEET (vs), &row, NULL); + var = psppire_var_store_get_var (var_store, row); + g_return_if_fail (var != NULL); + + format = *var_get_print_format (var); + psppire_var_type_dialog_run (GTK_WINDOW (gtk_widget_get_toplevel ( + GTK_WIDGET (vs))), &format); + var_set_width (var, fmt_var_width (&format)); + var_set_both_formats (var, &format); +} + +static void +var_sheet_show_val_labs_dialog (PsppireVarSheet *vs) +{ + PsppireVarStore *var_store; + struct val_labs *labels; + struct variable *var; + gint row; + + var_store = PSPPIRE_VAR_STORE (psppire_sheet_get_model (PSPPIRE_SHEET (vs))); + + psppire_sheet_get_active_cell (PSPPIRE_SHEET (vs), &row, NULL); + var = psppire_var_store_get_var (var_store, row); + g_return_if_fail (var != NULL); + + labels = psppire_val_labs_dialog_run (GTK_WINDOW (gtk_widget_get_toplevel ( + GTK_WIDGET (vs))), var); + if (labels) + { + var_set_value_labels (var, labels); + val_labs_destroy (labels); + } +} + +static void +var_sheet_show_miss_vals_dialog (PsppireVarSheet *vs) +{ + PsppireVarStore *var_store; + struct missing_values mv; + struct variable *var; + gint row; + + var_store = PSPPIRE_VAR_STORE (psppire_sheet_get_model (PSPPIRE_SHEET (vs))); + + psppire_sheet_get_active_cell (PSPPIRE_SHEET (vs), &row, NULL); + var = psppire_var_store_get_var (var_store, row); + g_return_if_fail (var != NULL); + psppire_missing_val_dialog_run (GTK_WINDOW (gtk_widget_get_toplevel ( + GTK_WIDGET (vs))), var, &mv); + var_set_missing_values (var, &mv); + mv_destroy (&mv); +} /* Callback whenever the active cell changes on the var sheet. @@ -363,12 +427,10 @@ var_sheet_change_active_cell (PsppireVarSheet *vs, customEntry = PSPPIRE_CUSTOM_ENTRY (psppire_sheet_get_entry (sheet)); - val_labs_dialog_set_target_variable (vs->val_labs_dialog, var); - g_signal_connect_swapped (customEntry, "clicked", - G_CALLBACK (val_labs_dialog_show), - vs->val_labs_dialog); + G_CALLBACK (var_sheet_show_val_labs_dialog), + vs); } break; @@ -381,13 +443,10 @@ var_sheet_change_active_cell (PsppireVarSheet *vs, customEntry = PSPPIRE_CUSTOM_ENTRY (psppire_sheet_get_entry (sheet)); - vs->missing_val_dialog->pv = - psppire_var_store_get_var (var_store, row); - g_signal_connect_swapped (customEntry, "clicked", - G_CALLBACK (missing_val_dialog_show), - vs->missing_val_dialog); + G_CALLBACK (var_sheet_show_miss_vals_dialog), + vs); } break; @@ -400,14 +459,10 @@ var_sheet_change_active_cell (PsppireVarSheet *vs, customEntry = PSPPIRE_CUSTOM_ENTRY (psppire_sheet_get_entry (sheet)); - - /* Popup the Variable Type dialog box */ - vs->var_type_dialog->pv = var; - g_signal_connect_swapped (customEntry, "clicked", - G_CALLBACK (var_type_dialog_show), - vs->var_type_dialog); + G_CALLBACK (var_sheet_show_var_type_dialog), + vs); } break; @@ -428,7 +483,7 @@ var_sheet_change_active_cell (PsppireVarSheet *vs, const gint current_value = g_strtod (s, NULL); GtkObject *adj ; - const struct fmt_spec *fmt = var_get_write_format (var); + const struct fmt_spec *fmt = var_get_print_format (var); switch (column) { case PSPPIRE_VAR_STORE_COL_WIDTH: @@ -448,9 +503,9 @@ var_sheet_change_active_cell (PsppireVarSheet *vs, } adj = gtk_adjustment_new (current_value, - r_min, r_max, - 1.0, 1.0, 1.0 /* steps */ - ); + r_min, r_max, + 1.0, 1.0, /* steps */ + 0); psppire_sheet_change_entry (sheet, GTK_TYPE_SPIN_BUTTON); @@ -471,37 +526,6 @@ var_sheet_change_active_cell (PsppireVarSheet *vs, } -static void -psppire_var_sheet_realize (GtkWidget *w) -{ - PsppireVarSheet *vs = PSPPIRE_VAR_SHEET (w); - - GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (vs)); - - vs->val_labs_dialog = val_labs_dialog_create (GTK_WINDOW (toplevel), - PSPPIRE_SHEET (vs)); - vs->missing_val_dialog = missing_val_dialog_create (GTK_WINDOW (toplevel)); - vs->var_type_dialog = var_type_dialog_create (GTK_WINDOW (toplevel)); - - /* Chain up to the parent class */ - GTK_WIDGET_CLASS (parent_class)->realize (w); -} - -static void -psppire_var_sheet_unrealize (GtkWidget *w) -{ - PsppireVarSheet *vs = PSPPIRE_VAR_SHEET (w); - - g_free (vs->val_labs_dialog); - g_free (vs->missing_val_dialog); - g_free (vs->var_type_dialog); - - /* Chain up to the parent class */ - GTK_WIDGET_CLASS (parent_class)->unrealize (w); -} - - - static void psppire_var_sheet_init (PsppireVarSheet *vs) {