X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fpsppire-data-store.c;h=2603d0f4fb63c4dbf259f8dc4896a7749947175e;hb=b0edc00b3466899dab038e27452125315c859b37;hp=c7d94cee81dc66270f74ea61176da0b7f96cdb3e;hpb=d908f52b818f4fdf2ab23797756812ec2986bd2b;p=pspp diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index c7d94cee81..2603d0f4fb 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -25,7 +25,6 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -#include #include #include #include @@ -45,10 +44,6 @@ #include #include -#include -#include - - static void psppire_data_store_init (PsppireDataStore *data_store); static void psppire_data_store_class_init (PsppireDataStoreClass *class); @@ -58,11 +53,6 @@ static void psppire_data_store_sheet_row_init (GSheetRowIface *iface); 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); @@ -199,13 +189,32 @@ psppire_data_store_get_font_desc (const GSheetModel *model, 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; @@ -480,8 +489,8 @@ psppire_data_store_insert_new_case (PsppireDataStore *ds, gint posn) } -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; @@ -489,7 +498,6 @@ psppire_data_store_get_string (const GSheetModel *model, gint row, gint column) 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); @@ -575,12 +583,10 @@ psppire_data_store_clear_datum (GSheetModel *model, 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); @@ -639,43 +645,6 @@ psppire_data_store_show_labels (PsppireDataStore *store, gboolean show_labels) } - -/* 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) { @@ -778,6 +747,27 @@ geometry_get_column_button_label (const GSheetColumn *geom, gint unit) } +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) { @@ -797,6 +787,7 @@ psppire_data_store_sheet_column_init (GSheetColumnIface *iface) 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; } @@ -839,7 +830,7 @@ geometry_get_row_button_label (const GSheetRow *geom, gint unit, gpointer data) 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);