+2007-06-29 John Darrington <john@darrington.wattle.id.au>
+
+ * data-editor.c data-editor.glade psppire-data-store.c
+ psppire-data-store.h: Enabled cell reference entry and datum
+ entry widgets.
+
2007-06-29 John Darrington <john@darrington.wattle.id.au>
* data-editor.c data-sheet.c: Moved update_cell_ref_entry from
#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.
GtkSheet *var_sheet ;
GtkSheet *data_sheet ;
PsppireVarStore *vs;
+ GtkWidget *datum_entry;
de = g_malloc0 (sizeof (*de));
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);
de->action_data_open);
-
-
-
#if RECENT_LISTS_AVAILABLE
{
GtkRecentManager *rm = gtk_recent_manager_get_default ();
{
GladeXML *data_editor_xml = data;
- /* The entry where the reference to the current cell is displayed */
- GtkEntry *cell_ref_entry;
-
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 *pv =
+ const struct variable *var =
psppire_dict_get_variable (data_store->dict, col);
- gchar *text ;
- gchar *s ;
+ {
+ /* 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"));
- text = g_strdup_printf ("%d: %s", row,
- pv ? var_get_name (pv) : "");
+ gchar *text = g_strdup_printf ("%d: %s", row,
+ var ? var_get_name (var) : "");
- cell_ref_entry = GTK_ENTRY (get_widget_assert (data_editor_xml,
- "cell_ref_entry"));
+ gchar *s = pspp_locale_to_utf8 (text, -1, 0);
- s = pspp_locale_to_utf8 (text, -1, 0);
+ g_free (text);
- g_free (text);
+ gtk_entry_set_text (cell_ref_entry, s);
- gtk_entry_set_text (cell_ref_entry, s);
+ g_free (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;
</packing>
</child>
<child>
- <widget class="GtkEntry" id="entry4">
+ <widget class="GtkEntry" id="datum_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
static void psppire_data_store_finalize (GObject *object);
-static gchar *psppire_data_store_get_string (const GSheetModel *sheet_model, gint row, gint column);
-
-static gboolean psppire_data_store_set_string (GSheetModel *model,
- const gchar *text, gint row, gint column);
-
static gboolean psppire_data_store_clear_datum (GSheetModel *model,
gint row, gint column);
return store->font_desc;
}
+static inline gchar *
+psppire_data_store_get_string_wrapper (const GSheetModel *model, gint row,
+ gint column)
+{
+ return psppire_data_store_get_string (PSPPIRE_DATA_STORE (model), row, column);
+}
+
+
+static inline gboolean
+psppire_data_store_set_string_wrapper (GSheetModel *model,
+ const gchar *text,
+ gint row, gint column)
+{
+ return psppire_data_store_set_string (PSPPIRE_DATA_STORE (model), text,
+ row, column);
+}
+
+
+
static void
psppire_data_store_sheet_model_init (GSheetModelIface *iface)
{
iface->free_strings = TRUE;
- iface->get_string = psppire_data_store_get_string;
- iface->set_string = psppire_data_store_set_string;
+ iface->get_string = psppire_data_store_get_string_wrapper;
+ iface->set_string = psppire_data_store_set_string_wrapper;
iface->clear_datum = psppire_data_store_clear_datum;
iface->is_editable = NULL;
iface->is_visible = NULL;
}
-static gchar *
-psppire_data_store_get_string (const GSheetModel *model, gint row, gint column)
+gchar *
+psppire_data_store_get_string (PsppireDataStore *store, gint row, gint column)
{
gint idx;
char *text;
const struct variable *pv ;
union value *v ;
GString *s;
- PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
g_return_val_if_fail (store->dict, NULL);
g_return_val_if_fail (store->case_file, NULL);
to ROW, COL with the value TEXT.
Returns true if anything was updated, false otherwise.
*/
-static gboolean
-psppire_data_store_set_string (GSheetModel *model,
- const gchar *text, gint row, gint col)
+gboolean
+psppire_data_store_set_string (PsppireDataStore *store,
+ const gchar *text, gint row, gint col)
{
- PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
-
const struct variable *pv = psppire_dict_get_variable (store->dict, col);
g_return_val_if_fail (pv, FALSE);
struct casereader * psppire_data_store_get_reader (PsppireDataStore *ds);
+gchar * psppire_data_store_get_string (PsppireDataStore *ds,
+ gint row, gint column);
+gboolean psppire_data_store_set_string (PsppireDataStore *ds,
+ const gchar *text,
+ gint row, gint column);
#ifdef __cplusplus
}