From: John Darrington Date: Sun, 14 Aug 2016 05:51:36 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/master' into sheet X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;h=f062823782af5f98fecb1808136df3d565194698;hp=-c;p=pspp Merge remote-tracking branch 'origin/master' into sheet Conflicts: src/ui/gui/psppire-data-window.c --- f062823782af5f98fecb1808136df3d565194698 diff --combined src/ui/gui/psppire-data-window.c index c0f8ba5344,fddd3bb3e3..b4c9b09dac --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@@ -36,6 -36,8 +36,6 @@@ #include "ui/gui/psppire-encoding-selector.h" #include "ui/gui/psppire-syntax-window.h" #include "ui/gui/psppire-window.h" -#include "ui/gui/psppire-data-sheet.h" -#include "ui/gui/psppire-var-sheet.h" #include "ui/gui/windows-menu.h" #include "ui/gui/goto-case-dialog.h" #include "ui/gui/psppire.h" @@@ -45,8 -47,6 +45,8 @@@ #include "gl/c-strcasestr.h" #include "gl/xvasprintf.h" +#include "ui/gui/efficient-sheet/jmd-sheet.h" + #include "find-dialog.h" #include "psppire-dialog-action-1sks.h" #include "psppire-dialog-action-aggregate.h" @@@ -1068,80 -1068,19 +1068,80 @@@ on_cut (PsppireDataWindow *dw 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); + } + } + } } + + static void on_copy (PsppireDataWindow *dw) { 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])); } } @@@ -1151,11 -1090,8 +1151,11 @@@ on_paste (PsppireDataWindow *dw 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); } } @@@ -1163,20 -1099,17 +1163,20 @@@ 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) { PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor); psppire_data_sheet_edit_clear_cases (ds); } +#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) { @@@ -1187,15 -1120,12 +1187,15 @@@ { psppire_var_sheet_clear_variables (PSPPIRE_VAR_SHEET (dw->data_editor->var_sheet)); } +#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) { @@@ -1206,34 -1136,27 +1206,34 @@@ { psppire_var_sheet_insert_variable (PSPPIRE_VAR_SHEET (dw->data_editor->var_sheet)); } +#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 } + + static void goto_case (PsppireDataWindow *dw) { - PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor); - - goto_case_dialog (ds); + 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)); + } } - static GtkWidget * create_file_menu (PsppireDataWindow *dw) { @@@ -1366,7 -1289,6 +1366,7 @@@ return menuitem; } + static GtkWidget * create_edit_menu (PsppireDataWindow *dw) { @@@ -1445,6 -1367,7 +1445,6 @@@ return menuitem; } - static void psppire_data_window_finish_init (PsppireDataWindow *de, struct dataset *ds) @@@ -1511,7 -1434,7 +1511,7 @@@ G_CALLBACK (on_split_change), de); - g_signal_connect_swapped (de->dict, "backend-changed", + g_signal_connect_swapped (de->dict, "changed", G_CALLBACK (enable_save), de); g_signal_connect_swapped (de->dict, "variable-inserted", G_CALLBACK (enable_save), de); @@@ -1818,7 -1741,6 +1818,7 @@@ ll_push_head (&all_data_windows, &de->ll); } + static void psppire_data_window_dispose (GObject *object) { @@@ -1921,7 -1843,6 +1921,7 @@@ psppire_data_window_get_property (GObje } + GtkWidget* psppire_data_window_new (struct dataset *ds) { @@@ -1955,15 -1876,12 +1955,15 @@@ return dw; } + + bool psppire_data_window_is_empty (PsppireDataWindow *dw) { return psppire_dict_get_var_cnt (dw->dict) == 0; } + static void psppire_data_window_iface_init (PsppireWindowIface *iface) { @@@ -1974,7 -1892,6 +1974,7 @@@ + PsppireDataWindow * psppire_default_data_window (void) { @@@ -1983,8 -1900,6 +1983,8 @@@ return ll_data (ll_head (&all_data_windows), PsppireDataWindow, ll); } + + void psppire_data_window_set_default (PsppireDataWindow *pdw) { @@@ -1999,15 -1914,25 +1999,15 @@@ psppire_data_window_undefault (PsppireD ll_push_tail (&all_data_windows, &pdw->ll); } -PsppireDataWindow * -psppire_data_window_for_dataset (struct dataset *ds) -{ - PsppireDataWindow *pdw; - ll_for_each (pdw, PsppireDataWindow, ll, &all_data_windows) - if (pdw->dataset == ds) - return pdw; - - return NULL; -} PsppireDataWindow * -psppire_data_window_for_data_store (PsppireDataStore *data_store) +psppire_data_window_for_dataset (struct dataset *ds) { PsppireDataWindow *pdw; ll_for_each (pdw, PsppireDataWindow, ll, &all_data_windows) - if (pdw->data_store == data_store) + if (pdw->dataset == ds) return pdw; return NULL; @@@ -2023,9 -1948,7 +2023,7 @@@ create_data_window (void return GTK_WINDOW (w); } - - - void + GtkWindow * open_data_window (PsppireWindow *victim, const char *file_name, const char *encoding, gpointer hint) { @@@ -2042,4 -1965,5 +2040,5 @@@ psppire_window_load (PSPPIRE_WINDOW (window), file_name, encoding, hint); gtk_widget_show_all (window); + return GTK_WINDOW (window); }