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