X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dialog-action-factor.c;h=48f72ffbd62f7c38fce19235126a120cb6e3a390;hb=339f1956cc72;hp=6802bfe2c182850a233e8a325bc7d08e8065f15d;hpb=0bda70f475aad77db5636ae0bca170513353c988;p=pspp diff --git a/src/ui/gui/psppire-dialog-action-factor.c b/src/ui/gui/psppire-dialog-action-factor.c index 6802bfe2c1..48f72ffbd6 100644 --- a/src/ui/gui/psppire-dialog-action-factor.c +++ b/src/ui/gui/psppire-dialog-action-factor.c @@ -38,7 +38,7 @@ static void psppire_dialog_action_factor_class_init (PsppireDialogActionFac G_DEFINE_TYPE (PsppireDialogActionFactor, psppire_dialog_action_factor, PSPPIRE_TYPE_DIALOG_ACTION); -static const char *rot_method_syntax[] = +static const char *rot_method_syntax[] = { "NOROTATE", "VARIMAX", @@ -56,7 +56,7 @@ on_extract_toggle (GtkToggleButton *button, PsppireDialogActionFactor *f) } static char * -generate_syntax (PsppireDialogAction *act) +generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionFactor *rd = PSPPIRE_DIALOG_ACTION_FACTOR (act); @@ -70,7 +70,7 @@ generate_syntax (PsppireDialogAction *act) ds_put_cstr (&str, "\n\t/CRITERIA = "); - if ( rd->extraction.explicit_nfactors ) + if (rd->extraction.explicit_nfactors) ds_put_c_format (&str, "FACTORS (%d)", rd->extraction.n_factors); else ds_put_c_format (&str, "MINEIGEN (%.*g)", @@ -84,19 +84,19 @@ generate_syntax (PsppireDialogAction *act) ds_put_cstr (&str, "\n\t/EXTRACTION ="); - if ( rd->extraction.paf) + if (rd->extraction.paf) ds_put_cstr (&str, "PAF"); else ds_put_cstr (&str, "PC"); ds_put_cstr (&str, "\n\t/METHOD = "); - if ( rd->extraction.covariance ) + if (rd->extraction.covariance) ds_put_cstr (&str, "COVARIANCE"); else ds_put_cstr (&str, "CORRELATION"); - if ( rd->extraction.scree ) + if (rd->extraction.scree) { ds_put_cstr (&str, "\n\t/PLOT = "); ds_put_cstr (&str, "EIGEN"); @@ -105,17 +105,17 @@ generate_syntax (PsppireDialogAction *act) ds_put_cstr (&str, "\n\t/PRINT = "); ds_put_cstr (&str, "INITIAL "); - if ( rd->extraction.unrotated ) + if (rd->extraction.unrotated) ds_put_cstr (&str, "EXTRACTION "); - if ( rd->rotation.rotated_solution ) + if (rd->rotation.rotated_solution) ds_put_cstr (&str, "ROTATION"); /* The CRITERIA = ITERATE subcommand is overloaded. It applies to the next /ROTATION and/or EXTRACTION command whatever comes first. */ - ds_put_c_format (&str, "\n\t/CRITERIA = ITERATE (%d)", rd->rotation.iterations ); + ds_put_c_format (&str, "\n\t/CRITERIA = ITERATE (%d)", rd->rotation.iterations); ds_put_cstr (&str, "\n\t/ROTATION = "); ds_put_cstr (&str, rot_method_syntax[rd->rotation.method]); @@ -133,7 +133,7 @@ load_rotation_parameters (PsppireDialogActionFactor *fd, const struct rotation_p { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->display_rotated_solution), p->rotated_solution); - + gtk_spin_button_set_value (GTK_SPIN_BUTTON (fd->rotate_iterations), p->iterations); @@ -180,11 +180,11 @@ load_extraction_parameters (PsppireDialogActionFactor *fd, const struct extracti gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->scree_button), p->scree); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->unrotated_button), p->unrotated); - if ( p->paf ) + if (p->paf) gtk_combo_box_set_active (GTK_COMBO_BOX (fd->extraction_combo), 1); else gtk_combo_box_set_active (GTK_COMBO_BOX (fd->extraction_combo), 0); - + } static gboolean @@ -225,16 +225,16 @@ set_rotation_parameters (PsppireDialogActionFactor *act, struct rotation_paramet p->rotated_solution = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->display_rotated_solution)); - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->rotation_none))) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->rotation_none))) p->method = ROT_NONE; - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->rotation_varimax))) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->rotation_varimax))) p->method = ROT_VARIMAX; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->rotation_quartimax))) p->method = ROT_QUARTIMAX; - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->rotation_equimax))) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (act->rotation_equimax))) p->method = ROT_EQUIMAX; } @@ -262,7 +262,7 @@ run_extractions_subdialog (PsppireDialogActionFactor *act) gint response = psppire_dialog_run (PSPPIRE_DIALOG (act->extraction_dialog)); - if ( response == PSPPIRE_RESPONSE_CONTINUE ) + if (response == PSPPIRE_RESPONSE_CONTINUE) { /* Set the parameters from their respective widgets */ set_extraction_parameters (act, ex); @@ -281,7 +281,7 @@ run_rotations_subdialog (PsppireDialogActionFactor *act) gint response = psppire_dialog_run (PSPPIRE_DIALOG (act->rotation_dialog)); - if ( response == PSPPIRE_RESPONSE_CONTINUE ) + if (response == PSPPIRE_RESPONSE_CONTINUE) { /* Set the parameters from their respective widgets */ set_rotation_parameters (act, rot); @@ -293,90 +293,82 @@ run_rotations_subdialog (PsppireDialogActionFactor *act) } } -static void -psppire_dialog_action_factor_activate (PsppireDialogAction *a) +static GtkBuilder * +psppire_dialog_action_factor_activate (PsppireDialogAction *a, GVariant *param) { PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionFactor *act = PSPPIRE_DIALOG_ACTION_FACTOR (a); GtkWidget *extraction_button ; GtkWidget *rotation_button ; - GHashTable *thing = psppire_dialog_action_get_hash_table (pda); - GtkBuilder *xml = g_hash_table_lookup (thing, a); - if (!xml) - { - xml = builder_new ("factor.ui"); - g_hash_table_insert (thing, a, xml); - + GtkBuilder *xml = builder_new ("factor.ui"); - pda->dialog = get_widget_assert (xml, "factor-dialog"); - pda->source = get_widget_assert (xml, "dict-view"); + pda->dialog = get_widget_assert (xml, "factor-dialog"); + pda->source = get_widget_assert (xml, "dict-view"); - extraction_button = get_widget_assert (xml, "button-extractions"); - rotation_button = get_widget_assert (xml, "button-rotations"); + extraction_button = get_widget_assert (xml, "button-extractions"); + rotation_button = get_widget_assert (xml, "button-rotations"); - act->extraction_dialog = get_widget_assert (xml, "extractions-dialog"); - act->rotation_dialog = get_widget_assert (xml, "rotations-dialog"); + act->extraction_dialog = get_widget_assert (xml, "extractions-dialog"); + act->rotation_dialog = get_widget_assert (xml, "rotations-dialog"); - act->variables = get_widget_assert (xml, "psppire-var-view1"); + act->variables = get_widget_assert (xml, "psppire-var-view1"); - { - GtkWidget *hbox = get_widget_assert (xml, "hbox6"); - GtkWidget *eigenvalue_extraction ; - - act->mineigen_toggle = get_widget_assert (xml, "mineigen-radiobutton"); + { + GtkWidget *hbox = get_widget_assert (xml, "hbox6"); + GtkWidget *eigenvalue_extraction ; - eigenvalue_extraction = psppire_scanf_new (_("_Eigenvalues over %4.2f times the mean eigenvalue"), &act->mineigen); + act->mineigen_toggle = get_widget_assert (xml, "mineigen-radiobutton"); - g_object_set (eigenvalue_extraction, - "use-underline", TRUE, - "mnemonic-widget", act->mineigen_toggle, - NULL); + eigenvalue_extraction = psppire_scanf_new (_("_Eigenvalues over %4.2f times the mean eigenvalue"), &act->mineigen); - act->nfactors_toggle = get_widget_assert (xml, "nfactors-radiobutton"); - act->n_factors = get_widget_assert (xml, "spinbutton-nfactors"); - act->extract_iterations = get_widget_assert (xml, "spinbutton-extract-iterations"); - act->covariance_toggle = get_widget_assert (xml, "covariance-radiobutton"); - act->correlation_toggle = get_widget_assert (xml, "correlations-radiobutton"); + g_object_set (eigenvalue_extraction, + "use-underline", TRUE, + "mnemonic-widget", act->mineigen_toggle, + NULL); - act->scree_button = get_widget_assert (xml, "scree-button"); - act->unrotated_button = get_widget_assert (xml, "unrotated-button"); - act->extraction_combo = get_widget_assert (xml, "combobox1"); + act->nfactors_toggle = get_widget_assert (xml, "nfactors-radiobutton"); + act->n_factors = get_widget_assert (xml, "spinbutton-nfactors"); + act->extract_iterations = get_widget_assert (xml, "spinbutton-extract-iterations"); + act->covariance_toggle = get_widget_assert (xml, "covariance-radiobutton"); + act->correlation_toggle = get_widget_assert (xml, "correlations-radiobutton"); - gtk_container_add (GTK_CONTAINER (hbox), eigenvalue_extraction); + act->scree_button = get_widget_assert (xml, "scree-button"); + act->unrotated_button = get_widget_assert (xml, "unrotated-button"); + act->extraction_combo = get_widget_assert (xml, "combobox1"); - g_signal_connect (act->nfactors_toggle, "toggled", G_CALLBACK (on_extract_toggle), act); + gtk_container_add (GTK_CONTAINER (hbox), eigenvalue_extraction); - gtk_widget_show_all (eigenvalue_extraction); - } + g_signal_connect (act->nfactors_toggle, "toggled", G_CALLBACK (on_extract_toggle), act); - { - act->rotate_iterations = get_widget_assert (xml, "spinbutton-rot-iterations"); + gtk_widget_show_all (eigenvalue_extraction); + } - act->display_rotated_solution = get_widget_assert (xml, "checkbutton-rotated-solution"); + { + act->rotate_iterations = get_widget_assert (xml, "spinbutton-rot-iterations"); - act->rotation_none = get_widget_assert (xml, "radiobutton-none"); - act->rotation_varimax = get_widget_assert (xml, "radiobutton-varimax"); - act->rotation_quartimax = get_widget_assert (xml, "radiobutton-quartimax"); - act->rotation_equimax = get_widget_assert (xml, "radiobutton-equimax"); - } + act->display_rotated_solution = get_widget_assert (xml, "checkbutton-rotated-solution"); - g_signal_connect_swapped (extraction_button, "clicked", - G_CALLBACK (run_extractions_subdialog), act); - g_signal_connect_swapped (rotation_button, "clicked", G_CALLBACK (run_rotations_subdialog), act); + act->rotation_none = get_widget_assert (xml, "radiobutton-none"); + act->rotation_varimax = get_widget_assert (xml, "radiobutton-varimax"); + act->rotation_quartimax = get_widget_assert (xml, "radiobutton-quartimax"); + act->rotation_equimax = get_widget_assert (xml, "radiobutton-equimax"); + } - } + g_signal_connect_swapped (extraction_button, "clicked", + G_CALLBACK (run_extractions_subdialog), act); + g_signal_connect_swapped (rotation_button, "clicked", G_CALLBACK (run_rotations_subdialog), act); 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_factor_parent_class)->activate (pda); + return xml; } static void psppire_dialog_action_factor_class_init (PsppireDialogActionFactorClass *class) { - psppire_dialog_action_set_activation (class, psppire_dialog_action_factor_activate); + PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_factor_activate; PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax; }