Regression Dialog: Convert to PsppireDialogAction object 20120520030503/pspp 20120521030502/pspp 20120522030504/pspp 20120523030503/pspp 20120524030503/pspp 20120525030504/pspp 20120526030503/pspp 20120527030504/pspp 20120528030503/pspp 20120530030501/pspp 20120531030508/pspp 20120602060505/pspp 20120603060503/pspp 20120604060508/pspp 20120605060508/pspp 20120606060502/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 20 May 2012 07:12:04 +0000 (09:12 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 20 May 2012 07:12:04 +0000 (09:12 +0200)
src/ui/gui/automake.mk
src/ui/gui/data-editor.ui
src/ui/gui/psppire-data-window.c
src/ui/gui/psppire-dialog-action-regression.c [new file with mode: 0644]
src/ui/gui/psppire-dialog-action-regression.h [new file with mode: 0644]
src/ui/gui/regression-dialog.c [deleted file]
src/ui/gui/regression-dialog.h [deleted file]
src/ui/gui/widgets.c

index 3e2280a5d72e71a1fe3a64328eaba05f22d3b5c7..9c237b0031b45b1717a752cfe5bfdf8c6c15915f 100644 (file)
@@ -238,14 +238,16 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/psppire-dialog-action-means.h \
        src/ui/gui/psppire-dialog-action-rank.c \
        src/ui/gui/psppire-dialog-action-rank.h \
+       src/ui/gui/psppire-dialog-action-regression.c \
+       src/ui/gui/psppire-dialog-action-regression.h \
        src/ui/gui/psppire-dialog-action-reliability.c \
        src/ui/gui/psppire-dialog-action-reliability.h \
+       src/ui/gui/psppire-dialog-action-roc.c \
+       src/ui/gui/psppire-dialog-action-roc.h \
        src/ui/gui/psppire-dialog-action-sort.c \
        src/ui/gui/psppire-dialog-action-sort.h \
        src/ui/gui/psppire-dialog-action-var-info.c \
        src/ui/gui/psppire-dialog-action-var-info.h \
-       src/ui/gui/psppire-dialog-action-roc.c \
-       src/ui/gui/psppire-dialog-action-roc.h \
        src/ui/gui/psppire-dict.c \
        src/ui/gui/psppire-dict.h \
        src/ui/gui/psppire-dictview.c \
@@ -290,8 +292,6 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/psppire-window-register.h \
        src/ui/gui/recode-dialog.c \
        src/ui/gui/recode-dialog.h \
-       src/ui/gui/regression-dialog.c \
-       src/ui/gui/regression-dialog.h \
        src/ui/gui/runs-dialog.c \
        src/ui/gui/runs-dialog.h \
        src/ui/gui/select-cases-dialog.c \
@@ -383,3 +383,4 @@ src/ui/gui/include/gtk/gtk.h: src/ui/gui/include/gtk/gtk.in.h
        mv $@-t $@
 CLEANFILES += src/ui/gui/include/gtk/gtk.h
 EXTRA_DIST += src/ui/gui/include/gtk/gtk.in.h
+
index 19014e9cf16220f2bc5b87bc88b1b951deb136b1..cfa5b3e91834ea6e4cab79daaf83f02d0b8e7902 100644 (file)
           </object>
         </child>
         <child>
-          <object class="GtkAction" id="linear-regression">
+          <object class="PsppireDialogActionRegression" id="linear-regression">
             <property name="name">linear-regression</property>
+            <property name="manager">uimanager1</property>
             <property name="label" translatable="yes">Linear _Regression...</property>
           </object>
         </child>
index 4e8d41a821a1aa5fe9cc45fa47b3f4d6efc54b3f..6dc422e3404773b993ad2c1ed78b14fae19a1c85 100644 (file)
@@ -51,7 +51,6 @@
 #include "ui/gui/runs-dialog.h"
 #include "ui/gui/ks-one-sample-dialog.h"
 #include "ui/gui/recode-dialog.h"
-#include "ui/gui/regression-dialog.h"
 #include "ui/gui/select-cases-dialog.h"
 #include "ui/gui/split-file-dialog.h"
 #include "ui/gui/t-test-one-sample.h"
@@ -1072,7 +1071,6 @@ psppire_data_window_finish_init (PsppireDataWindow *de,
   connect_action (de, "transform_recode-different", G_CALLBACK (recode_different_dialog));
   connect_action (de, "analyze_frequencies", G_CALLBACK (frequencies_dialog));
   connect_action (de, "crosstabs", G_CALLBACK (crosstabs_dialog));
-  connect_action (de, "linear-regression", G_CALLBACK (regression_dialog));
   connect_action (de, "univariate", G_CALLBACK (univariate_dialog));
   connect_action (de, "chi-square", G_CALLBACK (chisquare_dialog));
   connect_action (de, "binomial", G_CALLBACK (binomial_dialog));
diff --git a/src/ui/gui/psppire-dialog-action-regression.c b/src/ui/gui/psppire-dialog-action-regression.c
new file mode 100644 (file)
index 0000000..29df2a4
--- /dev/null
@@ -0,0 +1,268 @@
+/* PSPPIRE - a graphical user interface for PSPP.
+   Copyright (C) 2008, 2010, 2011, 2012  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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+
+#include "psppire-dialog-action-regression.h"
+#include "psppire-value-entry.h"
+
+#include "dialog-common.h"
+#include "helper.h"
+#include <ui/syntax-gen.h>
+#include "psppire-var-view.h"
+
+#include "psppire-dialog.h"
+#include "builder-wrapper.h"
+#include "checkbox-treeview.h"
+#include "psppire-dict.h"
+#include "libpspp/str.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+
+#define REGRESSION_STATS                         \
+  RG (COEFF, N_("Coeff"))                         \
+  RG (R, N_("R"))                                \
+  RG (ANOVA, N_("Anova"))                        \
+  RG (BCOV, N_("Bcov"))
+enum
+  {
+#define RG(NAME, LABEL) RG_##NAME,
+    REGRESSION_STATS
+#undef RG
+    N_REGRESSION_STATS
+  };
+
+enum
+  {
+#define RG(NAME, LABEL) B_RG_##NAME = 1u << RG_##NAME,
+    REGRESSION_STATS
+#undef RG
+    B_RG_STATS_ALL = (1u << N_REGRESSION_STATS) - 1,
+    B_RG_STATS_DEFAULT = B_RG_ANOVA | B_RG_COEFF | B_RG_R
+  };
+
+static const struct checkbox_entry_item stats[] =
+  {
+#define RG(NAME, LABEL) {#NAME, LABEL},
+    REGRESSION_STATS
+#undef RG
+  };
+
+static void
+psppire_dialog_action_regression_class_init (PsppireDialogActionRegressionClass *class);
+
+G_DEFINE_TYPE (PsppireDialogActionRegression, psppire_dialog_action_regression, PSPPIRE_TYPE_DIALOG_ACTION);
+
+static gboolean
+dialog_state_valid (gpointer data)
+{
+  PsppireDialogActionRegression *rd = PSPPIRE_DIALOG_ACTION_REGRESSION (data);
+  GtkTreeModel *dep_vars = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->dep_vars));
+  GtkTreeModel *indep_vars = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->indep_vars));
+
+  GtkTreeIter notused;
+
+  return (gtk_tree_model_get_iter_first (dep_vars, &notused)
+    && gtk_tree_model_get_iter_first (indep_vars, &notused));
+}
+
+static void
+refresh (PsppireDialogAction *rd_)
+{
+  PsppireDialogActionRegression *rd = PSPPIRE_DIALOG_ACTION_REGRESSION (rd_);
+
+  GtkTreeModel *liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->dep_vars));
+  gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+  liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->indep_vars));
+  gtk_list_store_clear (GTK_LIST_STORE (liststore));
+}
+
+static void
+on_statistics_clicked (PsppireDialogActionRegression *rd)
+{
+  int ret;
+  GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->stat_view));
+
+  /* Take a backup copy of the existing model */
+  GtkListStore *backup_model = clone_list_store (GTK_LIST_STORE (model));
+
+  ret = psppire_dialog_run (PSPPIRE_DIALOG (rd->stat_dialog));
+
+  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));
+    }
+  g_object_unref (backup_model);
+}
+
+static void
+on_save_clicked (PsppireDialogActionRegression *rd)
+{
+  int ret;
+  if (rd->pred)
+    {
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->pred_button), TRUE);
+    }
+  if (rd->resid)
+    {
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->resid_button), TRUE);
+    }
+
+  ret = psppire_dialog_run (PSPPIRE_DIALOG (rd->save_dialog));
+
+  if ( ret == PSPPIRE_RESPONSE_CONTINUE )
+    {
+      rd->pred = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->pred_button)) == TRUE)
+       ? TRUE : FALSE;
+      rd->resid = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->resid_button)) == TRUE)
+       ? TRUE : FALSE;
+    }
+}
+
+
+static void
+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");
+  GtkWidget *stat_button = get_widget_assert (xml, "stat-button");
+  GtkWidget *save_button = get_widget_assert (xml, "save-button");
+
+  pda->dialog = get_widget_assert   (xml, "regression-dialog");
+  pda->source = get_widget_assert   (xml, "dict-view");
+
+  act->dep_vars  = get_widget_assert   (xml, "dep-view");
+  act->indep_vars  = get_widget_assert   (xml, "indep-view");
+  act->stat_view = get_widget_assert (xml, "stat-view");
+  act->stat_dialog = get_widget_assert (xml, "statistics-dialog");
+  act->save_dialog = get_widget_assert (xml, "save-dialog");
+  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_dialog_action_set_refresh (pda, refresh);
+
+  psppire_dialog_action_set_valid_predicate (pda,
+                                       dialog_state_valid);
+
+  g_signal_connect_swapped (stat_button, "clicked",
+                           G_CALLBACK (on_statistics_clicked),  act);
+
+  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);
+}
+
+
+
+static char *
+generate_syntax (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");
+
+  GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->stat_view));
+
+  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");
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->dep_vars), 0, string);
+
+  selected = 0;
+  for (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 
+       selected &= ~(1u << i);
+    }
+
+  if (selected)
+    {
+      g_string_append (string, "\n\t/STATISTICS=");
+      n = 0;
+      for (i = 0; i < N_REGRESSION_STATS; i++)
+       if (selected & (1u << i))
+         {
+           if (n++)
+             g_string_append (string, " ");
+           g_string_append (string, stats[i].name);
+         }
+    }
+
+  if (rd->pred || rd->resid)
+    {
+      g_string_append (string, "\n\t/SAVE=");
+      if (rd->pred)
+       g_string_append (string, " PRED");
+      if (rd->resid)
+       g_string_append (string, " RESID");
+    }
+
+  g_string_append (string, ".\n");
+
+  text = string->str;
+
+  g_string_free (string, FALSE);
+
+  return text;
+}
+
+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)->generate_syntax = generate_syntax;
+}
+
+
+static void
+psppire_dialog_action_regression_init (PsppireDialogActionRegression *act)
+{
+}
+
diff --git a/src/ui/gui/psppire-dialog-action-regression.h b/src/ui/gui/psppire-dialog-action-regression.h
new file mode 100644 (file)
index 0000000..bb78a36
--- /dev/null
@@ -0,0 +1,91 @@
+/* PSPPIRE - a graphical user interface for PSPP.
+   Copyright (C) 2012  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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-dialog-action.h"
+
+#ifndef __PSPPIRE_DIALOG_ACTION_REGRESSION_H__
+#define __PSPPIRE_DIALOG_ACTION_REGRESSION_H__
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION (psppire_dialog_action_regression_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION_REGRESSION(obj)  \
+                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                                                 PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, PsppireDialogActionRegression))
+
+#define PSPPIRE_DIALOG_ACTION_REGRESSION_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_CAST ((klass), \
+                                PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, \
+                                 PsppireDialogActionRegressionClass))
+
+
+#define PSPPIRE_IS_DIALOG_ACTION_REGRESSION(obj) \
+                    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION))
+
+#define PSPPIRE_IS_DIALOG_ACTION_REGRESSION_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION))
+
+
+#define PSPPIRE_DIALOG_ACTION_REGRESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                                  PSPPIRE_TYPE_DIALOG_ACTION_REGRESSION, \
+                                  PsppireDialogActionRegressionClass))
+
+typedef struct _PsppireDialogActionRegression       PsppireDialogActionRegression;
+typedef struct _PsppireDialogActionRegressionClass  PsppireDialogActionRegressionClass;
+
+
+struct _PsppireDialogActionRegression
+{
+  PsppireDialogAction parent;
+
+  /*< private >*/
+  gboolean dispose_has_run ;
+
+  GtkWidget *dep_vars;
+  GtkWidget *indep_vars;
+
+  GtkWidget *resid_button;
+  GtkWidget *pred_button;
+
+  GtkWidget *stat_dialog;
+  GtkWidget *save_dialog;
+
+  GtkWidget *stat_view;
+
+
+  /* Save Options */
+  gboolean pred;
+  gboolean resid;
+};
+
+
+struct _PsppireDialogActionRegressionClass
+{
+  PsppireDialogActionClass parent_class;
+};
+
+
+GType psppire_dialog_action_regression_get_type (void) ;
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_REGRESSION_H__ */
diff --git a/src/ui/gui/regression-dialog.c b/src/ui/gui/regression-dialog.c
deleted file mode 100644 (file)
index 06cdf82..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-/* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2008, 2010, 2011, 2012  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
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "checkbox-treeview.h"
-#include "regression-dialog.h"
-#include "executor.h"
-
-#include <gtk/gtk.h>
-#include <stdlib.h>
-
-#include <ui/gui/psppire-data-window.h>
-#include <ui/gui/dialog-common.h>
-#include <ui/gui/dict-display.h>
-#include <ui/gui/builder-wrapper.h>
-#include <ui/gui/helper.h>
-#include <ui/gui/psppire-dialog.h>
-#include <ui/gui/psppire-var-store.h>
-#include <ui/gui/psppire-var-view.h>
-
-
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-#define N_(msgid) msgid
-
-
-#define REGRESSION_STATS                         \
-  RG (COEFF, N_("Coeff"))                         \
-  RG (R, N_("R"))                                \
-  RG (ANOVA, N_("Anova"))                        \
-  RG (BCOV, N_("Bcov"))
-enum
-  {
-#define RG(NAME, LABEL) RG_##NAME,
-    REGRESSION_STATS
-#undef RG
-    N_REGRESSION_STATS
-  };
-
-enum
-  {
-#define RG(NAME, LABEL) B_RG_##NAME = 1u << RG_##NAME,
-    REGRESSION_STATS
-#undef RG
-    B_RG_STATS_ALL = (1u << N_REGRESSION_STATS) - 1,
-    B_RG_STATS_DEFAULT = B_RG_ANOVA | B_RG_COEFF | B_RG_R
-  };
-
-static const struct checkbox_entry_item stats[] =
-  {
-#define RG(NAME, LABEL) {#NAME, LABEL},
-    REGRESSION_STATS
-#undef RG
-  };
-
-struct save_options
-{
-  gboolean pred;
-  gboolean resid;
-};
-struct regression_dialog
-{
-  GtkTreeView *dep_vars;
-  GtkTreeView *indep_vars;
-  PsppireDict *dict;
-
-  GtkToggleButton *resid_button;
-  GtkToggleButton *pred_button;
-
-  GtkWidget *stat_dialog;
-  GtkWidget *save_dialog;
-
-  GtkWidget *stat_view;
-  struct save_options current_opts;
-};
-
-static void
-refresh (PsppireDialog *dialog, struct regression_dialog *rd)
-{
-  GtkTreeModel *liststore = gtk_tree_view_get_model (rd->dep_vars);
-  gtk_list_store_clear (GTK_LIST_STORE (liststore));
-
-  liststore = gtk_tree_view_get_model (rd->indep_vars);
-  gtk_list_store_clear (GTK_LIST_STORE (liststore));
-}
-
-static void
-on_statistics_clicked (struct regression_dialog *rd)
-{
-  int ret;
-  GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->stat_view));
-
-  /* Take a backup copy of the existing model */
-  GtkListStore *backup_model = clone_list_store (GTK_LIST_STORE (model));
-
-  ret = psppire_dialog_run (PSPPIRE_DIALOG (rd->stat_dialog));
-
-  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));
-    }
-  g_object_unref (backup_model);
-}
-
-static void
-on_save_clicked (struct regression_dialog *rd)
-{
-  int ret;
-  if (rd->current_opts.pred)
-    {
-      gtk_toggle_button_set_active (rd->pred_button, TRUE);
-    }
-  if (rd->current_opts.resid)
-    {
-      gtk_toggle_button_set_active (rd->resid_button, TRUE);
-    }
-
-  ret = psppire_dialog_run (PSPPIRE_DIALOG (rd->save_dialog));
-
-  if ( ret == PSPPIRE_RESPONSE_CONTINUE )
-    {
-      rd->current_opts.pred = (gtk_toggle_button_get_active (rd->pred_button) == TRUE)
-       ? TRUE : FALSE;
-      rd->current_opts.resid = (gtk_toggle_button_get_active (rd->resid_button) == TRUE)
-       ? TRUE : FALSE;
-    }
-}
-
-static char *
-generate_syntax (const struct regression_dialog *rd)
-{
-  gint i;
-  int n;
-  guint selected;
-  GtkTreeIter iter;
-  gboolean ok;
-
-  gchar *text;
-  GString *string = g_string_new ("REGRESSION");
-
-  GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (rd->stat_view));
-
-  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");
-  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->dep_vars), 0, string);
-
-  selected = 0;
-  for (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 
-       selected &= ~(1u << i);
-    }
-
-  if (selected)
-    {
-      g_string_append (string, "\n\t/STATISTICS=");
-      n = 0;
-      for (i = 0; i < N_REGRESSION_STATS; i++)
-       if (selected & (1u << i))
-         {
-           if (n++)
-             g_string_append (string, " ");
-           g_string_append (string, stats[i].name);
-         }
-    }
-  if (rd->current_opts.pred || rd->current_opts.resid)
-    {
-      g_string_append (string, "\n\t/SAVE=");
-      if (rd->current_opts.pred)
-       g_string_append (string, " PRED");
-      if (rd->current_opts.resid)
-       g_string_append (string, " RESID");
-    }
-  g_string_append (string, ".\n");
-
-  text = string->str;
-
-  g_string_free (string, FALSE);
-
-  return text;
-}
-
-/* Dialog is valid iff at least one dependent and one independent variable have
-   been selected. */
-static gboolean
-dialog_state_valid (gpointer data)
-{
-  struct regression_dialog *rd = data;
-
-  GtkTreeModel *dep_vars = gtk_tree_view_get_model (rd->dep_vars);
-  GtkTreeModel *indep_vars = gtk_tree_view_get_model (rd->indep_vars);
-
-  GtkTreeIter notused;
-
-  return (gtk_tree_model_get_iter_first (dep_vars, &notused)
-    && gtk_tree_model_get_iter_first (indep_vars, &notused));
-}
-
-/* Pops up the Regression dialog box */
-void
-regression_dialog (PsppireDataWindow *de)
-{
-  gint response;
-  struct regression_dialog rd;
-
-  GtkBuilder *xml = builder_new ("regression.ui");
-  PsppireVarStore *vs;
-
-  GtkWidget *dialog = get_widget_assert   (xml, "regression-dialog");
-  GtkWidget *source = get_widget_assert   (xml, "dict-view");
-  GtkWidget *dest_dep =   get_widget_assert   (xml, "dep-view");
-  GtkWidget *dest_indep =   get_widget_assert   (xml, "indep-view");
-  GtkWidget *stat_button = get_widget_assert (xml, "stat-button");
-  GtkWidget *save_button = get_widget_assert (xml, "save-button");
-
-  GtkWidget *dep_selector = get_widget_assert (xml, "dep-selector");
-
-  rd.stat_view = get_widget_assert (xml, "stat-view");
-
-  g_object_get (de->data_editor, "var-store", &vs, NULL);
-
-
-  put_checkbox_items_in_treeview (GTK_TREE_VIEW(rd.stat_view),
-                                 B_RG_STATS_DEFAULT,
-                                 N_REGRESSION_STATS,
-                                 stats
-                                 );
-
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
-
-  g_object_get (vs, "dictionary", &rd.dict, NULL);
-  g_object_set (source, "model", rd.dict, NULL);
-
-  rd.dep_vars = GTK_TREE_VIEW (dest_dep);
-  rd.indep_vars = GTK_TREE_VIEW (dest_indep);
-
-  psppire_selector_set_allow (PSPPIRE_SELECTOR (dep_selector), numeric_only);
-
-  rd.save_dialog = get_widget_assert (xml, "save-dialog");
-  rd.pred_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "pred-button"));
-  rd.resid_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "resid-button"));
-  rd.stat_dialog = get_widget_assert (xml, "statistics-dialog");
-
-  rd.current_opts.pred = FALSE;
-  rd.current_opts.resid = FALSE;
-
-  gtk_window_set_transient_for (GTK_WINDOW (rd.save_dialog), GTK_WINDOW (de));
-  gtk_window_set_transient_for (GTK_WINDOW (rd.stat_dialog), GTK_WINDOW (de));
-
-  g_signal_connect (dialog, "refresh", G_CALLBACK (refresh),  &rd);
-
-  psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
-                                     dialog_state_valid, &rd);
-
-  g_signal_connect_swapped (stat_button, "clicked",
-                           G_CALLBACK (on_statistics_clicked),  &rd);
-  g_signal_connect_swapped (save_button, "clicked",
-                           G_CALLBACK (on_save_clicked),  &rd);
-
-  response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
-
-
-  switch (response)
-    {
-    case GTK_RESPONSE_OK:
-      g_free (execute_syntax_string (de, generate_syntax (&rd)));
-      break;
-    case PSPPIRE_RESPONSE_PASTE:
-      g_free (paste_syntax_to_window (generate_syntax (&rd)));
-      break;
-    default:
-      break;
-    }
-
-  g_object_unref (xml);
-}
diff --git a/src/ui/gui/regression-dialog.h b/src/ui/gui/regression-dialog.h
deleted file mode 100644 (file)
index 32067cc..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2008  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
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef __REGRESSION_DIALOG_H
-#define __REGRESSION_DIALOG_H
-
-
-#include "psppire-data-window.h"
-
-void regression_dialog (PsppireDataWindow * data);
-
-#endif
index 74cfd4cf9415454b6317141b3da10bf0df00fac9..0da5c6c73fd0a97db6e07044dce58ae09d7c9b03 100644 (file)
@@ -22,6 +22,7 @@
 #include "psppire-dialog-action-means.h"
 #include "psppire-means-layer.h"
 #include "psppire-dialog-action-rank.h"
+#include "psppire-dialog-action-regression.h"
 #include "psppire-dialog-action-reliability.h"
 #include "psppire-dialog-action-roc.h"
 #include "psppire-dialog-action-sort.h"
@@ -57,6 +58,7 @@ preregister_widgets (void)
   psppire_dialog_action_var_info_get_type ();
   psppire_dialog_action_rank_get_type ();
   psppire_dialog_action_reliability_get_type ();
+  psppire_dialog_action_regression_get_type ();
   psppire_dialog_action_roc_get_type ();
   psppire_dialog_action_sort_get_type ();
 }