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=8025dcc3e696a57445561ce81be44d29f3679ed3;hp=6b6144a6fb70559928cd8e3831d7f98396940799;hpb=e0d88baeadd6bc1eb1176da30de771ac9658f4c9;p=pspp diff --git a/src/ui/gui/psppire-dialog-action-factor.c b/src/ui/gui/psppire-dialog-action-factor.c index 6b6144a6fb..48f72ffbd6 100644 --- a/src/ui/gui/psppire-dialog-action-factor.c +++ b/src/ui/gui/psppire-dialog-action-factor.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation + Copyright (C) 2009, 2010, 2011, 2012, 2014 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 @@ -19,6 +19,8 @@ #include "psppire-dialog-action-factor.h" +#include + #include "psppire-var-view.h" #include "dialog-common.h" #include "psppire-selector.h" @@ -26,6 +28,7 @@ #include "psppire-dialog.h" #include "builder-wrapper.h" #include "psppire-scanf.h" +#include #include "gettext.h" #define _(msgid) gettext (msgid) @@ -35,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", @@ -53,74 +56,74 @@ 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); gchar *text = NULL; - GString *string = g_string_new ("FACTOR "); + struct string str; + ds_init_cstr (&str, "FACTOR "); - g_string_append (string, "\n\t/VARIABLES="); + ds_put_cstr (&str, "\n\t/VARIABLES="); - psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->variables), 0, string); + psppire_var_view_append_names_str (PSPPIRE_VAR_VIEW (rd->variables), 0, &str); - g_string_append (string, "\n\t/CRITERIA = "); - if ( rd->extraction.explicit_nfactors ) - g_string_append_printf (string, "FACTORS (%d)", rd->extraction.n_factors); + ds_put_cstr (&str, "\n\t/CRITERIA = "); + if (rd->extraction.explicit_nfactors) + ds_put_c_format (&str, "FACTORS (%d)", rd->extraction.n_factors); else - g_string_append_printf (string, "MINEIGEN (%g)", rd->extraction.mineigen); + ds_put_c_format (&str, "MINEIGEN (%.*g)", + DBL_DIG + 1, rd->extraction.mineigen); /* The CRITERIA = ITERATE subcommand is overloaded. It applies to the next /ROTATION and/or EXTRACTION command whatever comes first. */ - g_string_append_printf (string, " ITERATE (%d)", rd->extraction.n_iterations); + ds_put_c_format (&str, " ITERATE (%d)", rd->extraction.n_iterations); - g_string_append (string, "\n\t/EXTRACTION ="); - if ( rd->extraction.paf) - g_string_append (string, "PAF"); + ds_put_cstr (&str, "\n\t/EXTRACTION ="); + if (rd->extraction.paf) + ds_put_cstr (&str, "PAF"); else - g_string_append (string, "PC"); + ds_put_cstr (&str, "PC"); - g_string_append (string, "\n\t/METHOD = "); - if ( rd->extraction.covariance ) - g_string_append (string, "COVARIANCE"); + ds_put_cstr (&str, "\n\t/METHOD = "); + if (rd->extraction.covariance) + ds_put_cstr (&str, "COVARIANCE"); else - g_string_append (string, "CORRELATION"); - + ds_put_cstr (&str, "CORRELATION"); - - if ( rd->extraction.scree ) + if (rd->extraction.scree) { - g_string_append (string, "\n\t/PLOT = "); - g_string_append (string, "EIGEN"); + ds_put_cstr (&str, "\n\t/PLOT = "); + ds_put_cstr (&str, "EIGEN"); } - g_string_append (string, "\n\t/PRINT = "); - g_string_append (string, "INITIAL "); + ds_put_cstr (&str, "\n\t/PRINT = "); + ds_put_cstr (&str, "INITIAL "); - if ( rd->extraction.unrotated ) - g_string_append (string, "EXTRACTION "); + if (rd->extraction.unrotated) + ds_put_cstr (&str, "EXTRACTION "); - if ( rd->rotation.rotated_solution ) - g_string_append (string, "ROTATION"); + 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. */ - g_string_append_printf (string, "\n\t/CRITERIA = ITERATE (%d)", rd->rotation.iterations ); + ds_put_c_format (&str, "\n\t/CRITERIA = ITERATE (%d)", rd->rotation.iterations); - g_string_append (string, "\n\t/ROTATION = "); - g_string_append (string, rot_method_syntax[rd->rotation.method]); + ds_put_cstr (&str, "\n\t/ROTATION = "); + ds_put_cstr (&str, rot_method_syntax[rd->rotation.method]); - g_string_append (string, "."); - text = string->str; + ds_put_cstr (&str, "."); + text = ds_steal_cstr (&str); - g_string_free (string, FALSE); + ds_destroy (&str); return text; } @@ -130,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); @@ -177,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 @@ -222,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; } @@ -259,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); @@ -278,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); @@ -290,8 +293,8 @@ run_rotations_subdialog (PsppireDialogActionFactor *act) } } -static void -psppire_dialog_action_factor_activate (GtkAction *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); @@ -356,19 +359,16 @@ psppire_dialog_action_factor_activate (GtkAction *a) 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); - - g_object_unref (xml); + return xml; } static void psppire_dialog_action_factor_class_init (PsppireDialogActionFactorClass *class) { - GTK_ACTION_CLASS (class)->activate = 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; }