/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010, 2011, 2012, 2016 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
static void
refresh_entry (PsppireDataEditor *de)
{
- g_print ("%s\n", __FUNCTION__);
+ union value val;
+ gint row, col;
+ jmd_sheet_get_active_cell (JMD_SHEET (de->data_sheet), &col, &row);
+
+ const struct variable *var = psppire_dict_get_variable (de->dict, col);
+ psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (de->datum_entry), var);
+
+ int width = var_get_width (var);
+ if (! psppire_data_store_get_value (PSPPIRE_DATA_STORE (de->data_store),
+ row, var, &val))
+ return;
+
+ psppire_value_entry_set_value (PSPPIRE_VALUE_ENTRY (de->datum_entry),
+ &val, width);
+ value_destroy (&val, width);
}
static void
psppire_data_editor_goto_variable (PsppireDataEditor *de, gint dict_index)
{
}
-
-#if SHEET_MERGE
-/* Returns the "active" data sheet in DE. If DE is in single-paned mode, this
- is the only data sheet. If DE is in split mode (showing four data sheets),
- this is the focused data sheet or, if none is focused, the data sheet with
- selected cells or, if none has selected cells, the upper-left data sheet. */
-PsppireDataSheet *
-psppire_data_editor_get_active_data_sheet (PsppireDataEditor *de)
-{
- if (de->split)
- {
- PsppireDataSheet *data_sheet;
- GtkWidget *scroller;
- int i;
-
- /* If one of the datasheet's scrollers is focused, choose that one. */
- scroller = gtk_container_get_focus_child (
- GTK_CONTAINER (de->datasheet_vbox_widget));
- if (scroller != NULL)
- return PSPPIRE_DATA_SHEET (gtk_bin_get_child (GTK_BIN (scroller)));
-
- /* Otherwise if there's a nonempty selection in some data sheet, choose
- that one. */
- FOR_EACH_DATA_SHEET (data_sheet, i, de)
- {
- PsppSheetSelection *selection;
-
- selection = pspp_sheet_view_get_selection (
- PSPP_SHEET_VIEW (data_sheet));
- if (pspp_sheet_selection_count_selected_rows (selection)
- && pspp_sheet_selection_count_selected_columns (selection))
- return data_sheet;
- }
- }
-
- return PSPPIRE_DATA_SHEET (de->data_sheets[0]);
-}
-#endif
return result;
}
-gchar *
-psppire_data_store_get_string (PsppireDataStore *store,
- glong row, const struct variable *var,
- bool use_value_label)
+gboolean
+psppire_data_store_get_value (PsppireDataStore *store,
+ glong row, const struct variable *var,
+ union value *val)
{
- gchar *string;
- union value v;
- int width;
-
g_return_val_if_fail (store != NULL, NULL);
g_return_val_if_fail (store->datasheet != NULL, NULL);
g_return_val_if_fail (var != NULL, NULL);
if (row < 0 || row >= datasheet_get_n_rows (store->datasheet))
- return NULL;
+ return FALSE;
- width = var_get_width (var);
- value_init (&v, width);
- datasheet_get_value (store->datasheet, row, var_get_case_index (var), &v);
+ int width = var_get_width (var);
+ value_init (val, width);
+ datasheet_get_value (store->datasheet, row, var_get_case_index (var), val);
+ return TRUE;
+}
+
+
+
+gchar *
+psppire_data_store_get_string (PsppireDataStore *store,
+ glong row, const struct variable *var,
+ bool use_value_label)
+{
+ gchar *string;
+ union value v;
+ int width = var_get_width (var);
+ if (! psppire_data_store_get_value (store, row, var, &v))
+ return NULL;
+
string = NULL;
if (use_value_label)
{
gchar *psppire_data_store_get_string (PsppireDataStore *,
glong row, const struct variable *,
bool use_value_label);
+
+
+gboolean psppire_data_store_get_value (PsppireDataStore *store,
+ glong row, const struct variable *var,
+ union value *val);
+
gboolean psppire_data_store_set_value (PsppireDataStore *,
casenumber casenum,
const struct variable *,
const union value *);
+
+
gboolean psppire_data_store_set_string (PsppireDataStore *ds,
const gchar *text,
glong row, const struct variable *,