X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-var-sheet.c;h=970da7dfbcb491c81ce21e3f0ee5a3cb38c51189;hb=refs%2Fbuilds%2F20121125032007%2Fpspp;hp=03d43dd9c2549ac1d1d9b4015103e1fbad1a4f20;hpb=71217a5a5fae81bec47e76138d6ca23cb46c6119;p=pspp diff --git a/src/ui/gui/psppire-var-sheet.c b/src/ui/gui/psppire-var-sheet.c index 03d43dd9c2..970da7dfbc 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) 2011, 2012 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 @@ -32,6 +32,7 @@ #include "ui/gui/psppire-empty-list-store.h" #include "ui/gui/psppire-marshal.h" #include "ui/gui/val-labs-dialog.h" +#include "ui/gui/var-type-dialog.h" #include "ui/gui/var-display.h" #include "ui/gui/var-type-dialog.h" @@ -224,8 +225,8 @@ on_var_column_edited (GtkCellRendererText *cell, format = *var_get_print_format (var); fmt_change_width (&format, width, var_sheet->format_use); - var_set_print_format (var, &format); var_set_width (var, fmt_var_width (&format)); + var_set_both_formats (var, &format); } break; @@ -341,16 +342,10 @@ render_var_cell (PsppSheetViewColumn *tree_column, break; case VS_WIDTH: - { - int step = fmt_step_width (print->type); - if (var_is_numeric (var)) - set_spin_cell (cell, print->w, - fmt_min_width (print->type, var_sheet->format_use), - fmt_max_width (print->type, var_sheet->format_use), - step); - else - set_spin_cell (cell, print->w, 0, 0, step); - } + set_spin_cell (cell, print->w, + fmt_min_width (print->type, var_sheet->format_use), + fmt_max_width (print->type, var_sheet->format_use), + fmt_step_width (print->type)); break; case VS_DECIMALS: @@ -449,8 +444,17 @@ on_type_click (PsppireCellRendererButton *cell, gchar *path, PsppireVarSheet *var_sheet) { - var_sheet->var_type_dialog->pv = path_string_to_variable (var_sheet, path); - var_type_dialog_show (var_sheet->var_type_dialog); + GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (var_sheet)); + struct fmt_spec format; + struct variable *var; + + var = path_string_to_variable (var_sheet, path); + g_return_if_fail (var != NULL); + + format = *var_get_print_format (var); + psppire_var_type_dialog_run (GTK_WINDOW (toplevel), &format); + var_set_width (var, fmt_var_width (&format)); + var_set_both_formats (var, &format); } static void @@ -458,9 +462,19 @@ on_value_labels_click (PsppireCellRendererButton *cell, gchar *path, PsppireVarSheet *var_sheet) { - struct variable *var = path_string_to_variable (var_sheet, path); - val_labs_dialog_set_target_variable (var_sheet->val_labs_dialog, var); - val_labs_dialog_show (var_sheet->val_labs_dialog); + GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (var_sheet)); + struct val_labs *labels; + struct variable *var; + + var = path_string_to_variable (var_sheet, path); + g_return_if_fail (var != NULL); + + labels = psppire_val_labs_dialog_run (GTK_WINDOW (toplevel), var); + if (labels) + { + var_set_value_labels (var, labels); + val_labs_destroy (labels); + } } static void @@ -468,9 +482,16 @@ on_missing_values_click (PsppireCellRendererButton *cell, gchar *path, PsppireVarSheet *var_sheet) { - var_sheet->missing_val_dialog->pv = path_string_to_variable (var_sheet, - path); - missing_val_dialog_show (var_sheet->missing_val_dialog); + GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (var_sheet)); + struct missing_values mv; + struct variable *var; + + var = path_string_to_variable (var_sheet, path); + g_return_if_fail (var != NULL); + + psppire_missing_val_dialog_run (GTK_WINDOW (toplevel), var, &mv); + var_set_missing_values (var, &mv); + mv_destroy (&mv); } static gint @@ -895,20 +916,6 @@ psppire_var_sheet_get_property (GObject *object, } } -static void -psppire_var_sheet_realize (GtkWidget *w) -{ - PsppireVarSheet *var_sheet = PSPPIRE_VAR_SHEET (w); - GtkWindow *toplevel; - - GTK_WIDGET_CLASS (psppire_var_sheet_parent_class)->realize (w); - - toplevel = GTK_WINDOW (gtk_widget_get_toplevel (w)); - var_sheet->val_labs_dialog = val_labs_dialog_create (toplevel); - var_sheet->missing_val_dialog = missing_val_dialog_create (toplevel); - var_sheet->var_type_dialog = var_type_dialog_create (toplevel); -} - static void psppire_var_sheet_dispose (GObject *obj) { @@ -947,15 +954,12 @@ static void psppire_var_sheet_class_init (PsppireVarSheetClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); GParamSpec *pspec; gobject_class->set_property = psppire_var_sheet_set_property; gobject_class->get_property = psppire_var_sheet_get_property; gobject_class->dispose = psppire_var_sheet_dispose; - widget_class->realize = psppire_var_sheet_realize; - g_signal_new ("var-double-clicked", G_OBJECT_CLASS_TYPE (gobject_class), G_SIGNAL_RUN_LAST, @@ -1050,6 +1054,16 @@ psppire_var_sheet_row_number_double_clicked (PsppireCellRendererButton *button, gtk_tree_path_free (path); } +static void +psppire_var_sheet_variables_column_clicked (PsppSheetViewColumn *column, + PsppireVarSheet *var_sheet) +{ + PsppSheetView *sheet_view = PSPP_SHEET_VIEW (var_sheet); + PsppSheetSelection *selection = pspp_sheet_view_get_selection (sheet_view); + + pspp_sheet_selection_select_all (selection); +} + static PsppSheetViewColumn * make_row_number_column (PsppireVarSheet *var_sheet) { @@ -1064,9 +1078,14 @@ make_row_number_column (PsppireVarSheet *var_sheet) column = pspp_sheet_view_column_new_with_attributes (_("Variable"), renderer, NULL); + pspp_sheet_view_column_set_clickable (column, TRUE); pspp_sheet_view_column_set_cell_data_func ( column, renderer, render_row_number_cell, var_sheet, NULL); pspp_sheet_view_column_set_fixed_width (column, 50); + g_signal_connect (column, "clicked", + G_CALLBACK (psppire_var_sheet_variables_column_clicked), + var_sheet); + return column; }