From: John Darrington Date: Sun, 30 Jul 2006 12:27:59 +0000 (+0000) Subject: Re-enabled automatic insertion of cases in data sheet. X-Git-Tag: v0.6.0~747 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2ccb0d20912f25021d9a6c24d9c2de1b81b87bf;p=pspp-builds.git Re-enabled automatic insertion of cases in data sheet. --- diff --git a/po/de.po b/po/de.po index dabaa739..145f70c6 100644 --- a/po/de.po +++ b/po/de.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.4.2\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2006-07-29 13:49+0800\n" +"POT-Creation-Date: 2006-07-30 14:13+0800\n" "PO-Revision-Date: 2006-05-26 17:49+0800\n" "Last-Translator: John Darrington \n" "Language-Team: German \n" @@ -4218,11 +4218,11 @@ msgstr "Tragbardatein (*.por)" msgid "All Files" msgstr "Alle Datei" -#: src/ui/gui/menu-actions.c:272 +#: src/ui/gui/menu-actions.c:273 msgid "Save Data As" msgstr "Speichern unter" -#: src/ui/gui/menu-actions.c:568 +#: src/ui/gui/menu-actions.c:582 msgid "Font Selection" msgstr "Schriftwahlung" @@ -4250,11 +4250,11 @@ msgstr "Falshe Spannweitebeschreibung" msgid "Sorry. The help system hasn't yet been implemented." msgstr "Es gibt noch nicht kein Helpsysteme. Schade!" -#: src/ui/gui/psppire-data-store.c:699 +#: src/ui/gui/psppire-data-store.c:731 msgid "var" msgstr "" -#: src/ui/gui/psppire-data-store.c:780 src/ui/gui/psppire-var-store.c:518 +#: src/ui/gui/psppire-data-store.c:812 src/ui/gui/psppire-var-store.c:518 #: src/ui/gui/psppire-var-store.c:528 src/ui/gui/psppire-var-store.c:538 #: src/ui/gui/psppire-var-store.c:735 #, c-format diff --git a/po/pspp.pot b/po/pspp.pot index 18743805..34ae5e40 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2006-07-29 13:49+0800\n" +"POT-Creation-Date: 2006-07-30 14:13+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4217,11 +4217,11 @@ msgstr "" msgid "All Files" msgstr "" -#: src/ui/gui/menu-actions.c:272 +#: src/ui/gui/menu-actions.c:273 msgid "Save Data As" msgstr "" -#: src/ui/gui/menu-actions.c:568 +#: src/ui/gui/menu-actions.c:582 msgid "Font Selection" msgstr "" @@ -4249,11 +4249,11 @@ msgstr "" msgid "Sorry. The help system hasn't yet been implemented." msgstr "" -#: src/ui/gui/psppire-data-store.c:699 +#: src/ui/gui/psppire-data-store.c:731 msgid "var" msgstr "" -#: src/ui/gui/psppire-data-store.c:780 src/ui/gui/psppire-var-store.c:518 +#: src/ui/gui/psppire-data-store.c:812 src/ui/gui/psppire-var-store.c:518 #: src/ui/gui/psppire-var-store.c:528 src/ui/gui/psppire-var-store.c:538 #: src/ui/gui/psppire-var-store.c:735 #, c-format diff --git a/src/ui/gui/TODO b/src/ui/gui/TODO index 6256855b..37edbb97 100644 --- a/src/ui/gui/TODO +++ b/src/ui/gui/TODO @@ -1,6 +1,6 @@ -* Blank cell reference when deselecting cells. (Eg New command). +* Crashes when reducing the size of string variables. -* Strip leading/trailing whitespace on data in cells. +* Blank cell reference when deselecting cells. (Eg New command). * Cell Ref Entry populate/depopulate. @@ -8,11 +8,11 @@ * Goto Variable. -* Widen columns in var sheet as necessary to accomodate non-english translations. - Wishlist ======== +* Widen columns in var sheet as necessary to accomodate non-english translations. + * Cut/Paste Buffer. Cut and paste: a) Between psppire instances. b) From other applications. * In datasheet, add tooltips to column buttons, so that hovering over a column button displays diff --git a/src/ui/gui/data-sheet.c b/src/ui/gui/data-sheet.c index 29e0309c..de4a357b 100644 --- a/src/ui/gui/data-sheet.c +++ b/src/ui/gui/data-sheet.c @@ -44,20 +44,31 @@ extern GladeXML *xml; - static gboolean traverse_callback (GtkSheet * sheet, - gint row, gint col, - gint *new_row, gint *new_column - ) + gint row, gint col, + gint *new_row, gint *new_column + ) { + gint case_count; PsppireDataStore *data_store = PSPPIRE_DATA_STORE(gtk_sheet_get_model(sheet)); - const gint n_vars = psppire_dict_get_var_cnt(data_store->dict); if ( *new_column >= n_vars ) return FALSE; + case_count = psppire_case_file_get_case_count(data_store->case_file); + + if ( *new_row >= case_count ) + { + gint i; + + for ( i = case_count ; i <= *new_row; ++i ) + psppire_data_store_insert_new_case (data_store, i); + + return TRUE; + } + return TRUE; } diff --git a/src/ui/gui/menu-actions.c b/src/ui/gui/menu-actions.c index b027b5a6..fb62f8a5 100644 --- a/src/ui/gui/menu-actions.c +++ b/src/ui/gui/menu-actions.c @@ -364,6 +364,8 @@ on_clear_activate (GtkMenuItem *menuitem, switch (page) { + case PAGE_VAR_SHEET: + break; case PAGE_DATA_SHEET: { GtkSheet *data_sheet = GTK_SHEET(get_widget_assert(xml, "data_sheet")); @@ -409,87 +411,6 @@ on_clear_activate (GtkMenuItem *menuitem, } -void -on_insert1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - GtkNotebook *notebook = GTK_NOTEBOOK(get_widget_assert(xml, "notebook1")); - gint page = -1; - - page = gtk_notebook_get_current_page(notebook); - - switch (page) - { - case PAGE_DATA_SHEET: -#if 0 - { - GtkSheet *data_sheet = GTK_SHEET(get_widget_assert(xml, "data_sheet")); - PsppireDataStore *data_store = - PSPPIRE_DATA_STORE(gtk_sheet_get_model(data_sheet)); - - psppire_case_array_insert_case(data_store->cases, - data_sheet->range.row0, - blank_case, the_dictionary); - } - break; -#endif - case PAGE_VAR_SHEET: - { - GtkSheet *var_sheet = - GTK_SHEET(get_widget_assert(xml, "variable_sheet")); - - PsppireVarStore *var_store = - PSPPIRE_VAR_STORE(gtk_sheet_get_model(var_sheet)); - - psppire_dict_insert_variable(var_store->dict, var_sheet->range.row0, 0); - } - break; - } -} - -#if 0 -void -on_delete1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - gint page = -1; - GtkWidget *notebook = get_widget_assert(xml, "notebook1"); - - page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); - switch ( page) - { -#if 0 - case PAGE_DATA_SHEET: - { - GtkSheet *data_sheet = GTK_SHEET(get_widget_assert(xml, "data_sheet")); - PsppireDataStore *data_store = - PSPPIRE_DATA_STORE(gtk_sheet_get_model(data_sheet)); - - psppire_case_array_delete_cases(data_store->cases, - data_sheet->range.row0, - 1 + data_sheet->range.rowi - - data_sheet->range.row0 ); - } - break; -#endif - case PAGE_VAR_SHEET: - { - GtkSheet *var_sheet = - GTK_SHEET(get_widget_assert(xml, "variable_sheet")); - - PsppireVarStore *var_store = - PSPPIRE_VAR_STORE(gtk_sheet_get_model(var_sheet)); - - psppire_dict_delete_variables(var_store->dict, - var_sheet->range.row0, - 1 + var_sheet->range.rowi - - var_sheet->range.row0 ); - } - break; - } -} -#endif - void on_about1_activate(GtkMenuItem *menuitem, gpointer user_data) @@ -769,7 +690,7 @@ insert_case(void) gtk_sheet_get_active_cell(data_sheet, &row, &col); - psppire_case_file_insert_case(data_store->case_file, row); + psppire_data_store_insert_new_case(data_store, row); } void diff --git a/src/ui/gui/psppire-case-file.c b/src/ui/gui/psppire-case-file.c index 5ad96ad9..b16fd7ca 100644 --- a/src/ui/gui/psppire-case-file.c +++ b/src/ui/gui/psppire-case-file.c @@ -156,7 +156,7 @@ psppire_case_file_new (gint val_cnt) { PsppireCaseFile *cf = g_object_new (G_TYPE_PSPPIRE_CASE_FILE, NULL); - cf->flexifile = flexifile_create(val_cnt); + cf->flexifile = flexifile_create (val_cnt); return cf; } @@ -177,23 +177,19 @@ psppire_case_file_delete_cases(PsppireCaseFile *cf, gint n_cases, gint first) return result; } -/* Insert a blank case to the case file */ +/* Insert case CC into the case file before POSN */ gboolean psppire_case_file_insert_case(PsppireCaseFile *cf, - gint posn) + struct ccase *cc, + gint posn) { bool result ; - struct ccase cc; g_return_val_if_fail(cf, FALSE); g_return_val_if_fail(cf->flexifile, FALSE); - case_create (&cc, casefile_get_value_cnt(cf->flexifile)); - - result = flexifile_insert_case(FLEXIFILE(cf->flexifile), &cc, posn); + result = flexifile_insert_case(FLEXIFILE(cf->flexifile), cc, posn); - case_destroy (&cc); - if ( result ) g_signal_emit(cf, signal[CASE_INSERTED], 0, posn); else @@ -202,6 +198,7 @@ psppire_case_file_insert_case(PsppireCaseFile *cf, return result; } + /* Append a case to the case file */ gboolean psppire_case_file_append_case(PsppireCaseFile *cf, @@ -354,8 +351,8 @@ psppire_case_file_sort(PsppireCaseFile *cf, const struct sort_criteria *sc) /* Resize the cases in the casefile, by inserting N_VALUES into every one of them. */ gboolean -psppire_case_file_insert_values(PsppireCaseFile *cf, - gint n_values, gint before) +psppire_case_file_insert_values (PsppireCaseFile *cf, + gint n_values, gint before) { g_return_val_if_fail(cf, FALSE); @@ -365,21 +362,18 @@ psppire_case_file_insert_values(PsppireCaseFile *cf, return TRUE; } - return flexifile_resize(FLEXIFILE(cf->flexifile), n_values, before); + return flexifile_resize (FLEXIFILE(cf->flexifile), n_values, before); } - - - /* Fills C with the CASENUMth case. Returns true on success, false otherwise. */ gboolean -psppire_case_file_get_case(const PsppireCaseFile *cf, gint casenum, +psppire_case_file_get_case (const PsppireCaseFile *cf, gint casenum, struct ccase *c) { - g_return_val_if_fail(cf, FALSE); - g_return_val_if_fail(cf->flexifile, FALSE); + g_return_val_if_fail (cf, FALSE); + g_return_val_if_fail (cf->flexifile, FALSE); - return flexifile_get_case(FLEXIFILE(cf->flexifile), casenum, c); + return flexifile_get_case (FLEXIFILE(cf->flexifile), casenum, c); } diff --git a/src/ui/gui/psppire-case-file.h b/src/ui/gui/psppire-case-file.h index fbfa7d75..7961b3cb 100644 --- a/src/ui/gui/psppire-case-file.h +++ b/src/ui/gui/psppire-case-file.h @@ -71,6 +71,8 @@ PsppireCaseFile *psppire_case_file_new (gint var_cnt); gboolean psppire_case_file_append_case(PsppireCaseFile *cf, struct ccase *c); +gboolean psppire_case_file_insert_case(PsppireCaseFile *cf, struct ccase *c, gint row); + gint psppire_case_file_get_case_count(const PsppireCaseFile *cf); @@ -91,9 +93,6 @@ void psppire_case_file_clear(PsppireCaseFile *cf); gboolean psppire_case_file_delete_cases(PsppireCaseFile *cf, gint n_rows, gint first); -gboolean psppire_case_file_insert_case(PsppireCaseFile *cf, gint row); - - gboolean psppire_case_file_insert_values(PsppireCaseFile *cf, gint n_values, gint before); struct sort_criteria; diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 5fbfcb48..eeaf31d6 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -327,9 +327,6 @@ dict_size_change_callback(GObject *obj, store = PSPPIRE_DATA_STORE(data); - /* - if ( adjustment > 0 ) - */ psppire_case_file_insert_values (store->case_file, adjustment, posn); } @@ -423,8 +420,43 @@ psppire_data_store_finalize (GObject *object) } + +/* Insert a blank case before POSN */ +gboolean +psppire_data_store_insert_new_case(PsppireDataStore *ds, gint 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 = casefile_get_value_cnt(ds->case_file->flexifile) ; + + case_create (&cc, val_cnt); + + memset ( case_data_rw (&cc, 0), 0, val_cnt * MAX_SHORT_STRING); + + for (v = 0 ; v < psppire_dict_get_var_cnt (ds->dict) ; ++v) + { + const struct PsppireVariable *pv = psppire_dict_get_variable(ds->dict, v); + if (ALPHA == psppire_variable_get_type(pv) ) + continue; + + case_data_rw (&cc, psppire_variable_get_fv (pv))->f = SYSMIS; + } + + result = psppire_case_file_insert_case (ds->case_file, &cc, posn); + + case_destroy (&cc); + + return result; +} + + static gchar * -psppire_data_store_get_string(const GSheetModel *model, gint row, gint column) +psppire_data_store_get_string (const GSheetModel *model, gint row, gint column) { gint idx; char *text; @@ -434,26 +466,26 @@ psppire_data_store_get_string(const GSheetModel *model, gint row, gint column) 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); + g_return_val_if_fail (store->dict, NULL); + g_return_val_if_fail (store->case_file, NULL); - if (column >= psppire_dict_get_var_cnt(store->dict)) + if (column >= psppire_dict_get_var_cnt (store->dict)) return NULL; - if ( row >= psppire_case_file_get_case_count(store->case_file)) + if ( row >= psppire_case_file_get_case_count (store->case_file)) return NULL; - pv = psppire_dict_get_variable(store->dict, column); + pv = psppire_dict_get_variable (store->dict, column); - idx = psppire_variable_get_fv(pv); + idx = psppire_variable_get_fv (pv); - v = psppire_case_file_get_value(store->case_file, row, idx); + v = psppire_case_file_get_value (store->case_file, row, idx); g_return_val_if_fail(v, NULL); if ( store->show_labels) { - const struct val_labs * vl = psppire_variable_get_value_labels(pv); + const struct val_labs * vl = psppire_variable_get_value_labels (pv); const gchar *label; if ( (label = val_labs_find(vl, *v)) ) @@ -462,29 +494,31 @@ psppire_data_store_get_string(const GSheetModel *model, gint row, gint column) } } - fp = psppire_variable_get_write_spec(pv); + fp = psppire_variable_get_write_spec (pv); s = g_string_sized_new (fp->w + 1); - g_string_set_size(s, fp->w); + g_string_set_size (s, fp->w); - memset(s->str, 0, fp->w); + memset (s->str, 0, fp->w); - g_assert(fp->w == s->len); + g_assert (fp->w == s->len); /* Converts binary value V into printable form in the exactly FP->W character in buffer S according to format specification FP. No null terminator is appended to the buffer. */ data_out (s->str, fp, v); - text = pspp_locale_to_utf8(s->str, fp->w, 0); - g_string_free(s, TRUE); + text = pspp_locale_to_utf8 (s->str, fp->w, 0); + g_string_free (s, TRUE); + + g_strchomp (text); return text; } static gboolean -psppire_data_store_clear_datum(GSheetModel *model, +psppire_data_store_clear_datum (GSheetModel *model, gint row, gint col) { diff --git a/src/ui/gui/psppire-data-store.h b/src/ui/gui/psppire-data-store.h index c16d158e..0787f116 100644 --- a/src/ui/gui/psppire-data-store.h +++ b/src/ui/gui/psppire-data-store.h @@ -98,8 +98,11 @@ void psppire_data_store_clear(PsppireDataStore *data_store); struct file_handle; -void psppire_data_store_create_system_file(PsppireDataStore *store, - struct file_handle *handle); +void psppire_data_store_create_system_file (PsppireDataStore *store, + struct file_handle *handle); + +gboolean psppire_data_store_insert_new_case (PsppireDataStore *ds, gint posn); + #ifdef __cplusplus