X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-window.c;h=73c98b383efcd6624809471dffbdf12badcfc25d;hb=a44f03df973e8dbce11e5424efb74c7b5e68334a;hp=f64c334103a6cee30f44c01ae8d98c33313b68aa;hpb=c15630be7fc977165f298acb81e75285a065c28f;p=pspp diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index f64c334103..73c98b383e 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -26,16 +26,13 @@ #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/count-dialog.h" -#include "ui/gui/crosstabs-dialog.h" #include "ui/gui/entry-dialog.h" #include "ui/gui/executor.h" -#include "ui/gui/frequencies-dialog.h" #include "ui/gui/help-menu.h" #include "ui/gui/helper.h" #include "ui/gui/helper.h" @@ -78,6 +75,7 @@ static void psppire_data_window_init (PsppireDataWindow *data_edit 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, @@ -145,6 +143,7 @@ psppire_data_window_class_init (PsppireDataWindowClass *class) 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; @@ -827,12 +826,24 @@ connect_action (PsppireDataWindow *dw, const char *action_name, 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. @@ -919,6 +930,13 @@ psppire_data_window_finish_init (PsppireDataWindow *de, G_CALLBACK (on_split_change), de); + 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)); @@ -952,11 +970,8 @@ psppire_data_window_finish_init (PsppireDataWindow *de, 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_frequencies", G_CALLBACK (frequencies_dialog)); - connect_action (de, "crosstabs", G_CALLBACK (crosstabs_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)); @@ -1053,6 +1068,13 @@ psppire_data_window_dispose (GObject *object) { 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); @@ -1081,6 +1103,27 @@ psppire_data_window_dispose (GObject *object) 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, @@ -1188,10 +1231,7 @@ psppire_data_window_new (struct dataset *ds) 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); }