X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-editor.c;h=b9c6fb62148f299421bf1c8aa6f32d75a47b5dca;hb=9c5440448a9999db5515937c85a3f37deb033efa;hp=d3e921d3b722c26191f45f2c3615b36757986223;hpb=e578eb29fb25153e5fa44696963ac5cef58c640d;p=pspp diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index d3e921d3b7..b9c6fb6214 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -20,7 +20,6 @@ #include "ui/gui/psppire-data-editor.h" #include -#include #include "data/datasheet.h" #include "data/value-labels.h" @@ -168,7 +167,16 @@ psppire_data_editor_set_property (GObject *object, g_object_set (de->var_sheet, "data-model", de->dict, NULL); break; + case PROP_VALUE_LABELS: + { + gboolean l = g_value_get_boolean (value); + g_object_set (de->data_sheet, "forward-conversion", + l ? + psppire_data_store_value_to_string_with_labels : + psppire_data_store_value_to_string, + NULL); + } break; default: @@ -210,7 +218,6 @@ psppire_data_editor_switch_page (GtkNotebook *notebook, guint page_num) { GTK_NOTEBOOK_CLASS (parent_class)->switch_page (notebook, w, page_num); - } static void @@ -218,7 +225,20 @@ psppire_data_editor_set_focus_child (GtkContainer *container, GtkWidget *widget) { GTK_CONTAINER_CLASS (parent_class)->set_focus_child (container, widget); +} + +static gboolean +on_key_press (GtkWidget *w, GdkEventKey *e) +{ + PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (w); + if (e->keyval == GDK_KEY_F2 && + PSPPIRE_DATA_EDITOR_DATA_VIEW == gtk_notebook_get_current_page (GTK_NOTEBOOK (de))) + { + gtk_widget_grab_focus (de->datum_entry); + } + + return FALSE; } static void @@ -232,6 +252,7 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); parent_class = g_type_class_peek_parent (klass); @@ -240,8 +261,8 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass) object_class->get_property = psppire_data_editor_get_property; container_class->set_focus_child = psppire_data_editor_set_focus_child; - notebook_class->switch_page = psppire_data_editor_switch_page; + widget_class->key_press_event = on_key_press; data_store_spec = g_param_spec_pointer ("data-store", @@ -339,8 +360,28 @@ refresh_entry (PsppireDataEditor *de) } static void -on_datum_entry_activate (PsppireValueEntry *entry, PsppireDataEditor *de) +on_datum_entry_activate (GtkEntry *entry, PsppireDataEditor *de) { + gint row, col; + if (ssw_sheet_get_active_cell (SSW_SHEET (de->data_sheet), &col, &row)) + { + union value val; + const struct variable *var = psppire_dict_get_variable (de->dict, col); + if (var == NULL) + return; + + int width = var_get_width (var); + value_init (&val, width); + if (psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (de->datum_entry), + &val, width)) + { + psppire_data_store_set_value (de->data_store, row, var, &val); + } + value_destroy (&val, width); + + gtk_widget_grab_focus (de->data_sheet); + ssw_sheet_set_active_cell (de->data_sheet, col, row, NULL); + } } @@ -450,8 +491,8 @@ psppire_data_editor_init (PsppireDataEditor *de) gtk_widget_set_valign (de->cell_ref_label, GTK_ALIGN_CENTER); de->datum_entry = psppire_value_entry_new (); - g_signal_connect (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (de->datum_entry))), - "activate", G_CALLBACK (on_datum_entry_activate), de); + g_signal_connect (de->datum_entry, "edit-done", + G_CALLBACK (on_datum_entry_activate), de); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (hbox), de->cell_ref_label, FALSE, FALSE, 0); @@ -502,6 +543,7 @@ psppire_data_editor_init (PsppireDataEditor *de) set_font_recursively (GTK_WIDGET (de), de->font); } + gtk_widget_add_events (GTK_WIDGET (de), GDK_KEY_PRESS_MASK); } GtkWidget*