#include "transpose-dialog.h"
#include "sort-cases-dialog.h"
#include "compute-dialog.h"
+#include "comments-dialog.h"
+#include "variable-info-dialog.h"
#include "dict-display.h"
#define _(msgid) gettext (msgid)
#include "psppire-data-store.h"
#include "psppire-var-store.h"
+
+/* Update the data_ref_entry with the reference of the active cell */
+static gint update_data_ref_entry (const GtkSheet *sheet,
+ gint row, gint col, gpointer data);
+
static void register_data_editor_actions (struct data_editor *de);
static void insert_variable (GtkCheckMenuItem *m, gpointer data);
-
/* Switch between the VAR SHEET and the DATA SHEET */
-enum {PAGE_DATA_SHEET = 0, PAGE_VAR_SHEET};
static gboolean click2column (GtkWidget *w, gint col, gpointer data);
#endif
+static void
+datum_entry_activate (GtkEntry *entry, gpointer data)
+{
+ gint row, column;
+ GtkSheet *data_sheet = GTK_SHEET (data);
+ PsppireDataStore *store = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet));
+
+ const char *text = gtk_entry_get_text (entry);
+ gtk_sheet_get_active_cell (data_sheet, &row, &column);
+
+ if ( row == -1 || column == -1)
+ return;
+
+ psppire_data_store_set_string (store, text, row, column);
+}
/*
Create a new data editor.
struct data_editor *de ;
struct editor_window *e;
GtkSheet *var_sheet ;
+ GtkSheet *data_sheet ;
PsppireVarStore *vs;
+ GtkWidget *datum_entry;
de = g_malloc0 (sizeof (*de));
de->xml = XML_NEW ("data-editor.glade");
var_sheet = GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+ data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
g_assert(vs); /* Traps a possible bug in win32 build */
+ g_signal_connect (G_OBJECT (data_sheet), "activate",
+ G_CALLBACK (update_data_ref_entry),
+ de->xml);
+
+ datum_entry = get_widget_assert (de->xml, "datum_entry");
+
+ g_signal_connect (G_OBJECT (datum_entry), "activate",
+ G_CALLBACK (datum_entry_activate),
+ data_sheet);
+
g_signal_connect (vs->dict, "weight-changed",
G_CALLBACK (on_weight_change),
de);
g_signal_connect (de->invoke_compute_dialog, "activate",
G_CALLBACK (compute_dialog), de);
+ de->invoke_comments_dialog =
+ gtk_action_new ("commments-dialog",
+ _("Data File Comments"),
+ _("Commentary text for the data file"),
+ NULL);
+
+ g_signal_connect (de->invoke_comments_dialog, "activate",
+ G_CALLBACK (comments_dialog), de);
+
+ de->invoke_variable_info_dialog =
+ gtk_action_new ("variable-info-dialog",
+ _("Variables"),
+ _("Jump to Variable"),
+ "pspp-goto-variable");
+
+ g_signal_connect (de->invoke_variable_info_dialog, "activate",
+ G_CALLBACK (variable_info_dialog), de);
e->window = GTK_WINDOW (get_widget_assert (de->xml, "data_editor"));
get_widget_assert (de->xml, "transform_compute")
);
+ gtk_action_connect_proxy (de->invoke_comments_dialog,
+ get_widget_assert (de->xml, "utilities_comments")
+ );
+
+ gtk_action_connect_proxy (de->invoke_variable_info_dialog,
+ get_widget_assert (de->xml, "utilities_variables")
+ );
g_signal_connect (get_widget_assert (de->xml,"help_about"),
"activate",
get_widget_assert (de->xml, "button-save")
);
+ gtk_action_connect_proxy (de->invoke_variable_info_dialog,
+ get_widget_assert (de->xml, "button-goto-variable")
+ );
+
gtk_action_connect_proxy (de->invoke_weight_cases_dialog,
get_widget_assert (de->xml, "button-weight-cases")
);
gtk_widget_destroy (dialog);
}
+
+
+
+/* Update the data_ref_entry with the reference of the active cell */
+static gint
+update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
+{
+ GladeXML *data_editor_xml = data;
+
+ PsppireDataStore *data_store = PSPPIRE_DATA_STORE (gtk_sheet_get_model (sheet));
+
+ g_return_val_if_fail (data_editor_xml, FALSE);
+
+ if (data_store)
+ {
+ const struct variable *var =
+ psppire_dict_get_variable (data_store->dict, col);
+
+ {
+ /* The entry where the reference to the current cell is displayed */
+ GtkEntry *cell_ref_entry =
+ GTK_ENTRY (get_widget_assert (data_editor_xml,
+ "cell_ref_entry"));
+
+ gchar *text = g_strdup_printf ("%d: %s", row,
+ var ? var_get_name (var) : "");
+
+ gchar *s = pspp_locale_to_utf8 (text, -1, 0);
+
+ g_free (text);
+
+ gtk_entry_set_text (cell_ref_entry, s);
+
+ g_free (s);
+ }
+
+ {
+ GtkEntry *datum_entry =
+ GTK_ENTRY (get_widget_assert (data_editor_xml,
+ "datum_entry"));
+
+ gchar *text =
+ psppire_data_store_get_string (data_store, row,
+ var_get_dict_index(var));
+ g_strchug (text);
+
+ gtk_entry_set_text (datum_entry, text);
+
+ free (text);
+ }
+ }
+
+ return FALSE;
+}