psppire-dialog-action-regression: Fix unused variable warning.
[pspp] / src / ui / gui / psppire-dialog-action-regression.c
index 29df2a4392ac0c7bc6c8ce20e12c443258205ca9..c3f2234c1cf30559a935d1e5367378fcfd472d1b 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "psppire-dialog.h"
 #include "builder-wrapper.h"
-#include "checkbox-treeview.h"
+#include "psppire-checkbox-treeview.h"
 #include "psppire-dict.h"
 #include "libpspp/str.h"
 
 #define N_(msgid) msgid
 
 
-#define REGRESSION_STATS                         \
-  RG (COEFF, N_("Coeff"))                         \
-  RG (R, N_("R"))                                \
-  RG (ANOVA, N_("Anova"))                        \
-  RG (BCOV, N_("Bcov"))
+#define REGRESSION_STATS       \
+  RG (COEFF, N_("Coeff"),          N_("Show the regression coefficients"))     \
+  RG (CI,    N_("Conf. Interval"), N_("Show the confidence interval for the regression coefficients"))   \
+  RG (R,     N_("R"),              N_("Show the correlation between observed and predicted values")) \
+  RG (ANOVA, N_("Anova"),          N_("Show the analysis of variance table"))  \
+  RG (BCOV,  N_("Bcov"),           N_("Show the variance coefficient matrix"))  \
+  RG (TOL,   N_("Tol"),            N_("Show the variance inflation factor and its reciprocal"))
+
 enum
   {
-#define RG(NAME, LABEL) RG_##NAME,
+#define RG(NAME, LABEL, TOOLTIP) RG_##NAME,
     REGRESSION_STATS
 #undef RG
     N_REGRESSION_STATS
@@ -51,7 +54,7 @@ enum
 
 enum
   {
-#define RG(NAME, LABEL) B_RG_##NAME = 1u << RG_##NAME,
+#define RG(NAME, LABEL, TOOLTIP) B_RG_##NAME = 1u << RG_##NAME,
     REGRESSION_STATS
 #undef RG
     B_RG_STATS_ALL = (1u << N_REGRESSION_STATS) - 1,
@@ -60,7 +63,7 @@ enum
 
 static const struct checkbox_entry_item stats[] =
   {
-#define RG(NAME, LABEL) {#NAME, LABEL},
+#define RG(NAME, LABEL, TOOLTIP) {#NAME, LABEL, TOOLTIP},
     REGRESSION_STATS
 #undef RG
   };
@@ -106,7 +109,7 @@ on_statistics_clicked (PsppireDialogActionRegression *rd)
 
   ret = psppire_dialog_run (PSPPIRE_DIALOG (rd->stat_dialog));
 
-  if ( ret != PSPPIRE_RESPONSE_CONTINUE )
+  if (ret != PSPPIRE_RESPONSE_CONTINUE)
     {
       /* If the user chose to abandon his changes, then replace the model, from the backup */
       gtk_tree_view_set_model (GTK_TREE_VIEW (rd->stat_view) , GTK_TREE_MODEL (backup_model));
@@ -129,7 +132,7 @@ on_save_clicked (PsppireDialogActionRegression *rd)
 
   ret = psppire_dialog_run (PSPPIRE_DIALOG (rd->save_dialog));
 
-  if ( ret == PSPPIRE_RESPONSE_CONTINUE )
+  if (ret == PSPPIRE_RESPONSE_CONTINUE)
     {
       rd->pred = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->pred_button)) == TRUE)
        ? TRUE : FALSE;
@@ -139,13 +142,14 @@ on_save_clicked (PsppireDialogActionRegression *rd)
 }
 
 
-static void
-psppire_dialog_action_regression_activate (GtkAction *a)
+static GtkBuilder *
+psppire_dialog_action_regression_activate (PsppireDialogAction *a, GVariant *param)
 {
   PsppireDialogActionRegression *act = PSPPIRE_DIALOG_ACTION_REGRESSION (a);
   PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
 
   GtkBuilder *xml = builder_new ("regression.ui");
+
   GtkWidget *stat_button = get_widget_assert (xml, "stat-button");
   GtkWidget *save_button = get_widget_assert (xml, "save-button");
 
@@ -160,12 +164,10 @@ 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);
-
-  put_checkbox_items_in_treeview (GTK_TREE_VIEW (act->stat_view),
-                                 B_RG_STATS_DEFAULT,
-                                 N_REGRESSION_STATS,
-                                 stats);
+  psppire_checkbox_treeview_populate (PSPPIRE_CHECKBOX_TREEVIEW (act->stat_view),
+                                 B_RG_STATS_DEFAULT,
+                                 N_REGRESSION_STATS,
+                                 stats);
 
   psppire_dialog_action_set_refresh (pda, refresh);
 
@@ -178,24 +180,19 @@ psppire_dialog_action_regression_activate (GtkAction *a)
   g_signal_connect_swapped (save_button, "clicked",
                            G_CALLBACK (on_save_clicked),  act);
 
-
-  if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_regression_parent_class)->activate)
-    PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_regression_parent_class)->activate (pda);
+  return xml;
 }
 
 
 
 static char *
-generate_syntax (PsppireDialogAction *a)
+generate_syntax (const PsppireDialogAction *a)
 {
   PsppireDialogActionRegression *rd = PSPPIRE_DIALOG_ACTION_REGRESSION (a);
   gchar *text = NULL;
 
-  gint i;
-  int n;
   guint selected;
   GtkTreeIter iter;
-  gboolean ok;
 
   GString *string = g_string_new ("REGRESSION");
 
@@ -203,27 +200,28 @@ generate_syntax (PsppireDialogAction *a)
 
   g_string_append (string, "\n\t/VARIABLES=");
   psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->indep_vars), 0, string);
-  g_string_append (string, "\n\t/DEPENDENT=\t");
+  g_string_append (string, "\n\t/DEPENDENT=");
   psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->dep_vars), 0, string);
+  g_string_append (string, "\n\t/METHOD=ENTER");
 
   selected = 0;
-  for (i = 0, ok = gtk_tree_model_get_iter_first (model, &iter); ok; 
+  for (gint i = 0, ok = gtk_tree_model_get_iter_first (model, &iter); ok;
        i++, ok = gtk_tree_model_iter_next (model, &iter))
     {
       gboolean toggled;
       gtk_tree_model_get (model, &iter,
-                         CHECKBOX_COLUMN_SELECTED, &toggled, -1); 
-      if (toggled) 
-       selected |= 1u << i; 
-      else 
+                         CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+      if (toggled)
+       selected |= 1u << i;
+      else
        selected &= ~(1u << i);
     }
 
   if (selected)
     {
       g_string_append (string, "\n\t/STATISTICS=");
-      n = 0;
-      for (i = 0; i < N_REGRESSION_STATS; i++)
+      int n = 0;
+      for (gint i = 0; i < N_REGRESSION_STATS; i++)
        if (selected & (1u << i))
          {
            if (n++)
@@ -253,9 +251,7 @@ generate_syntax (PsppireDialogAction *a)
 static void
 psppire_dialog_action_regression_class_init (PsppireDialogActionRegressionClass *class)
 {
-  GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
-  action_class->activate = psppire_dialog_action_regression_activate;
+  PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_regression_activate;
 
   PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
 }