/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation
+ Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 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 "libpspp/str.h"
#include "ui/gui/aggregate-dialog.h"
#include "ui/gui/autorecode-dialog.h"
-#include "ui/gui/binomial-dialog.h"
+#include "ui/gui/builder-wrapper.h"
#include "ui/gui/chi-square-dialog.h"
#include "ui/gui/comments-dialog.h"
#include "ui/gui/compute-dialog.h"
-#include "ui/gui/correlation-dialog.h"
#include "ui/gui/count-dialog.h"
-#include "ui/gui/crosstabs-dialog.h"
-#include "ui/gui/descriptives-dialog.h"
#include "ui/gui/entry-dialog.h"
-#include "ui/gui/examine-dialog.h"
#include "ui/gui/executor.h"
-#include "ui/gui/factor-dialog.h"
-#include "ui/gui/find-dialog.h"
-#include "ui/gui/frequencies-dialog.h"
-#include "ui/gui/goto-case-dialog.h"
#include "ui/gui/help-menu.h"
#include "ui/gui/helper.h"
-#include "ui/gui/k-means-dialog.h"
+#include "ui/gui/helper.h"
#include "ui/gui/k-related-dialog.h"
#include "ui/gui/npar-two-sample-related.h"
#include "ui/gui/oneway-anova-dialog.h"
#include "ui/gui/psppire-data-window.h"
+#include "ui/gui/psppire-dialog-action.h"
#include "ui/gui/psppire-syntax-window.h"
#include "ui/gui/psppire-window.h"
#include "ui/gui/psppire.h"
-#include "ui/gui/rank-dialog.h"
#include "ui/gui/runs-dialog.h"
#include "ui/gui/ks-one-sample-dialog.h"
#include "ui/gui/recode-dialog.h"
-#include "ui/gui/regression-dialog.h"
-#include "ui/gui/reliability-dialog.h"
-#include "ui/gui/roc-dialog.h"
#include "ui/gui/select-cases-dialog.h"
-#include "ui/gui/sort-cases-dialog.h"
#include "ui/gui/split-file-dialog.h"
-#include "ui/gui/t-test-independent-samples-dialog.h"
#include "ui/gui/t-test-one-sample.h"
#include "ui/gui/t-test-paired-samples.h"
#include "ui/gui/text-data-import-dialog.h"
#include "ui/gui/transpose-dialog.h"
-#include "ui/gui/variable-info-dialog.h"
+#include "ui/gui/univariate-dialog.h"
#include "ui/gui/weight-cases-dialog.h"
#include "ui/syntax-gen.h"
static void psppire_data_window_iface_init (PsppireWindowIface *iface);
static void psppire_data_window_dispose (GObject *object);
+static void psppire_data_window_finalize (GObject *object);
static void psppire_data_window_set_property (GObject *object,
guint prop_id,
const GValue *value,
GValue *value,
GParamSpec *pspec);
+static guint psppire_data_window_add_ui (PsppireDataWindow *, GtkUIManager *);
+static void psppire_data_window_remove_ui (PsppireDataWindow *,
+ GtkUIManager *, guint);
+
GType
psppire_data_window_get_type (void)
{
parent_class = g_type_class_peek_parent (class);
object_class->dispose = psppire_data_window_dispose;
+ object_class->finalize = psppire_data_window_finalize;
object_class->set_property = psppire_data_window_set_property;
object_class->get_property = psppire_data_window_get_property;
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
}
\f
-static void
-set_paste_menuitem_sensitivity (PsppireDataWindow *de, gboolean x)
-{
- GtkAction *edit_paste = get_action_assert (de->builder, "edit_paste");
-
- gtk_action_set_sensitive (edit_paste, x);
-}
-
-static void
-set_cut_copy_menuitem_sensitivity (PsppireDataWindow *de, gboolean x)
-{
- GtkAction *edit_copy = get_action_assert (de->builder, "edit_copy");
- GtkAction *edit_cut = get_action_assert (de->builder, "edit_cut");
-
- gtk_action_set_sensitive (edit_copy, x);
- gtk_action_set_sensitive (edit_cut, x);
-}
-
/* Run the EXECUTE command. */
static void
execute (PsppireDataWindow *dw)
}
else
{
- PsppireVarStore *vs = NULL;
PsppireDict *dict = NULL;
struct variable *var ;
gchar *text ;
- g_object_get (de->data_editor, "var-store", &vs, NULL);
- g_object_get (vs, "dictionary", &dict, NULL);
+ g_object_get (de->data_editor, "dictionary", &dict, NULL);
var = psppire_dict_get_variable (dict, filter_index);
else
{
struct variable *var ;
- PsppireVarStore *vs = NULL;
PsppireDict *dict = NULL;
gchar *text;
- g_object_get (de->data_editor, "var-store", &vs, NULL);
- g_object_get (vs, "dictionary", &dict, NULL);
+ g_object_get (de->data_editor, "dictionary", &dict, NULL);
var = psppire_dict_get_variable (dict, weight_index);
}
static gboolean
-load_file (PsppireWindow *de, const gchar *file_name)
+load_file (PsppireWindow *de, const gchar *file_name, gpointer syn)
{
- struct string filename;
- gchar *utf8_file_name;
- const char *mime_type;
- gchar *syntax;
+ const char *mime_type = NULL;
+ gchar *syntax = NULL;
bool ok;
- ds_init_empty (&filename);
-
- utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
-
- syntax_gen_string (&filename, ss_cstr (utf8_file_name));
-
- g_free (utf8_file_name);
+ if (syn == NULL)
+ {
+ gchar *utf8_file_name;
+ struct string filename;
+ ds_init_empty (&filename);
+
+ utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
+
+ syntax_gen_string (&filename, ss_cstr (utf8_file_name));
+
+ g_free (utf8_file_name);
+
+ syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename));
+ ds_destroy (&filename);
- syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename));
- ds_destroy (&filename);
+ }
+ else
+ {
+ syntax = syn;
+ }
ok = execute_syntax (PSPPIRE_DATA_WINDOW (de),
lex_reader_for_string (syntax));
g_free (syntax);
- mime_type = (name_has_por_suffix (file_name)
- ? "application/x-spss-por"
- : "application/x-spss-sav");
-
- add_most_recent (file_name, mime_type);
+ if (ok && syn == NULL)
+ {
+ if (name_has_por_suffix (file_name))
+ mime_type = "application/x-spss-por";
+ else if (name_has_sav_suffix (file_name))
+ mime_type = "application/x-spss-sav";
+
+ add_most_recent (file_name, mime_type);
+ }
return ok;
}
}
-static void
-insert_case (PsppireDataWindow *dw)
-{
- psppire_data_editor_insert_case (dw->data_editor);
-}
-
-static void
-on_insert_variable (PsppireDataWindow *dw)
-{
- psppire_data_editor_insert_variable (dw->data_editor);
-}
-
-
static void
display_dict (PsppireDataWindow *de)
{
g_object_set (dialog, "local-only", FALSE, NULL);
gtk_file_filter_set_name (filter, _("System Files (*.sav)"));
- gtk_file_filter_add_pattern (filter, "*.sav");
- gtk_file_filter_add_pattern (filter, "*.SAV");
+ gtk_file_filter_add_mime_type (filter, "application/x-spss-sav");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("Portable Files (*.por) "));
- gtk_file_filter_add_pattern (filter, "*.por");
- gtk_file_filter_add_pattern (filter, "*.POR");
+ gtk_file_filter_add_mime_type (filter, "application/x-spss-por");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
filter = gtk_file_filter_new ();
gtk_message_dialog_format_secondary_text (
GTK_MESSAGE_DIALOG (dialog),
- _("Renaming \"%s\" to \"%s\" will delete destroy the existing "
+ _("Renaming \"%s\" to \"%s\" will destroy the existing "
"dataset named \"%s\". Are you sure that you want to do this?"),
old_dataset, new_dataset, existing_dataset);
GTK_STOCK_DELETE, GTK_RESPONSE_OK,
NULL);
- g_object_set (dialog, "icon-name", "psppicon", NULL);
+ g_object_set (dialog, "icon-name", "pspp", NULL);
result = gtk_dialog_run (GTK_DIALOG (dialog));
free (new_name);
}
-static void
-on_edit_paste (PsppireDataWindow *de)
-{
- psppire_data_editor_clip_paste (de->data_editor);
-}
-
-static void
-on_edit_copy (PsppireDataWindow *de)
-{
- psppire_data_editor_clip_copy (de->data_editor);
-}
-
-
-
-static void
-on_edit_cut (PsppireDataWindow *de)
-{
- psppire_data_editor_clip_cut (de->data_editor);
-}
-
-
static void
status_bar_activate (PsppireDataWindow *de, GtkToggleAction *action)
{
psppire_quit ();
}
-
static void
on_recent_data_select (GtkMenuShell *menushell,
PsppireWindow *window)
g_free (uri);
- open_data_window (window, file);
+ open_data_window (window, file, NULL);
g_free (file);
}
free (encoding);
- if ( psppire_window_load (PSPPIRE_WINDOW (se), file) )
+ if ( psppire_window_load (PSPPIRE_WINDOW (se), file, NULL) )
gtk_widget_show (se);
else
gtk_widget_destroy (se);
g_free (file);
}
-
-
static void
-enable_delete_cases (GtkWidget *w, gint case_num, gpointer data)
+set_unsaved (gpointer w)
{
- PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
-
- gtk_action_set_visible (de->delete_cases, case_num != -1);
+ psppire_window_set_unsaved (PSPPIRE_WINDOW (w));
}
-
static void
-enable_delete_variables (GtkWidget *w, gint var, gpointer data)
+on_switch_page (PsppireDataEditor *de, gpointer p,
+ gint pagenum, PsppireDataWindow *dw)
{
- PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data);
-
- gtk_action_set_visible (de->delete_variables, var != -1);
+ GtkWidget *page_menu_item;
+ gboolean is_ds;
+ const char *path;
+
+ is_ds = pagenum == PSPPIRE_DATA_EDITOR_DATA_VIEW;
+ path = (is_ds
+ ? "/ui/menubar/view/view_data"
+ : "/ui/menubar/view/view_variables");
+ page_menu_item = gtk_ui_manager_get_widget (dw->ui_manager, path);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (page_menu_item), TRUE);
}
-/* Callback for when the datasheet/varsheet is selected */
static void
-on_switch_sheet (GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- gpointer user_data)
+on_ui_manager_changed (PsppireDataEditor *de,
+ GParamSpec *pspec UNUSED,
+ PsppireDataWindow *dw)
{
- PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (user_data);
-
- GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
-
- GtkWidget *view_data =
- gtk_ui_manager_get_widget (uim,"/ui/menubar/view/view_data");
-
- GtkWidget *view_variables =
- gtk_ui_manager_get_widget (uim,"/ui/menubar/view/view_variables");
+ GtkUIManager *uim = psppire_data_editor_get_ui_manager (de);
+ if (uim == dw->uim)
+ return;
- switch (page_num)
+ if (dw->uim)
{
- case PSPPIRE_DATA_EDITOR_VARIABLE_VIEW:
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_variables),
- TRUE);
- gtk_action_set_sensitive (de->insert_variable, TRUE);
- gtk_action_set_sensitive (de->insert_case, FALSE);
- gtk_action_set_sensitive (de->invoke_goto_dialog, FALSE);
- break;
- case PSPPIRE_DATA_EDITOR_DATA_VIEW:
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_data), TRUE);
- gtk_action_set_sensitive (de->invoke_goto_dialog, TRUE);
- gtk_action_set_sensitive (de->insert_case, TRUE);
- break;
- default:
- g_assert_not_reached ();
- break;
+ psppire_data_window_remove_ui (dw, dw->uim, dw->merge_id);
+ g_object_unref (dw->uim);
+ dw->uim = NULL;
}
-#if 0
- update_paste_menuitem (de, page_num);
-#endif
-}
-
-
-
-static void
-set_unsaved (gpointer w)
-{
- psppire_window_set_unsaved (PSPPIRE_WINDOW (w));
+ dw->uim = uim;
+ if (dw->uim)
+ {
+ g_object_ref (dw->uim);
+ dw->merge_id = psppire_data_window_add_ui (dw, dw->uim);
+ }
}
-
/* Connects the action called ACTION_NAME to HANDLER passing DW as the auxilliary data.
Returns a pointer to the action
*/
GCallback handler)
{
GtkAction *action = get_action_assert (dw->builder, action_name);
-
+
g_signal_connect_swapped (action, "activate", handler, dw);
return action;
}
+/* Only a data file with at least one variable can be saved. */
+static void
+enable_save (PsppireDataWindow *dw)
+{
+ gboolean enable = psppire_dict_get_var_cnt (dw->dict) > 0;
+
+ gtk_action_set_sensitive (get_action_assert (dw->builder, "file_save"),
+ enable);
+ gtk_action_set_sensitive (get_action_assert (dw->builder, "file_save_as"),
+ enable);
+}
+
/* Initializes as much of a PsppireDataWindow as we can and must before the
dataset has been set.
static void
psppire_data_window_init (PsppireDataWindow *de)
{
- GtkUIManager *uim;
-
de->builder = builder_new ("data-editor.ui");
- uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
+ de->ui_manager = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
PSPPIRE_WINDOW (de)->menu =
- GTK_MENU_SHELL (gtk_ui_manager_get_widget (uim,"/ui/menubar/windows/windows_minimise_all")->parent);
+ GTK_MENU_SHELL (gtk_ui_manager_get_widget (de->ui_manager, "/ui/menubar/windows/windows_minimise_all")->parent);
+
+ de->uim = NULL;
+ de->merge_id = 0;
}
static void
transformation_change_callback, /* transformations_changed */
};
- PsppireDict *dict;
-
GtkWidget *menubar;
GtkWidget *hb ;
GtkWidget *sb ;
GtkWidget *box = gtk_vbox_new (FALSE, 0);
de->dataset = ds;
- dict = psppire_dict_new_from_dict (dataset_dict (ds));
- de->var_store = psppire_var_store_new (dict);
- de->data_store = psppire_data_store_new (dict);
+ de->dict = psppire_dict_new_from_dict (dataset_dict (ds));
+ de->data_store = psppire_data_store_new (de->dict);
psppire_data_store_set_reader (de->data_store, NULL);
menubar = get_widget_assert (de->builder, "menubar");
hb = get_widget_assert (de->builder, "handlebox1");
sb = get_widget_assert (de->builder, "status-bar");
+ de->uim = NULL;
+ de->merge_id = 0;
+
de->data_editor =
- PSPPIRE_DATA_EDITOR (psppire_data_editor_new (de, de->var_store,
- de->data_store));
+ PSPPIRE_DATA_EDITOR (psppire_data_editor_new (de->dict, de->data_store));
+ g_signal_connect (de->data_editor, "switch-page",
+ G_CALLBACK (on_switch_page), de);
g_signal_connect_swapped (de->data_store, "case-changed",
G_CALLBACK (set_unsaved), de);
gtk_container_add (GTK_CONTAINER (de), box);
- set_cut_copy_menuitem_sensitivity (de, FALSE);
-
- g_signal_connect_swapped (de->data_editor, "data-selection-changed",
- G_CALLBACK (set_cut_copy_menuitem_sensitivity), de);
-
-
- set_paste_menuitem_sensitivity (de, FALSE);
-
- g_signal_connect_swapped (de->data_editor, "data-available-changed",
- G_CALLBACK (set_paste_menuitem_sensitivity), de);
-
- g_signal_connect (dict, "weight-changed",
+ g_signal_connect (de->dict, "weight-changed",
G_CALLBACK (on_weight_change),
de);
- g_signal_connect (dict, "filter-changed",
+ g_signal_connect (de->dict, "filter-changed",
G_CALLBACK (on_filter_change),
de);
- g_signal_connect (dict, "split-changed",
+ g_signal_connect (de->dict, "split-changed",
G_CALLBACK (on_split_change),
de);
-
- connect_action (de, "edit_copy", G_CALLBACK (on_edit_copy));
-
- connect_action (de, "edit_cut", G_CALLBACK (on_edit_cut));
+ g_signal_connect_swapped (de->dict, "backend-changed",
+ G_CALLBACK (enable_save), de);
+ g_signal_connect_swapped (de->dict, "variable-inserted",
+ G_CALLBACK (enable_save), de);
+ g_signal_connect_swapped (de->dict, "variable-deleted",
+ G_CALLBACK (enable_save), de);
+ enable_save (de);
connect_action (de, "file_new_data", G_CALLBACK (create_data_window));
- connect_action (de, "file_import-text", G_CALLBACK (text_data_import_assistant));
+ connect_action (de, "file_import", G_CALLBACK (text_data_import_assistant));
connect_action (de, "file_save", G_CALLBACK (psppire_window_save));
connect_action (de, "file_information_external-file", G_CALLBACK (sysfile_info));
- connect_action (de, "edit_paste", G_CALLBACK (on_edit_paste));
-
- de->insert_case = connect_action (de, "edit_insert-case", G_CALLBACK (insert_case));
-
- de->insert_variable = connect_action (de, "action_insert-variable", G_CALLBACK (on_insert_variable));
-
- de->invoke_goto_dialog = connect_action (de, "edit_goto-case", G_CALLBACK (goto_case_dialog));
-
g_signal_connect_swapped (get_action_assert (de->builder, "view_value-labels"), "toggled", G_CALLBACK (toggle_value_labels), de);
- {
- de->delete_cases = get_action_assert (de->builder, "edit_clear-cases");
-
- g_signal_connect_swapped (de->delete_cases, "activate", G_CALLBACK (psppire_data_editor_delete_cases), de->data_editor);
-
- gtk_action_set_visible (de->delete_cases, FALSE);
- }
-
-
- {
- de->delete_variables = get_action_assert (de->builder, "edit_clear-variables");
-
- g_signal_connect_swapped (de->delete_variables, "activate", G_CALLBACK (psppire_data_editor_delete_variables), de->data_editor);
-
- gtk_action_set_visible (de->delete_variables, FALSE);
- }
-
-
connect_action (de, "data_transpose", G_CALLBACK (transpose_dialog));
-
connect_action (de, "data_select-cases", G_CALLBACK (select_cases_dialog));
-
- connect_action (de, "data_sort-cases", G_CALLBACK (sort_cases_dialog));
-
connect_action (de, "data_aggregate", G_CALLBACK (aggregate_dialog));
-
connect_action (de, "transform_compute", G_CALLBACK (compute_dialog));
-
connect_action (de, "transform_autorecode", G_CALLBACK (autorecode_dialog));
-
- connect_action (de, "edit_find", G_CALLBACK (find_dialog));
-
connect_action (de, "data_split-file", G_CALLBACK (split_file_dialog));
-
connect_action (de, "data_weight-cases", G_CALLBACK (weight_cases_dialog));
-
-
- connect_action (de, "utilities_variables", G_CALLBACK (variable_info_dialog));
-
connect_action (de, "oneway-anova", G_CALLBACK (oneway_anova_dialog));
-
- connect_action (de, "indep-t-test", G_CALLBACK (t_test_independent_samples_dialog));
-
connect_action (de, "paired-t-test", G_CALLBACK (t_test_paired_samples_dialog));
-
connect_action (de, "one-sample-t-test", G_CALLBACK (t_test_one_sample_dialog));
-
connect_action (de, "utilities_comments", G_CALLBACK (comments_dialog));
-
- connect_action (de, "transform_rank", G_CALLBACK (rank_dialog));
-
connect_action (de, "transform_count", G_CALLBACK (count_dialog));
-
connect_action (de, "transform_recode-same", G_CALLBACK (recode_same_dialog));
-
connect_action (de, "transform_recode-different", G_CALLBACK (recode_different_dialog));
-
- connect_action (de, "analyze_descriptives", G_CALLBACK (descriptives_dialog));
-
- connect_action (de, "analyze_frequencies", G_CALLBACK (frequencies_dialog));
-
- connect_action (de, "crosstabs", G_CALLBACK (crosstabs_dialog));
-
- connect_action (de, "analyze_explore", G_CALLBACK (examine_dialog));
-
- connect_action (de, "linear-regression", G_CALLBACK (regression_dialog));
-
- connect_action (de, "reliability", G_CALLBACK (reliability_dialog));
-
- connect_action (de, "roc-curve", G_CALLBACK (roc_dialog));
-
- connect_action (de, "correlation", G_CALLBACK (correlation_dialog));
-
- connect_action (de, "factor-analysis", G_CALLBACK (factor_dialog));
-
- connect_action (de, "k-means", G_CALLBACK (k_means_dialog));
-
+ connect_action (de, "univariate", G_CALLBACK (univariate_dialog));
connect_action (de, "chi-square", G_CALLBACK (chisquare_dialog));
- connect_action (de, "binomial", G_CALLBACK (binomial_dialog));
connect_action (de, "runs", G_CALLBACK (runs_dialog));
connect_action (de, "ks-one-sample", G_CALLBACK (ks_one_sample_dialog));
connect_action (de, "k-related-samples", G_CALLBACK (k_related_dialog));
connect_action (de, "two-related-samples", G_CALLBACK (two_related_dialog));
-
{
- GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
-
GtkWidget *recent_data =
- gtk_ui_manager_get_widget (uim,"/ui/menubar/file/file_recent-data");
+ gtk_ui_manager_get_widget (de->ui_manager, "/ui/menubar/file/file_recent-data");
GtkWidget *recent_files =
- gtk_ui_manager_get_widget (uim,"/ui/menubar/file/file_recent-files");
+ gtk_ui_manager_get_widget (de->ui_manager, "/ui/menubar/file/file_recent-files");
GtkWidget *menu_data = gtk_recent_chooser_menu_new_for_manager (
connect_action (de, "file_new_syntax", G_CALLBACK (create_syntax_window));
- g_signal_connect (de->data_editor,
- "cases-selected",
- G_CALLBACK (enable_delete_cases),
- de);
-
- g_signal_connect (de->data_editor,
- "variables-selected",
- G_CALLBACK (enable_delete_variables),
- de);
-
-
- g_signal_connect (de->data_editor,
- "switch-page",
- G_CALLBACK (on_switch_sheet), de);
-
gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_VARIABLE_VIEW);
gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_DATA_VIEW);
g_signal_connect_swapped (get_action_assert (de->builder, "windows_split"), "toggled", G_CALLBACK (toggle_split_window), de);
- {
- GtkUIManager *uim = GTK_UI_MANAGER (get_object_assert (de->builder, "uimanager1", GTK_TYPE_UI_MANAGER));
-
- merge_help_menu (uim);
- }
-
- {
- GtkWidget *data_sheet_cases_popup_menu = get_widget_assert (de->builder,
- "datasheet-cases-popup");
-
- GtkWidget *var_sheet_variable_popup_menu = get_widget_assert (de->builder,
- "varsheet-variable-popup");
-
- GtkWidget *data_sheet_variable_popup_menu = get_widget_assert (de->builder,
- "datasheet-variable-popup");
-
- g_signal_connect_swapped (get_action_assert (de->builder, "sort-up"), "activate",
- G_CALLBACK (psppire_data_editor_sort_ascending),
- de->data_editor);
+ merge_help_menu (de->ui_manager);
- g_signal_connect_swapped (get_action_assert (de->builder, "sort-down"), "activate",
- G_CALLBACK (psppire_data_editor_sort_descending),
- de->data_editor);
-
- g_object_set (de->data_editor,
- "datasheet-column-menu", data_sheet_variable_popup_menu,
- "datasheet-row-menu", data_sheet_cases_popup_menu,
- "varsheet-row-menu", var_sheet_variable_popup_menu,
- NULL);
- }
+ g_signal_connect (de->data_editor, "notify::ui-manager",
+ G_CALLBACK (on_ui_manager_changed), de);
+ on_ui_manager_changed (de->data_editor, NULL, de);
gtk_widget_show (GTK_WIDGET (de->data_editor));
gtk_widget_show (box);
{
PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (object);
+ if (dw->uim)
+ {
+ psppire_data_window_remove_ui (dw, dw->uim, dw->merge_id);
+ g_object_unref (dw->uim);
+ dw->uim = NULL;
+ }
+
if (dw->builder != NULL)
{
g_object_unref (dw->builder);
dw->builder = NULL;
}
- if (dw->var_store)
+ if (dw->dict)
{
- g_object_unref (dw->var_store);
- dw->var_store = NULL;
+ g_object_unref (dw->dict);
+ dw->dict = NULL;
}
if (dw->data_store)
G_OBJECT_CLASS (parent_class)->dispose (object);
}
+static void
+psppire_data_window_finalize (GObject *object)
+{
+ PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (object);
+
+ if (dw->dataset)
+ {
+ struct dataset *dataset = dw->dataset;
+ struct session *session = dataset_session (dataset);
+
+ dw->dataset = NULL;
+
+ dataset_set_callbacks (dataset, NULL, NULL);
+ session_set_active_dataset (session, NULL);
+ dataset_destroy (dataset);
+ }
+
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
psppire_data_window_set_property (GObject *object,
guint prop_id,
};
}
+static guint
+psppire_data_window_add_ui (PsppireDataWindow *pdw, GtkUIManager *uim)
+{
+ gchar *ui_string;
+ guint merge_id;
+ GList *list;
+
+ ui_string = gtk_ui_manager_get_ui (uim);
+ merge_id = gtk_ui_manager_add_ui_from_string (pdw->ui_manager, ui_string,
+ -1, NULL);
+ g_free (ui_string);
+
+ g_return_val_if_fail (merge_id != 0, 0);
+
+ list = gtk_ui_manager_get_action_groups (uim);
+ for (; list != NULL; list = list->next)
+ {
+ GtkActionGroup *action_group = list->data;
+ GList *actions = gtk_action_group_list_actions (action_group);
+ GList *action;
+
+ for (action = actions; action != NULL; action = action->next)
+ {
+ GtkAction *a = action->data;
+
+ if (PSPPIRE_IS_DIALOG_ACTION (a))
+ g_object_set (a, "manager", pdw->ui_manager, NULL);
+ }
+
+ gtk_ui_manager_insert_action_group (pdw->ui_manager, action_group, 0);
+ }
+
+ gtk_window_add_accel_group (GTK_WINDOW (pdw),
+ gtk_ui_manager_get_accel_group (uim));
+
+ return merge_id;
+}
+
+static void
+psppire_data_window_remove_ui (PsppireDataWindow *pdw,
+ GtkUIManager *uim, guint merge_id)
+{
+ GList *list;
+
+ g_return_if_fail (merge_id != 0);
+
+ gtk_ui_manager_remove_ui (pdw->ui_manager, merge_id);
+
+ list = gtk_ui_manager_get_action_groups (uim);
+ for (; list != NULL; list = list->next)
+ {
+ GtkActionGroup *action_group = list->data;
+ gtk_ui_manager_remove_action_group (pdw->ui_manager, action_group);
+ }
+
+ gtk_window_remove_accel_group (GTK_WINDOW (pdw),
+ gtk_ui_manager_get_accel_group (uim));
+}
+
GtkWidget*
psppire_data_window_new (struct dataset *ds)
{
GtkWidget *dw;
if (the_session == NULL)
- the_session = session_create ();
+ the_session = session_create (NULL);
if (ds == NULL)
{
- static int n_datasets;
- char *dataset_name;
-
- dataset_name = xasprintf ("DataSet%d", ++n_datasets);
+ char *dataset_name = session_generate_dataset_name (the_session);
ds = dataset_create (the_session, dataset_name);
free (dataset_name);
}
dw = GTK_WIDGET (
g_object_new (
psppire_data_window_get_type (),
- /* TRANSLATORS: This will form a filename. Please avoid whitespace. */
"description", _("Data Editor"),
"dataset", ds,
NULL));
bool
psppire_data_window_is_empty (PsppireDataWindow *dw)
{
- return psppire_var_store_get_var_cnt (dw->var_store) == 0;
+ return psppire_dict_get_var_cnt (dw->dict) == 0;
}
static void
return NULL;
}
+PsppireDataWindow *
+psppire_data_window_for_data_store (PsppireDataStore *data_store)
+{
+ PsppireDataWindow *pdw;
+
+ ll_for_each (pdw, PsppireDataWindow, ll, &all_data_windows)
+ if (pdw->data_store == data_store)
+ return pdw;
+
+ return NULL;
+}
+
void
create_data_window (void)
{
}
void
-open_data_window (PsppireWindow *victim, const char *file_name)
+open_data_window (PsppireWindow *victim, const char *file_name, gpointer hint)
{
GtkWidget *window;
if (PSPPIRE_IS_DATA_WINDOW (victim)
&& psppire_data_window_is_empty (PSPPIRE_DATA_WINDOW (victim)))
- window = GTK_WIDGET (victim);
+ {
+ window = GTK_WIDGET (victim);
+ gtk_widget_hide (GTK_WIDGET (PSPPIRE_DATA_WINDOW (window)->data_editor));
+ }
else
window = psppire_data_window_new (NULL);
- psppire_window_load (PSPPIRE_WINDOW (window), file_name);
- gtk_widget_show (window);
+ psppire_window_load (PSPPIRE_WINDOW (window), file_name, hint);
+ gtk_widget_show_all (window);
}
+