1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2008, 2009, 2010 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include <gtk/gtksignal.h>
20 #include <gtk/gtkbox.h>
23 #include "data/any-reader.h"
24 #include "data/procedure.h"
25 #include "language/syntax-string-source.h"
26 #include "libpspp/message.h"
27 #include "ui/gui/about.h"
28 #include "ui/gui/comments-dialog.h"
29 #include "ui/gui/compute-dialog.h"
30 #include "ui/gui/correlation-dialog.h"
31 #include "ui/gui/crosstabs-dialog.h"
32 #include "ui/gui/descriptives-dialog.h"
33 #include "ui/gui/examine-dialog.h"
34 #include "ui/gui/executor.h"
35 #include "ui/gui/factor-dialog.h"
36 #include "ui/gui/find-dialog.h"
37 #include "ui/gui/frequencies-dialog.h"
38 #include "ui/gui/goto-case-dialog.h"
39 #include "ui/gui/helper.h"
40 #include "ui/gui/oneway-anova-dialog.h"
41 #include "ui/gui/psppire-data-window.h"
42 #include "ui/gui/psppire-syntax-window.h"
43 #include "ui/gui/psppire-window.h"
44 #include "ui/gui/psppire.h"
45 #include "ui/gui/rank-dialog.h"
46 #include "ui/gui/recode-dialog.h"
47 #include "ui/gui/regression-dialog.h"
48 #include "ui/gui/reliability-dialog.h"
49 #include "ui/gui/roc-dialog.h"
50 #include "ui/gui/select-cases-dialog.h"
51 #include "ui/gui/sort-cases-dialog.h"
52 #include "ui/gui/split-file-dialog.h"
53 #include "ui/gui/t-test-independent-samples-dialog.h"
54 #include "ui/gui/t-test-one-sample.h"
55 #include "ui/gui/t-test-paired-samples.h"
56 #include "ui/gui/text-data-import-dialog.h"
57 #include "ui/gui/transpose-dialog.h"
58 #include "ui/gui/variable-info-dialog.h"
59 #include "ui/gui/weight-cases-dialog.h"
60 #include "ui/syntax-gen.h"
63 #define _(msgid) gettext (msgid)
64 #define N_(msgid) msgid
68 static void psppire_data_window_base_finalize (PsppireDataWindowClass *, gpointer);
69 static void psppire_data_window_base_init (PsppireDataWindowClass *class);
70 static void psppire_data_window_class_init (PsppireDataWindowClass *class);
71 static void psppire_data_window_init (PsppireDataWindow *data_editor);
74 static void psppire_data_window_iface_init (PsppireWindowIface *iface);
78 psppire_data_window_get_type (void)
80 static GType psppire_data_window_type = 0;
82 if (!psppire_data_window_type)
84 static const GTypeInfo psppire_data_window_info =
86 sizeof (PsppireDataWindowClass),
87 (GBaseInitFunc) psppire_data_window_base_init,
88 (GBaseFinalizeFunc) psppire_data_window_base_finalize,
89 (GClassInitFunc)psppire_data_window_class_init,
90 (GClassFinalizeFunc) NULL,
92 sizeof (PsppireDataWindow),
94 (GInstanceInitFunc) psppire_data_window_init,
97 static const GInterfaceInfo window_interface_info =
99 (GInterfaceInitFunc) psppire_data_window_iface_init,
104 psppire_data_window_type =
105 g_type_register_static (PSPPIRE_TYPE_WINDOW, "PsppireDataWindow",
106 &psppire_data_window_info, 0);
109 g_type_add_interface_static (psppire_data_window_type,
110 PSPPIRE_TYPE_WINDOW_MODEL,
111 &window_interface_info);
114 return psppire_data_window_type;
117 static GObjectClass *parent_class ;
120 psppire_data_window_finalize (GObject *object)
122 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (object);
124 g_object_unref (de->builder);
126 if (G_OBJECT_CLASS (parent_class)->finalize)
127 (*G_OBJECT_CLASS (parent_class)->finalize) (object);
132 psppire_data_window_class_init (PsppireDataWindowClass *class)
134 parent_class = g_type_class_peek_parent (class);
139 psppire_data_window_base_init (PsppireDataWindowClass *class)
141 GObjectClass *object_class = G_OBJECT_CLASS (class);
143 object_class->finalize = psppire_data_window_finalize;
149 psppire_data_window_base_finalize (PsppireDataWindowClass *class,
158 extern PsppireVarStore *the_var_store;
159 extern struct dataset *the_dataset;
160 extern PsppireDataStore *the_data_store ;
162 extern GtkRecentManager *the_recent_mgr;
165 set_paste_menuitem_sensitivity (PsppireDataWindow *de, gboolean x)
167 GtkAction *edit_paste = get_action_assert (de->builder, "edit_paste");
169 gtk_action_set_sensitive (edit_paste, x);
173 set_cut_copy_menuitem_sensitivity (PsppireDataWindow *de, gboolean x)
175 GtkAction *edit_copy = get_action_assert (de->builder, "edit_copy");
176 GtkAction *edit_cut = get_action_assert (de->builder, "edit_cut");
178 gtk_action_set_sensitive (edit_copy, x);
179 gtk_action_set_sensitive (edit_cut, x);
182 /* Run the EXECUTE command. */
184 execute (GtkMenuItem *mi, gpointer data)
186 struct getl_interface *sss = create_syntax_string_source ("EXECUTE.");
188 execute_syntax (sss);
192 transformation_change_callback (bool transformations_pending,
195 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
197 GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
199 GtkWidget *menuitem =
200 gtk_ui_manager_get_widget (uim,"/ui/menubar/transform/transform_run-pending");
202 GtkWidget *status_label =
203 get_widget_assert (de->builder, "case-counter-area");
205 gtk_widget_set_sensitive (menuitem, transformations_pending);
208 if ( transformations_pending)
209 gtk_label_set_text (GTK_LABEL (status_label),
210 _("Transformations Pending"));
212 gtk_label_set_text (GTK_LABEL (status_label), "");
215 /* Callback for when the dictionary changes its filter variable */
217 on_filter_change (GObject *o, gint filter_index, gpointer data)
219 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
221 GtkWidget *filter_status_area =
222 get_widget_assert (de->builder, "filter-use-status-area");
224 if ( filter_index == -1 )
226 gtk_label_set_text (GTK_LABEL (filter_status_area), _("Filter off"));
230 PsppireVarStore *vs = NULL;
231 PsppireDict *dict = NULL;
232 struct variable *var ;
235 g_object_get (de->data_editor, "var-store", &vs, NULL);
236 g_object_get (vs, "dictionary", &dict, NULL);
238 var = psppire_dict_get_variable (dict, filter_index);
240 text = g_strdup_printf (_("Filter by %s"), var_get_name (var));
242 gtk_label_set_text (GTK_LABEL (filter_status_area), text);
248 /* Callback for when the dictionary changes its split variables */
250 on_split_change (PsppireDict *dict, gpointer data)
252 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
254 size_t n_split_vars = dict_get_split_cnt (dict->dict);
256 GtkWidget *split_status_area =
257 get_widget_assert (de->builder, "split-file-status-area");
259 if ( n_split_vars == 0 )
261 gtk_label_set_text (GTK_LABEL (split_status_area), _("No Split"));
267 const struct variable *const * split_vars =
268 dict_get_split_vars (dict->dict);
270 text = g_string_new (_("Split by "));
272 for (i = 0 ; i < n_split_vars - 1; ++i )
274 g_string_append_printf (text, "%s, ", var_get_name (split_vars[i]));
276 g_string_append (text, var_get_name (split_vars[i]));
278 gtk_label_set_text (GTK_LABEL (split_status_area), text->str);
280 g_string_free (text, TRUE);
287 /* Callback for when the dictionary changes its weights */
289 on_weight_change (GObject *o, gint weight_index, gpointer data)
291 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
293 GtkWidget *weight_status_area =
294 get_widget_assert (de->builder, "weight-status-area");
296 if ( weight_index == -1 )
298 gtk_label_set_text (GTK_LABEL (weight_status_area), _("Weights off"));
302 struct variable *var ;
303 PsppireVarStore *vs = NULL;
304 PsppireDict *dict = NULL;
307 g_object_get (de->data_editor, "var-store", &vs, NULL);
308 g_object_get (vs, "dictionary", &dict, NULL);
310 var = psppire_dict_get_variable (dict, weight_index);
312 text = g_strdup_printf (_("Weight by %s"), var_get_name (var));
314 gtk_label_set_text (GTK_LABEL (weight_status_area), text);
322 dump_rm (GtkRecentManager *rm)
324 GList *items = gtk_recent_manager_get_items (rm);
328 g_print ("Recent Items:\n");
329 for (i = items; i; i = i->next)
331 GtkRecentInfo *ri = i->data;
333 g_print ("Item: %s (Mime: %s) (Desc: %s) (URI: %s)\n",
334 gtk_recent_info_get_short_name (ri),
335 gtk_recent_info_get_mime_type (ri),
336 gtk_recent_info_get_description (ri),
337 gtk_recent_info_get_uri (ri)
341 gtk_recent_info_unref (ri);
350 load_file (PsppireWindow *de, const gchar *file_name)
352 gchar *native_file_name;
353 struct getl_interface *sss;
354 struct string filename;
356 ds_init_empty (&filename);
359 convert_glib_filename_to_system_filename (file_name, NULL);
361 syntax_gen_string (&filename, ss_cstr (native_file_name));
363 g_free (native_file_name);
365 sss = create_syntax_string_source ("GET FILE=%s.",
366 ds_cstr (&filename));
368 ds_destroy (&filename);
370 if (execute_syntax (sss) )
377 sysfile_chooser_dialog (PsppireWindow *toplevel)
380 gtk_file_chooser_dialog_new (_("Open"),
381 GTK_WINDOW (toplevel),
382 GTK_FILE_CHOOSER_ACTION_OPEN,
383 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
384 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
387 GtkFileFilter *filter;
389 filter = gtk_file_filter_new ();
390 gtk_file_filter_set_name (filter, _("Data and Syntax Files"));
391 gtk_file_filter_add_pattern (filter, "*.sav");
392 gtk_file_filter_add_pattern (filter, "*.SAV");
393 gtk_file_filter_add_pattern (filter, "*.por");
394 gtk_file_filter_add_pattern (filter, "*.POR");
395 gtk_file_filter_add_pattern (filter, "*.sps");
396 gtk_file_filter_add_pattern (filter, "*.SPS");
397 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
399 filter = gtk_file_filter_new ();
400 gtk_file_filter_set_name (filter, _("System Files (*.sav)"));
401 gtk_file_filter_add_pattern (filter, "*.sav");
402 gtk_file_filter_add_pattern (filter, "*.SAV");
403 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
405 filter = gtk_file_filter_new ();
406 gtk_file_filter_set_name (filter, _("Portable Files (*.por) "));
407 gtk_file_filter_add_pattern (filter, "*.por");
408 gtk_file_filter_add_pattern (filter, "*.POR");
409 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
411 filter = gtk_file_filter_new ();
412 gtk_file_filter_set_name (filter, _("Syntax Files (*.sps) "));
413 gtk_file_filter_add_pattern (filter, "*.sps");
414 gtk_file_filter_add_pattern (filter, "*.SPS");
415 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
417 filter = gtk_file_filter_new ();
418 gtk_file_filter_set_name (filter, _("All Files"));
419 gtk_file_filter_add_pattern (filter, "*");
420 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
424 gchar *filename = NULL;
425 g_object_get (toplevel, "filename", &filename, NULL);
427 if ( ! g_path_is_absolute (filename))
430 g_build_filename (g_get_current_dir (), filename, NULL);
431 dir_name = g_path_get_dirname (path);
436 dir_name = g_path_get_dirname (filename);
438 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
446 /* Callback for the data_open action.
447 Prompts for a filename and opens it */
449 open_window (GtkAction *action, PsppireWindow *de)
451 GtkWidget *dialog = sysfile_chooser_dialog (de);
453 switch (gtk_dialog_run (GTK_DIALOG (dialog)))
455 case GTK_RESPONSE_ACCEPT:
458 gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
460 if (any_reader_may_open (name))
461 psppire_window_load (de, name);
463 open_syntax_window (name);
472 gtk_widget_destroy (dialog);
475 /* Returns true if NAME has a suffix which might denote a PSPP file */
477 name_has_suffix (const gchar *name)
479 if ( g_str_has_suffix (name, ".sav"))
481 if ( g_str_has_suffix (name, ".SAV"))
483 if ( g_str_has_suffix (name, ".por"))
485 if ( g_str_has_suffix (name, ".POR"))
492 /* Save DE to file */
494 save_file (PsppireWindow *w)
496 gchar *native_file_name = NULL;
497 gchar *file_name = NULL;
499 struct getl_interface *sss;
500 struct string filename ;
501 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (w);
503 g_object_get (w, "filename", &file_name, NULL);
505 fnx = g_string_new (file_name);
507 if ( ! name_has_suffix (fnx->str))
509 if ( de->save_as_portable)
510 g_string_append (fnx, ".por");
512 g_string_append (fnx, ".sav");
515 ds_init_empty (&filename);
518 convert_glib_filename_to_system_filename (fnx->str, NULL);
520 g_string_free (fnx, TRUE);
522 syntax_gen_string (&filename, ss_cstr (native_file_name));
523 g_free (native_file_name);
525 if ( de->save_as_portable )
527 sss = create_syntax_string_source ("EXPORT OUTFILE=%s.",
528 ds_cstr (&filename));
532 sss = create_syntax_string_source ("SAVE OUTFILE=%s.",
533 ds_cstr (&filename));
536 ds_destroy (&filename);
538 execute_syntax (sss);
543 insert_case (GtkAction *action, gpointer data)
545 PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (data);
546 psppire_data_editor_insert_case (dw->data_editor);
550 on_insert_variable (GtkAction *action, gpointer data)
552 PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
553 psppire_data_editor_insert_variable (de);
558 display_dict (PsppireDataWindow *de)
561 struct getl_interface *sss =
562 create_syntax_string_source ("DISPLAY DICTIONARY.");
564 execute_syntax (sss);
568 sysfile_info (PsppireDataWindow *de)
570 GtkWidget *dialog = sysfile_chooser_dialog (PSPPIRE_WINDOW (de));
572 if ( GTK_RESPONSE_ACCEPT == gtk_dialog_run (GTK_DIALOG (dialog)))
574 struct string filename;
575 struct getl_interface *sss;
577 gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
579 gchar *native_file_name =
580 convert_glib_filename_to_system_filename (file_name, NULL);
582 ds_init_empty (&filename);
584 syntax_gen_string (&filename, ss_cstr (native_file_name));
586 g_free (native_file_name);
588 sss = create_syntax_string_source ("SYSFILE INFO %s.",
589 ds_cstr (&filename));
590 execute_syntax (sss);
593 gtk_widget_destroy (dialog);
597 /* Callback for data_save_as action. Prompt for a filename and save */
599 data_save_as_dialog (PsppireDataWindow *de)
601 GtkWidget *button_sys;
603 gtk_file_chooser_dialog_new (_("Save"),
605 GTK_FILE_CHOOSER_ACTION_SAVE,
606 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
607 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
610 GtkFileFilter *filter = gtk_file_filter_new ();
611 gtk_file_filter_set_name (filter, _("System Files (*.sav)"));
612 gtk_file_filter_add_pattern (filter, "*.sav");
613 gtk_file_filter_add_pattern (filter, "*.SAV");
614 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
616 filter = gtk_file_filter_new ();
617 gtk_file_filter_set_name (filter, _("Portable Files (*.por) "));
618 gtk_file_filter_add_pattern (filter, "*.por");
619 gtk_file_filter_add_pattern (filter, "*.POR");
620 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
622 filter = gtk_file_filter_new ();
623 gtk_file_filter_set_name (filter, _("All Files"));
624 gtk_file_filter_add_pattern (filter, "*");
625 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
628 GtkWidget *button_por;
629 GtkWidget *vbox = gtk_vbox_new (TRUE, 5);
631 gtk_radio_button_new_with_label (NULL, _("System File"));
634 gtk_radio_button_new_with_label
635 (gtk_radio_button_get_group (GTK_RADIO_BUTTON(button_sys)),
638 psppire_box_pack_start_defaults (GTK_BOX (vbox), button_sys);
639 psppire_box_pack_start_defaults (GTK_BOX (vbox), button_por);
641 gtk_widget_show_all (vbox);
643 gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(dialog), vbox);
646 switch (gtk_dialog_run (GTK_DIALOG (dialog)))
648 case GTK_RESPONSE_ACCEPT:
653 gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog))
656 de->save_as_portable =
657 ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_sys));
659 if ( ! name_has_suffix (filename->str))
661 if ( de->save_as_portable)
662 g_string_append (filename, ".por");
664 g_string_append (filename, ".sav");
667 psppire_window_set_filename (PSPPIRE_WINDOW (de), filename->str);
669 save_file (PSPPIRE_WINDOW (de));
671 g_string_free (filename, TRUE);
678 gtk_widget_destroy (dialog);
682 /* Callback for data_save action.
685 data_save (PsppireWindow *de)
687 const gchar *fn = psppire_window_get_filename (de);
690 psppire_window_save (de);
692 data_save_as_dialog (PSPPIRE_DATA_WINDOW (de));
696 /* Callback for data_new action.
697 Performs the NEW FILE command */
699 new_file (GtkAction *action, PsppireDataWindow *de)
701 struct getl_interface *sss =
702 create_syntax_string_source ("NEW FILE.");
704 execute_syntax (sss);
706 psppire_window_set_filename (PSPPIRE_WINDOW (de), NULL);
712 on_edit_paste (GtkAction *a, gpointer data)
714 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
716 psppire_data_editor_clip_paste (de->data_editor);
720 on_edit_copy (GtkMenuItem *m, gpointer data)
722 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
724 psppire_data_editor_clip_copy (de->data_editor);
730 on_edit_cut (GtkMenuItem *m, gpointer data)
732 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
734 psppire_data_editor_clip_cut (de->data_editor);
739 status_bar_activate (GtkToggleAction *action, gpointer data)
741 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
742 GtkWidget *statusbar = get_widget_assert (de->builder, "status-bar");
744 if ( gtk_toggle_action_get_active (action) )
745 gtk_widget_show (statusbar);
747 gtk_widget_hide (statusbar);
752 grid_lines_activate (GtkToggleAction *action, gpointer data)
754 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
755 const gboolean grid_visible = gtk_toggle_action_get_active (action);
757 psppire_data_editor_show_grid (de->data_editor, grid_visible);
761 data_view_activate (GtkCheckMenuItem *menuitem, gpointer data)
763 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
765 gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_DATA_VIEW);
770 variable_view_activate (GtkCheckMenuItem *menuitem, gpointer data)
772 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
774 gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_VARIABLE_VIEW);
779 fonts_activate (GtkMenuItem *menuitem, gpointer data)
781 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
782 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (de));
783 PangoFontDescription *current_font;
786 gtk_font_selection_dialog_new (_("Font Selection"));
789 current_font = GTK_WIDGET(de->data_editor)->style->font_desc;
790 font_name = pango_font_description_to_string (current_font);
792 gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (dialog), font_name);
796 gtk_window_set_transient_for (GTK_WINDOW (dialog),
797 GTK_WINDOW (toplevel));
799 if ( GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (dialog)) )
801 const gchar *font = gtk_font_selection_dialog_get_font_name
802 (GTK_FONT_SELECTION_DIALOG (dialog));
804 PangoFontDescription* font_desc =
805 pango_font_description_from_string (font);
807 psppire_data_editor_set_font (de->data_editor, font_desc);
810 gtk_widget_hide (dialog);
815 /* Callback for the value labels action */
817 toggle_value_labels (GtkToggleAction *ta, gpointer data)
819 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
821 g_object_set (de->data_editor, "value-labels", gtk_toggle_action_get_active (ta), NULL);
825 toggle_split_window (GtkToggleAction *ta, gpointer data)
827 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
829 psppire_data_editor_split_window (de->data_editor,
830 gtk_toggle_action_get_active (ta));
835 file_quit (GtkCheckMenuItem *menuitem, gpointer data)
837 /* FIXME: Need to be more intelligent here.
838 Give the user the opportunity to save any unsaved data.
840 g_object_unref (the_data_store);
848 create_data_sheet_variable_popup_menu (PsppireDataWindow *de)
850 GtkWidget *menu = gtk_menu_new ();
852 GtkWidget *sort_ascending =
853 gtk_action_create_menu_item (gtk_action_new ("sort-up",
856 "gtk-sort-ascending"));
858 GtkWidget *sort_descending =
859 gtk_action_create_menu_item (gtk_action_new ("sort-down",
860 _("Sort Descending"),
862 "gtk-sort-descending"));
864 GtkWidget *insert_variable =
865 gtk_menu_item_new_with_label (_("Insert Variable"));
867 GtkWidget *clear_variable =
868 gtk_menu_item_new_with_label (_("Clear"));
871 gtk_action_connect_proxy (de->delete_variables,
875 gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable);
878 gtk_menu_shell_append (GTK_MENU_SHELL (menu),
879 gtk_separator_menu_item_new ());
882 gtk_menu_shell_append (GTK_MENU_SHELL (menu), clear_variable);
885 gtk_menu_shell_append (GTK_MENU_SHELL (menu),
886 gtk_separator_menu_item_new ());
889 gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_ascending);
892 g_signal_connect_swapped (sort_ascending, "activate",
893 G_CALLBACK (psppire_data_editor_sort_ascending),
896 g_signal_connect_swapped (sort_descending, "activate",
897 G_CALLBACK (psppire_data_editor_sort_descending),
900 g_signal_connect_swapped (insert_variable, "activate",
901 G_CALLBACK (gtk_action_activate),
902 de->insert_variable);
905 gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_descending);
907 gtk_widget_show_all (menu);
914 create_data_sheet_cases_popup_menu (PsppireDataWindow *de)
916 GtkWidget *menu = gtk_menu_new ();
918 GtkWidget *insert_case =
919 gtk_menu_item_new_with_label (_("Insert Case"));
921 GtkWidget *delete_case =
922 gtk_menu_item_new_with_label (_("Clear"));
925 gtk_action_connect_proxy (de->delete_cases,
929 gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_case);
931 g_signal_connect_swapped (insert_case, "activate",
932 G_CALLBACK (gtk_action_activate),
936 gtk_menu_shell_append (GTK_MENU_SHELL (menu),
937 gtk_separator_menu_item_new ());
940 gtk_menu_shell_append (GTK_MENU_SHELL (menu), delete_case);
943 gtk_widget_show_all (menu);
950 create_var_sheet_variable_popup_menu (PsppireDataWindow *de)
952 GtkWidget *menu = gtk_menu_new ();
954 GtkWidget *insert_variable =
955 gtk_menu_item_new_with_label (_("Insert Variable"));
957 GtkWidget *delete_variable =
958 gtk_menu_item_new_with_label (_("Clear"));
961 gtk_action_connect_proxy (de->delete_variables,
965 gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable);
967 g_signal_connect_swapped (insert_variable, "activate",
968 G_CALLBACK (gtk_action_activate),
969 de->insert_variable);
972 gtk_menu_shell_append (GTK_MENU_SHELL (menu),
973 gtk_separator_menu_item_new ());
976 gtk_menu_shell_append (GTK_MENU_SHELL (menu), delete_variable);
979 gtk_widget_show_all (menu);
986 on_recent_data_select (GtkMenuShell *menushell,
987 PsppireWindow *window)
992 gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell));
994 file = g_filename_from_uri (uri, NULL, NULL);
998 psppire_window_load (window, file);
1004 on_recent_files_select (GtkMenuShell *menushell, gpointer user_data)
1011 gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell));
1013 file = g_filename_from_uri (uri, NULL, NULL);
1017 se = psppire_syntax_window_new ();
1019 if ( psppire_window_load (PSPPIRE_WINDOW (se), file) )
1020 gtk_widget_show (se);
1022 gtk_widget_destroy (se);
1029 enable_delete_cases (GtkWidget *w, gint case_num, gpointer data)
1031 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
1033 gtk_action_set_visible (de->delete_cases, case_num != -1);
1038 enable_delete_variables (GtkWidget *w, gint var, gpointer data)
1040 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
1042 gtk_action_set_visible (de->delete_variables, var != -1);
1045 /* Callback for when the datasheet/varsheet is selected */
1047 on_switch_sheet (GtkNotebook *notebook,
1048 GtkNotebookPage *page,
1052 PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (user_data);
1054 GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
1056 GtkWidget *view_data =
1057 gtk_ui_manager_get_widget (uim,"/ui/menubar/view/view_data");
1059 GtkWidget *view_variables =
1060 gtk_ui_manager_get_widget (uim,"/ui/menubar/view/view_variables");
1064 case PSPPIRE_DATA_EDITOR_VARIABLE_VIEW:
1065 gtk_widget_hide (view_variables);
1066 gtk_widget_show (view_data);
1067 gtk_action_set_sensitive (de->insert_variable, TRUE);
1068 gtk_action_set_sensitive (de->insert_case, FALSE);
1069 gtk_action_set_sensitive (de->invoke_goto_dialog, FALSE);
1071 case PSPPIRE_DATA_EDITOR_DATA_VIEW:
1072 gtk_widget_show (view_variables);
1073 gtk_widget_hide (view_data);
1074 gtk_action_set_sensitive (de->invoke_goto_dialog, TRUE);
1075 gtk_action_set_sensitive (de->insert_case, TRUE);
1078 g_assert_not_reached ();
1083 update_paste_menuitem (de, page_num);
1089 resolve_action (GtkBuilder *builder, const gchar *action, const gchar *proxy)
1091 GtkWidget *pr = NULL;
1092 GtkAction *act = get_action_assert (builder, action);
1093 g_assert (GTK_IS_ACTION (act));
1096 pr = get_widget_assert (builder, proxy);
1099 gtk_action_connect_proxy (act, pr);
1106 set_unsaved (gpointer w)
1108 psppire_window_set_unsaved (PSPPIRE_WINDOW (w));
1112 psppire_data_window_init (PsppireDataWindow *de)
1114 PsppireVarStore *vs;
1115 PsppireDict *dict = NULL;
1121 GtkWidget *box = gtk_vbox_new (FALSE, 0);
1122 de->builder = builder_new ("data-editor.ui");
1124 menubar = get_widget_assert (de->builder, "menubar");
1125 hb = get_widget_assert (de->builder, "handlebox1");
1126 sb = get_widget_assert (de->builder, "status-bar");
1129 PSPPIRE_DATA_EDITOR (psppire_data_editor_new (the_var_store, the_data_store));
1131 g_signal_connect_swapped (the_data_store, "case-changed",
1132 G_CALLBACK (set_unsaved), de);
1134 g_signal_connect_swapped (the_data_store, "case-inserted",
1135 G_CALLBACK (set_unsaved), de);
1137 g_signal_connect_swapped (the_data_store, "cases-deleted",
1138 G_CALLBACK (set_unsaved), de);
1140 dataset_set_callback (the_dataset, set_unsaved, de);
1142 connect_help (de->builder);
1144 gtk_box_pack_start (GTK_BOX (box), menubar, FALSE, TRUE, 0);
1145 gtk_box_pack_start (GTK_BOX (box), hb, FALSE, TRUE, 0);
1146 gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (de->data_editor), TRUE, TRUE, 0);
1147 gtk_box_pack_start (GTK_BOX (box), sb, FALSE, TRUE, 0);
1149 gtk_container_add (GTK_CONTAINER (de), box);
1151 set_cut_copy_menuitem_sensitivity (de, FALSE);
1153 g_signal_connect_swapped (de->data_editor, "data-selection-changed",
1154 G_CALLBACK (set_cut_copy_menuitem_sensitivity), de);
1157 set_paste_menuitem_sensitivity (de, FALSE);
1159 g_signal_connect_swapped (de->data_editor, "data-available-changed",
1160 G_CALLBACK (set_paste_menuitem_sensitivity), de);
1162 dataset_add_transform_change_callback (the_dataset,
1163 transformation_change_callback,
1169 g_assert(vs); /* Traps a possible bug in w32 build */
1171 g_object_get (vs, "dictionary", &dict, NULL);
1173 g_signal_connect (dict, "weight-changed",
1174 G_CALLBACK (on_weight_change),
1177 g_signal_connect (dict, "filter-changed",
1178 G_CALLBACK (on_filter_change),
1181 g_signal_connect (dict, "split-changed",
1182 G_CALLBACK (on_split_change),
1186 g_signal_connect (get_action_assert (de->builder, "edit_copy"),
1188 G_CALLBACK (on_edit_copy), de);
1190 g_signal_connect (get_action_assert (de->builder, "edit_cut"),
1192 G_CALLBACK (on_edit_cut), de);
1197 GtkWidget *toolbarbutton = get_widget_assert (de->builder, "button-open");
1199 GtkAction *action_data_open =
1200 resolve_action (de->builder, "file_open", NULL);
1202 g_object_set (action_data_open,
1203 "tooltip", _("Open a data or syntax file"),
1204 "stock-id", "gtk-open",
1207 g_signal_connect (action_data_open, "activate",
1208 G_CALLBACK (open_window), de);
1210 g_signal_connect_swapped (toolbarbutton, "clicked",
1211 G_CALLBACK (gtk_action_activate), action_data_open);
1217 GtkAction *action_data_new =
1218 resolve_action (de->builder, "file_new_data", NULL);
1220 g_object_set (action_data_new,
1221 "tooltip", _("New data file"),
1222 "stock-id", "gtk-new",
1225 g_signal_connect (action_data_new, "activate",
1226 G_CALLBACK (new_file), de);
1232 GtkAction *invoke_text_import_assistant =
1233 resolve_action (de->builder, "file_import-text", NULL);
1235 g_object_set (invoke_text_import_assistant,
1236 "tooltip", _("Import text data file"),
1237 "stock-id", "gtk-convert",
1240 g_signal_connect (invoke_text_import_assistant, "activate",
1241 G_CALLBACK (text_data_import_assistant), de);
1247 GtkAction *action_data_save =
1248 resolve_action (de->builder, "file_save", "button-save");
1251 g_object_set (action_data_save,
1252 "tooltip", _("Save data to file"),
1253 "stock-id", "gtk-save",
1256 g_signal_connect_swapped (action_data_save, "activate",
1257 G_CALLBACK (data_save), de);
1264 GtkAction *action_data_save_as =
1265 resolve_action (de->builder, "file_save_as", NULL);
1267 g_object_set (action_data_save_as,
1268 "tooltip", _("Save data to file"),
1269 "stock-id", "gtk-save-as",
1272 g_signal_connect_swapped (action_data_save_as, "activate",
1273 G_CALLBACK (data_save_as_dialog), de);
1278 GtkAction *action_info_working_file =
1279 resolve_action (de->builder,
1280 "file_information_working-file", NULL);
1283 g_signal_connect_swapped (action_info_working_file, "activate",
1284 G_CALLBACK (display_dict), de);
1289 GtkAction *action_info_external_file =
1290 resolve_action (de->builder,
1291 "file_information_external-file", NULL);
1294 g_signal_connect_swapped (action_info_external_file, "activate",
1295 G_CALLBACK (sysfile_info), de);
1301 GtkAction *value_labels_action =
1302 resolve_action (de->builder,
1303 "view_value-labels", "togglebutton-value-labels");
1305 g_object_set (value_labels_action,
1306 "tooltip", _("Show/hide value labels"),
1307 "stock-id", "pspp-value-labels",
1310 g_signal_connect (value_labels_action, "toggled",
1311 G_CALLBACK (toggle_value_labels), de);
1315 g_signal_connect (get_action_assert (de->builder, "edit_paste"), "activate",
1316 G_CALLBACK (on_edit_paste),
1321 resolve_action (de->builder, "edit_clear-cases", NULL);
1324 g_object_set (de->delete_cases,
1325 "label", _("Clear"),
1326 "tooltip", _("Delete the cases at the selected position(s)"),
1327 "stock-id", "gtk-clear",
1330 g_signal_connect_swapped (de->delete_cases, "activate",
1331 G_CALLBACK (psppire_data_editor_delete_cases),
1334 gtk_action_set_visible (de->delete_cases, FALSE);
1339 de->delete_variables =
1340 resolve_action (de->builder, "edit_clear-variables", NULL);
1342 g_object_set (de->delete_variables,
1343 "label", _("Clear"),
1344 "tooltip", _("Delete the variables at the selected position(s)"),
1345 "stock-id", "gtk-clear",
1349 g_signal_connect_swapped (de->delete_variables, "activate",
1350 G_CALLBACK (psppire_data_editor_delete_variables),
1353 gtk_action_set_visible (de->delete_variables, FALSE);
1357 de->insert_variable =
1358 resolve_action (de->builder, "edit_insert-variable",
1359 "button-insert-variable");
1361 g_object_set (de->insert_variable,
1362 "tooltip", _("Create a new variable at the current position"),
1363 "stock-id", "pspp-insert-variable",
1366 g_signal_connect (de->insert_variable, "activate",
1367 G_CALLBACK (on_insert_variable), de->data_editor);
1374 resolve_action (de->builder, "edit_insert-case", "button-insert-case");
1376 g_object_set (de->insert_case,
1377 "tooltip", _("Create a new case at the current position"),
1378 "stock-id", "pspp-insert-case",
1381 g_signal_connect (de->insert_case, "activate",
1382 G_CALLBACK (insert_case), de);
1388 de->invoke_goto_dialog =
1389 resolve_action (de->builder, "edit_goto-case", "button-goto-case");
1392 g_object_set (de->invoke_goto_dialog,
1393 "tooltip", _("Jump to a Case in the Data Sheet"),
1394 "stock-id", "gtk-jump-to",
1397 g_signal_connect (de->invoke_goto_dialog, "activate",
1398 G_CALLBACK (goto_case_dialog), de);
1403 GtkAction *invoke_weight_cases_dialog =
1404 resolve_action (de->builder, "data_weight-cases", "button-weight-cases");
1407 g_object_set (invoke_weight_cases_dialog,
1408 "stock-id", "pspp-weight-cases",
1409 "tooltip", _("Weight cases by variable"),
1412 g_signal_connect (invoke_weight_cases_dialog, "activate",
1413 G_CALLBACK (weight_cases_dialog), de);
1418 GtkAction *invoke_transpose_dialog =
1419 resolve_action (de->builder, "data_transpose", NULL);
1422 g_object_set (invoke_transpose_dialog,
1423 "tooltip", _("Transpose the cases with the variables"),
1424 "stock-id", "pspp-transpose",
1427 g_signal_connect (invoke_transpose_dialog, "activate",
1428 G_CALLBACK (transpose_dialog), de);
1433 GtkAction *invoke_split_file_dialog =
1434 resolve_action (de->builder, "data_split-file", "button-split-file");
1436 g_object_set (invoke_split_file_dialog,
1437 "tooltip", _("Split the active file"),
1438 "stock-id", "pspp-split-file",
1441 g_signal_connect (invoke_split_file_dialog, "activate",
1442 G_CALLBACK (split_file_dialog), de);
1447 GtkAction *invoke_sort_cases_dialog =
1448 resolve_action (de->builder, "data_sort-cases", NULL);
1451 g_object_set (invoke_sort_cases_dialog,
1452 "tooltip", _("Sort cases in the active file"),
1453 "stock-id", "gtk-sort-ascending",
1456 g_signal_connect (invoke_sort_cases_dialog, "activate",
1457 G_CALLBACK (sort_cases_dialog), de);
1462 GtkAction *invoke_select_cases_dialog =
1463 resolve_action (de->builder, "data_select-cases", "button-select-cases");
1465 g_object_set (invoke_select_cases_dialog,
1466 "tooltip", _("Select cases from the active file"),
1467 "stock-id", "pspp-select-cases",
1470 g_signal_connect (invoke_select_cases_dialog, "activate",
1471 G_CALLBACK (select_cases_dialog), de);
1476 GtkAction *invoke_compute_dialog =
1477 resolve_action (de->builder, "transform_compute", NULL);
1479 g_object_set (invoke_compute_dialog,
1480 "tooltip", _("Compute new values for a variable"),
1481 "stock-id", "pspp-compute",
1484 g_signal_connect (invoke_compute_dialog, "activate",
1485 G_CALLBACK (compute_dialog), de);
1490 GtkAction *invoke_oneway_anova_dialog =
1491 resolve_action (de->builder, "oneway-anova", NULL);
1493 g_object_set (invoke_oneway_anova_dialog,
1494 "tooltip", _("Perform one way analysis of variance"),
1497 g_signal_connect (invoke_oneway_anova_dialog, "activate",
1498 G_CALLBACK (oneway_anova_dialog), de);
1503 GtkAction *invoke_t_test_independent_samples_dialog =
1504 resolve_action (de->builder, "indep-t-test", NULL);
1507 g_object_set (invoke_t_test_independent_samples_dialog,
1509 _("Calculate T Test for samples from independent groups"),
1512 g_signal_connect (invoke_t_test_independent_samples_dialog, "activate",
1513 G_CALLBACK (t_test_independent_samples_dialog), de);
1518 GtkAction *invoke_t_test_paired_samples_dialog =
1519 resolve_action (de->builder, "paired-t-test", NULL);
1521 g_object_set (invoke_t_test_paired_samples_dialog,
1523 _("Calculate T Test for paired samples"),
1526 g_signal_connect (invoke_t_test_paired_samples_dialog, "activate",
1527 G_CALLBACK (t_test_paired_samples_dialog), de);
1532 GtkAction *invoke_t_test_one_sample_dialog =
1533 resolve_action (de->builder, "one-sample-t-test", NULL);
1535 g_object_set (invoke_t_test_one_sample_dialog,
1537 _("Calculate T Test for sample from a single distribution"),
1540 g_signal_connect (invoke_t_test_one_sample_dialog, "activate",
1541 G_CALLBACK (t_test_one_sample_dialog), de);
1546 GtkAction *invoke_comments_dialog =
1547 resolve_action (de->builder, "utilities_comments", NULL);
1550 g_object_set (invoke_comments_dialog,
1552 _("Commentary text for the data file"),
1555 g_signal_connect (invoke_comments_dialog, "activate",
1556 G_CALLBACK (comments_dialog), de);
1562 GtkAction *invoke_find_dialog =
1563 resolve_action (de->builder, "edit_find", "button-find");
1565 g_object_set (invoke_find_dialog, "stock-id", "gtk-find", NULL);
1567 g_signal_connect (invoke_find_dialog, "activate",
1568 G_CALLBACK (find_dialog), de);
1573 GtkAction *invoke_rank_dialog =
1574 resolve_action (de->builder, "transform_rank", NULL);
1576 g_object_set (invoke_rank_dialog,
1577 "stock-id", "pspp-rank-cases",
1578 "tooltip", _("Rank Cases"),
1581 g_signal_connect (invoke_rank_dialog, "activate",
1582 G_CALLBACK (rank_dialog), de);
1587 GtkAction *invoke_recode_same_dialog =
1588 resolve_action (de->builder, "transform_recode-same", NULL);
1590 g_object_set (invoke_recode_same_dialog,
1591 "stock-id", "pspp-recode-same",
1592 "tooltip", _("Recode values into the same variables"),
1595 g_signal_connect (invoke_recode_same_dialog, "activate",
1596 G_CALLBACK (recode_same_dialog), de);
1601 GtkAction *invoke_recode_different_dialog =
1602 resolve_action (de->builder, "transform_recode-different", NULL);
1604 g_object_set (invoke_recode_different_dialog,
1605 "stock-id", "pspp-recode-different",
1606 "tooltip", _("Recode values into different variables"),
1609 g_signal_connect (invoke_recode_different_dialog, "activate",
1610 G_CALLBACK (recode_different_dialog), de);
1615 GtkAction *invoke_variable_info_dialog =
1616 resolve_action (de->builder, "utilities_variables", "button-goto-variable");
1618 g_object_set (invoke_variable_info_dialog,
1619 "stock-id", "pspp-goto-variable",
1620 "tooltip", _("Jump to variable"),
1623 g_signal_connect (invoke_variable_info_dialog, "activate",
1624 G_CALLBACK (variable_info_dialog), de);
1629 GtkAction *invoke_descriptives_dialog =
1630 resolve_action (de->builder, "analyze_descriptives", NULL);
1632 g_object_set (invoke_descriptives_dialog,
1633 "tooltip", _("Calculate descriptive statistics (mean, variance, ...)"),
1634 "stock-id", "pspp-descriptives",
1637 g_signal_connect (invoke_descriptives_dialog, "activate",
1638 G_CALLBACK (descriptives_dialog), de);
1643 GtkAction *invoke_frequencies_dialog =
1644 resolve_action (de->builder, "analyze_frequencies", NULL);
1646 g_object_set (invoke_frequencies_dialog,
1647 "tooltip", _("Generate frequency statistics"),
1648 "stock-id", "pspp-frequencies",
1651 g_signal_connect (invoke_frequencies_dialog, "activate",
1652 G_CALLBACK (frequencies_dialog), de);
1657 GtkAction *invoke_crosstabs_dialog =
1658 resolve_action (de->builder, "crosstabs", NULL);
1660 g_object_set (invoke_crosstabs_dialog,
1661 "tooltip", _("Generate crosstabulations"),
1662 "stock-id", "pspp-crosstabs",
1665 g_signal_connect (invoke_crosstabs_dialog, "activate",
1666 G_CALLBACK (crosstabs_dialog), de);
1672 GtkAction *invoke_examine_dialog =
1673 resolve_action (de->builder, "analyze_explore", NULL);
1675 g_object_set (invoke_examine_dialog,
1676 "tooltip", _("Examine Data by Factors"),
1677 "stock-id", "pspp-examine",
1680 g_signal_connect (invoke_examine_dialog, "activate",
1681 G_CALLBACK (examine_dialog), de);
1686 GtkAction *invoke_regression_dialog =
1687 resolve_action (de->builder, "linear-regression", NULL);
1689 g_object_set (invoke_regression_dialog,
1690 "tooltip", _("Estimate parameters of the linear model"),
1691 "stock-id", "pspp-regression",
1695 g_signal_connect (invoke_regression_dialog, "activate",
1696 G_CALLBACK (regression_dialog), de);
1700 GtkAction *invoke_reliability_dialog =
1701 resolve_action (de->builder, "reliability", NULL);
1703 g_object_set (invoke_reliability_dialog,
1704 "tooltip", _("Reliability Analysis"),
1705 "stock-id", "pspp-reliability",
1709 g_signal_connect (invoke_reliability_dialog, "activate",
1710 G_CALLBACK (reliability_dialog), de);
1714 GtkAction *invoke_roc_dialog =
1715 resolve_action (de->builder, "roc-curve", NULL);
1717 g_object_set (invoke_roc_dialog,
1718 "tooltip", _("ROC Curve"),
1719 "stock-id", "pspp-roc",
1723 g_signal_connect (invoke_roc_dialog, "activate",
1724 G_CALLBACK (roc_dialog), de);
1728 GtkAction *invoke_correlation_dialog =
1729 resolve_action (de->builder, "correlation", NULL);
1731 g_object_set (invoke_correlation_dialog,
1732 "tooltip", _("Bivariate Correlation"),
1733 "stock-id", "pspp-correlation",
1737 g_signal_connect (invoke_correlation_dialog, "activate",
1738 G_CALLBACK (correlation_dialog), de);
1742 GtkAction *invoke_factor_dialog =
1743 resolve_action (de->builder, "factor-analysis", NULL);
1745 g_object_set (invoke_factor_dialog,
1746 "tooltip", _("Principal Axis Factoring and Principal Components Analysis"),
1747 "stock-id", "pspp-factor",
1751 g_signal_connect (invoke_factor_dialog, "activate",
1752 G_CALLBACK (factor_dialog), de);
1757 GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
1759 GtkWidget *recent_data =
1760 gtk_ui_manager_get_widget (uim,"/ui/menubar/file/file_recent-data");
1762 GtkWidget *recent_files =
1763 gtk_ui_manager_get_widget (uim,"/ui/menubar/file/file_recent-files");
1766 GtkWidget *menu_data =
1767 gtk_recent_chooser_menu_new_for_manager (the_recent_mgr);
1769 GtkWidget *menu_files =
1770 gtk_recent_chooser_menu_new_for_manager (the_recent_mgr);
1773 GtkRecentFilter *filter = gtk_recent_filter_new ();
1775 gtk_recent_filter_add_pattern (filter, "*.sav");
1776 gtk_recent_filter_add_pattern (filter, "*.SAV");
1777 gtk_recent_filter_add_pattern (filter, "*.por");
1778 gtk_recent_filter_add_pattern (filter, "*.POR");
1780 gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu_data), GTK_RECENT_SORT_MRU);
1782 gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu_data), filter);
1785 gtk_menu_item_set_submenu (GTK_MENU_ITEM (recent_data), menu_data);
1788 g_signal_connect (menu_data, "selection-done",
1789 G_CALLBACK (on_recent_data_select),
1793 GtkRecentFilter *filter = gtk_recent_filter_new ();
1795 gtk_recent_filter_add_pattern (filter, "*.sps");
1796 gtk_recent_filter_add_pattern (filter, "*.SPS");
1798 gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu_files), GTK_RECENT_SORT_MRU);
1800 gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu_files), filter);
1803 gtk_menu_item_set_submenu (GTK_MENU_ITEM (recent_files), menu_files);
1805 g_signal_connect (menu_files, "selection-done",
1806 G_CALLBACK (on_recent_files_select),
1811 g_signal_connect (get_action_assert (de->builder,"file_new_syntax"),
1813 G_CALLBACK (create_syntax_window),
1818 GtkAction *abt = get_action_assert (de->builder, "help_about");
1819 g_object_set (abt, "stock-id", "gtk-about", NULL);
1820 g_signal_connect (abt,
1822 G_CALLBACK (about_new),
1827 g_signal_connect (get_action_assert (de->builder,"help_reference"),
1829 G_CALLBACK (reference_manual),
1833 g_signal_connect (de->data_editor,
1835 G_CALLBACK (enable_delete_cases),
1838 g_signal_connect (de->data_editor,
1839 "variables-selected",
1840 G_CALLBACK (enable_delete_variables),
1844 g_signal_connect (de->data_editor,
1846 G_CALLBACK (on_switch_sheet), de);
1848 gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_VARIABLE_VIEW);
1849 gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_DATA_VIEW);
1851 g_signal_connect (get_action_assert (de->builder, "view_statusbar"),
1853 G_CALLBACK (status_bar_activate), de);
1856 g_signal_connect (get_action_assert (de->builder, "view_gridlines"),
1858 G_CALLBACK (grid_lines_activate), de);
1862 g_signal_connect (get_action_assert (de->builder, "view_data"),
1864 G_CALLBACK (data_view_activate), de);
1866 g_signal_connect (get_action_assert (de->builder, "view_variables"),
1868 G_CALLBACK (variable_view_activate), de);
1872 GtkAction *font_action =
1873 resolve_action (de->builder, "view_fonts", NULL);
1875 g_object_set (font_action,
1876 "stock-id", "gtk-select-font",
1879 g_signal_connect (font_action,
1881 G_CALLBACK (fonts_activate), de);
1886 g_signal_connect (get_action_assert (de->builder, "file_quit"),
1888 G_CALLBACK (file_quit), de);
1890 g_signal_connect (get_action_assert (de->builder, "transform_run-pending"),
1892 G_CALLBACK (execute), de);
1895 g_signal_connect (get_action_assert (de->builder, "windows_minimise_all"),
1897 G_CALLBACK (psppire_window_minimise_all), NULL);
1901 GtkAction *split_window_action =
1902 resolve_action (de->builder, "windows_split", NULL);
1904 g_object_set (split_window_action,
1905 "tooltip", _("Split the window vertically and horizontally"),
1906 "stock-id", "pspp-split-window",
1909 g_signal_connect (split_window_action, "toggled",
1910 G_CALLBACK (toggle_split_window),
1915 GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
1917 PSPPIRE_WINDOW (de)->menu =
1918 GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar/windows/windows_minimise_all")->parent);
1922 GtkMenu *data_sheet_variable_popup_menu =
1923 GTK_MENU (create_data_sheet_variable_popup_menu (de));
1925 GtkMenu *var_sheet_variable_popup_menu =
1926 GTK_MENU (create_var_sheet_variable_popup_menu (de));
1928 GtkMenu *data_sheet_cases_popup_menu =
1929 GTK_MENU (create_data_sheet_cases_popup_menu (de));
1931 g_object_set (de->data_editor,
1932 "datasheet-column-menu", data_sheet_variable_popup_menu,
1933 "datasheet-row-menu", data_sheet_cases_popup_menu,
1934 "varsheet-row-menu", var_sheet_variable_popup_menu,
1938 gtk_widget_show (GTK_WIDGET (de->data_editor));
1939 gtk_widget_show (box);
1944 psppire_data_window_new (void)
1946 return GTK_WIDGET (g_object_new (psppire_data_window_get_type (),
1947 "description", _("Data Editor"),
1957 psppire_data_window_iface_init (PsppireWindowIface *iface)
1959 iface->save = save_file;
1960 iface->load = load_file;