#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-#include <data/casewriter.h>
#include <data/datasheet.h>
#include <data/data-out.h>
#include <data/variable.h>
#include <data/value-labels.h>
#include <data/data-in.h>
-#include <data/file-handle-def.h>
-#include <data/sys-file-writer.h>
-
-
static void psppire_data_store_init (PsppireDataStore *data_store);
static void psppire_data_store_class_init (PsppireDataStoreClass *class);
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);
}
-
-/* FIXME: There's no reason to actually have this function.
- It should be done by a procedure */
-void
-psppire_data_store_create_system_file (PsppireDataStore *store,
- struct file_handle *handle)
-{
- gint i, var_cnt;
- const struct sfm_write_options wo = {
- true, /* writeable */
- false, /* dont compress */
- 3 /* version */
- };
-
- struct casewriter *writer;
-
- g_assert (handle);
-
- writer = sfm_open_writer (handle, store->dict->dict, wo);
-
- if ( ! writer)
- return;
-
-
- var_cnt = psppire_data_store_get_var_count (G_SHEET_MODEL (store));
-
- for (i = 0 ; i < psppire_case_file_get_case_count (store->case_file); ++i )
- {
- struct ccase c;
- psppire_case_file_get_case (store->case_file, i, &c);
- casewriter_write (writer, &c);
- }
- casewriter_destroy (writer);
-}
-
-
-
void
psppire_data_store_clear (PsppireDataStore *data_store)
{
}
+static gchar *
+geometry_get_column_subtitle (const GSheetColumn *geom, gint unit)
+{
+ gchar *text;
+ const struct variable *v ;
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
+
+ if ( unit >= psppire_dict_get_var_cnt (ds->dict) )
+ return NULL;
+
+ v = psppire_dict_get_variable (ds->dict, unit);
+
+ if ( ! var_has_label (v))
+ return NULL;
+
+ text = pspp_locale_to_utf8 (var_get_label (v), -1, 0);
+
+ return text;
+}
+
+
static gboolean
geometry_get_sensitivity (const GSheetColumn *geom, gint unit)
{
iface->get_sensitivity = geometry_get_sensitivity;
iface->get_justification = geometry_get_justification;
iface->get_button_label = geometry_get_column_button_label;
+ iface->get_subtitle = geometry_get_column_subtitle;
}
TRAILING_ROWS + psppire_case_file_get_case_count (ds->case_file))
return 0;
- s = g_strdup_printf (_("%d"), unit);
+ s = g_strdup_printf (_("%d"), unit + FIRST_CASE_NUMBER);
text = pspp_locale_to_utf8 (s, -1, 0);