X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dialog-action-examine.c;h=12627bd7a5f76b7a72972b3c1e4d9a09a891958b;hb=4cee6fc1f72440698ca8f3f89a71d29e7ee46a0d;hp=904beec1e810b2abc416bb483a7461c6a7ee39ef;hpb=b1bb3352ce1e12a85c0b1ee1def1d1bcd6f62e69;p=pspp diff --git a/src/ui/gui/psppire-dialog-action-examine.c b/src/ui/gui/psppire-dialog-action-examine.c index 904beec1e8..12627bd7a5 100644 --- a/src/ui/gui/psppire-dialog-action-examine.c +++ b/src/ui/gui/psppire-dialog-action-examine.c @@ -20,6 +20,8 @@ #include "psppire-dialog-action-examine.h" #include "psppire-var-view.h" +#include "dialog-common.h" +#include "psppire-selector.h" #include "psppire-dict.h" #include "psppire-dialog.h" #include "builder-wrapper.h" @@ -53,16 +55,16 @@ run_stats_dialog (PsppireDialogActionExamine *ed) response = psppire_dialog_run (PSPPIRE_DIALOG (ed->stats_dialog)); - if ( response == PSPPIRE_RESPONSE_CONTINUE ) + if (response == PSPPIRE_RESPONSE_CONTINUE) { ed->stats = 0; - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->descriptives_button) )) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->descriptives_button))) ed->stats |= STAT_DESCRIPTIVES; - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->extremes_button) )) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->extremes_button))) ed->stats |= STAT_EXTREMES; - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->percentiles_button) )) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->percentiles_button))) ed->stats |= STAT_PERCENTILES; } } @@ -90,7 +92,7 @@ run_opts_dialog (PsppireDialogActionExamine *ed) response = psppire_dialog_run (PSPPIRE_DIALOG (ed->opts_dialog)); - if ( response == PSPPIRE_RESPONSE_CONTINUE ) + if (response == PSPPIRE_RESPONSE_CONTINUE) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->listwise))) ed->opts = OPT_LISTWISE; @@ -105,7 +107,7 @@ run_opts_dialog (PsppireDialogActionExamine *ed) static char * -generate_syntax (PsppireDialogAction *act) +generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionExamine *ed = PSPPIRE_DIALOG_ACTION_EXAMINE (act); @@ -116,7 +118,7 @@ generate_syntax (PsppireDialogAction *act) g_string_append (str, "\n\t/VARIABLES="); psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ed->variables), 0, str); - if ( 0 < gtk_tree_model_iter_n_children + if (0 < gtk_tree_model_iter_n_children (gtk_tree_view_get_model (GTK_TREE_VIEW (ed->factors)), NULL)) { g_string_append (str, "\n\tBY "); @@ -124,24 +126,24 @@ generate_syntax (PsppireDialogAction *act) } label = gtk_entry_get_text (GTK_ENTRY (ed->id_var)); - if ( 0 != strcmp (label, "") ) + if (0 != strcmp (label, "")) { g_string_append (str, "\n\t/ID = "); g_string_append (str, label); } - if ( ed->stats & (STAT_DESCRIPTIVES | STAT_EXTREMES)) + if (ed->stats & (STAT_DESCRIPTIVES | STAT_EXTREMES)) { g_string_append (str, "\n\t/STATISTICS ="); - if ( ed->stats & STAT_DESCRIPTIVES) + if (ed->stats & STAT_DESCRIPTIVES) g_string_append (str, " DESCRIPTIVES"); - if ( ed->stats & STAT_EXTREMES) + if (ed->stats & STAT_EXTREMES) g_string_append (str, " EXTREME"); } - if ( ed->stats & STAT_PERCENTILES) + if (ed->stats & STAT_PERCENTILES) g_string_append (str, "\n\t/PERCENTILES"); @@ -195,8 +197,8 @@ dialog_refresh (PsppireDialogAction *da) dae->opts = OPT_LISTWISE; } -static void -psppire_dialog_action_examine_activate (GtkAction *a) +static GtkBuilder * +psppire_dialog_action_examine_activate (PsppireDialogAction *a, GVariant *param) { PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionExamine *act = PSPPIRE_DIALOG_ACTION_EXAMINE (a); @@ -206,15 +208,40 @@ psppire_dialog_action_examine_activate (GtkAction *a) GtkWidget *stats_button = get_widget_assert (xml, "stats-button"); GtkWidget *opts_button = get_widget_assert (xml, "opts-button"); + g_signal_connect_swapped (stats_button, "clicked", + G_CALLBACK (run_stats_dialog), act); + + g_signal_connect_swapped (opts_button, "clicked", + G_CALLBACK (run_opts_dialog), act); + + GtkWidget *dep_sel = get_widget_assert (xml, "psppire-selector1"); + GtkWidget *dep_sel2 = get_widget_assert (xml, "psppire-selector2"); + GtkWidget *dep_sel3 = get_widget_assert (xml, "psppire-selector3"); + GtkWidget *table = get_widget_assert (xml, "table1"); + pda->dialog = get_widget_assert (xml, "examine-dialog"); pda->source = get_widget_assert (xml, "treeview1"); act->variables = get_widget_assert (xml, "treeview2"); act->factors = get_widget_assert (xml, "treeview3"); act->id_var = get_widget_assert (xml, "entry1"); + /* Setting the focus chain like this is a pain. + But the default focus order seems to be somewhat odd. */ + GList *list = NULL; + list = g_list_append (list, get_widget_assert (xml, "scrolledwindow1")); + list = g_list_append (list, dep_sel); + list = g_list_append (list, get_widget_assert (xml, "frame1")); + list = g_list_append (list, dep_sel2); + list = g_list_append (list, get_widget_assert (xml, "frame2")); + list = g_list_append (list, dep_sel3); + list = g_list_append (list, get_widget_assert (xml, "frame3")); + gtk_container_set_focus_chain (GTK_CONTAINER (table), list); + g_list_free (list); + + act->stats_dialog = get_widget_assert (xml, "statistics-dialog"); act->descriptives_button = get_widget_assert (xml, "descriptives-button"); - act->extremes_button = get_widget_assert (xml, "extremes-button"); + act->extremes_button = get_widget_assert (xml, "extremes-button"); act->percentiles_button = get_widget_assert (xml, "percentiles-button"); act->opts_dialog = get_widget_assert (xml, "options-dialog"); @@ -222,27 +249,17 @@ psppire_dialog_action_examine_activate (GtkAction *a) act->pairwise = get_widget_assert (xml, "radiobutton2"); act->report = get_widget_assert (xml, "radiobutton3"); - g_object_set (pda->source, - "model", pda->dict, - "predicate", var_is_numeric, - NULL); + psppire_selector_set_allow (PSPPIRE_SELECTOR (dep_sel), numeric_only); psppire_dialog_action_set_valid_predicate (pda, (void *) dialog_state_valid); psppire_dialog_action_set_refresh (pda, dialog_refresh); - - g_signal_connect_swapped (stats_button, "clicked", - G_CALLBACK (run_stats_dialog), act); - - g_signal_connect_swapped (opts_button, "clicked", - G_CALLBACK (run_opts_dialog), act); - - PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_examine_parent_class)->activate (pda); + return xml; } static void psppire_dialog_action_examine_class_init (PsppireDialogActionExamineClass *class) { - GTK_ACTION_CLASS (class)->activate = psppire_dialog_action_examine_activate; + PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_examine_activate; PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax; }