/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016 Free Software Foundation
+ Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014,
+ 2016, 2017 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "gl/c-strcasestr.h"
#include "gl/xvasprintf.h"
+#include "ui/gui/efficient-sheet/jmd-sheet.h"
+
#include "find-dialog.h"
+#include "options-dialog.h"
#include "psppire-dialog-action-1sks.h"
#include "psppire-dialog-action-aggregate.h"
#include "psppire-dialog-action-autorecode.h"
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (de));
GtkWidget *dialog = gtk_font_chooser_dialog_new (NULL, GTK_WINDOW (toplevel));
GtkStyleContext *style = gtk_widget_get_style_context (GTK_WIDGET(de->data_editor));
- const PangoFontDescription *current_font = gtk_style_context_get_font (style, GTK_STATE_FLAG_NORMAL);
+ const PangoFontDescription *current_font ;
+
+ gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", ¤t_font, NULL);
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (dialog), current_font);
static void
on_cut (PsppireDataWindow *dw)
{
-#if SHEET_MERGE
int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
if (p == 0)
{
- PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
- psppire_data_sheet_edit_cut (ds);
+ PsppireDict *dict = NULL;
+ g_object_get (dw->data_editor, "dictionary", &dict, NULL);
+
+ gint x, y;
+ JmdSheet *sheet = JMD_SHEET (dw->data_editor->data_sheet);
+ JmdRange sel = *sheet->selection;
+
+ GtkClipboard *clip =
+ gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)),
+ GDK_SELECTION_CLIPBOARD);
+
+ /* Save the selected area to a string */
+ GString *str = g_string_new ("");
+ for (y = sel.start_y ; y <= sel.end_y; ++y)
+ {
+ for (x = sel.start_x ; x <= sel.end_x; ++x)
+ {
+ const struct variable * var = psppire_dict_get_variable (dict, x);
+ gchar *s = psppire_data_store_get_string (dw->data_editor->data_store,
+ y, var, FALSE);
+ g_string_append (str, s);
+ g_string_append (str, "\t");
+ g_free (s);
+ }
+ g_string_append (str, "\n");
+ }
+
+ gtk_clipboard_set_text (clip, str->str, str->len);
+ g_string_free (str, TRUE);
+
+ /* Now fill the selected area with SYSMIS */
+ union value sm ;
+ sm.f = SYSMIS;
+ for (x = sel.start_x ; x <= sel.end_x; ++x)
+ {
+ const struct variable * var = psppire_dict_get_variable (dict, x);
+ for (y = sel.start_y ; y <= sel.end_y; ++y)
+ {
+ psppire_data_store_set_value (dw->data_editor->data_store,
+ y,
+ var, &sm);
+ }
+ }
+
}
-#endif
}
static void
on_copy (PsppireDataWindow *dw)
{
-#if SHEET_MERGE
int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
if (p == 0)
{
- PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
- psppire_data_sheet_edit_copy (ds);
+ GtkClipboard *clip =
+ gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)),
+ GDK_SELECTION_CLIPBOARD);
+
+ jmd_sheet_set_clip (JMD_SHEET (dw->data_editor->data_sheet), clip);
+ }
+}
+
+
+static void
+trf (GtkClipboard *clip,
+ GdkAtom *atoms,
+ gint n_atoms,
+ gpointer data)
+{
+ int i;
+ for (i = 0; i < n_atoms; ++i)
+ {
+ g_print ("%s\n", gdk_atom_name (atoms[i]));
}
-#endif
}
static void
on_paste (PsppireDataWindow *dw)
{
-#if SHEET_MERGE
int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
if (p == 0)
{
- PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
- psppire_data_sheet_edit_paste (ds);
+ GtkClipboard *clip =
+ gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)),
+ GDK_SELECTION_CLIPBOARD);
+
+ gtk_clipboard_request_targets (clip, trf, dw);
}
-#endif
}
static void
goto_case (PsppireDataWindow *dw)
{
-#if SHEET_MERGE
- PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
-
- goto_case_dialog (ds);
-#endif
+ int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
+ if (p == 0)
+ {
+ goto_case_dialog (JMD_SHEET (dw->data_editor->data_sheet));
+ }
}
dw->mi_find = gtk_menu_item_new_with_mnemonic (_("_Find..."));
g_signal_connect_swapped (dw->mi_find, "activate", G_CALLBACK (find_dialog), dw);
- gtk_menu_attach (GTK_MENU (menu), dw->mi_find, 0, 1, i, i + 1); ++i;
+ gtk_menu_attach (GTK_MENU (menu), dw->mi_find, 0, 1, i, i + 1); ++i;
+ }
+
+ {
+ dw->mi_options = gtk_menu_item_new_with_mnemonic (_("_Options..."));
+ g_signal_connect_swapped (dw->mi_options, "activate",
+ G_CALLBACK (options_dialog), dw);
+ gtk_menu_attach (GTK_MENU (menu), dw->mi_options, 0, 1, i, i + 1); ++i;
}
g_object_set (menuitem, "submenu", menu, NULL);
g_signal_connect_swapped (de->data_store, "case-changed",
G_CALLBACK (set_unsaved), de);
- g_signal_connect_swapped (de->data_store, "case-inserted",
- G_CALLBACK (set_unsaved), de);
-
- g_signal_connect_swapped (de->data_store, "cases-deleted",
- G_CALLBACK (set_unsaved), de);
-
dataset_set_callbacks (de->dataset, &cbs, de);
connect_help (de->builder);
G_CALLBACK (on_split_change),
de);
- g_signal_connect_swapped (de->dict, "changed",
+ g_signal_connect_swapped (de->dict, "items-changed",
G_CALLBACK (enable_save), de);
g_signal_connect_swapped (de->dict, "variable-inserted",
G_CALLBACK (enable_save), de);
return NULL;
}
-#if SHEET_MERGE
-
PsppireDataWindow *
psppire_data_window_for_data_store (PsppireDataStore *data_store)
{
return NULL;
}
-#endif
-
GtkWindow *
create_data_window (void)
{
return GTK_WINDOW (w);
}
-
-
-void
+GtkWindow *
open_data_window (PsppireWindow *victim, const char *file_name,
const char *encoding, gpointer hint)
{
psppire_window_load (PSPPIRE_WINDOW (window), file_name, encoding, hint);
gtk_widget_show_all (window);
+ return GTK_WINDOW (window);
}