From fc6620099bbc53762095569d5356b67a81a85402 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 28 Nov 2015 07:55:01 +0100 Subject: [PATCH] Persist dialog box widget settings. Arrange for the status of widgets within dialog boxes to persist between calls when called for the same dataset. Some users have requested this to make repeated operations easier. --- NEWS | 14 +++-- src/ui/gui/psppire-checkbox-treeview.c | 2 +- src/ui/gui/psppire-dialog-action-1sks.c | 11 +++- src/ui/gui/psppire-dialog-action-barchart.c | 13 +++-- src/ui/gui/psppire-dialog-action-binomial.c | 11 ++-- src/ui/gui/psppire-dialog-action-chisquare.c | 10 +++- src/ui/gui/psppire-dialog-action-compute.c | 11 +++- .../gui/psppire-dialog-action-correlation.c | 15 +++-- src/ui/gui/psppire-dialog-action-count.c | 12 ++-- src/ui/gui/psppire-dialog-action-crosstabs.c | 11 ++-- .../gui/psppire-dialog-action-descriptives.c | 15 +++-- src/ui/gui/psppire-dialog-action-examine.c | 10 +++- src/ui/gui/psppire-dialog-action-factor.c | 10 +++- src/ui/gui/psppire-dialog-action-flip.c | 11 +++- .../gui/psppire-dialog-action-frequencies.c | 12 ++-- src/ui/gui/psppire-dialog-action-histogram.c | 11 +++- .../gui/psppire-dialog-action-indep-samps.c | 11 ++-- src/ui/gui/psppire-dialog-action-k-related.c | 11 +++- src/ui/gui/psppire-dialog-action-kmeans.c | 12 ++-- src/ui/gui/psppire-dialog-action-logistic.c | 10 +++- src/ui/gui/psppire-dialog-action-means.c | 21 ++++--- src/ui/gui/psppire-dialog-action-oneway.c | 11 +++- src/ui/gui/psppire-dialog-action-paired.c | 11 +++- src/ui/gui/psppire-dialog-action-rank.c | 10 +++- src/ui/gui/psppire-dialog-action-regression.c | 11 +++- .../gui/psppire-dialog-action-reliability.c | 12 +++- src/ui/gui/psppire-dialog-action-roc.c | 12 +++- src/ui/gui/psppire-dialog-action-runs.c | 12 ++-- .../gui/psppire-dialog-action-scatterplot.c | 10 +++- src/ui/gui/psppire-dialog-action-sort.c | 17 ++++-- src/ui/gui/psppire-dialog-action-tt1s.c | 12 ++-- src/ui/gui/psppire-dialog-action-two-sample.c | 11 +++- src/ui/gui/psppire-dialog-action-univariate.c | 11 +++- src/ui/gui/psppire-dialog-action-var-info.c | 12 ++-- src/ui/gui/psppire-dialog-action.c | 58 ++++++++++++++++--- src/ui/gui/psppire-dialog-action.h | 1 + src/ui/gui/psppire-dialog.c | 8 +-- 37 files changed, 323 insertions(+), 140 deletions(-) diff --git a/NEWS b/NEWS index d7d0a4102b..f7deed7fa7 100644 --- a/NEWS +++ b/NEWS @@ -13,13 +13,17 @@ Changes from 0.8.5 to 0.9.0: * A Russian localisation has been contributed. - * The graphic user interface now has a Graphs menu to access the GRAPH - command. - * The GRAPH command now has a /BAR subcommand to draw barcharts. - * The graphical user interface uses Gtk+ version 3 instead of version 2. - Accordingly, it has a somewhat different look and feel. + * The graphical user interface (psppire) has been changed as follows: + + - It now uses Gtk+ version 3 instead of version 2. Accordingly, it has a + somewhat different look and feel. + + - There is now has a Graphs menu to access the GRAPH command. + + - The status of dialog box widgets are now preserved between calls + to the same dialog box for the same dataset. * The pspp-convert utility can now decrypt encrypted syntax files. The encrypted syntax file format is unacceptably insecure, so to diff --git a/src/ui/gui/psppire-checkbox-treeview.c b/src/ui/gui/psppire-checkbox-treeview.c index 04f49d3747..005ab54269 100644 --- a/src/ui/gui/psppire-checkbox-treeview.c +++ b/src/ui/gui/psppire-checkbox-treeview.c @@ -123,7 +123,7 @@ psppire_checkbox_treeview_init (PsppireCheckboxTreeview *cbtv) G_TYPE_STRING)); gtk_tree_view_set_model (GTK_TREE_VIEW (cbtv), cbtv->list); - g_object_unref (cbtv->list); + // g_object_unref (cbtv->list); treeview_checkbox_populate (GTK_TREE_VIEW (cbtv)); } diff --git a/src/ui/gui/psppire-dialog-action-1sks.c b/src/ui/gui/psppire-dialog-action-1sks.c index 055d3e9f0c..0d25f3e7ce 100644 --- a/src/ui/gui/psppire-dialog-action-1sks.c +++ b/src/ui/gui/psppire-dialog-action-1sks.c @@ -122,7 +122,14 @@ psppire_dialog_action_1sks_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogAction1sks *act = PSPPIRE_DIALOG_ACTION_1SKS (a); - GtkBuilder *xml = builder_new ("ks-one-sample.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("ks-one-sample.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "ks-one-sample-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -136,8 +143,6 @@ psppire_dialog_action_1sks_activate (GtkAction *a) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_1sks_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_1sks_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-barchart.c b/src/ui/gui/psppire-dialog-action-barchart.c index 87b8fa1318..d381c1abf1 100644 --- a/src/ui/gui/psppire-dialog-action-barchart.c +++ b/src/ui/gui/psppire-dialog-action-barchart.c @@ -120,7 +120,14 @@ psppire_dialog_action_barchart_activate (GtkAction *a) PsppireDialogActionBarchart *act = PSPPIRE_DIALOG_ACTION_BARCHART (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("barchart.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("barchart.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "barchart-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -138,15 +145,13 @@ psppire_dialog_action_barchart_activate (GtkAction *a) populate_combo_model (GTK_COMBO_BOX(act->combobox)); - g_object_unref (xml); - g_signal_connect_swapped (act->button_summary_func, "toggled", G_CALLBACK (on_summary_toggle), act); psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, - dialog_state_valid); + dialog_state_valid); if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_barchart_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_barchart_parent_class)->activate (pda); diff --git a/src/ui/gui/psppire-dialog-action-binomial.c b/src/ui/gui/psppire-dialog-action-binomial.c index 6581b96c0d..0f63e0652f 100644 --- a/src/ui/gui/psppire-dialog-action-binomial.c +++ b/src/ui/gui/psppire-dialog-action-binomial.c @@ -102,7 +102,13 @@ psppire_dialog_action_binomial_activate (GtkAction *a) PsppireDialogActionBinomial *act = PSPPIRE_DIALOG_ACTION_BINOMIAL (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("binomial.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("binomial.ui"); + g_hash_table_insert (thing, a, xml); + } pda->dialog = get_widget_assert (xml, "binomial-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -114,9 +120,6 @@ psppire_dialog_action_binomial_activate (GtkAction *a) act->cutpoint_entry = get_widget_assert (xml, "cutpoint-entry"); act->cutpoint_button = get_widget_assert (xml, "radiobutton4"); - g_object_unref (xml); - - g_signal_connect (act->cutpoint_button, "toggled", G_CALLBACK (set_sensitivity_from_toggle), act->cutpoint_entry); diff --git a/src/ui/gui/psppire-dialog-action-chisquare.c b/src/ui/gui/psppire-dialog-action-chisquare.c index bca99ab575..ca08698ae0 100644 --- a/src/ui/gui/psppire-dialog-action-chisquare.c +++ b/src/ui/gui/psppire-dialog-action-chisquare.c @@ -134,7 +134,13 @@ psppire_dialog_action_chisquare_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionChisquare *act = PSPPIRE_DIALOG_ACTION_CHISQUARE (a); - GtkBuilder *xml = builder_new ("chi-square.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("chi-square.ui"); + g_hash_table_insert (thing, a, xml); + } GtkWidget *range_table = get_widget_assert (xml, "range-table"); GtkWidget *values_acr = get_widget_assert (xml, "psppire-acr1"); @@ -159,8 +165,6 @@ psppire_dialog_action_chisquare_activate (GtkAction *a) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - g_signal_connect (act->range_button, "toggled", G_CALLBACK (set_sensitivity_from_toggle), range_table); diff --git a/src/ui/gui/psppire-dialog-action-compute.c b/src/ui/gui/psppire-dialog-action-compute.c index 5fc63d5ded..164737ce21 100644 --- a/src/ui/gui/psppire-dialog-action-compute.c +++ b/src/ui/gui/psppire-dialog-action-compute.c @@ -461,7 +461,14 @@ psppire_dialog_action_compute_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionCompute *act = PSPPIRE_DIALOG_ACTION_COMPUTE (a); - GtkBuilder *xml = builder_new ("compute.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("compute.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "compute-variable-dialog"); pda->source = get_widget_assert (xml, "compute-treeview1"); @@ -520,8 +527,6 @@ psppire_dialog_action_compute_activate (GtkAction *a) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_compute_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_compute_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-correlation.c b/src/ui/gui/psppire-dialog-action-correlation.c index 29f6e20179..4dd10f3b42 100644 --- a/src/ui/gui/psppire-dialog-action-correlation.c +++ b/src/ui/gui/psppire-dialog-action-correlation.c @@ -97,9 +97,16 @@ psppire_dialog_action_correlation_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionCorrelation *act = PSPPIRE_DIALOG_ACTION_CORRELATION (a); - GtkBuilder *xml = builder_new ("correlation.ui"); - pda->dialog = get_widget_assert (xml, "correlation-dialog"); - pda->source = get_widget_assert (xml, "dict-view"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("correlation.ui"); + g_hash_table_insert (thing, a, xml); + } + + pda->dialog = get_widget_assert (xml, "correlation-dialog"); + pda->source = get_widget_assert (xml, "dict-view"); act->variables = get_widget_assert (xml, "psppire-var-view1"); act->significant = get_widget_assert (xml, "button-flag-significants"); @@ -108,8 +115,6 @@ psppire_dialog_action_correlation_activate (GtkAction *a) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_correlation_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_correlation_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-count.c b/src/ui/gui/psppire-dialog-action-count.c index edb44a065c..69174950b1 100644 --- a/src/ui/gui/psppire-dialog-action-count.c +++ b/src/ui/gui/psppire-dialog-action-count.c @@ -150,7 +150,14 @@ psppire_dialog_action_count_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionCount *act = PSPPIRE_DIALOG_ACTION_COUNT (a); - GtkBuilder *xml = builder_new ("count.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("count.ui"); + g_hash_table_insert (thing, a, xml); + } + GtkWidget *selector = get_widget_assert (xml, "count-selector1"); GtkWidget *button = get_widget_assert (xml, "button1"); @@ -168,12 +175,9 @@ psppire_dialog_action_count_activate (GtkAction *a) g_signal_connect_swapped (button, "clicked", G_CALLBACK (values_dialog), act); - psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_count_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_count_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-crosstabs.c b/src/ui/gui/psppire-dialog-action-crosstabs.c index fa9f282ac6..f6883a8804 100644 --- a/src/ui/gui/psppire-dialog-action-crosstabs.c +++ b/src/ui/gui/psppire-dialog-action-crosstabs.c @@ -208,7 +208,13 @@ psppire_dialog_action_crosstabs_activate (GtkAction *a) PsppireDialogActionCrosstabs *act = PSPPIRE_DIALOG_ACTION_CROSSTABS (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("crosstabs.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("crosstabs.ui"); + g_hash_table_insert (thing, a, xml); + } pda->dialog = get_widget_assert (xml, "crosstabs-dialog"); pda->source = get_widget_assert (xml, "dict-treeview"); @@ -228,9 +234,6 @@ psppire_dialog_action_crosstabs_activate (GtkAction *a) act->table_button = get_widget_assert (xml, "print-tables"); act->pivot_button = get_widget_assert (xml, "pivot"); - - g_object_unref (xml); - act->format_options_avalue = TRUE; act->format_options_table = TRUE; act->format_options_pivot = TRUE; diff --git a/src/ui/gui/psppire-dialog-action-descriptives.c b/src/ui/gui/psppire-dialog-action-descriptives.c index 04781ea8f3..9140e19c3c 100644 --- a/src/ui/gui/psppire-dialog-action-descriptives.c +++ b/src/ui/gui/psppire-dialog-action-descriptives.c @@ -192,22 +192,29 @@ dialog_refresh (PsppireDialogAction *scd_) gtk_toggle_button_set_active (scd->save_z_scores, false); } + static void psppire_dialog_action_descriptives_activate (GtkAction *a) { PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionDescriptives *act = PSPPIRE_DIALOG_ACTION_DESCRIPTIVES (a); - GtkBuilder *xml = builder_new ("descriptives.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("descriptives.ui"); + g_hash_table_insert (thing, a, xml); + } - GtkWidget *stats_treeview = get_widget_assert (xml, "statistics"); + GtkWidget *stats_treeview = get_widget_assert (xml, "statistics"); pda->dialog = get_widget_assert (xml, "descriptives-dialog"); pda->source = get_widget_assert (xml, "all-variables"); act->variables = get_widget_assert (xml, "stat-variables"); g_object_set (pda->source, - "predicate", var_is_numeric, NULL); + "predicate", var_is_numeric, NULL); psppire_checkbox_treeview_populate (PSPPIRE_CHECKBOX_TREEVIEW (stats_treeview), B_DS_DEFAULT, @@ -227,8 +234,6 @@ psppire_dialog_action_descriptives_activate (GtkAction *a) psppire_dialog_action_set_refresh (pda, dialog_refresh); PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_descriptives_parent_class)->activate (pda); - - g_object_unref (xml); } static void diff --git a/src/ui/gui/psppire-dialog-action-examine.c b/src/ui/gui/psppire-dialog-action-examine.c index bba35cf124..a2248671d5 100644 --- a/src/ui/gui/psppire-dialog-action-examine.c +++ b/src/ui/gui/psppire-dialog-action-examine.c @@ -203,7 +203,13 @@ psppire_dialog_action_examine_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionExamine *act = PSPPIRE_DIALOG_ACTION_EXAMINE (a); - GtkBuilder *xml = builder_new ("examine.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("examine.ui"); + g_hash_table_insert (thing, a, xml); + } GtkWidget *stats_button = get_widget_assert (xml, "stats-button"); GtkWidget *opts_button = get_widget_assert (xml, "opts-button"); @@ -255,9 +261,7 @@ psppire_dialog_action_examine_activate (GtkAction *a) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_examine_parent_class)->activate (pda); - g_list_free (list); - g_object_unref (xml); } static void diff --git a/src/ui/gui/psppire-dialog-action-factor.c b/src/ui/gui/psppire-dialog-action-factor.c index e8874449cc..8ec9e22849 100644 --- a/src/ui/gui/psppire-dialog-action-factor.c +++ b/src/ui/gui/psppire-dialog-action-factor.c @@ -301,7 +301,13 @@ psppire_dialog_action_factor_activate (GtkAction *a) GtkWidget *extraction_button ; GtkWidget *rotation_button ; - GtkBuilder *xml = builder_new ("factor.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("factor.ui"); + g_hash_table_insert (thing, a, xml); + } pda->dialog = get_widget_assert (xml, "factor-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -364,8 +370,6 @@ psppire_dialog_action_factor_activate (GtkAction *a) psppire_dialog_action_set_refresh (pda, dialog_refresh); PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_factor_parent_class)->activate (pda); - - g_object_unref (xml); } static void diff --git a/src/ui/gui/psppire-dialog-action-flip.c b/src/ui/gui/psppire-dialog-action-flip.c index 1b63856df5..2c265f3826 100644 --- a/src/ui/gui/psppire-dialog-action-flip.c +++ b/src/ui/gui/psppire-dialog-action-flip.c @@ -95,7 +95,14 @@ psppire_dialog_action_flip_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionFlip *act = PSPPIRE_DIALOG_ACTION_FLIP (a); - GtkBuilder *xml = builder_new ("psppire.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("psppire.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "transpose-dialog"); pda->source = get_widget_assert (xml, "source-treeview"); @@ -105,8 +112,6 @@ psppire_dialog_action_flip_activate (GtkAction *a) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_flip_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_flip_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-frequencies.c b/src/ui/gui/psppire-dialog-action-frequencies.c index d0ae660a25..490a735f53 100644 --- a/src/ui/gui/psppire-dialog-action-frequencies.c +++ b/src/ui/gui/psppire-dialog-action-frequencies.c @@ -259,7 +259,13 @@ psppire_dialog_action_frequencies_activate (GtkAction * a) PsppireDialogActionFrequencies *act = PSPPIRE_DIALOG_ACTION_FREQUENCIES (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("frequencies.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("frequencies.ui"); + g_hash_table_insert (thing, a, xml); + } GtkWidget *stats_treeview = get_widget_assert (xml, "stats-treeview"); GtkWidget *tables_button = get_widget_assert (xml, "tables-button"); @@ -327,10 +333,6 @@ psppire_dialog_action_frequencies_activate (GtkAction * a) act->bar = (get_widget_assert (xml, "bar")); - - g_object_unref (xml); - - act->tables_opts_order = FRQ_AVALUE; act->tables_opts_table = FRQ_TABLE; act->tables_opts_limit = 50; diff --git a/src/ui/gui/psppire-dialog-action-histogram.c b/src/ui/gui/psppire-dialog-action-histogram.c index 5a57c2aece..08ffc1ad22 100644 --- a/src/ui/gui/psppire-dialog-action-histogram.c +++ b/src/ui/gui/psppire-dialog-action-histogram.c @@ -65,15 +65,20 @@ psppire_dialog_action_histogram_activate (GtkAction *a) PsppireDialogActionHistogram *act = PSPPIRE_DIALOG_ACTION_HISTOGRAM (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("histogram.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("histogram.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "histogram-dialog"); pda->source = get_widget_assert (xml, "dict-view"); act->variable = get_widget_assert (xml, "entry1"); act->curve = get_widget_assert (xml, "curve"); - g_object_unref (xml); - psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, diff --git a/src/ui/gui/psppire-dialog-action-indep-samps.c b/src/ui/gui/psppire-dialog-action-indep-samps.c index 8709b1da07..08529e43e8 100644 --- a/src/ui/gui/psppire-dialog-action-indep-samps.c +++ b/src/ui/gui/psppire-dialog-action-indep-samps.c @@ -292,7 +292,13 @@ psppire_dialog_action_indep_samps_activate (GtkAction *a) PsppireDialogActionIndepSamps *act = PSPPIRE_DIALOG_ACTION_INDEP_SAMPS (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("indep-samples.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("indep-samples.ui"); + g_hash_table_insert (thing, a, xml); + } pda->dialog = get_widget_assert (xml,"independent-samples-dialog"); pda->source = get_widget_assert (xml, "indep-samples-treeview1"); @@ -324,9 +330,6 @@ psppire_dialog_action_indep_samps_activate (GtkAction *a) g_signal_connect (act->dg_values_toggle_button, "toggled", G_CALLBACK (set_group_criterion_type), act); - - g_object_unref (xml); - psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, diff --git a/src/ui/gui/psppire-dialog-action-k-related.c b/src/ui/gui/psppire-dialog-action-k-related.c index 387dbd3048..16f0f721c3 100644 --- a/src/ui/gui/psppire-dialog-action-k-related.c +++ b/src/ui/gui/psppire-dialog-action-k-related.c @@ -110,7 +110,14 @@ psppire_dialog_action_k_related_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionKRelated *act = PSPPIRE_DIALOG_ACTION_K_RELATED (a); - GtkBuilder *xml = builder_new ("k-related.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("k-related.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "k-related-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -126,8 +133,6 @@ psppire_dialog_action_k_related_activate (GtkAction *a) "predicate", var_is_numeric, NULL); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_k_related_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_k_related_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-kmeans.c b/src/ui/gui/psppire-dialog-action-kmeans.c index 18f7138cd6..c1c913b37d 100644 --- a/src/ui/gui/psppire-dialog-action-kmeans.c +++ b/src/ui/gui/psppire-dialog-action-kmeans.c @@ -86,7 +86,14 @@ psppire_dialog_action_kmeans_activate (GtkAction *a) { PsppireDialogActionKmeans *act = PSPPIRE_DIALOG_ACTION_KMEANS (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("k-means.ui"); + + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("k-means.ui"); + g_hash_table_insert (thing, a, xml); + } pda->dialog = get_widget_assert (xml, "k-means-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -95,11 +102,8 @@ psppire_dialog_action_kmeans_activate (GtkAction *a) act->variables = get_widget_assert (xml, "psppire-var-view1"); psppire_dialog_action_set_refresh (pda, refresh); - psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_kmeans_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_kmeans_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-logistic.c b/src/ui/gui/psppire-dialog-action-logistic.c index 8da049f538..074b8e1456 100644 --- a/src/ui/gui/psppire-dialog-action-logistic.c +++ b/src/ui/gui/psppire-dialog-action-logistic.c @@ -102,7 +102,13 @@ psppire_dialog_action_logistic_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); GtkWidget *opts_button; - GtkBuilder *xml = builder_new ("logistic.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("logistic.ui"); + g_hash_table_insert (thing, a, xml); + } pda->dialog = get_widget_assert (xml, "logistic-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -134,8 +140,6 @@ psppire_dialog_action_logistic_activate (GtkAction *a) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(act->conf_checkbox), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(act->conf_checkbox), FALSE); - g_object_unref (xml); - psppire_dialog_action_set_refresh (pda, refresh); psppire_dialog_action_set_valid_predicate (pda, diff --git a/src/ui/gui/psppire-dialog-action-means.c b/src/ui/gui/psppire-dialog-action-means.c index 9b20560a05..6610f59556 100644 --- a/src/ui/gui/psppire-dialog-action-means.c +++ b/src/ui/gui/psppire-dialog-action-means.c @@ -97,18 +97,24 @@ psppire_dialog_action_means_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionMeans *act = PSPPIRE_DIALOG_ACTION_MEANS (a); - GtkBuilder *xml = builder_new ("means.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("means.ui"); + g_hash_table_insert (thing, a, xml); + } - GtkWidget *vb = get_widget_assert (xml, "alignment3"); - GtkWidget *selector = get_widget_assert (xml, "layer-selector"); + GtkWidget *vb = get_widget_assert (xml, "alignment3"); + GtkWidget *selector = get_widget_assert (xml, "layer-selector"); act->layer = psppire_means_layer_new (); gtk_container_add (GTK_CONTAINER (vb), act->layer); gtk_widget_show (act->layer); - pda->dialog = get_widget_assert (xml, "means-dialog"); - pda->source = get_widget_assert (xml, "all-variables"); - act->variables = get_widget_assert (xml, "stat-variables"); + pda->dialog = get_widget_assert (xml, "means-dialog"); + pda->source = get_widget_assert (xml, "all-variables"); + act->variables = get_widget_assert (xml, "stat-variables"); g_object_set (pda->source, "predicate", var_is_numeric, @@ -118,13 +124,10 @@ psppire_dialog_action_means_activate (GtkAction *a) "dest-widget", act->layer, NULL); - psppire_dialog_action_set_valid_predicate (pda, (void *) dialog_state_valid); psppire_dialog_action_set_refresh (pda, dialog_refresh); PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_means_parent_class)->activate (pda); - - g_object_unref (xml); } static void diff --git a/src/ui/gui/psppire-dialog-action-oneway.c b/src/ui/gui/psppire-dialog-action-oneway.c index 6e66862c4b..604c271f57 100644 --- a/src/ui/gui/psppire-dialog-action-oneway.c +++ b/src/ui/gui/psppire-dialog-action-oneway.c @@ -226,7 +226,14 @@ psppire_dialog_action_oneway_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionOneway *act = PSPPIRE_DIALOG_ACTION_ONEWAY (a); - GtkBuilder *xml = builder_new ("oneway.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("oneway.ui"); + g_hash_table_insert (thing, a, xml); + } + GtkWidget *contrasts_button = get_widget_assert (xml, "contrasts-button"); GtkEntry *entry = GTK_ENTRY (get_widget_assert (xml, "entry1")); @@ -266,8 +273,6 @@ psppire_dialog_action_oneway_activate (GtkAction *a) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_oneway_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_oneway_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-paired.c b/src/ui/gui/psppire-dialog-action-paired.c index d08fc109aa..a5ce1584a4 100644 --- a/src/ui/gui/psppire-dialog-action-paired.c +++ b/src/ui/gui/psppire-dialog-action-paired.c @@ -155,7 +155,14 @@ psppire_dialog_action_paired_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionPaired *act = PSPPIRE_DIALOG_ACTION_PAIRED (a); - GtkBuilder *xml = builder_new ("paired-samples.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("paired-samples.ui"); + g_hash_table_insert (thing, a, xml); + } + GtkWidget *selector = get_widget_assert (xml, "psppire-selector3"); GtkWidget *bb = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); GtkWidget *button = gtk_button_new_with_mnemonic (_("O_ptions...")); @@ -192,8 +199,6 @@ psppire_dialog_action_paired_activate (GtkAction *a) select_as_pair_member, act); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_paired_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_paired_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-rank.c b/src/ui/gui/psppire-dialog-action-rank.c index eb7d7d20d1..c120fe260d 100644 --- a/src/ui/gui/psppire-dialog-action-rank.c +++ b/src/ui/gui/psppire-dialog-action-rank.c @@ -212,7 +212,13 @@ psppire_dialog_action_rank_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionRank *act = PSPPIRE_DIALOG_ACTION_RANK (a); - GtkBuilder *xml = builder_new ("rank.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("rank.ui"); + g_hash_table_insert (thing, a, xml); + } GtkWidget *types_button = get_widget_assert (xml, "button1"); GtkWidget *ties_button = get_widget_assert (xml, "button2"); @@ -293,8 +299,6 @@ psppire_dialog_action_rank_activate (GtkAction *a) psppire_dialog_action_set_refresh (pda, dialog_refresh); PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_rank_parent_class)->activate (pda); - - g_object_unref (xml); } static void diff --git a/src/ui/gui/psppire-dialog-action-regression.c b/src/ui/gui/psppire-dialog-action-regression.c index 5a64162993..fd168c4350 100644 --- a/src/ui/gui/psppire-dialog-action-regression.c +++ b/src/ui/gui/psppire-dialog-action-regression.c @@ -147,7 +147,14 @@ psppire_dialog_action_regression_activate (GtkAction *a) PsppireDialogActionRegression *act = PSPPIRE_DIALOG_ACTION_REGRESSION (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("regression.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("regression.ui"); + g_hash_table_insert (thing, a, xml); + } + GtkWidget *stat_button = get_widget_assert (xml, "stat-button"); GtkWidget *save_button = get_widget_assert (xml, "save-button"); @@ -162,8 +169,6 @@ psppire_dialog_action_regression_activate (GtkAction *a) act->pred_button = get_widget_assert (xml, "pred-button"); act->resid_button = get_widget_assert (xml, "resid-button"); - g_object_unref (xml); - psppire_checkbox_treeview_populate (PSPPIRE_CHECKBOX_TREEVIEW (act->stat_view), B_RG_STATS_DEFAULT, N_REGRESSION_STATS, diff --git a/src/ui/gui/psppire-dialog-action-reliability.c b/src/ui/gui/psppire-dialog-action-reliability.c index e53ce23cf1..c3d035cfbd 100644 --- a/src/ui/gui/psppire-dialog-action-reliability.c +++ b/src/ui/gui/psppire-dialog-action-reliability.c @@ -125,7 +125,15 @@ psppire_dialog_action_reliability_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionReliability *act = PSPPIRE_DIALOG_ACTION_RELIABILITY (a); GtkTreeModel *liststore ; - GtkBuilder *xml = builder_new ("reliability.ui"); + + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("reliability.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "reliability-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -159,8 +167,6 @@ psppire_dialog_action_reliability_activate (GtkAction *a) if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_reliability_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_reliability_parent_class)->activate (pda); - - g_object_unref (xml); } static void diff --git a/src/ui/gui/psppire-dialog-action-roc.c b/src/ui/gui/psppire-dialog-action-roc.c index 578ef74777..03748f2946 100644 --- a/src/ui/gui/psppire-dialog-action-roc.c +++ b/src/ui/gui/psppire-dialog-action-roc.c @@ -126,7 +126,15 @@ psppire_dialog_action_roc_activate (GtkAction *a) PsppireDialogActionRoc *act = PSPPIRE_DIALOG_ACTION_ROC (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GtkBuilder *xml = builder_new ("roc.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("roc.ui"); + g_hash_table_insert (thing, a, xml); + } + + pda->dialog = get_widget_assert (xml, "roc-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -142,8 +150,6 @@ psppire_dialog_action_roc_activate (GtkAction *a) g_signal_connect_swapped (act->state_variable, "changed", G_CALLBACK (on_state_var_changed), act); - g_object_unref (xml); - g_signal_connect (act->curve, "toggled", G_CALLBACK (on_curve_button_toggle), act); diff --git a/src/ui/gui/psppire-dialog-action-runs.c b/src/ui/gui/psppire-dialog-action-runs.c index 8649fbbe6d..62d6b27754 100644 --- a/src/ui/gui/psppire-dialog-action-runs.c +++ b/src/ui/gui/psppire-dialog-action-runs.c @@ -133,7 +133,14 @@ psppire_dialog_action_runs_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionRuns *act = PSPPIRE_DIALOG_ACTION_RUNS (a); - GtkBuilder *xml = builder_new ("runs.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("runs.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "runs-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -144,12 +151,9 @@ psppire_dialog_action_runs_activate (GtkAction *a) act->cb[CB_CUSTOM] = get_widget_assert (xml, "checkbutton3"); act->variables = get_widget_assert (xml, "psppire-var-view1"); - psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_runs_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_runs_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-scatterplot.c b/src/ui/gui/psppire-dialog-action-scatterplot.c index 64017df7c9..3b89d443a3 100644 --- a/src/ui/gui/psppire-dialog-action-scatterplot.c +++ b/src/ui/gui/psppire-dialog-action-scatterplot.c @@ -96,7 +96,13 @@ psppire_dialog_action_scatterplot_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionScatterplot *act = PSPPIRE_DIALOG_ACTION_SCATTERPLOT (a); - GtkBuilder *xml = builder_new ("scatterplot.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("scatterplot.ui"); + g_hash_table_insert (thing, a, xml); + } pda->dialog = get_widget_assert (xml, "scatterplot-dialog"); pda->source = get_widget_assert (xml, "scatterplot-treeview1"); @@ -107,8 +113,6 @@ psppire_dialog_action_scatterplot_activate (GtkAction *a) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_scatterplot_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_scatterplot_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-sort.c b/src/ui/gui/psppire-dialog-action-sort.c index 1c5a9e0184..024a659de1 100644 --- a/src/ui/gui/psppire-dialog-action-sort.c +++ b/src/ui/gui/psppire-dialog-action-sort.c @@ -95,11 +95,18 @@ psppire_dialog_action_sort_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionSort *act = PSPPIRE_DIALOG_ACTION_SORT (a); - GtkBuilder *xml = builder_new ("sort.ui"); - pda->dialog = get_widget_assert (xml, "sort-cases-dialog"); - pda->source = get_widget_assert (xml, "sort-cases-treeview1"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("sort.ui"); + g_hash_table_insert (thing, a, xml); + } + + pda->dialog = get_widget_assert (xml, "sort-cases-dialog"); + pda->source = get_widget_assert (xml, "sort-cases-treeview1"); - act->variables = get_widget_assert (xml, "sort-cases-treeview2"); + act->variables = get_widget_assert (xml, "sort-cases-treeview2"); act->ascending = get_widget_assert (xml, "sort-cases-radiobutton0"); psppire_dialog_action_set_refresh (pda, reset); @@ -109,8 +116,6 @@ psppire_dialog_action_sort_activate (GtkAction *a) if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_sort_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_sort_parent_class)->activate (pda); - - g_object_unref (xml); } static void diff --git a/src/ui/gui/psppire-dialog-action-tt1s.c b/src/ui/gui/psppire-dialog-action-tt1s.c index 0d00f06ea9..4bf486340d 100644 --- a/src/ui/gui/psppire-dialog-action-tt1s.c +++ b/src/ui/gui/psppire-dialog-action-tt1s.c @@ -108,7 +108,14 @@ psppire_dialog_action_tt1s_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionTt1s *act = PSPPIRE_DIALOG_ACTION_TT1S (a); - GtkBuilder *xml = builder_new ("t-test.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("t-test.ui"); + g_hash_table_insert (thing, a, xml); + } + GtkWidget *options_button = get_widget_assert (xml, "button1"); pda->dialog = get_widget_assert (xml, "t-test-one-sample-dialog"); @@ -128,9 +135,6 @@ psppire_dialog_action_tt1s_activate (GtkAction *a) g_signal_connect_swapped (options_button, "clicked", G_CALLBACK (tt_options_dialog_run), act->opt); - - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_tt1s_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_tt1s_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-two-sample.c b/src/ui/gui/psppire-dialog-action-two-sample.c index 74612d267a..8cc0c00121 100644 --- a/src/ui/gui/psppire-dialog-action-two-sample.c +++ b/src/ui/gui/psppire-dialog-action-two-sample.c @@ -174,7 +174,14 @@ psppire_dialog_action_two_sample_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionTwoSample *act = PSPPIRE_DIALOG_ACTION_TWO_SAMPLE (a); - GtkBuilder *xml = builder_new ("paired-samples.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("paired-samples.ui"); + g_hash_table_insert (thing, a, xml); + } + GtkWidget *selector = get_widget_assert (xml, "psppire-selector3"); pda->dialog = get_widget_assert (xml, "t-test-paired-samples-dialog"); @@ -222,8 +229,6 @@ psppire_dialog_action_two_sample_activate (GtkAction *a) select_as_pair_member, act); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_two_sample_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_two_sample_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-univariate.c b/src/ui/gui/psppire-dialog-action-univariate.c index 30b9526f72..664dd36e43 100644 --- a/src/ui/gui/psppire-dialog-action-univariate.c +++ b/src/ui/gui/psppire-dialog-action-univariate.c @@ -88,7 +88,14 @@ psppire_dialog_action_univariate_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionUnivariate *act = PSPPIRE_DIALOG_ACTION_UNIVARIATE (a); - GtkBuilder *xml = builder_new ("univariate.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("univariate.ui"); + g_hash_table_insert (thing, a, xml); + } + pda->dialog = get_widget_assert (xml, "univariate-dialog"); pda->source = get_widget_assert (xml, "dict-view"); @@ -98,8 +105,6 @@ psppire_dialog_action_univariate_activate (GtkAction *a) psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); psppire_dialog_action_set_refresh (pda, refresh); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_univariate_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_univariate_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action-var-info.c b/src/ui/gui/psppire-dialog-action-var-info.c index 4e2d8ea039..b8336d224b 100644 --- a/src/ui/gui/psppire-dialog-action-var-info.c +++ b/src/ui/gui/psppire-dialog-action-var-info.c @@ -169,7 +169,14 @@ psppire_dialog_action_var_info_activate (GtkAction *a) PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionVarInfo *act = PSPPIRE_DIALOG_ACTION_VAR_INFO (pda); - GtkBuilder *xml = builder_new ("variable-info.ui"); + GHashTable *thing = psppire_dialog_action_get_pointer (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("variable-info.ui"); + g_hash_table_insert (thing, a, xml); + } + act->output = psppire_output_view_new ( GTK_LAYOUT (get_widget_assert (xml, "layout1")), NULL, NULL, NULL); @@ -184,15 +191,12 @@ psppire_dialog_action_var_info_activate (GtkAction *a) "changed", G_CALLBACK (populate_output), act); - g_signal_connect (pda->dialog, "response", G_CALLBACK (jump_to), pda); psppire_dialog_action_set_valid_predicate (pda, treeview_item_selected); - g_object_unref (xml); - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_var_info_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_var_info_parent_class)->activate (pda); } diff --git a/src/ui/gui/psppire-dialog-action.c b/src/ui/gui/psppire-dialog-action.c index 7c399175dd..a97421f7ea 100644 --- a/src/ui/gui/psppire-dialog-action.c +++ b/src/ui/gui/psppire-dialog-action.c @@ -83,6 +83,46 @@ psppire_dialog_action_get_property (GObject *object, } +static void +set_toplevel (PsppireDialogAction *act) +{ + if (act->toplevel) + return; + + GSList *sl = gtk_ui_manager_get_toplevels (act->uim, GTK_UI_MANAGER_MENUBAR | GTK_UI_MANAGER_TOOLBAR); + g_return_if_fail (sl); + + act->toplevel = gtk_widget_get_toplevel (GTK_WIDGET (sl->data)); + g_slist_free (sl); +} + +static void +on_destroy_dataset (GObject *w) +{ + GHashTable *t = g_object_get_data (w, "thing-table"); + GSList *dl = g_object_get_data (w, "widget-list"); + + g_slist_free_full (dl, (GDestroyNotify) gtk_widget_destroy); + g_hash_table_unref (t); +} + +GHashTable * +psppire_dialog_action_get_pointer (PsppireDialogAction *act) +{ + set_toplevel (act); + + GHashTable *thing = g_object_get_data (G_OBJECT (act->toplevel), "thing-table"); + if (thing == NULL) + { + thing = g_hash_table_new_full (g_direct_hash, g_direct_equal, 0, g_object_unref); + g_object_set_data (G_OBJECT (act->toplevel), "thing-table", thing); + g_object_set_data (G_OBJECT (act->toplevel), "widget-list", NULL); + g_signal_connect (act->toplevel, "destroy", G_CALLBACK (on_destroy_dataset), NULL); + } + + return thing; +} + static void psppire_dialog_action_activate (PsppireDialogAction *act) { @@ -90,24 +130,28 @@ psppire_dialog_action_activate (PsppireDialogAction *act) PsppireDialogActionClass *class = PSPPIRE_DIALOG_ACTION_GET_CLASS (act); - GSList *sl = gtk_ui_manager_get_toplevels (act->uim, GTK_UI_MANAGER_MENUBAR | GTK_UI_MANAGER_TOOLBAR); - g_return_if_fail (sl); + gboolean first_time = ! act->toplevel; - act->toplevel = gtk_widget_get_toplevel (GTK_WIDGET (sl->data)); - g_slist_free (sl); + set_toplevel (act); act->dict = PSPPIRE_DATA_WINDOW(act->toplevel)->dict; g_object_set (act->source, "model", act->dict, NULL); - - gtk_window_set_transient_for (GTK_WINDOW (act->dialog), GTK_WINDOW (act->toplevel)); + GSList *wl = g_object_get_data (G_OBJECT (act->toplevel), "widget-list"); + wl = g_slist_prepend (wl, act->dialog); + g_object_set_data (G_OBJECT (act->toplevel), "widget-list", wl); + + gtk_window_set_transient_for (GTK_WINDOW (act->dialog), GTK_WINDOW (act->toplevel)); if (GTK_ACTION_CLASS (psppire_dialog_action_parent_class)->activate) GTK_ACTION_CLASS (psppire_dialog_action_parent_class)->activate ( GTK_ACTION (act)); gtk_widget_grab_focus (act->source); + if (first_time) + psppire_dialog_reload (PSPPIRE_DIALOG (act->dialog)); + response = psppire_dialog_run (PSPPIRE_DIALOG (act->dialog)); if ( class->generate_syntax ) @@ -125,8 +169,6 @@ psppire_dialog_action_activate (PsppireDialogAction *act) break; } } - - gtk_widget_destroy (act->dialog); } static void diff --git a/src/ui/gui/psppire-dialog-action.h b/src/ui/gui/psppire-dialog-action.h index 071bfaeea5..215d89a52a 100644 --- a/src/ui/gui/psppire-dialog-action.h +++ b/src/ui/gui/psppire-dialog-action.h @@ -100,6 +100,7 @@ typedef void (*activation) (GtkAction *); void psppire_dialog_action_set_activation (gpointer class, activation a); +GHashTable *psppire_dialog_action_get_pointer (PsppireDialogAction *act); diff --git a/src/ui/gui/psppire-dialog.c b/src/ui/gui/psppire-dialog.c index 5726cc76a9..aeecfee86e 100644 --- a/src/ui/gui/psppire-dialog.c +++ b/src/ui/gui/psppire-dialog.c @@ -422,7 +422,7 @@ psppire_dialog_run (PsppireDialog *dialog) if (title == NULL) g_warning ("PsppireDialog %s has no title", gtk_widget_get_name (GTK_WIDGET (dialog))); - + if ( dialog->contents_are_valid != NULL ) gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child(GTK_BIN(dialog))), connect_notify_signal, @@ -431,11 +431,7 @@ psppire_dialog_run (PsppireDialog *dialog) dialog->loop = g_main_loop_new (NULL, FALSE); gtk_widget_show (GTK_WIDGET (dialog)); - - if ( dialog->contents_are_valid != NULL) - g_signal_emit (dialog, signals [VALIDITY_CHANGED], 0, FALSE); - - g_signal_emit (dialog, signals [DIALOG_REFRESH], 0); + psppire_dialog_notify_change (dialog); g_main_loop_run (dialog->loop); -- 2.30.2