X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-store.c;h=40c3843fab3d429fffd3f8c43b27855015180a04;hb=077c3c1774fd75627783b407169d6884adcbe663;hp=2603d0f4fb63c4dbf259f8dc4896a7749947175e;hpb=b0edc00b3466899dab038e27452125315c859b37;p=pspp diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 2603d0f4fb..40c3843fab 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -1,11 +1,9 @@ -/* psppire-data-store.c - - PSPPIRE --- A Graphical User Interface for PSPP +/* PSPPIRE - a graphical user interface for PSPP. Copyright (C) 2006 Free Software Foundation - This program is free software; you can redistribute it and/or modify + 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 - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,9 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ #include #include @@ -54,7 +50,7 @@ static void psppire_data_store_sheet_row_init (GSheetRowIface *iface); static void psppire_data_store_finalize (GObject *object); static gboolean psppire_data_store_clear_datum (GSheetModel *model, - gint row, gint column); + glong row, glong column); #define MIN_COLUMNS 10 @@ -155,7 +151,7 @@ psppire_data_store_class_init (PsppireDataStoreClass *class) -static gint +static glong psppire_data_store_get_var_count (const GSheetModel *model) { const PsppireDataStore *store = PSPPIRE_DATA_STORE (model); @@ -163,15 +159,20 @@ psppire_data_store_get_var_count (const GSheetModel *model) return psppire_dict_get_var_cnt (store->dict); } -static gint -psppire_data_store_get_case_count (const GSheetModel *model) +casenumber +psppire_data_store_get_case_count (PsppireDataStore *store) +{ + return psppire_case_file_get_case_count (store->case_file); +} + +static glong +psppire_data_store_get_case_count_from_model (const GSheetModel *model) { const PsppireDataStore *store = PSPPIRE_DATA_STORE (model); return psppire_case_file_get_case_count (store->case_file); } - static void psppire_data_store_init (PsppireDataStore *data_store) { @@ -182,7 +183,7 @@ psppire_data_store_init (PsppireDataStore *data_store) const PangoFontDescription * psppire_data_store_get_font_desc (const GSheetModel *model, - gint row, gint column) + glong row, glong column) { PsppireDataStore *store = PSPPIRE_DATA_STORE (model); @@ -190,8 +191,8 @@ psppire_data_store_get_font_desc (const GSheetModel *model, } static inline gchar * -psppire_data_store_get_string_wrapper (const GSheetModel *model, gint row, - gint column) +psppire_data_store_get_string_wrapper (const GSheetModel *model, glong row, + glong column) { return psppire_data_store_get_string (PSPPIRE_DATA_STORE (model), row, column); } @@ -200,7 +201,7 @@ psppire_data_store_get_string_wrapper (const GSheetModel *model, gint row, static inline gboolean psppire_data_store_set_string_wrapper (GSheetModel *model, const gchar *text, - gint row, gint column) + glong row, glong column) { return psppire_data_store_set_string (PSPPIRE_DATA_STORE (model), text, row, column); @@ -223,7 +224,7 @@ psppire_data_store_sheet_model_init (GSheetModelIface *iface) iface->get_font_desc = psppire_data_store_get_font_desc; iface->get_cell_border = NULL; iface->get_column_count = psppire_data_store_get_var_count; - iface->get_row_count = psppire_data_store_get_case_count; + iface->get_row_count = psppire_data_store_get_case_count_from_model; } static @@ -234,7 +235,8 @@ gboolean always_true () static void -delete_cases_callback (GtkWidget *w, gint first, gint n_cases, gpointer data) +delete_cases_callback (GtkWidget *w, + casenumber first, casenumber n_cases, gpointer data) { PsppireDataStore *store ; @@ -249,7 +251,7 @@ delete_cases_callback (GtkWidget *w, gint first, gint n_cases, gpointer data) static void -insert_case_callback (GtkWidget *w, gint casenum, gpointer data) +insert_case_callback (GtkWidget *w, casenumber casenum, gpointer data) { PsppireDataStore *store ; @@ -453,21 +455,30 @@ psppire_data_store_finalize (GObject *object) (* parent_class->finalize) (object); } +gboolean +psppire_data_store_delete_cases (PsppireDataStore *ds, + casenumber first, casenumber count) +{ + g_return_val_if_fail (ds, FALSE); + + return psppire_case_file_delete_cases (ds->case_file, count, first); +} + /* Insert a blank case before POSN */ gboolean -psppire_data_store_insert_new_case (PsppireDataStore *ds, gint posn) +psppire_data_store_insert_new_case (PsppireDataStore *ds, casenumber posn) { gboolean result; gint val_cnt, v; struct ccase cc; g_return_val_if_fail (ds, FALSE); - - /* Opportunity for optimisation exists here when creating a blank case */ val_cnt = datasheet_get_column_cnt (ds->case_file->datasheet) ; + g_return_val_if_fail (val_cnt > 0, FALSE); + case_create (&cc, val_cnt); memset ( case_data_rw_idx (&cc, 0), 0, val_cnt * MAX_SHORT_STRING); @@ -490,7 +501,7 @@ psppire_data_store_insert_new_case (PsppireDataStore *ds, gint posn) gchar * -psppire_data_store_get_string (PsppireDataStore *store, gint row, gint column) +psppire_data_store_get_string (PsppireDataStore *store, glong row, glong column) { gint idx; char *text; @@ -557,8 +568,7 @@ psppire_data_store_get_string (PsppireDataStore *store, gint row, gint column) static gboolean psppire_data_store_clear_datum (GSheetModel *model, - gint row, gint col) - + glong row, glong col) { PsppireDataStore *store = PSPPIRE_DATA_STORE (model); @@ -585,7 +595,7 @@ psppire_data_store_clear_datum (GSheetModel *model, */ gboolean psppire_data_store_set_string (PsppireDataStore *store, - const gchar *text, gint row, gint col) + const gchar *text, glong row, glong col) { const struct variable *pv = psppire_dict_get_variable (store->dict, col); g_return_val_if_fail (pv, FALSE); @@ -670,7 +680,7 @@ psppire_data_store_get_reader (PsppireDataStore *ds) /* Column related funcs */ -static gint +static glong geometry_get_column_count (const GSheetColumn *geom) { PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom); @@ -681,7 +691,7 @@ geometry_get_column_count (const GSheetColumn *geom) static gint -geometry_get_width (const GSheetColumn *geom, gint unit) +geometry_get_width (const GSheetColumn *geom, glong unit) { const struct variable *pv ; PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom); @@ -698,7 +708,7 @@ geometry_get_width (const GSheetColumn *geom, gint unit) } static void -geometry_set_width (GSheetColumn *geom, gint unit, gint width) +geometry_set_width (GSheetColumn *geom, glong unit, gint width) { PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom); @@ -710,7 +720,7 @@ geometry_set_width (GSheetColumn *geom, gint unit, gint width) static GtkJustification -geometry_get_justification (const GSheetColumn *geom, gint unit) +geometry_get_justification (const GSheetColumn *geom, glong unit) { PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom); const struct variable *pv ; @@ -730,7 +740,7 @@ geometry_get_justification (const GSheetColumn *geom, gint unit) static const gchar null_var_name[]=N_("var"); static gchar * -geometry_get_column_button_label (const GSheetColumn *geom, gint unit) +geometry_get_column_button_label (const GSheetColumn *geom, glong unit) { gchar *text; struct variable *pv ; @@ -748,7 +758,7 @@ geometry_get_column_button_label (const GSheetColumn *geom, gint unit) static gchar * -geometry_get_column_subtitle (const GSheetColumn *geom, gint unit) +geometry_get_column_subtitle (const GSheetColumn *geom, glong unit) { gchar *text; const struct variable *v ; @@ -769,7 +779,7 @@ geometry_get_column_subtitle (const GSheetColumn *geom, gint unit) static gboolean -geometry_get_sensitivity (const GSheetColumn *geom, gint unit) +geometry_get_sensitivity (const GSheetColumn *geom, glong unit) { PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom); @@ -793,7 +803,7 @@ psppire_data_store_sheet_column_init (GSheetColumnIface *iface) /* Row related funcs */ -static gint +static glong geometry_get_row_count (const GSheetRow *geom, gpointer data) { PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom); @@ -803,14 +813,14 @@ geometry_get_row_count (const GSheetRow *geom, gpointer data) static gint -geometry_get_height (const GSheetRow *geom, gint unit, gpointer data) +geometry_get_height (const GSheetRow *geom, glong unit, gpointer data) { return 25; } static gboolean -geometry_get_row_sensitivity (const GSheetRow *geom, gint unit, gpointer data) +geometry_get_row_sensitivity (const GSheetRow *geom, glong unit, gpointer data) { PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom); @@ -820,7 +830,7 @@ geometry_get_row_sensitivity (const GSheetRow *geom, gint unit, gpointer data) static gchar * -geometry_get_row_button_label (const GSheetRow *geom, gint unit, gpointer data) +geometry_get_row_button_label (const GSheetRow *geom, glong unit, gpointer data) { gchar *text; gchar *s; @@ -830,7 +840,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 + FIRST_CASE_NUMBER); + s = g_strdup_printf (_("%ld"), unit + FIRST_CASE_NUMBER); text = pspp_locale_to_utf8 (s, -1, 0); @@ -852,6 +862,3 @@ psppire_data_store_sheet_row_init (GSheetRowIface *iface) iface->get_button_label = geometry_get_row_button_label; } - - -