X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fpsppire-data-editor.c;h=16b1393df3977593f2e94c226ead0fedd478c6e5;hb=698f289d1ecf1620aa5429599f2e76db23cff452;hp=094a4f6988ada771e840e81b037be42e9b5203db;hpb=0c5217288cb57d0994d4c99997f5341e2c3a6871;p=pspp diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 094a4f6988..16b1393df3 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010, 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 @@ -15,11 +15,11 @@ along with this program. If not, see . */ #include -#include #include #include #include "psppire-data-editor.h" #include "psppire-var-sheet.h" +#include "psppire.h" #include "psppire-data-store.h" #include @@ -89,6 +89,7 @@ psppire_data_editor_dispose (GObject *obj) if (de->dispose_has_run) return; + g_object_unref (de->data_window); g_object_unref (de->data_store); g_object_unref (de->var_store); @@ -195,6 +196,7 @@ traverse_cell_callback (PsppireSheet *sheet, enum { PROP_0, + PROP_DATA_WINDOW, PROP_DATA_STORE, PROP_VAR_STORE, PROP_VS_ROW_MENU, @@ -223,6 +225,13 @@ new_data_callback (PsppireDataStore *ds, gpointer data) psppire_axis_clear (de->vaxis[i]); psppire_axis_append_n (de->vaxis[i], n_cases, DEFAULT_ROW_HEIGHT); } + + /* All of the data (potentially) changed, so unselect any selected cell(s) in + the data sheets. If we don't do this, then the sheet remembers the value + that was in the selected cell and stores it back, wiping out whatever + value there is in the new data. Bug #30502. */ + if (de->data_sheet[0] != NULL) + psppire_sheet_unselect_range (PSPPIRE_SHEET (de->data_sheet[0])); } static void @@ -328,17 +337,18 @@ insert_variable_callback (PsppireDict *dict, gint x, gpointer data) static void -delete_variable_callback (PsppireDict *dict, gint posn, - gint x UNUSED, gint y UNUSED, gpointer data) +delete_variable_callback (PsppireDict *dict, + const struct variable *var UNUSED, + gint dict_idx, gint case_idx UNUSED, gpointer data) { PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data); PsppireAxis *var_vaxis; g_object_get (de->var_sheet, "vertical-axis", &var_vaxis, NULL); - psppire_axis_delete (var_vaxis, posn, 1); + psppire_axis_delete (var_vaxis, dict_idx, 1); - psppire_axis_delete (de->haxis, posn, 1); + psppire_axis_delete (de->haxis, dict_idx, 1); } @@ -374,6 +384,10 @@ psppire_data_editor_set_property (GObject *object, case PROP_SPLIT_WINDOW: psppire_data_editor_split_window (de, g_value_get_boolean (value)); break; + case PROP_DATA_WINDOW: + de->data_window = g_value_get_pointer (value); + g_object_ref (de->data_window); + break; case PROP_DATA_STORE: if ( de->data_store) g_object_unref (de->data_store); de->data_store = g_value_get_pointer (value); @@ -501,6 +515,9 @@ psppire_data_editor_get_property (GObject *object, case PROP_SPLIT_WINDOW: g_value_set_boolean (value, de->split); break; + case PROP_DATA_WINDOW: + g_value_set_pointer (value, de->data_window); + break; case PROP_DATA_STORE: g_value_set_pointer (value, de->data_store); break; @@ -534,6 +551,7 @@ psppire_data_editor_get_property (GObject *object, static void psppire_data_editor_class_init (PsppireDataEditorClass *klass) { + GParamSpec *data_window_spec ; GParamSpec *data_store_spec ; GParamSpec *var_store_spec ; GParamSpec *column_menu_spec; @@ -556,6 +574,16 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass) + data_window_spec = + g_param_spec_pointer ("data-window", + "Data Window", + "A pointer to the data window associated with this editor", + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE ); + + g_object_class_install_property (object_class, + PROP_DATA_WINDOW, + data_window_spec); + data_store_spec = g_param_spec_pointer ("data-store", "Data Store", @@ -1008,13 +1036,15 @@ psppire_data_editor_init (PsppireDataEditor *de) GtkWidget* -psppire_data_editor_new (PsppireVarStore *var_store, +psppire_data_editor_new (PsppireDataWindow *data_window, + PsppireVarStore *var_store, PsppireDataStore *data_store) { return g_object_new (PSPPIRE_DATA_EDITOR_TYPE, - "var-store", var_store, - "data-store", data_store, - NULL); + "data-window", data_window, + "var-store", var_store, + "data-store", data_store, + NULL); } @@ -1246,15 +1276,15 @@ popup_cases_menu (PsppireSheet *sheet, gint row, /* Sorting */ static void -do_sort (PsppireDataStore *ds, int var, gboolean descend) +do_sort (PsppireDataEditor *de, int var, gboolean descend) { - const struct variable *v = - psppire_dict_get_variable (ds->dict, var); + const struct variable *v + = psppire_dict_get_variable (de->data_store->dict, var); gchar *syntax; syntax = g_strdup_printf ("SORT CASES BY %s%s.", var_get_name (v), descend ? " (D)" : ""); - g_free (execute_syntax_string (syntax)); + g_free (execute_syntax_string (de->data_window, syntax)); } @@ -1266,7 +1296,7 @@ psppire_data_editor_sort_ascending (PsppireDataEditor *de) PsppireSheetRange range; psppire_sheet_get_selected_range (PSPPIRE_SHEET(de->data_sheet[0]), &range); - do_sort (de->data_store, range.col0, FALSE); + do_sort (de, range.col0, FALSE); } @@ -1278,7 +1308,7 @@ psppire_data_editor_sort_descending (PsppireDataEditor *de) PsppireSheetRange range; psppire_sheet_get_selected_range (PSPPIRE_SHEET(de->data_sheet[0]), &range); - do_sort (de->data_store, range.col0, TRUE); + do_sort (de, range.col0, TRUE); } @@ -1406,7 +1436,6 @@ void psppire_data_editor_set_font (PsppireDataEditor *de, PangoFontDescription *font_desc) { set_font (GTK_WIDGET (de), font_desc); - gtk_container_foreach (GTK_CONTAINER (de), set_font, font_desc); } @@ -1612,8 +1641,7 @@ data_sheet_set_clip (PsppireSheet *sheet) } /* Construct clip dictionary. */ - clip_dict = dict_create (); - dict_set_encoding (clip_dict, dict_get_encoding (ds->dict->dict)); + clip_dict = dict_create (dict_get_encoding (ds->dict->dict)); for (i = col0; i <= coli; i++) dict_clone_var_assert (clip_dict, dict_get_var (ds->dict->dict, i));