/* 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 "ui/gui/helper.h"
#include "ui/gui/psppire-import-assistant.h"
#include "ui/gui/psppire-data-window.h"
+#include "ui/gui/psppire-data-editor.h"
#include "ui/gui/psppire-dialog-action.h"
#include "ui/gui/psppire-encoding-selector.h"
#include "ui/gui/psppire-syntax-window.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"
on_cut (PsppireDataWindow *dw)
{
int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
- if (p == 0)
- {
+ if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW)
+ {
PsppireDict *dict = NULL;
g_object_get (dw->data_editor, "dictionary", &dict, NULL);
}
}
-
-
static void
on_copy (PsppireDataWindow *dw)
{
int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
- if (p == 0)
+ if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW)
{
GtkClipboard *clip =
gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)),
}
}
-
-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]));
- }
-}
-
static void
on_paste (PsppireDataWindow *dw)
{
int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
- if (p == 0)
+ if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW)
{
- GtkClipboard *clip =
- gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)),
- GDK_SELECTION_CLIPBOARD);
-
- gtk_clipboard_request_targets (clip, trf, dw);
+ psppire_data_editor_paste (dw->data_editor);
}
}
-
static void
on_clear_cases (PsppireDataWindow *dw)
{
-#if SHEET_MERGE
- int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
- if (p == 0)
+ PsppireDataEditor *de = dw->data_editor;
+ int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (de));
+ if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW)
{
- PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
- psppire_data_sheet_edit_clear_cases (ds);
+ JmdRange *range = JMD_SHEET(de->data_sheet)->selection;
+ psppire_data_store_delete_cases (de->data_store, range->start_y,
+ range->end_y - range->start_y + 1);
+ gtk_widget_queue_draw (GTK_WIDGET (de->data_sheet));
}
-#endif
}
static void
on_clear_variables (PsppireDataWindow *dw)
{
-#if SHEET_MERGE
- int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
- if (p == 0)
+ PsppireDataEditor *de = dw->data_editor;
+ int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (de));
+ if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW)
{
- PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
- psppire_data_sheet_edit_clear_variables (ds);
+ psppire_data_editor_data_delete_variables (de);
}
else
{
- psppire_var_sheet_clear_variables (PSPPIRE_VAR_SHEET (dw->data_editor->var_sheet));
+ psppire_data_editor_var_delete_variables (de);
}
-#endif
}
-
-
static void
insert_variable (PsppireDataWindow *dw)
{
-#if SHEET_MERGE
- int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
- if (p == 0)
+ PsppireDataEditor *de = dw->data_editor;
+ int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (de));
+
+ if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW)
{
- PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
- psppire_data_sheet_insert_variable (ds);
+ JmdRange *range = JMD_SHEET(de->data_sheet)->selection;
+ psppire_data_editor_insert_new_variable_at_posn (de, range->start_x);
}
else
{
- psppire_var_sheet_insert_variable (PSPPIRE_VAR_SHEET (dw->data_editor->var_sheet));
+ JmdRange *range = JMD_SHEET(de->var_sheet)->selection;
+ psppire_data_editor_insert_new_variable_at_posn (de, range->start_y);
}
-#endif
}
-
-
static void
insert_case_at_row (PsppireDataWindow *dw)
{
-#if SHEET_MERGE
- PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
-
- psppire_data_sheet_insert_case (ds);
-#endif
+ PsppireDataEditor *de = dw->data_editor;
+ JmdRange *range = JMD_SHEET(de->data_sheet)->selection;
+ psppire_data_editor_insert_new_case_at_posn (de, range->start_y);
}
-
-
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
+ PsppireDataEditor *de = dw->data_editor;
+ int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (de));
+ if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW)
+ {
+ goto_case_dialog (JMD_SHEET (de->data_sheet));
+ }
}
-
static GtkWidget *
create_file_menu (PsppireDataWindow *dw)
{
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);
}