From: John Darrington Date: Sat, 18 Aug 2007 02:52:35 +0000 (+0000) Subject: Added the ability to paste from the clipboard to the data sheet. X-Git-Tag: v0.6.0~300 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93b405c0e37eb86c0bf019b7fccc8d53aa7e59f2;p=pspp-builds.git Added the ability to paste from the clipboard to the data sheet. --- diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index bdcef65d..3830dac1 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -3896,10 +3896,6 @@ gtk_sheet_activate_cell (GtkSheet *sheet, gint row, gint col) if (row >= yyy_row_count (sheet) || col >= xxx_column_count (sheet)) return FALSE; - /* _gtkextra_signal_emit (GTK_OBJECT (sheet), sheet_signals[ACTIVATE], row, col, &veto); - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return veto; - */ - if (!veto) return FALSE; if (sheet->state != GTK_SHEET_NORMAL) { @@ -3926,7 +3922,7 @@ gtk_sheet_activate_cell (GtkSheet *sheet, gint row, gint col) G_CALLBACK (gtk_sheet_entry_changed), sheet); - _gtkextra_signal_emit (GTK_OBJECT (sheet), sheet_signals[ACTIVATE], row, col, &veto); + _gtkextra_signal_emit (GTK_OBJECT (sheet), sheet_signals [ACTIVATE], row, col, &veto); return TRUE; } @@ -5014,6 +5010,7 @@ gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column, gboolean *veto) *veto = FALSE; return; } + gtk_sheet_activate_cell (sheet, row, column); } if (gtk_sheet_autoscroll (sheet)) diff --git a/po/de.po b/po/de.po index f34643a9..ae83b71c 100644 --- a/po/de.po +++ b/po/de.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.4.3\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2007-08-16 14:11+0800\n" +"POT-Creation-Date: 2007-08-18 08:25+0800\n" "PO-Revision-Date: 2006-07-28 19:32+0800\n" "Last-Translator: John Darrington \n" "Language-Team: German \n" @@ -3078,11 +3078,11 @@ msgstr "" msgid "Multivariate GLM not yet supported" msgstr "" -#: src/language/stats/glm.q:268 src/language/stats/regression.q:1153 +#: src/language/stats/glm.q:268 src/language/stats/regression.q:1155 msgid "Dependent variable must be numeric." msgstr "" -#: src/language/stats/glm.q:343 src/language/stats/regression.q:1252 +#: src/language/stats/glm.q:343 src/language/stats/regression.q:1254 msgid "No valid data found. This command was skipped." msgstr "" @@ -3336,9 +3336,9 @@ msgstr "" #: src/language/stats/regression.q:1031 msgid "" -"The dependent variable is equal to the independent variable. The least " -"sequares line is therefore Y=X. Standard errors and related statistics may " -"be meaningless." +"The dependent variable is equal to the independent variable.The least " +"squares line is therefore Y=X.Standard errors and related statistics may be " +"meaningless." msgstr "" #: src/language/stats/sort-cases.c:63 @@ -4239,223 +4239,223 @@ msgstr "Spalten" msgid "Style of bevel around the custom entry button" msgstr "" -#: src/ui/gui/data-editor.c:151 +#: src/ui/gui/data-editor.c:154 msgid "Transformations Pending" msgstr "" -#: src/ui/gui/data-editor.c:290 +#: src/ui/gui/data-editor.c:349 #, fuzzy msgid "Labels" msgstr "Kennsatz" -#: src/ui/gui/data-editor.c:291 +#: src/ui/gui/data-editor.c:350 msgid "Show/hide value labels" msgstr "" -#: src/ui/gui/data-editor.c:309 src/ui/gui/data-editor.c:324 -#: src/ui/gui/data-editor.c:1603 src/ui/gui/data-editor.c:1656 +#: src/ui/gui/data-editor.c:368 src/ui/gui/data-editor.c:385 +#: src/ui/gui/data-editor.c:1660 src/ui/gui/data-editor.c:1713 msgid "Clear" msgstr "" -#: src/ui/gui/data-editor.c:310 +#: src/ui/gui/data-editor.c:369 msgid "Delete the cases at the selected position(s)" msgstr "" -#: src/ui/gui/data-editor.c:325 +#: src/ui/gui/data-editor.c:386 msgid "Delete the variables at the selected position(s)" msgstr "" -#: src/ui/gui/data-editor.c:339 src/ui/gui/data-editor.c:1600 +#: src/ui/gui/data-editor.c:400 src/ui/gui/data-editor.c:1657 #: src/ui/gui/data-editor.glade:286 src/ui/gui/data-editor.glade:654 #, fuzzy msgid "Insert Variable" msgstr "Variableansicht" -#: src/ui/gui/data-editor.c:340 +#: src/ui/gui/data-editor.c:401 msgid "Create a new variable at the current position" msgstr "" -#: src/ui/gui/data-editor.c:358 src/ui/gui/data-editor.c:1653 +#: src/ui/gui/data-editor.c:419 src/ui/gui/data-editor.c:1710 #: src/ui/gui/data-editor.glade:642 #, fuzzy msgid "Insert Case" msgstr "_Stecken" -#: src/ui/gui/data-editor.c:359 +#: src/ui/gui/data-editor.c:420 msgid "Create a new case at the current position" msgstr "" -#: src/ui/gui/data-editor.c:379 +#: src/ui/gui/data-editor.c:440 #, fuzzy msgid "Goto Case" msgstr "_Stecken" -#: src/ui/gui/data-editor.c:380 +#: src/ui/gui/data-editor.c:441 msgid "Jump to a Case in the Data Sheet" msgstr "" -#: src/ui/gui/data-editor.c:399 +#: src/ui/gui/data-editor.c:460 #, fuzzy msgid "Weights" msgstr "Rechts" -#: src/ui/gui/data-editor.c:400 +#: src/ui/gui/data-editor.c:461 msgid "Weight cases by variable" msgstr "" -#: src/ui/gui/data-editor.c:409 src/ui/gui/data-editor.glade:323 +#: src/ui/gui/data-editor.c:470 src/ui/gui/data-editor.glade:323 msgid "Transpose" msgstr "" -#: src/ui/gui/data-editor.c:410 +#: src/ui/gui/data-editor.c:471 msgid "Transpose the cases with the variables" msgstr "" -#: src/ui/gui/data-editor.c:421 +#: src/ui/gui/data-editor.c:482 #, fuzzy msgid "Split" msgstr "Alle Datei" -#: src/ui/gui/data-editor.c:422 +#: src/ui/gui/data-editor.c:483 msgid "Split the active file" msgstr "" -#: src/ui/gui/data-editor.c:432 +#: src/ui/gui/data-editor.c:493 msgid "Sort" msgstr "" -#: src/ui/gui/data-editor.c:433 +#: src/ui/gui/data-editor.c:494 msgid "Sort cases in the active file" msgstr "" -#: src/ui/gui/data-editor.c:441 src/ui/gui/data-editor.glade:360 +#: src/ui/gui/data-editor.c:502 src/ui/gui/data-editor.glade:360 #: src/ui/gui/data-editor.glade:697 msgid "Select Cases" msgstr "" -#: src/ui/gui/data-editor.c:442 +#: src/ui/gui/data-editor.c:503 msgid "Select cases from the active file" msgstr "" -#: src/ui/gui/data-editor.c:451 +#: src/ui/gui/data-editor.c:512 msgid "Compute" msgstr "" -#: src/ui/gui/data-editor.c:452 +#: src/ui/gui/data-editor.c:513 #, fuzzy msgid "Compute new values for a variable" msgstr "Unpassend Wert für Variable" -#: src/ui/gui/data-editor.c:460 +#: src/ui/gui/data-editor.c:521 #, fuzzy msgid "Data File Comments" msgstr "Datei Fehler" -#: src/ui/gui/data-editor.c:461 +#: src/ui/gui/data-editor.c:522 msgid "Commentary text for the data file" msgstr "" -#: src/ui/gui/data-editor.c:469 src/ui/gui/data-editor.glade:267 +#: src/ui/gui/data-editor.c:530 src/ui/gui/data-editor.glade:267 #: src/ui/gui/data-editor.glade:601 msgid "Variables" msgstr "Variableansicht" -#: src/ui/gui/data-editor.c:470 +#: src/ui/gui/data-editor.c:531 #, fuzzy msgid "Jump to Variable" msgstr "Variableansicht" -#: src/ui/gui/data-editor.c:871 +#: src/ui/gui/data-editor.c:928 msgid "Font Selection" msgstr "Schriftwahlung" -#: src/ui/gui/data-editor.c:1078 +#: src/ui/gui/data-editor.c:1135 msgid "No Split" msgstr "" -#: src/ui/gui/data-editor.c:1087 +#: src/ui/gui/data-editor.c:1144 #, fuzzy msgid "Split by " msgstr "Alle Datei" -#: src/ui/gui/data-editor.c:1112 +#: src/ui/gui/data-editor.c:1169 msgid "Filter off" msgstr "" -#: src/ui/gui/data-editor.c:1125 +#: src/ui/gui/data-editor.c:1182 #, c-format msgid "Filter by %s" msgstr "" -#: src/ui/gui/data-editor.c:1143 +#: src/ui/gui/data-editor.c:1200 msgid "Weights off" msgstr "" -#: src/ui/gui/data-editor.c:1156 +#: src/ui/gui/data-editor.c:1213 #, c-format msgid "Weight by %s" msgstr "" -#: src/ui/gui/data-editor.c:1179 src/ui/gui/data-editor.c:1410 +#: src/ui/gui/data-editor.c:1236 src/ui/gui/data-editor.c:1467 #: src/ui/gui/data-editor.glade:512 msgid "Open" msgstr "Öffen" -#: src/ui/gui/data-editor.c:1180 +#: src/ui/gui/data-editor.c:1237 msgid "Open a data file" msgstr "" -#: src/ui/gui/data-editor.c:1188 src/ui/gui/data-editor.c:1295 +#: src/ui/gui/data-editor.c:1245 src/ui/gui/data-editor.c:1352 #: src/ui/gui/data-editor.glade:522 msgid "Save" msgstr "Speichen" -#: src/ui/gui/data-editor.c:1189 src/ui/gui/data-editor.c:1199 +#: src/ui/gui/data-editor.c:1246 src/ui/gui/data-editor.c:1256 #, fuzzy msgid "Save data to file" msgstr "Speichern unter" -#: src/ui/gui/data-editor.c:1198 +#: src/ui/gui/data-editor.c:1255 #, fuzzy msgid "Save As" msgstr "Speichern unter" -#: src/ui/gui/data-editor.c:1207 +#: src/ui/gui/data-editor.c:1264 msgid "New" msgstr "" -#: src/ui/gui/data-editor.c:1208 +#: src/ui/gui/data-editor.c:1265 msgid "New data file" msgstr "" -#: src/ui/gui/data-editor.c:1303 src/ui/gui/data-editor.c:1418 +#: src/ui/gui/data-editor.c:1360 src/ui/gui/data-editor.c:1475 msgid "System Files (*.sav)" msgstr "Systemedatein (*.sav)" -#: src/ui/gui/data-editor.c:1309 src/ui/gui/data-editor.c:1424 +#: src/ui/gui/data-editor.c:1366 src/ui/gui/data-editor.c:1481 msgid "Portable Files (*.por) " msgstr "Tragbardatein (*.por)" -#: src/ui/gui/data-editor.c:1315 src/ui/gui/data-editor.c:1430 +#: src/ui/gui/data-editor.c:1372 src/ui/gui/data-editor.c:1487 #: src/ui/gui/syntax-editor.c:138 src/ui/gui/syntax-editor.c:524 msgid "All Files" msgstr "Alle Datei" -#: src/ui/gui/data-editor.c:1323 +#: src/ui/gui/data-editor.c:1380 #, fuzzy msgid "System File" msgstr "Systemedatein (*.sav)" -#: src/ui/gui/data-editor.c:1328 +#: src/ui/gui/data-editor.c:1385 #, fuzzy msgid "Portable File" msgstr "Tragbardatein (*.por)" -#: src/ui/gui/data-editor.c:1593 +#: src/ui/gui/data-editor.c:1650 msgid "Sort Ascending" msgstr "" -#: src/ui/gui/data-editor.c:1596 +#: src/ui/gui/data-editor.c:1653 msgid "Sort Descending" msgstr "" diff --git a/po/pspp.pot b/po/pspp.pot index 583a4bb2..15f19e63 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: 2007-08-16 14:11+0800\n" +"POT-Creation-Date: 2007-08-18 08:25+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -3071,11 +3071,11 @@ msgstr "" msgid "Multivariate GLM not yet supported" msgstr "" -#: src/language/stats/glm.q:268 src/language/stats/regression.q:1153 +#: src/language/stats/glm.q:268 src/language/stats/regression.q:1155 msgid "Dependent variable must be numeric." msgstr "" -#: src/language/stats/glm.q:343 src/language/stats/regression.q:1252 +#: src/language/stats/glm.q:343 src/language/stats/regression.q:1254 msgid "No valid data found. This command was skipped." msgstr "" @@ -3329,9 +3329,9 @@ msgstr "" #: src/language/stats/regression.q:1031 msgid "" -"The dependent variable is equal to the independent variable. The least " -"sequares line is therefore Y=X. Standard errors and related statistics may " -"be meaningless." +"The dependent variable is equal to the independent variable.The least " +"squares line is therefore Y=X.Standard errors and related statistics may be " +"meaningless." msgstr "" #: src/language/stats/sort-cases.c:63 @@ -4232,209 +4232,209 @@ msgstr "" msgid "Style of bevel around the custom entry button" msgstr "" -#: src/ui/gui/data-editor.c:151 +#: src/ui/gui/data-editor.c:154 msgid "Transformations Pending" msgstr "" -#: src/ui/gui/data-editor.c:290 +#: src/ui/gui/data-editor.c:349 msgid "Labels" msgstr "" -#: src/ui/gui/data-editor.c:291 +#: src/ui/gui/data-editor.c:350 msgid "Show/hide value labels" msgstr "" -#: src/ui/gui/data-editor.c:309 src/ui/gui/data-editor.c:324 -#: src/ui/gui/data-editor.c:1603 src/ui/gui/data-editor.c:1656 +#: src/ui/gui/data-editor.c:368 src/ui/gui/data-editor.c:385 +#: src/ui/gui/data-editor.c:1660 src/ui/gui/data-editor.c:1713 msgid "Clear" msgstr "" -#: src/ui/gui/data-editor.c:310 +#: src/ui/gui/data-editor.c:369 msgid "Delete the cases at the selected position(s)" msgstr "" -#: src/ui/gui/data-editor.c:325 +#: src/ui/gui/data-editor.c:386 msgid "Delete the variables at the selected position(s)" msgstr "" -#: src/ui/gui/data-editor.c:339 src/ui/gui/data-editor.c:1600 +#: src/ui/gui/data-editor.c:400 src/ui/gui/data-editor.c:1657 #: src/ui/gui/data-editor.glade:286 src/ui/gui/data-editor.glade:654 msgid "Insert Variable" msgstr "" -#: src/ui/gui/data-editor.c:340 +#: src/ui/gui/data-editor.c:401 msgid "Create a new variable at the current position" msgstr "" -#: src/ui/gui/data-editor.c:358 src/ui/gui/data-editor.c:1653 +#: src/ui/gui/data-editor.c:419 src/ui/gui/data-editor.c:1710 #: src/ui/gui/data-editor.glade:642 msgid "Insert Case" msgstr "" -#: src/ui/gui/data-editor.c:359 +#: src/ui/gui/data-editor.c:420 msgid "Create a new case at the current position" msgstr "" -#: src/ui/gui/data-editor.c:379 +#: src/ui/gui/data-editor.c:440 msgid "Goto Case" msgstr "" -#: src/ui/gui/data-editor.c:380 +#: src/ui/gui/data-editor.c:441 msgid "Jump to a Case in the Data Sheet" msgstr "" -#: src/ui/gui/data-editor.c:399 +#: src/ui/gui/data-editor.c:460 msgid "Weights" msgstr "" -#: src/ui/gui/data-editor.c:400 +#: src/ui/gui/data-editor.c:461 msgid "Weight cases by variable" msgstr "" -#: src/ui/gui/data-editor.c:409 src/ui/gui/data-editor.glade:323 +#: src/ui/gui/data-editor.c:470 src/ui/gui/data-editor.glade:323 msgid "Transpose" msgstr "" -#: src/ui/gui/data-editor.c:410 +#: src/ui/gui/data-editor.c:471 msgid "Transpose the cases with the variables" msgstr "" -#: src/ui/gui/data-editor.c:421 +#: src/ui/gui/data-editor.c:482 msgid "Split" msgstr "" -#: src/ui/gui/data-editor.c:422 +#: src/ui/gui/data-editor.c:483 msgid "Split the active file" msgstr "" -#: src/ui/gui/data-editor.c:432 +#: src/ui/gui/data-editor.c:493 msgid "Sort" msgstr "" -#: src/ui/gui/data-editor.c:433 +#: src/ui/gui/data-editor.c:494 msgid "Sort cases in the active file" msgstr "" -#: src/ui/gui/data-editor.c:441 src/ui/gui/data-editor.glade:360 +#: src/ui/gui/data-editor.c:502 src/ui/gui/data-editor.glade:360 #: src/ui/gui/data-editor.glade:697 msgid "Select Cases" msgstr "" -#: src/ui/gui/data-editor.c:442 +#: src/ui/gui/data-editor.c:503 msgid "Select cases from the active file" msgstr "" -#: src/ui/gui/data-editor.c:451 +#: src/ui/gui/data-editor.c:512 msgid "Compute" msgstr "" -#: src/ui/gui/data-editor.c:452 +#: src/ui/gui/data-editor.c:513 msgid "Compute new values for a variable" msgstr "" -#: src/ui/gui/data-editor.c:460 +#: src/ui/gui/data-editor.c:521 msgid "Data File Comments" msgstr "" -#: src/ui/gui/data-editor.c:461 +#: src/ui/gui/data-editor.c:522 msgid "Commentary text for the data file" msgstr "" -#: src/ui/gui/data-editor.c:469 src/ui/gui/data-editor.glade:267 +#: src/ui/gui/data-editor.c:530 src/ui/gui/data-editor.glade:267 #: src/ui/gui/data-editor.glade:601 msgid "Variables" msgstr "" -#: src/ui/gui/data-editor.c:470 +#: src/ui/gui/data-editor.c:531 msgid "Jump to Variable" msgstr "" -#: src/ui/gui/data-editor.c:871 +#: src/ui/gui/data-editor.c:928 msgid "Font Selection" msgstr "" -#: src/ui/gui/data-editor.c:1078 +#: src/ui/gui/data-editor.c:1135 msgid "No Split" msgstr "" -#: src/ui/gui/data-editor.c:1087 +#: src/ui/gui/data-editor.c:1144 msgid "Split by " msgstr "" -#: src/ui/gui/data-editor.c:1112 +#: src/ui/gui/data-editor.c:1169 msgid "Filter off" msgstr "" -#: src/ui/gui/data-editor.c:1125 +#: src/ui/gui/data-editor.c:1182 #, c-format msgid "Filter by %s" msgstr "" -#: src/ui/gui/data-editor.c:1143 +#: src/ui/gui/data-editor.c:1200 msgid "Weights off" msgstr "" -#: src/ui/gui/data-editor.c:1156 +#: src/ui/gui/data-editor.c:1213 #, c-format msgid "Weight by %s" msgstr "" -#: src/ui/gui/data-editor.c:1179 src/ui/gui/data-editor.c:1410 +#: src/ui/gui/data-editor.c:1236 src/ui/gui/data-editor.c:1467 #: src/ui/gui/data-editor.glade:512 msgid "Open" msgstr "" -#: src/ui/gui/data-editor.c:1180 +#: src/ui/gui/data-editor.c:1237 msgid "Open a data file" msgstr "" -#: src/ui/gui/data-editor.c:1188 src/ui/gui/data-editor.c:1295 +#: src/ui/gui/data-editor.c:1245 src/ui/gui/data-editor.c:1352 #: src/ui/gui/data-editor.glade:522 msgid "Save" msgstr "" -#: src/ui/gui/data-editor.c:1189 src/ui/gui/data-editor.c:1199 +#: src/ui/gui/data-editor.c:1246 src/ui/gui/data-editor.c:1256 msgid "Save data to file" msgstr "" -#: src/ui/gui/data-editor.c:1198 +#: src/ui/gui/data-editor.c:1255 msgid "Save As" msgstr "" -#: src/ui/gui/data-editor.c:1207 +#: src/ui/gui/data-editor.c:1264 msgid "New" msgstr "" -#: src/ui/gui/data-editor.c:1208 +#: src/ui/gui/data-editor.c:1265 msgid "New data file" msgstr "" -#: src/ui/gui/data-editor.c:1303 src/ui/gui/data-editor.c:1418 +#: src/ui/gui/data-editor.c:1360 src/ui/gui/data-editor.c:1475 msgid "System Files (*.sav)" msgstr "" -#: src/ui/gui/data-editor.c:1309 src/ui/gui/data-editor.c:1424 +#: src/ui/gui/data-editor.c:1366 src/ui/gui/data-editor.c:1481 msgid "Portable Files (*.por) " msgstr "" -#: src/ui/gui/data-editor.c:1315 src/ui/gui/data-editor.c:1430 +#: src/ui/gui/data-editor.c:1372 src/ui/gui/data-editor.c:1487 #: src/ui/gui/syntax-editor.c:138 src/ui/gui/syntax-editor.c:524 msgid "All Files" msgstr "" -#: src/ui/gui/data-editor.c:1323 +#: src/ui/gui/data-editor.c:1380 msgid "System File" msgstr "" -#: src/ui/gui/data-editor.c:1328 +#: src/ui/gui/data-editor.c:1385 msgid "Portable File" msgstr "" -#: src/ui/gui/data-editor.c:1593 +#: src/ui/gui/data-editor.c:1650 msgid "Sort Ascending" msgstr "" -#: src/ui/gui/data-editor.c:1596 +#: src/ui/gui/data-editor.c:1653 msgid "Sort Descending" msgstr "" diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 3aec8fc0..a3d4f6a9 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,8 @@ +2007-08-18 John Darrington + + * clipboard.c clipboard.h data-editor.c: Added the ability to paste from + the clipboard into the data sheet. + 2007-08-16 John Darrington * output-viewer.c output-viewer.h output-viewer.glade (new files) diff --git a/src/ui/gui/clipboard.c b/src/ui/gui/clipboard.c index b7ed1334..1661d413 100644 --- a/src/ui/gui/clipboard.c +++ b/src/ui/gui/clipboard.c @@ -26,7 +26,9 @@ #include #include #include +#include "helper.h" #include +#include "data-editor.h" /* A casereader and dictionary holding the data currently in the clip */ @@ -307,3 +309,72 @@ data_sheet_update_clipboard (GtkSheet *sheet) clipboard_clear_cb (clipboard, sheet); } + + +/* A callback for when clipboard contents have been received */ +void +data_sheet_contents_received_callback (GtkClipboard *clipboard, + GtkSelectionData *sd, + gpointer data) +{ + struct data_editor *de = data; + + gint count = 0; + gint row, column; + gint next_row, next_column; + gint first_column; + char *c; + GtkSheet *data_sheet ; + PsppireDataStore *data_store; + + if ( sd->length < 0 ) + return; + + if ( sd->type != gdk_atom_intern ("UTF8_STRING", FALSE)) + return; + + c = (char *) sd->data; + + /* Paste text to selected position */ + data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet")); + data_store = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet)); + + gtk_sheet_get_active_cell (data_sheet, &row, &column); + + g_return_if_fail (row >= 0); + g_return_if_fail (column >= 0); + + first_column = column; + next_row = row; + next_column = column; + while (count < sd->length) + { + char *s = c; + + row = next_row; + column = next_column; + while (*c != '\t' && *c != '\n' && count < sd->length) + { + c++; + count++; + } + if ( *c == '\t') + { + next_row = row ; + next_column = column + 1; + } + else if ( *c == '\n') + { + next_row = row + 1; + next_column = first_column; + } + *c++ = '\0'; + count++; + + /* Append some new cases if pasting beyond the last row */ + if ( row >= psppire_data_store_get_case_count (data_store)) + psppire_data_store_insert_new_case (data_store, row); + + gtk_sheet_set_cell_text (data_sheet, row, column, s); + } +} diff --git a/src/ui/gui/clipboard.h b/src/ui/gui/clipboard.h index 1cdffe8f..b7bd5782 100644 --- a/src/ui/gui/clipboard.h +++ b/src/ui/gui/clipboard.h @@ -23,6 +23,10 @@ void data_sheet_set_clip (GtkSheet *data_sheet); +void data_sheet_contents_received_callback (GtkClipboard *clipboard, + GtkSelectionData *sd, + gpointer data); + #endif /* CLIPBOARD_H */ diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index 50c181ee..7cba02f2 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -54,6 +54,9 @@ #include "psppire-var-store.h" static void on_edit_copy (GtkMenuItem *, gpointer); +static void on_edit_cut (GtkMenuItem *, gpointer); +static void on_edit_paste (GtkAction *a, gpointer data); + static void create_data_sheet_variable_popup_menu (struct data_editor *); static void create_data_sheet_cases_popup_menu (struct data_editor *); @@ -88,7 +91,7 @@ static void on_weight_change (GObject *, gint, gpointer); static void on_filter_change (GObject *, gint, gpointer); static void on_split_change (PsppireDict *, gpointer); -static void data_var_select (GtkNotebook *notebook, +static void on_switch_sheet (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data); @@ -219,6 +222,96 @@ datum_entry_activate (GtkEntry *entry, gpointer data) psppire_data_store_set_string (store, text, row, column); } + +/* Update the Edit->Paste menuitem + If PAGE is not -1 , then it should be set to the current page of + the data editors notebook widget. + If -1, then it'll be queried. +*/ +static void +update_paste_menuitem (struct data_editor *de, gint page) +{ + GtkWidget * edit_paste = get_widget_assert (de->xml, "edit_paste"); + GtkWidget *notebook = get_widget_assert (de->xml, "notebook"); + GtkSheet * data_sheet ; + gint row, column; + + if ( page < 0 ) + page = gtk_notebook_get_current_page (GTK_NOTEBOOK(notebook)); + + + if ( PAGE_VAR_SHEET == page ) + { + /* We don't yet support pasting to the var sheet */ + gtk_widget_set_sensitive (edit_paste, FALSE); + return; + } + + data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet")); + + gtk_sheet_get_active_cell (data_sheet, &row, &column); + + if ( row < 0 || column < 0 ) + gtk_widget_set_sensitive (edit_paste, FALSE); + else + gtk_widget_set_sensitive (edit_paste, TRUE); +} + +/* Update the Edit->Cut and Edit->Copy menuitems + If PAGE is not -1 , then it should be set to the current page of + the data editors notebook widget. + If -1, then it'll be queried. +*/ +static void +update_cut_copy_menuitem (struct data_editor *de, gint page) +{ + GtkWidget * edit_copy = get_widget_assert (de->xml, "edit_copy"); + GtkWidget * edit_cut = get_widget_assert (de->xml, "edit_cut"); + GtkWidget *notebook = get_widget_assert (de->xml, "notebook"); + GtkSheet * data_sheet ; + gint row, column; + + if ( page < 0 ) + page = gtk_notebook_get_current_page (GTK_NOTEBOOK(notebook)); + + + if ( PAGE_VAR_SHEET == page ) + { + /* We don't yet support copying from the var sheet */ + gtk_widget_set_sensitive (edit_copy, FALSE); + gtk_widget_set_sensitive (edit_cut, FALSE); + return; + } + + data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet")); + + gtk_sheet_get_active_cell (data_sheet, &row, &column); + + if ( row < 0 || column < 0 ) + { + gtk_widget_set_sensitive (edit_copy, FALSE); + gtk_widget_set_sensitive (edit_cut, FALSE); + return; + } + + gtk_widget_set_sensitive (edit_copy, TRUE); + gtk_widget_set_sensitive (edit_cut, TRUE); +} + + +/* Callback for when the datasheet's active cell becomes active/inactive */ +static gboolean +on_data_sheet_activate_change (GtkSheet *sheet, + gint row, gint column, gpointer data) +{ + struct data_editor *de = data; + + update_paste_menuitem (de, -1); + update_cut_copy_menuitem (de, -1); + + return TRUE; +} + extern struct dataset *the_dataset; /* @@ -248,6 +341,14 @@ new_data_editor (void) var_sheet = GTK_SHEET (get_widget_assert (de->xml, "variable_sheet")); data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet")); + + g_signal_connect (G_OBJECT (data_sheet), "activate", + G_CALLBACK (on_data_sheet_activate_change), de); + + g_signal_connect (G_OBJECT (data_sheet), "deactivate", + G_CALLBACK (on_data_sheet_activate_change), de); + + vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet)); g_assert(vs); /* Traps a possible bug in win32 build */ @@ -282,6 +383,10 @@ new_data_editor (void) "activate", G_CALLBACK (on_edit_copy), de); + g_signal_connect (get_widget_assert (de->xml, "edit_cut"), + "activate", + G_CALLBACK (on_edit_cut), de); + register_data_editor_actions (de); @@ -316,6 +421,8 @@ new_data_editor (void) gtk_action_connect_proxy (de->delete_cases, get_widget_assert (de->xml, "edit_clear-cases")); + g_signal_connect (get_widget_assert (de->xml, "edit_paste"), "activate", + G_CALLBACK (on_edit_paste), de); gtk_action_set_visible (de->delete_cases, FALSE); @@ -620,7 +727,7 @@ new_data_editor (void) g_signal_connect (get_widget_assert (de->xml, "notebook"), "switch-page", - G_CALLBACK (data_var_select), de); + G_CALLBACK (on_switch_sheet), de); g_signal_connect (get_widget_assert (de->xml, "view_statusbar"), @@ -699,12 +806,6 @@ new_data_editor (void) g_signal_connect (G_OBJECT (data_sheet), "button-event-row", G_CALLBACK (popup_cases_menu), de); - /* The "switch-page" signal does get emitted unless the page actually - changes. But the state is indeterminate at startup. Therefore we - must explicitly change it to one state, then the other */ - data_editor_select_sheet (de, PAGE_VAR_SHEET); - data_editor_select_sheet (de, PAGE_DATA_SHEET); - return de; } @@ -768,9 +869,9 @@ new_data_window (GtkMenuItem *menuitem, gpointer parent) window_create (WINDOW_DATA, NULL); } - +/* Callback for when the datasheet/varsheet is selected */ static void -data_var_select (GtkNotebook *notebook, +on_switch_sheet (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data) @@ -779,14 +880,12 @@ data_var_select (GtkNotebook *notebook, GtkWidget *view_data = get_widget_assert (de->xml, "view_data"); GtkWidget *view_variables = get_widget_assert (de->xml, "view_variables"); - GtkWidget *edit_copy = get_widget_assert (de->xml, "edit_copy"); switch (page_num) { case PAGE_VAR_SHEET: gtk_widget_hide (view_variables); gtk_widget_show (view_data); - gtk_widget_set_sensitive (edit_copy, FALSE); gtk_action_set_sensitive (de->insert_variable, TRUE); gtk_action_set_sensitive (de->insert_case, FALSE); gtk_action_set_sensitive (de->invoke_goto_dialog, FALSE); @@ -796,12 +895,14 @@ data_var_select (GtkNotebook *notebook, gtk_widget_show (view_data); gtk_action_set_sensitive (de->invoke_goto_dialog, TRUE); gtk_action_set_sensitive (de->insert_case, TRUE); - gtk_widget_set_sensitive (edit_copy, TRUE); break; default: g_assert_not_reached (); break; } + + update_paste_menuitem (de, page_num); + update_cut_copy_menuitem (de, page_num); } @@ -1726,6 +1827,17 @@ popup_cases_menu (GtkSheet *sheet, gint row, } +static void +on_edit_paste (GtkAction *a, gpointer data) +{ + GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); + + gtk_clipboard_request_contents (clipboard, + gdk_atom_intern ("UTF8_STRING", TRUE), + data_sheet_contents_received_callback, + data); +} + static void on_edit_copy (GtkMenuItem *m, gpointer data) @@ -1739,3 +1851,73 @@ on_edit_copy (GtkMenuItem *m, gpointer data) } + +static void +on_edit_cut (GtkMenuItem *m, gpointer data) +{ + struct data_editor *de = data; + gint max_rows, max_columns; + gint r; + GtkSheetRange range; + PsppireDataStore *ds; + GtkSheet *data_sheet = GTK_SHEET (get_widget_assert (de->xml, + "data_sheet")); + + data_sheet_set_clip (data_sheet); + + + /* Now blank all the cells */ + gtk_sheet_get_selected_range (data_sheet, &range); + + ds = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet)); + + + /* If nothing selected, then use active cell */ + if ( range.row0 < 0 || range.col0 < 0 ) + { + gint row, col; + gtk_sheet_get_active_cell (data_sheet, &row, &col); + + range.row0 = range.rowi = row; + range.col0 = range.coli = col; + } + + /* The sheet range can include cells that do not include data. + Exclude them from the range. */ + max_rows = psppire_data_store_get_case_count (ds); + if (range.rowi >= max_rows) + { + if (max_rows == 0) + return; + range.rowi = max_rows - 1; + } + + max_columns = dict_get_var_cnt (ds->dict->dict); + if (range.coli >= max_columns) + { + if (max_columns == 0) + return; + range.coli = max_columns - 1; + } + + g_return_if_fail (range.rowi >= range.row0); + g_return_if_fail (range.row0 >= 0); + g_return_if_fail (range.coli >= range.col0); + g_return_if_fail (range.col0 >= 0); + + + for (r = range.row0; r <= range.rowi ; ++r ) + { + gint c; + + for (c = range.col0 ; c <= range.coli; ++c) + { + psppire_data_store_set_string (ds, "", r, c); + } + } + + /* and remove the selection */ + gtk_sheet_unselect_range (data_sheet); +} + +