e852b7d92b403d2d1647c7ea8b863cddd648def5
[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         g_object_set (de->data_sheet, "forward-conversion",
177                       l ?
178                       psppire_data_store_value_to_string_with_labels :
179                       psppire_data_store_value_to_string,
180                       NULL);
181       }
182       break;
183
184     default:
185       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
186       break;
187     };
188 }
189
190 static void
191 psppire_data_editor_get_property (GObject         *object,
192                                   guint            prop_id,
193                                   GValue          *value,
194                                   GParamSpec      *pspec)
195 {
196   PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (object);
197
198   switch (prop_id)
199     {
200     case PROP_SPLIT_WINDOW:
201       g_value_set_boolean (value, de->split);
202       break;
203     case PROP_DATA_STORE:
204       g_value_set_pointer (value, de->data_store);
205       break;
206     case PROP_DICTIONARY:
207       g_value_set_pointer (value, de->dict);
208       break;
209     case PROP_VALUE_LABELS:
210       break;
211     default:
212       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
213       break;
214     }
215 }
216
217 static void
218 psppire_data_editor_switch_page (GtkNotebook     *notebook,
219                                  GtkWidget *w,
220                                  guint            page_num)
221 {
222   GTK_NOTEBOOK_CLASS (parent_class)->switch_page (notebook, w, page_num);
223 }
224
225 static void
226 psppire_data_editor_set_focus_child (GtkContainer *container,
227                                      GtkWidget    *widget)
228 {
229   GTK_CONTAINER_CLASS (parent_class)->set_focus_child (container, widget);
230 }
231
232
233 static gboolean
234 on_key_press (GtkWidget *w, GdkEventKey *e)
235 {
236   PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (w);
237   if (e->keyval == GDK_KEY_F2 &&
238       PSPPIRE_DATA_EDITOR_DATA_VIEW == gtk_notebook_get_current_page (GTK_NOTEBOOK (de)))
239     {
240       gtk_widget_grab_focus (de->datum_entry);
241     }
242
243   return FALSE;
244 }
245
246 static void
247 psppire_data_editor_class_init (PsppireDataEditorClass *klass)
248 {
249   GParamSpec *data_store_spec ;
250   GParamSpec *dict_spec ;
251   GParamSpec *value_labels_spec;
252   GParamSpec *split_window_spec;
253
254   GObjectClass *object_class = G_OBJECT_CLASS (klass);
255   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
256   GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
257   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
258
259   parent_class = g_type_class_peek_parent (klass);
260
261   object_class->dispose = psppire_data_editor_dispose;
262   object_class->finalize = psppire_data_editor_finalize;
263   object_class->set_property = psppire_data_editor_set_property;
264   object_class->get_property = psppire_data_editor_get_property;
265
266   container_class->set_focus_child = psppire_data_editor_set_focus_child;
267   notebook_class->switch_page = psppire_data_editor_switch_page;
268   widget_class->key_press_event = on_key_press;
269
270   data_store_spec =
271     g_param_spec_pointer ("data-store",
272                           "Data Store",
273                           "A pointer to the data store associated with this editor",
274                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE);
275
276   g_object_class_install_property (object_class,
277                                    PROP_DATA_STORE,
278                                    data_store_spec);
279
280   dict_spec =
281     g_param_spec_pointer ("dictionary",
282                           "Dictionary",
283                           "A pointer to the dictionary associated with this editor",
284                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE);
285
286   g_object_class_install_property (object_class,
287                                    PROP_DICTIONARY,
288                                    dict_spec);
289
290   value_labels_spec =
291     g_param_spec_boolean ("value-labels",
292                          "Value Labels",
293                          "Whether or not the data sheet should display labels instead of values",
294                           FALSE,
295                          G_PARAM_WRITABLE | G_PARAM_READABLE);
296
297   g_object_class_install_property (object_class,
298                                    PROP_VALUE_LABELS,
299                                    value_labels_spec);
300
301
302   split_window_spec =
303     g_param_spec_boolean ("split",
304                           "Split Window",
305                           "True iff the data sheet is split",
306                           FALSE,
307                           G_PARAM_READABLE | G_PARAM_WRITABLE);
308
309   g_object_class_install_property (object_class,
310                                    PROP_SPLIT_WINDOW,
311                                    split_window_spec);
312 }
313
314
315 static void
316 on_var_sheet_var_double_clicked (void *var_sheet, gint dict_index,
317                                  PsppireDataEditor *de)
318 {
319   gtk_notebook_set_current_page (GTK_NOTEBOOK (de),
320                                  PSPPIRE_DATA_EDITOR_DATA_VIEW);
321
322   ssw_sheet_scroll_to (SSW_SHEET (de->data_sheet), dict_index, -1);
323 }
324
325
326 static void
327 on_data_sheet_var_double_clicked (SswSheet *data_sheet, gint dict_index,
328                                  PsppireDataEditor *de)
329 {
330
331   gtk_notebook_set_current_page (GTK_NOTEBOOK (de),
332                                  PSPPIRE_DATA_EDITOR_VARIABLE_VIEW);
333
334   ssw_sheet_scroll_to (SSW_SHEET (de->var_sheet), -1, dict_index);
335 }
336
337
338
339 /* Refreshes 'de->cell_ref_label' and 'de->datum_entry' from the currently
340    active cell or cells. */
341 static void
342 refresh_entry (PsppireDataEditor *de)
343 {
344   gint row, col;
345   if (ssw_sheet_get_active_cell (SSW_SHEET (de->data_sheet), &col, &row))
346     {
347       union value val;
348       const struct variable *var = psppire_dict_get_variable (de->dict, col);
349       if (var == NULL)
350         return;
351
352       psppire_value_entry_set_variable (PSPPIRE_VALUE_ENTRY (de->datum_entry), var);
353
354       int width = var_get_width (var);
355       if (! psppire_data_store_get_value (PSPPIRE_DATA_STORE (de->data_store),
356                                           row, var, &val))
357         return;
358
359       psppire_value_entry_set_value (PSPPIRE_VALUE_ENTRY (de->datum_entry),
360                                      &val, width);
361       value_destroy (&val, width);
362     }
363 }
364
365 static void
366 on_datum_entry_activate (GtkEntry *entry, PsppireDataEditor *de)
367 {
368   gint row, col;
369   if (ssw_sheet_get_active_cell (SSW_SHEET (de->data_sheet), &col, &row))
370     {
371       union value val;
372       const struct variable *var = psppire_dict_get_variable (de->dict, col);
373       if (var == NULL)
374         return;
375
376       int width = var_get_width (var);
377       value_init (&val, width);
378       if (psppire_value_entry_get_value (PSPPIRE_VALUE_ENTRY (de->datum_entry),
379                                          &val, width))
380         {
381           psppire_data_store_set_value (de->data_store, row, var, &val);
382         }
383       value_destroy (&val, width);
384
385       gtk_widget_grab_focus (de->data_sheet);
386       ssw_sheet_set_active_cell (SSW_SHEET (de->data_sheet), col, row, NULL);
387     }
388 }
389
390
391 /* Called when the active cell or the selection in the data sheet changes */
392 static void
393 on_data_selection_change (PsppireDataEditor *de, SswRange *sel)
394 {
395   gchar *ref_cell_text = NULL;
396
397   gint n_cases = abs (sel->end_y - sel->start_y) + 1;
398   gint n_vars = abs (sel->end_x - sel->start_x) + 1;
399
400   if (n_cases == 1 && n_vars == 1)
401     {
402       /* A single cell is selected */
403       const struct variable *var = psppire_dict_get_variable (de->dict, sel->start_x);
404
405       if (var)
406         ref_cell_text = g_strdup_printf (_("%d : %s"),
407                                          sel->start_y + 1, var_get_name (var));
408     }
409   else
410     {
411       struct string s;
412
413       /* The glib string library does not understand the ' printf modifier
414          on all platforms, but the "struct string" library does (because
415          Gnulib fixes that problem), so use the latter.  */
416       ds_init_empty (&s);
417       ds_put_format (&s, ngettext ("%'d case", "%'d cases", n_cases),
418                      n_cases);
419       ds_put_byte (&s, ' ');
420       ds_put_unichar (&s, 0xd7); /* U+00D7 MULTIPLICATION SIGN */
421       ds_put_byte (&s, ' ');
422       ds_put_format (&s, ngettext ("%'d variable", "%'d variables",
423                                    n_vars),
424                      n_vars);
425       ref_cell_text = ds_steal_cstr (&s);
426     }
427
428   gtk_label_set_label (GTK_LABEL (de->cell_ref_label),
429                        ref_cell_text ? ref_cell_text : "");
430
431   g_free (ref_cell_text);
432 }
433
434
435 static void set_font_recursively (GtkWidget *w, gpointer data);
436
437 \f
438
439 void
440 psppire_data_editor_data_delete_variables (PsppireDataEditor *de)
441 {
442   psppire_data_sheet_delete_variables (PSPPIRE_DATA_SHEET (de->data_sheet));
443 }
444
445 void
446 psppire_data_editor_var_delete_variables (PsppireDataEditor *de)
447 {
448   SswRange *range = SSW_SHEET(de->var_sheet)->selection;
449
450   if (range->start_x > range->end_x)
451     {
452       gint temp = range->start_x;
453       range->start_x = range->end_x;
454       range->end_x = temp;
455     }
456
457   psppire_dict_delete_variables (de->dict, range->start_y,
458                                  (range->end_y - range->start_y + 1));
459
460   gtk_widget_queue_draw (GTK_WIDGET (de->var_sheet));
461 }
462
463 void
464 psppire_data_editor_insert_new_case_at_posn  (PsppireDataEditor *de, gint posn)
465 {
466   g_return_if_fail (posn >= 0);
467
468   psppire_data_store_insert_new_case (de->data_store, posn);
469
470   gtk_widget_queue_draw (GTK_WIDGET (de->data_sheet));
471 }
472
473 void
474 psppire_data_editor_insert_new_variable_at_posn (PsppireDataEditor *de, gint posn)
475 {
476   psppire_data_sheet_insert_new_variable_at_posn (PSPPIRE_DATA_SHEET (de->data_sheet), posn);
477 }
478
479 static void
480 psppire_data_editor_init (PsppireDataEditor *de)
481 {
482   GtkWidget *hbox;
483   gchar *fontname = NULL;
484
485   GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (de));
486   gtk_style_context_add_class (context, "psppire-data-editor");
487
488   de->dispose_has_run = FALSE;
489
490   de->font = NULL;
491
492   g_object_set (de, "tab-pos", GTK_POS_BOTTOM, NULL);
493
494   de->cell_ref_label = gtk_label_new ("");
495   gtk_label_set_width_chars (GTK_LABEL (de->cell_ref_label), 25);
496   gtk_widget_set_valign (de->cell_ref_label, GTK_ALIGN_CENTER);
497
498   de->datum_entry = psppire_value_entry_new ();
499   g_signal_connect (de->datum_entry, "edit-done",
500                     G_CALLBACK (on_datum_entry_activate), de);
501
502   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
503   gtk_box_pack_start (GTK_BOX (hbox), de->cell_ref_label, FALSE, FALSE, 0);
504   gtk_box_pack_start (GTK_BOX (hbox), de->datum_entry, TRUE, TRUE, 0);
505
506   de->split = FALSE;
507   de->data_sheet = psppire_data_sheet_new ();
508
509   GtkWidget *data_button = ssw_sheet_get_button (SSW_SHEET (de->data_sheet));
510   gtk_button_set_label (GTK_BUTTON (data_button), _("Case"));
511   de->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
512   gtk_box_pack_start (GTK_BOX (de->vbox), hbox, FALSE, FALSE, 0);
513   gtk_box_pack_start (GTK_BOX (de->vbox), de->data_sheet, TRUE, TRUE, 0);
514
515
516   g_signal_connect_swapped (de->data_sheet, "selection-changed",
517                     G_CALLBACK (on_data_selection_change), de);
518
519   gtk_notebook_append_page (GTK_NOTEBOOK (de), de->vbox,
520                             gtk_label_new_with_mnemonic (_("Data View")));
521
522   gtk_widget_show_all (de->vbox);
523
524   de->var_sheet = psppire_variable_sheet_new ();
525
526   GtkWidget *var_button = ssw_sheet_get_button (SSW_SHEET (de->var_sheet));
527   gtk_button_set_label (GTK_BUTTON (var_button), _("Variable"));
528
529   gtk_notebook_append_page (GTK_NOTEBOOK (de), de->var_sheet,
530                             gtk_label_new_with_mnemonic (_("Variable View")));
531
532   gtk_widget_show_all (de->var_sheet);
533
534   g_signal_connect (de->var_sheet, "row-header-double-clicked",
535                     G_CALLBACK (on_var_sheet_var_double_clicked), de);
536
537   g_signal_connect (de->data_sheet, "column-header-double-clicked",
538                     G_CALLBACK (on_data_sheet_var_double_clicked), de);
539
540   g_object_set (de, "can-focus", FALSE, NULL);
541
542   if (psppire_conf_get_string (psppire_conf_new (),
543                            "Data Editor", "font",
544                                 &fontname))
545     {
546       de->font = pango_font_description_from_string (fontname);
547       g_free (fontname);
548       set_font_recursively (GTK_WIDGET (de), de->font);
549     }
550
551   gtk_widget_add_events (GTK_WIDGET (de), GDK_KEY_PRESS_MASK);
552 }
553
554 GtkWidget*
555 psppire_data_editor_new (PsppireDict *dict,
556                          PsppireDataStore *data_store)
557 {
558   return  g_object_new (PSPPIRE_DATA_EDITOR_TYPE,
559                         "dictionary",  dict,
560                         "data-store",  data_store,
561                         NULL);
562 }
563 \f
564 /* Turns the visible grid on or off, according to GRID_VISIBLE, for DE's data
565    sheet(s) and variable sheet. */
566 void
567 psppire_data_editor_show_grid (PsppireDataEditor *de, gboolean grid_visible)
568 {
569   g_object_set (SSW_SHEET (de->var_sheet), "gridlines", grid_visible, NULL);
570   g_object_set (SSW_SHEET (de->data_sheet), "gridlines", grid_visible, NULL);
571 }
572
573
574 static void
575 set_font_recursively (GtkWidget *w, gpointer data)
576 {
577   PangoFontDescription *font_desc = data;
578
579   GtkStyleContext *style = gtk_widget_get_style_context (w);
580   GtkCssProvider *cssp = gtk_css_provider_new ();
581
582   /* The Pango font description as string has a different syntax than the
583      css style description:
584      Pango: Courier Italic 12
585      CSS: italic 12pt Courier
586      I ignore Weight, Style and Variant and just take family and size */
587   const gchar *str = pango_font_description_get_family (font_desc);
588   gint size = pango_font_description_get_size (font_desc);
589   gchar *css =
590     g_strdup_printf ("* {font: %dpt %s}", size/PANGO_SCALE, str);
591
592   GError *err = NULL;
593   gtk_css_provider_load_from_data (cssp, css, -1, &err);
594   if (err)
595     {
596       g_warning ("Failed to load font css \"%s\": %s", css, err->message);
597       g_error_free (err);
598     }
599   g_free (css);
600
601   gtk_style_context_add_provider (style,
602                                   GTK_STYLE_PROVIDER (cssp),
603                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
604   g_object_unref (cssp);
605
606
607   if (GTK_IS_CONTAINER (w))
608     gtk_container_foreach (GTK_CONTAINER (w), set_font_recursively, font_desc);
609 }
610
611 /* Sets FONT_DESC as the font used by the data sheet(s) and variable sheet. */
612 void
613 psppire_data_editor_set_font (PsppireDataEditor *de, PangoFontDescription *font_desc)
614 {
615   gchar *font_name;
616   set_font_recursively (GTK_WIDGET (de), font_desc);
617
618   if (de->font)
619     pango_font_description_free (de->font);
620   de->font = pango_font_description_copy (font_desc);
621   font_name = pango_font_description_to_string (de->font);
622
623   psppire_conf_set_string (psppire_conf_new (),
624                            "Data Editor", "font",
625                            font_name);
626   g_free (font_name);
627 }
628
629 /* If SPLIT is TRUE, splits DE's data sheet into four panes.
630    If SPLIT is FALSE, un-splits it into a single pane. */
631 void
632 psppire_data_editor_split_window (PsppireDataEditor *de, gboolean split)
633 {
634   g_object_set (de, "split", split, NULL);
635 }
636
637 /* Makes the variable with dictionary index DICT_INDEX in DE's dictionary
638    visible and selected in the active view in DE. */
639 void
640 psppire_data_editor_goto_variable (PsppireDataEditor *de, gint dict_index)
641 {
642   gint page = gtk_notebook_get_current_page (GTK_NOTEBOOK (de));
643
644   switch (page)
645     {
646       case PSPPIRE_DATA_EDITOR_DATA_VIEW:
647         ssw_sheet_scroll_to (SSW_SHEET (de->data_sheet), dict_index, -1);
648         ssw_sheet_set_active_cell (SSW_SHEET (de->data_sheet), dict_index, -1, NULL);
649         break;
650       case PSPPIRE_DATA_EDITOR_VARIABLE_VIEW:
651         ssw_sheet_scroll_to (SSW_SHEET (de->var_sheet), -1, dict_index);
652         ssw_sheet_set_active_cell (SSW_SHEET (de->var_sheet), -1, dict_index, NULL);
653         break;
654     }
655 }
656
657 /* Set the datum at COL, ROW, to that contained in VALUE.
658  */
659 static void
660 store_set_datum (GtkTreeModel *model, gint col, gint row,
661                          const GValue *value)
662 {
663   PsppireDataStore *store = PSPPIRE_DATA_STORE (model);
664   GVariant *v = g_value_get_variant (value);
665   union value uv;
666   value_variant_get (&uv, v);
667   const struct variable *var = psppire_dict_get_variable (store->dict, col);
668   psppire_data_store_set_value (store, row, var, &uv);
669   value_destroy_from_variant (&uv, v);
670 }
671
672 void
673 psppire_data_editor_paste (PsppireDataEditor *de)
674 {
675   SswSheet *sheet = SSW_SHEET (de->data_sheet);
676   GtkClipboard *clip =
677     gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (sheet)),
678                                    GDK_SELECTION_CLIPBOARD);
679
680   ssw_sheet_paste (sheet, clip, store_set_datum);
681 }