gui: clipboard CUT and COPY store same data with/without label
[pspp] / src / ui / gui / psppire-data-editor.c
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2008, 2009, 2010, 2011, 2012, 2016,
3    2017, 2019 Free Software Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
17
18 #include <config.h>
19
20 #include "ui/gui/psppire-data-editor.h"
21
22 #include <gtk/gtk.h>
23
24 #include "data/datasheet.h"
25 #include "data/value-labels.h"
26 #include "libpspp/range-set.h"
27 #include "libpspp/str.h"
28
29 #include "ui/gui/helper.h"
30 #include "ui/gui/var-display.h"
31 #include "ui/gui/val-labs-dialog.h"
32 #include "ui/gui/missing-val-dialog.h"
33 #include "ui/gui/var-type-dialog.h"
34 #include "ui/gui/value-variant.h"
35 #include "ui/gui/psppire-dict.h"
36 #include "ui/gui/psppire-data-store.h"
37 #include "ui/gui/psppire-data-window.h"
38 #include "ui/gui/psppire-value-entry.h"
39 #include "ui/gui/psppire-conf.h"
40 #include "ui/gui/psppire-variable-sheet.h"
41 #include "ui/gui/psppire-data-sheet.h"
42
43
44 #include <ssw-sheet.h>
45
46 #include <gettext.h>
47 #define _(msgid) gettext (msgid)
48
49 static void psppire_data_editor_class_init          (PsppireDataEditorClass *klass);
50 static void psppire_data_editor_init                (PsppireDataEditor      *de);
51
52 static void refresh_entry (PsppireDataEditor *);
53
54 GType
55 psppire_data_editor_get_type (void)
56 {
57   static GType de_type = 0;
58
59   if (!de_type)
60     {
61       static const GTypeInfo de_info =
62       {
63         sizeof (PsppireDataEditorClass),
64         NULL, /* base_init */
65         NULL, /* base_finalize */
66         (GClassInitFunc) psppire_data_editor_class_init,
67         NULL, /* class_finalize */
68         NULL, /* class_data */
69         sizeof (PsppireDataEditor),
70         0,
71         (GInstanceInitFunc) psppire_data_editor_init,
72       };
73
74       de_type = g_type_register_static (GTK_TYPE_NOTEBOOK, "PsppireDataEditor",
75                                         &de_info, 0);
76     }
77
78   return de_type;
79 }
80
81 static GObjectClass * parent_class = NULL;
82
83 static void
84 psppire_data_editor_finalize (GObject *obj)
85 {
86   PsppireDataEditor *de = (PsppireDataEditor *) obj;
87   if (de->font)
88     pango_font_description_free (de->font);
89
90   /* Chain up to the parent class */
91   G_OBJECT_CLASS (parent_class)->finalize (obj);
92 }
93
94 static void
95 psppire_data_editor_dispose (GObject *obj)
96 {
97   PsppireDataEditor *de = (PsppireDataEditor *) obj;
98
99   if (de->dispose_has_run)
100     return;
101
102   de->dispose_has_run = TRUE;
103
104   g_object_unref (de->data_store);
105   g_object_unref (de->dict);
106
107   /* Chain up to the parent class */
108   G_OBJECT_CLASS (parent_class)->dispose (obj);
109 }
110
111 enum
112   {
113     PROP_0,
114     PROP_DATA_STORE,
115     PROP_DICTIONARY,
116     PROP_VALUE_LABELS,
117     PROP_SPLIT_WINDOW
118   };
119
120 static void
121 psppire_data_editor_refresh_model (PsppireDataEditor *de)
122 {
123 }
124
125
126 static void
127 psppire_data_editor_set_property (GObject         *object,
128                                   guint            prop_id,
129                                   const GValue    *value,
130                                   GParamSpec      *pspec)
131 {
132   PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (object);
133
134   switch (prop_id)
135     {
136     case PROP_SPLIT_WINDOW:
137       de->split = g_value_get_boolean (value);
138       g_object_set (de->data_sheet, "split", de->split, NULL);
139       g_object_set (de->var_sheet, "split", de->split, NULL);
140       break;
141     case PROP_DATA_STORE:
142       if (de->data_store)
143         {
144           g_signal_handlers_disconnect_by_func (de->data_store,
145                                                 G_CALLBACK (refresh_entry),
146                                                 de);
147           g_object_unref (de->data_store);
148         }
149
150       de->data_store = g_value_get_pointer (value);
151       g_object_ref (de->data_store);
152
153       g_object_set (de->data_sheet, "data-model", de->data_store, NULL);
154       psppire_data_editor_refresh_model (de);
155
156       g_signal_connect_swapped (de->data_sheet, "selection-changed",
157                                 G_CALLBACK (refresh_entry),
158                                 de);
159
160       g_signal_connect_swapped (de->data_store, "case-changed",
161                                 G_CALLBACK (refresh_entry), de);
162
163       break;
164     case PROP_DICTIONARY:
165       if (de->dict)
166         g_object_unref (de->dict);
167       de->dict = g_value_get_pointer (value);
168       g_object_ref (de->dict);
169
170       g_object_set (de->var_sheet, "data-model", de->dict, NULL);
171       break;
172
173     case PROP_VALUE_LABELS:
174       {
175         gboolean l = g_value_get_boolean (value);
176         de->use_value_labels = l;
177         g_object_set (de->data_sheet, "forward-conversion",
178                       l ?
179                       psppire_data_store_value_to_string_with_labels :
180                       psppire_data_store_value_to_string,
181                       NULL);
182       }
183       break;
184
185     default:
186       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
187       break;
188     };
189 }
190
191 static void
192 psppire_data_editor_get_property (GObject         *object,
193                                   guint            prop_id,
194                                   GValue          *value,
195                                   GParamSpec      *pspec)
196 {
197   PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (object);
198
199   switch (prop_id)
200     {
201     case PROP_SPLIT_WINDOW:
202       g_value_set_boolean (value, de->split);
203       break;
204     case PROP_DATA_STORE:
205       g_value_set_pointer (value, de->data_store);
206       break;
207     case PROP_DICTIONARY:
208       g_value_set_pointer (value, de->dict);
209       break;
210     case PROP_VALUE_LABELS:
211       g_value_set_boolean (value, de->use_value_labels);
212       break;
213     default:
214       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
215       break;
216     }
217 }
218
219 static void
220 psppire_data_editor_switch_page (GtkNotebook     *notebook,
221                                  GtkWidget *w,
222                                  guint            page_num)
223 {
224   GTK_NOTEBOOK_CLASS (parent_class)->switch_page (notebook, w, page_num);
225 }
226
227 static void
228 psppire_data_editor_set_focus_child (GtkContainer *container,
229                                      GtkWidget    *widget)
230 {
231   GTK_CONTAINER_CLASS (parent_class)->set_focus_child (container, widget);
232 }
233
234
235 static gboolean
236 on_key_press (GtkWidget *w, GdkEventKey *e)
237 {
238   PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (w);
239   if (e->keyval == GDK_KEY_F2 &&
240       PSPPIRE_DATA_EDITOR_DATA_VIEW == gtk_notebook_get_current_page (GTK_NOTEBOOK (de)))
241     {
242       gtk_widget_grab_focus (de->datum_entry);
243     }
244
245   return FALSE;
246 }
247
248 static void
249 psppire_data_editor_class_init (PsppireDataEditorClass *klass)
250 {
251   GParamSpec *data_store_spec ;
252   GParamSpec *dict_spec ;
253   GParamSpec *value_labels_spec;
254   GParamSpec *split_window_spec;
255
256   GObjectClass *object_class = G_OBJECT_CLASS (klass);
257   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
258   GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
259   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
260
261   parent_class = g_type_class_peek_parent (klass);
262
263   object_class->dispose = psppire_data_editor_dispose;
264   object_class->finalize = psppire_data_editor_finalize;
265   object_class->set_property = psppire_data_editor_set_property;
266   object_class->get_property = psppire_data_editor_get_property;
267
268   container_class->set_focus_child = psppire_data_editor_set_focus_child;
269   notebook_class->switch_page = psppire_data_editor_switch_page;
270   widget_class->key_press_event = on_key_press;
271
272   data_store_spec =
273     g_param_spec_pointer ("data-store",
274                           "Data Store",
275                           "A pointer to the data store associated with this editor",
276                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE);
277
278   g_object_class_install_property (object_class,
279                                    PROP_DATA_STORE,
280                                    data_store_spec);
281
282   dict_spec =
283     g_param_spec_pointer ("dictionary",
284                           "Dictionary",
285                           "A pointer to the dictionary associated with this editor",
286                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE);
287
288   g_object_class_install_property (object_class,
289                                    PROP_DICTIONARY,
290                                    dict_spec);
291
292   value_labels_spec =
293     g_param_spec_boolean ("value-labels",
294                          "Value Labels",
295                          "Whether or not the data sheet should display labels instead of values",
296                           FALSE,
297                          G_PARAM_WRITABLE | G_PARAM_READABLE);
298
299   g_object_class_install_property (object_class,
300                                    PROP_VALUE_LABELS,
301                                    value_labels_spec);
302
303
304   split_window_spec =
305     g_param_spec_boolean ("split",
306                           "Split Window",
307                           "True iff the data sheet is split",
308                           FALSE,
309                           G_PARAM_READABLE | G_PARAM_WRITABLE);
310
311   g_object_class_install_property (object_class,
312                                    PROP_SPLIT_WINDOW,
313                                    split_window_spec);
314 }
315
316
317 static void
318 on_var_sheet_var_double_clicked (void *var_sheet, gint dict_index,
319                                  PsppireDataEditor *de)
320 {
321   gtk_notebook_set_current_page (GTK_NOTEBOOK (de),
322                                  PSPPIRE_DATA_EDITOR_DATA_VIEW);
323
324   ssw_sheet_scroll_to (SSW_SHEET (de->data_sheet), dict_index, -1);
325 }
326
327
328 static void
329 on_data_sheet_var_double_clicked (SswSheet *data_sheet, gint dict_index,
330                                  PsppireDataEditor *de)
331 {
332
333   gtk_notebook_set_current_page (GTK_NOTEBOOK (de),
334                                  PSPPIRE_DATA_EDITOR_VARIABLE_VIEW);
335
336   ssw_sheet_scroll_to (SSW_SHEET (de->var_sheet), -1, dict_index);
337 }
338
339
340
341 /* Refreshes 'de->cell_ref_label' and 'de->datum_entry' from the currently
342    active cell or cells. */
343 static void
344 refresh_entry (PsppireDataEditor *de)
345 {
346   gint row, col;
347   if (ssw_sheet_get_active_cell (SSW_SHEET (de->data_sheet), &col, &row))
348     {
349       union value val;
350       const struct variable *var = psppire_dict_get_variable (de->dict, col);
351       if (var == NULL)
352         return;
353
354       psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (de->datum_entry), var);
355
356       int width = var_get_width (var);
357       if (! psppire_data_store_get_value (PSPPIRE_DATA_STORE (de->data_store),
358                                           row, var, &val))
359         return;
360
361       psppire_value_entry_set_value (PSPPIRE_VALUE_ENTRY (de->datum_entry),
362                                      &val, width);
363       value_destroy (&val, width);
364     }
365 }
366
367 static void
368 on_datum_entry_activate (GtkEntry *entry, PsppireDataEditor *de)
369 {
370   gint row, col;
371   if (ssw_sheet_get_active_cell (SSW_SHEET (de->data_sheet), &col, &row))
372     {
373       union value val;
374       const struct variable *var = psppire_dict_get_variable (de->dict, col);
375       if (var == NULL)
376         return;
377
378       int width = var_get_width (var);
379       value_init (&val, width);
380       if (psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (de->datum_entry),
381                                          &val, width))
382         {
383           psppire_data_store_set_value (de->data_store, row, var, &val);
384         }
385       value_destroy (&val, width);
386
387       gtk_widget_grab_focus (de->data_sheet);
388       ssw_sheet_set_active_cell (SSW_SHEET (de->data_sheet), col, row, NULL);
389     }
390 }
391
392
393 /* Called when the active cell or the selection in the data sheet changes */
394 static void
395 on_data_selection_change (PsppireDataEditor *de, SswRange *sel)
396 {
397   gchar *ref_cell_text = NULL;
398
399   gint n_cases = abs (sel->end_y - sel->start_y) + 1;
400   gint n_vars = abs (sel->end_x - sel->start_x) + 1;
401
402   if (n_cases == 1 && n_vars == 1)
403     {
404       /* A single cell is selected */
405       const struct variable *var = psppire_dict_get_variable (de->dict, sel->start_x);
406
407       if (var)
408         ref_cell_text = g_strdup_printf (_("%d : %s"),
409                                          sel->start_y + 1, var_get_name (var));
410     }
411   else
412     {
413       struct string s;
414
415       /* The glib string library does not understand the ' printf modifier
416          on all platforms, but the "struct string" library does (because
417          Gnulib fixes that problem), so use the latter.  */
418       ds_init_empty (&s);
419       ds_put_format (&s, ngettext ("%'d case", "%'d cases", n_cases),
420                      n_cases);
421       ds_put_byte (&s, ' ');
422       ds_put_unichar (&s, 0xd7); /* U+00D7 MULTIPLICATION SIGN */
423       ds_put_byte (&s, ' ');
424       ds_put_format (&s, ngettext ("%'d variable", "%'d variables",
425                                    n_vars),
426                      n_vars);
427       ref_cell_text = ds_steal_cstr (&s);
428     }
429
430   gtk_label_set_label (GTK_LABEL (de->cell_ref_label),
431                        ref_cell_text ? ref_cell_text : "");
432
433   g_free (ref_cell_text);
434 }
435
436
437 static void set_font_recursively (GtkWidget *w, gpointer data);
438
439 \f
440
441 void
442 psppire_data_editor_data_delete_variables (PsppireDataEditor *de)
443 {
444   psppire_data_sheet_delete_variables (PSPPIRE_DATA_SHEET (de->data_sheet));
445 }
446
447 void
448 psppire_data_editor_var_delete_variables (PsppireDataEditor *de)
449 {
450   SswRange *range = SSW_SHEET(de->var_sheet)->selection;
451
452   if (range->start_x > range->end_x)
453     {
454       gint temp = range->start_x;
455       range->start_x = range->end_x;
456       range->end_x = temp;
457     }
458
459   psppire_dict_delete_variables (de->dict, range->start_y,
460                                  (range->end_y - range->start_y + 1));
461
462   gtk_widget_queue_draw (GTK_WIDGET (de->var_sheet));
463 }
464
465 void
466 psppire_data_editor_insert_new_case_at_posn  (PsppireDataEditor *de, gint posn)
467 {
468   g_return_if_fail (posn >= 0);
469
470   psppire_data_store_insert_new_case (de->data_store, posn);
471
472   gtk_widget_queue_draw (GTK_WIDGET (de->data_sheet));
473 }
474
475 void
476 psppire_data_editor_insert_new_variable_at_posn (PsppireDataEditor *de, gint posn)
477 {
478   psppire_data_sheet_insert_new_variable_at_posn (PSPPIRE_DATA_SHEET (de->data_sheet), posn);
479 }
480
481 static void
482 psppire_data_editor_init (PsppireDataEditor *de)
483 {
484   GtkWidget *hbox;
485   gchar *fontname = NULL;
486
487   GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (de));
488   gtk_style_context_add_class (context, "psppire-data-editor");
489
490   de->dispose_has_run = FALSE;
491
492   de->font = NULL;
493
494   g_object_set (de, "tab-pos", GTK_POS_BOTTOM, NULL);
495
496   de->cell_ref_label = gtk_label_new ("");
497   gtk_label_set_width_chars (GTK_LABEL (de->cell_ref_label), 25);
498   gtk_widget_set_valign (de->cell_ref_label, GTK_ALIGN_CENTER);
499
500   de->datum_entry = psppire_value_entry_new ();
501   g_signal_connect (de->datum_entry, "edit-done",
502                     G_CALLBACK (on_datum_entry_activate), de);
503
504   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
505   gtk_box_pack_start (GTK_BOX (hbox), de->cell_ref_label, FALSE, FALSE, 0);
506   gtk_box_pack_start (GTK_BOX (hbox), de->datum_entry, TRUE, TRUE, 0);
507
508   de->split = FALSE;
509   de->use_value_labels = FALSE;
510   de->data_sheet = psppire_data_sheet_new ();
511
512   GtkWidget *data_button = ssw_sheet_get_button (SSW_SHEET (de->data_sheet));
513   gtk_button_set_label (GTK_BUTTON (data_button), _("Case"));
514   de->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
515   gtk_box_pack_start (GTK_BOX (de->vbox), hbox, FALSE, FALSE, 0);
516   gtk_box_pack_start (GTK_BOX (de->vbox), de->data_sheet, TRUE, TRUE, 0);
517
518
519   g_signal_connect_swapped (de->data_sheet, "selection-changed",
520                     G_CALLBACK (on_data_selection_change), de);
521
522   gtk_notebook_append_page (GTK_NOTEBOOK (de), de->vbox,
523                             gtk_label_new_with_mnemonic (_("Data View")));
524
525   gtk_widget_show_all (de->vbox);
526
527   de->var_sheet = psppire_variable_sheet_new ();
528
529   GtkWidget *var_button = ssw_sheet_get_button (SSW_SHEET (de->var_sheet));
530   gtk_button_set_label (GTK_BUTTON (var_button), _("Variable"));
531
532   gtk_notebook_append_page (GTK_NOTEBOOK (de), de->var_sheet,
533                             gtk_label_new_with_mnemonic (_("Variable View")));
534
535   gtk_widget_show_all (de->var_sheet);
536
537   g_signal_connect (de->var_sheet, "row-header-double-clicked",
538                     G_CALLBACK (on_var_sheet_var_double_clicked), de);
539
540   g_signal_connect (de->data_sheet, "column-header-double-clicked",
541                     G_CALLBACK (on_data_sheet_var_double_clicked), de);
542
543   g_object_set (de, "can-focus", FALSE, NULL);
544
545   if (psppire_conf_get_string (psppire_conf_new (),
546                            "Data Editor", "font",
547                                 &fontname))
548     {
549       de->font = pango_font_description_from_string (fontname);
550       g_free (fontname);
551       set_font_recursively (GTK_WIDGET (de), de->font);
552     }
553
554   gtk_widget_add_events (GTK_WIDGET (de), GDK_KEY_PRESS_MASK);
555 }
556
557 GtkWidget*
558 psppire_data_editor_new (PsppireDict *dict,
559                          PsppireDataStore *data_store)
560 {
561   return  g_object_new (PSPPIRE_DATA_EDITOR_TYPE,
562                         "dictionary",  dict,
563                         "data-store",  data_store,
564                         NULL);
565 }
566 \f
567 /* Turns the visible grid on or off, according to GRID_VISIBLE, for DE's data
568    sheet(s) and variable sheet. */
569 void
570 psppire_data_editor_show_grid (PsppireDataEditor *de, gboolean grid_visible)
571 {
572   g_object_set (SSW_SHEET (de->var_sheet), "gridlines", grid_visible, NULL);
573   g_object_set (SSW_SHEET (de->data_sheet), "gridlines", grid_visible, NULL);
574 }
575
576
577 static void
578 set_font_recursively (GtkWidget *w, gpointer data)
579 {
580   PangoFontDescription *font_desc = data;
581
582   GtkStyleContext *style = gtk_widget_get_style_context (w);
583   GtkCssProvider *cssp = gtk_css_provider_new ();
584
585   /* The Pango font description as string has a different syntax than the
586      css style description:
587      Pango: Courier Italic 12
588      CSS: italic 12pt Courier
589      I ignore Weight, Style and Variant and just take family and size */
590   const gchar *str = pango_font_description_get_family (font_desc);
591   gint size = pango_font_description_get_size (font_desc);
592   gchar *css =
593     g_strdup_printf ("* {font: %dpt %s}", size/PANGO_SCALE, str);
594
595   GError *err = NULL;
596   gtk_css_provider_load_from_data (cssp, css, -1, &err);
597   if (err)
598     {
599       g_warning ("Failed to load font css \"%s\": %s", css, err->message);
600       g_error_free (err);
601     }
602   g_free (css);
603
604   gtk_style_context_add_provider (style,
605                                   GTK_STYLE_PROVIDER (cssp),
606                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
607   g_object_unref (cssp);
608
609
610   if (GTK_IS_CONTAINER (w))
611     gtk_container_foreach (GTK_CONTAINER (w), set_font_recursively, font_desc);
612 }
613
614 /* Sets FONT_DESC as the font used by the data sheet(s) and variable sheet. */
615 void
616 psppire_data_editor_set_font (PsppireDataEditor *de, PangoFontDescription *font_desc)
617 {
618   gchar *font_name;
619   set_font_recursively (GTK_WIDGET (de), font_desc);
620
621   if (de->font)
622     pango_font_description_free (de->font);
623   de->font = pango_font_description_copy (font_desc);
624   font_name = pango_font_description_to_string (de->font);
625
626   psppire_conf_set_string (psppire_conf_new (),
627                            "Data Editor", "font",
628                            font_name);
629   g_free (font_name);
630 }
631
632 /* If SPLIT is TRUE, splits DE's data sheet into four panes.
633    If SPLIT is FALSE, un-splits it into a single pane. */
634 void
635 psppire_data_editor_split_window (PsppireDataEditor *de, gboolean split)
636 {
637   g_object_set (de, "split", split, NULL);
638 }
639
640 /* Makes the variable with dictionary index DICT_INDEX in DE's dictionary
641    visible and selected in the active view in DE. */
642 void
643 psppire_data_editor_goto_variable (PsppireDataEditor *de, gint dict_index)
644 {
645   gint page = gtk_notebook_get_current_page (GTK_NOTEBOOK (de));
646
647   switch (page)
648     {
649       case PSPPIRE_DATA_EDITOR_DATA_VIEW:
650         ssw_sheet_scroll_to (SSW_SHEET (de->data_sheet), dict_index, -1);
651         ssw_sheet_set_active_cell (SSW_SHEET (de->data_sheet), dict_index, -1, NULL);
652         break;
653       case PSPPIRE_DATA_EDITOR_VARIABLE_VIEW:
654         ssw_sheet_scroll_to (SSW_SHEET (de->var_sheet), -1, dict_index);
655         ssw_sheet_set_active_cell (SSW_SHEET (de->var_sheet), -1, dict_index, NULL);
656         break;
657     }
658 }
659
660 /* Set the datum at COL, ROW, to that contained in VALUE.
661  */
662 static void
663 store_set_datum (GtkTreeModel *model, gint col, gint row,
664                          const GValue *value)
665 {
666   PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
667   GVariant *v = g_value_get_variant (value);
668   union value uv;
669   value_variant_get (&uv, v);
670   const struct variable *var = psppire_dict_get_variable (store->dict, col);
671   psppire_data_store_set_value (store, row, var, &uv);
672   value_destroy_from_variant (&uv, v);
673 }
674
675 void
676 psppire_data_editor_paste (PsppireDataEditor *de)
677 {
678   SswSheet *sheet = SSW_SHEET (de->data_sheet);
679   GtkClipboard *clip =
680     gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (sheet)),
681                                    GDK_SELECTION_CLIPBOARD);
682
683   ssw_sheet_paste (sheet, clip, store_set_datum);
684 }