X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Fui%2Fgui%2Fpsppire-var-sheet.c;h=b02a0a03ec613b4b272b9d323bfb170be440f192;hb=6e29a48cd6e626fb2542d5babcbdcc7f67c071d3;hp=a3208f00007e4dad0258ec2d42ef4cbfbd41b213;hpb=f00405e1ee47e1bf52ee1a37bae28e383a27c204;p=pspp diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index a3208f0000..b02a0a03ec 100644 --- a/src/ui/gui/psppire-var-sheet.c +++ b/src/ui/gui/psppire-var-sheet.c @@ -23,7 +23,10 @@ #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) @@ -32,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 @@ -184,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; @@ -309,6 +307,49 @@ var_sheet_show_var_type_dialog (PsppireVarSheet *vs) 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. */ @@ -386,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; @@ -404,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; @@ -490,35 +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)); - - vs->missing_val_dialog = missing_val_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); - - /* Chain up to the parent class */ - GTK_WIDGET_CLASS (parent_class)->unrealize (w); -} - - - static void psppire_var_sheet_init (PsppireVarSheet *vs) {