/* 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
#include "ui/gui/psppire-conf.h"
#include "ui/gui/psppire-var-sheet-header.h"
+#include "value-variant.h"
+
+
#include "ui/gui/efficient-sheet/jmd-sheet.h"
+#include "ui/gui/efficient-sheet/jmd-sheet-body.h"
#include <gettext.h>
#define _(msgid) gettext (msgid)
{
const struct variable *var = psppire_dict_get_variable (store->dict, col);
+ if (NULL == var)
+ return;
+
union value v;
- value_init (&v, var_get_width (var));
- v.f = g_value_get_double (value);
+
+ GVariant *vrnt = g_value_get_variant (value);
+
+ value_variant_get (&v, vrnt);
psppire_data_store_set_value (store, row, var, &v);
- value_destroy (&v, var_get_width (var));
+ value_destroy_from_variant (&v, vrnt);
}
static void
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
{
/* A single cell is selected */
const struct variable *var = psppire_dict_get_variable (de->dict, sel->start_x);
-
- ref_cell_text = g_strdup_printf (_("%d : %s"),
- sel->start_y + 1, var_get_name (var));
+
+ if (var)
+ ref_cell_text = g_strdup_printf (_("%d : %s"),
+ sel->start_y + 1, var_get_name (var));
}
else
{
static void set_font_recursively (GtkWidget *w, gpointer data);
+gchar *myconvfunc (GtkTreeModel *m, gint col, gint row, const GValue *v);
+void myreversefunc (GtkTreeModel *model, gint col, gint row, const gchar *in, GValue *out);
+
+
static void
psppire_data_editor_init (PsppireDataEditor *de)
{
GtkWidget *hbox;
gchar *fontname = NULL;
+ GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (de));
+ gtk_style_context_add_class (context, "psppire-data-editor");
+
de->font = NULL;
de->old_vbox_widget = NULL;
gtk_box_pack_start (GTK_BOX (hbox), de->datum_entry, TRUE, TRUE, 0);
de->split = FALSE;
- de->data_sheet = g_object_new (JMD_TYPE_SHEET, NULL);
+ de->data_sheet = jmd_sheet_new ();
+ jmd_sheet_body_set_conversion_func
+ (JMD_SHEET_BODY (JMD_SHEET(de->data_sheet)->selected_body),
+ myconvfunc, myreversefunc);
+
GtkWidget *data_button = jmd_sheet_get_button (JMD_SHEET (de->data_sheet));
gtk_button_set_label (GTK_BUTTON (data_button), _("Case"));
de->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
{
PangoFontDescription *font_desc = data;
- gtk_widget_override_font (w, font_desc);
+ GtkStyleContext *style = gtk_widget_get_style_context (w);
+ GtkCssProvider *cssp = gtk_css_provider_new ();
+
+ gchar *str = pango_font_description_to_string (font_desc);
+ gchar *css =
+ g_strdup_printf ("* {font: %s}", str);
+ g_free (str);
+
+ GError *err = NULL;
+ gtk_css_provider_load_from_data (cssp, css, -1, &err);
+ if (err)
+ {
+ g_warning ("Failed to load font css \"%s\": %s", css, err->message);
+ g_error_free (err);
+ }
+ g_free (css);
+
+ gtk_style_context_add_provider (style,
+ GTK_STYLE_PROVIDER (cssp),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (cssp);
+
if ( GTK_IS_CONTAINER (w))
gtk_container_foreach (GTK_CONTAINER (w), set_font_recursively, font_desc);
psppire_conf_set_string (psppire_conf_new (),
"Data Editor", "font",
font_name);
-
+ g_free (font_name);
}
/* If SPLIT is TRUE, splits DE's data sheet into four panes.
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