Explore Dialog: Replace add hoc functions with the new DialogAction class
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 31 Mar 2012 06:41:27 +0000 (08:41 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 31 Mar 2012 06:41:27 +0000 (08:41 +0200)
src/ui/gui/automake.mk
src/ui/gui/data-editor.ui
src/ui/gui/examine-dialog.c [deleted file]
src/ui/gui/examine-dialog.h [deleted file]
src/ui/gui/psppire-data-window.c
src/ui/gui/psppire-dialog-action-examine.c [new file with mode: 0644]
src/ui/gui/psppire-dialog-action-examine.h [new file with mode: 0644]
src/ui/gui/widgets.c

index cd2696fba55894453e139d65ebaed9191afaff95..75ca28a7133229054de674edd3e347ab9f2d3f6d 100644 (file)
@@ -170,8 +170,6 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/dict-display.c \
        src/ui/gui/entry-dialog.c \
        src/ui/gui/entry-dialog.h \
-       src/ui/gui/examine-dialog.c \
-       src/ui/gui/examine-dialog.h \
        src/ui/gui/executor.c \
        src/ui/gui/executor.h \
        src/ui/gui/find-dialog.c \
@@ -216,6 +214,8 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/psppire-dialog-action-correlation.h \
        src/ui/gui/psppire-dialog-action-descriptives.c \
        src/ui/gui/psppire-dialog-action-descriptives.h \
+       src/ui/gui/psppire-dialog-action-examine.c \
+       src/ui/gui/psppire-dialog-action-examine.h \
        src/ui/gui/psppire-dialog-action-kmeans.c \
        src/ui/gui/psppire-dialog-action-kmeans.h \
        src/ui/gui/psppire-dialog-action-means.c \
index 3e9179681292f475b3ace88a938c8c5d6bb3a413..e568f2bc408c9c9534bf0f3701ce85f900f1bd07 100644 (file)
           </object>
         </child>
         <child>
-          <object class="GtkAction" id="analyze_explore">
+          <object class="PsppireDialogActionExamine" id="explore">
             <property name="name">analyze_explore</property>
+            <property name="manager">uimanager1</property>
             <property name="label" translatable="yes">_Explore...</property>
           </object>
         </child>
           <menu action="descriptive-statistics">
             <menuitem action="analyze_frequencies"/>
             <menuitem action="analyze_descriptives"/>
-            <menuitem action="analyze_explore"/>
+            <menuitem action="explore"/>
             <menuitem action="crosstabs"/>
           </menu>
           <menu action="compare-means">
diff --git a/src/ui/gui/examine-dialog.c b/src/ui/gui/examine-dialog.c
deleted file mode 100644 (file)
index 857394f..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-/* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2008, 2009, 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 "examine-dialog.h"
-#include "psppire-var-view.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/psppire-dialog.h>
-#include <ui/gui/psppire-var-store.h>
-#include "executor.h"
-#include "helper.h"
-
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-#define N_(msgid) msgid
-
-enum opts
-  {
-    OPT_LISTWISE,
-    OPT_PAIRWISE,
-    OPT_REPORT
-  };
-
-
-#define     STAT_DESCRIPTIVES  0x01
-#define     STAT_EXTREMES      0x02
-#define     STAT_PERCENTILES   0x04
-
-
-struct examine_dialog
-{
-  PsppireDict *dict;
-
-  GtkWidget *dep_list ;
-  GtkWidget *fct_list ;
-  GtkWidget *id_entry ;
-
-  GtkWidget *stats_dialog;
-  GtkWidget *opts_dialog;
-
-  /* Options */
-  enum opts opts;
-  guint stats;
-  GtkWidget *listwise;
-  GtkWidget *pairwise;
-  GtkWidget *report;
-
-  GtkToggleButton *descriptives_button;
-  GtkToggleButton *extremes_button;
-  GtkToggleButton *percentiles_button;
-};
-
-static void
-refresh (PsppireDialog *dialog, struct examine_dialog *ex_d)
-{
-  GtkTreeModel *liststore =
-    gtk_tree_view_get_model (GTK_TREE_VIEW (ex_d->dep_list));
-
-  gtk_list_store_clear (GTK_LIST_STORE (liststore));
-
-  liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (ex_d->fct_list));
-  gtk_list_store_clear (GTK_LIST_STORE (liststore));
-
-
-  gtk_entry_set_text (GTK_ENTRY (ex_d->id_entry), "");
-
-  ex_d->opts = OPT_LISTWISE;
-  ex_d->stats = 0x00;
-}
-
-static char *
-generate_syntax (const struct examine_dialog *ed)
-{
-  const char *label;
-  gchar *text = NULL;
-  GString *str = g_string_new ("EXAMINE ");
-
-  g_string_append (str, "\n\t/VARIABLES=");
-  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ed->dep_list), 0, str);
-
-  if ( 0  < gtk_tree_model_iter_n_children
-       (gtk_tree_view_get_model (GTK_TREE_VIEW (ed->fct_list)), NULL))
-    {
-      g_string_append (str, "\n\tBY ");
-      psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ed->fct_list), 0, str);
-    }
-
-  label = gtk_entry_get_text (GTK_ENTRY (ed->id_entry));
-  if ( 0 != strcmp (label, "") )
-    {
-      g_string_append (str, "\n\t/ID = ");
-      g_string_append (str, label);
-    }
-
-  if ( ed->stats & (STAT_DESCRIPTIVES | STAT_EXTREMES))
-    {
-      g_string_append (str, "\n\t/STATISTICS =");
-
-      if ( ed->stats & STAT_DESCRIPTIVES)
-       g_string_append (str, " DESCRIPTIVES");
-
-      if ( ed->stats & STAT_EXTREMES)
-       g_string_append (str, " EXTREME");
-    }
-
-  if ( ed->stats & STAT_PERCENTILES)
-    g_string_append (str, "\n\t/PERCENTILES");
-
-  g_string_append (str, "\n\t/MISSING=");
-  switch (ed->opts)
-    {
-    case OPT_REPORT:
-      g_string_append (str, "REPORT");
-      break;
-    case OPT_PAIRWISE:
-      g_string_append (str, "PAIRWISE");
-      break;
-    default:
-      g_string_append (str, "LISTWISE");
-      break;
-    };
-
-  g_string_append (str, ".");
-
-  text = str->str;
-
-  g_string_free (str, FALSE);
-
-  return text;
-}
-
-/* Dialog is valid iff at least one variable has been selected */
-static gboolean
-dialog_state_valid (gpointer data)
-{
-  struct examine_dialog *ex_d = data;
-
-  GtkTreeModel *vars =
-    gtk_tree_view_get_model (GTK_TREE_VIEW (ex_d->dep_list));
-
-  GtkTreeIter notused;
-
-  return gtk_tree_model_get_iter_first (vars, &notused);
-}
-
-
-static void
-run_stats_dialog (struct examine_dialog *ed)
-{
-  gint response;
-
-  gtk_toggle_button_set_active (ed->descriptives_button,
-                               ed->stats & STAT_DESCRIPTIVES);
-
-  gtk_toggle_button_set_active (ed->extremes_button,
-                               ed->stats & STAT_EXTREMES);
-
-  gtk_toggle_button_set_active (ed->percentiles_button,
-                               ed->stats & STAT_PERCENTILES);
-
-  response = psppire_dialog_run (PSPPIRE_DIALOG (ed->stats_dialog));
-
-  if ( response == PSPPIRE_RESPONSE_CONTINUE )
-    {
-      ed->stats = 0;
-      if ( gtk_toggle_button_get_active (ed->descriptives_button) )
-       ed->stats |= STAT_DESCRIPTIVES;
-
-      if ( gtk_toggle_button_get_active (ed->extremes_button) )
-       ed->stats |= STAT_EXTREMES;
-
-      if ( gtk_toggle_button_get_active (ed->percentiles_button) )
-       ed->stats |= STAT_PERCENTILES;
-    }
-}
-
-static void
-run_opts_dialog (struct examine_dialog *ed)
-{
-  gint response;
-
-
-  switch (ed->opts)
-    {
-    case OPT_LISTWISE:
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->listwise), TRUE);
-      break;
-    case OPT_PAIRWISE:
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->pairwise), TRUE);
-      break;
-    case OPT_REPORT:
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->report), TRUE);
-      break;
-    default:
-      g_assert_not_reached ();
-      break;
-    };
-
-  response = psppire_dialog_run (PSPPIRE_DIALOG (ed->opts_dialog));
-
-  if ( response == PSPPIRE_RESPONSE_CONTINUE )
-    {
-      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->listwise)))
-       ed->opts = OPT_LISTWISE;
-      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->pairwise)))
-       ed->opts = OPT_PAIRWISE;
-      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->report)))
-       ed->opts = OPT_REPORT;
-  }
-}
-
-
-
-/* Pops up the Examine dialog box */
-void
-examine_dialog (PsppireDataWindow *de)
-{
-  gint response;
-
-  struct examine_dialog ex_d;
-
-  GtkBuilder *xml = builder_new ("examine.ui");
-
-  GtkWidget *dialog = get_widget_assert   (xml, "examine-dialog");
-  GtkWidget *source = get_widget_assert   (xml, "treeview1");
-
-  GtkWidget *stats_button = get_widget_assert   (xml, "stats-button");
-  GtkWidget *opts_button = get_widget_assert   (xml, "opts-button");
-
-
-  GtkWidget *dep_selector = get_widget_assert (xml, "psppire-selector1");
-
-  PsppireVarStore *vs = NULL;
-
-  g_object_get (de->data_editor, "var-store", &vs, NULL);
-
-  ex_d.dep_list =   get_widget_assert   (xml, "treeview2");
-  ex_d.fct_list =   get_widget_assert   (xml, "treeview3");
-  ex_d.id_entry =   get_widget_assert   (xml, "entry1");
-  ex_d.stats_dialog =   get_widget_assert   (xml, "statistics-dialog");
-  ex_d.opts_dialog =   get_widget_assert   (xml, "options-dialog");
-  ex_d.listwise = get_widget_assert (xml, "radiobutton1");
-  ex_d.pairwise = get_widget_assert (xml, "radiobutton2");
-  ex_d.report   = get_widget_assert (xml, "radiobutton3");
-
-  ex_d.descriptives_button = GTK_TOGGLE_BUTTON
-    (get_widget_assert (xml, "descriptives-button"));
-
-  ex_d.extremes_button    = GTK_TOGGLE_BUTTON
-    (get_widget_assert (xml, "extremes-button"));
-
-  ex_d.percentiles_button = GTK_TOGGLE_BUTTON
-    (get_widget_assert (xml, "percentiles-button"));
-
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
-  gtk_window_set_transient_for (GTK_WINDOW (ex_d.stats_dialog), GTK_WINDOW (de));
-  gtk_window_set_transient_for (GTK_WINDOW (ex_d.opts_dialog), GTK_WINDOW (de));
-
-  g_object_get (vs, "dictionary", &ex_d.dict, NULL);
-  g_object_set (source, "model", ex_d.dict, NULL);
-
-  psppire_selector_set_allow (PSPPIRE_SELECTOR (dep_selector),
-                             numeric_only);
-
-  g_signal_connect (dialog, "refresh", G_CALLBACK (refresh),  &ex_d);
-
-  psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
-                                     dialog_state_valid, &ex_d);
-
-
-  g_signal_connect_swapped (stats_button, "clicked",
-                   G_CALLBACK (run_stats_dialog), &ex_d);
-
-  g_signal_connect_swapped (opts_button, "clicked",
-                   G_CALLBACK (run_opts_dialog), &ex_d);
-
-  response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
-
-
-  switch (response)
-    {
-    case GTK_RESPONSE_OK:
-      g_free (execute_syntax_string (de, generate_syntax (&ex_d)));
-      break;
-    case PSPPIRE_RESPONSE_PASTE:
-      g_free (paste_syntax_to_window (generate_syntax (&ex_d)));
-      break;
-    default:
-      break;
-    }
-
-  g_object_unref (xml);
-}
diff --git a/src/ui/gui/examine-dialog.h b/src/ui/gui/examine-dialog.h
deleted file mode 100644 (file)
index 15835a0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2010  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 __EXAMINE_DIALOG_H
-#define __EXAMINE_DIALOG_H
-
-#include "psppire-data-window.h"
-
-void examine_dialog (PsppireDataWindow * data);
-
-#endif
index 5e9691c5d0c5ade12598de794bc406f42b41374b..87a6bb69fca2206f9b239f801ef1c49e29afc2d3 100644 (file)
@@ -34,7 +34,6 @@
 #include "ui/gui/count-dialog.h"
 #include "ui/gui/crosstabs-dialog.h"
 #include "ui/gui/entry-dialog.h"
-#include "ui/gui/examine-dialog.h"
 #include "ui/gui/executor.h"
 #include "ui/gui/factor-dialog.h"
 #include "ui/gui/find-dialog.h"
@@ -1096,9 +1095,6 @@ psppire_data_window_finish_init (PsppireDataWindow *de,
   connect_action (de, "analyze_frequencies", G_CALLBACK (frequencies_dialog));
  
   connect_action (de, "crosstabs", G_CALLBACK (crosstabs_dialog));
-  connect_action (de, "analyze_explore", G_CALLBACK (examine_dialog));
   connect_action (de, "linear-regression", G_CALLBACK (regression_dialog));
  
   connect_action (de, "univariate", G_CALLBACK (univariate_dialog));
diff --git a/src/ui/gui/psppire-dialog-action-examine.c b/src/ui/gui/psppire-dialog-action-examine.c
new file mode 100644 (file)
index 0000000..904beec
--- /dev/null
@@ -0,0 +1,253 @@
+/* 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 <config.h>
+
+#include "psppire-dialog-action-examine.h"
+
+#include "psppire-var-view.h"
+#include "psppire-dict.h"
+#include "psppire-dialog.h"
+#include "builder-wrapper.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+static void psppire_dialog_action_examine_class_init      (PsppireDialogActionExamineClass *class);
+
+G_DEFINE_TYPE (PsppireDialogActionExamine, psppire_dialog_action_examine, PSPPIRE_TYPE_DIALOG_ACTION);
+
+
+#define     STAT_DESCRIPTIVES  0x01
+#define     STAT_EXTREMES      0x02
+#define     STAT_PERCENTILES   0x04
+
+static void
+run_stats_dialog (PsppireDialogActionExamine *ed)
+{
+  gint response;
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->descriptives_button),
+                               ed->stats & STAT_DESCRIPTIVES);
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->extremes_button),
+                               ed->stats & STAT_EXTREMES);
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->percentiles_button),
+                               ed->stats & STAT_PERCENTILES);
+
+  response = psppire_dialog_run (PSPPIRE_DIALOG (ed->stats_dialog));
+
+  if ( response == PSPPIRE_RESPONSE_CONTINUE )
+    {
+      ed->stats = 0;
+      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) ))
+       ed->stats |= STAT_EXTREMES;
+
+      if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->percentiles_button) ))
+       ed->stats |= STAT_PERCENTILES;
+    }
+}
+
+static void
+run_opts_dialog (PsppireDialogActionExamine *ed)
+{
+  gint response;
+
+  switch (ed->opts)
+    {
+    case OPT_LISTWISE:
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->listwise), TRUE);
+      break;
+    case OPT_PAIRWISE:
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->pairwise), TRUE);
+      break;
+    case OPT_REPORT:
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ed->report), TRUE);
+      break;
+    default:
+      g_assert_not_reached ();
+      break;
+    };
+
+  response = psppire_dialog_run (PSPPIRE_DIALOG (ed->opts_dialog));
+
+  if ( response == PSPPIRE_RESPONSE_CONTINUE )
+    {
+      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->listwise)))
+       ed->opts = OPT_LISTWISE;
+      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->pairwise)))
+       ed->opts = OPT_PAIRWISE;
+      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ed->report)))
+       ed->opts = OPT_REPORT;
+  }
+}
+
+
+
+
+static char *
+generate_syntax (PsppireDialogAction *act)
+{
+  PsppireDialogActionExamine *ed  = PSPPIRE_DIALOG_ACTION_EXAMINE (act);
+
+  const char *label;
+  gchar *text = NULL;
+  GString *str = g_string_new ("EXAMINE ");
+
+  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
+       (gtk_tree_view_get_model (GTK_TREE_VIEW (ed->factors)), NULL))
+    {
+      g_string_append (str, "\n\tBY ");
+      psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ed->factors), 0, str);
+    }
+
+  label = gtk_entry_get_text (GTK_ENTRY (ed->id_var));
+  if ( 0 != strcmp (label, "") )
+    {
+      g_string_append (str, "\n\t/ID = ");
+      g_string_append (str, label);
+    }
+
+  if ( ed->stats & (STAT_DESCRIPTIVES | STAT_EXTREMES))
+    {
+      g_string_append (str, "\n\t/STATISTICS =");
+
+      if ( ed->stats & STAT_DESCRIPTIVES)
+       g_string_append (str, " DESCRIPTIVES");
+
+      if ( ed->stats & STAT_EXTREMES)
+       g_string_append (str, " EXTREME");
+    }
+
+  if ( ed->stats & STAT_PERCENTILES)
+    g_string_append (str, "\n\t/PERCENTILES");
+
+
+  g_string_append (str, "\n\t/MISSING=");
+  switch (ed->opts)
+    {
+    case OPT_REPORT:
+      g_string_append (str, "REPORT");
+      break;
+    case OPT_PAIRWISE:
+      g_string_append (str, "PAIRWISE");
+      break;
+    default:
+      g_string_append (str, "LISTWISE");
+      break;
+    };
+
+  g_string_append (str, ".");
+  text = str->str;
+
+  g_string_free (str, FALSE);
+
+  return text;
+}
+
+static gboolean
+dialog_state_valid (PsppireDialogAction *da)
+{
+  PsppireDialogActionExamine *pae  = PSPPIRE_DIALOG_ACTION_EXAMINE (da);
+  GtkTreeIter notused;
+  GtkTreeModel *vars =
+    gtk_tree_view_get_model (GTK_TREE_VIEW (pae->variables));
+
+  return gtk_tree_model_get_iter_first (vars, &notused);
+}
+
+static void
+dialog_refresh (PsppireDialogAction *da)
+{
+  PsppireDialogActionExamine *dae  = PSPPIRE_DIALOG_ACTION_EXAMINE (da);
+  GtkTreeModel *liststore = NULL;
+
+  liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (dae->variables));
+  gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+  liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (dae->factors));
+  gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+  gtk_entry_set_text (GTK_ENTRY (dae->id_var), "");
+  dae->stats = 0x00;
+  dae->opts = OPT_LISTWISE;
+}
+
+static void
+psppire_dialog_action_examine_activate (GtkAction *a)
+{
+  PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
+  PsppireDialogActionExamine *act = PSPPIRE_DIALOG_ACTION_EXAMINE (a);
+
+  GtkBuilder *xml = builder_new ("examine.ui");
+
+  GtkWidget *stats_button = get_widget_assert (xml, "stats-button");
+  GtkWidget *opts_button = get_widget_assert (xml, "opts-button");
+
+  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");
+
+  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->percentiles_button  = get_widget_assert (xml, "percentiles-button");
+
+  act->opts_dialog = get_widget_assert (xml, "options-dialog");
+  act->listwise    = get_widget_assert (xml, "radiobutton1");
+  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_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);
+}
+
+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)->generate_syntax = generate_syntax;
+}
+
+static void
+psppire_dialog_action_examine_init (PsppireDialogActionExamine *act)
+{
+}
diff --git a/src/ui/gui/psppire-dialog-action-examine.h b/src/ui/gui/psppire-dialog-action-examine.h
new file mode 100644 (file)
index 0000000..0780064
--- /dev/null
@@ -0,0 +1,98 @@
+/* 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/>. */
+
+
+#ifndef __PSPPIRE_DIALOG_ACTION_EXAMINE_H__
+#define __PSPPIRE_DIALOG_ACTION_EXAMINE_H__
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-dialog-action.h"
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE (psppire_dialog_action_examine_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION_EXAMINE(obj)     \
+                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                                                 PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, PsppireDialogActionExamine))
+
+#define PSPPIRE_DIALOG_ACTION_EXAMINE_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_CAST ((klass), \
+                                PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, \
+                                 PsppireDialogActionExamineClass))
+
+
+#define PSPPIRE_IS_DIALOG_ACTION_EXAMINE(obj) \
+                    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE))
+
+#define PSPPIRE_IS_DIALOG_ACTION_EXAMINE_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE))
+
+
+#define PSPPIRE_DIALOG_ACTION_EXAMINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                                  PSPPIRE_TYPE_DIALOG_ACTION_EXAMINE, \
+                                  PsppireDialogActionExamineClass))
+
+typedef struct _PsppireDialogActionExamine       PsppireDialogActionExamine;
+typedef struct _PsppireDialogActionExamineClass  PsppireDialogActionExamineClass;
+
+
+enum PsppireDialogActionExamineOpts
+  {
+    OPT_LISTWISE,
+    OPT_PAIRWISE,
+    OPT_REPORT
+  };
+
+struct _PsppireDialogActionExamine
+{
+  PsppireDialogAction parent;
+
+  /*< private >*/
+  GtkWidget *variables;
+  GtkWidget *factors;
+  GtkWidget *id_var;
+
+  /* The stats dialog */
+  GtkWidget *stats_dialog;
+  GtkWidget *descriptives_button;
+  GtkWidget *extremes_button;
+  GtkWidget *percentiles_button;
+  guint stats;
+
+  /* The options dialog */
+  GtkWidget *opts_dialog;
+  GtkWidget *listwise;
+  GtkWidget *pairwise;
+  GtkWidget *report;
+  enum PsppireDialogActionExamineOpts opts;
+};
+
+
+struct _PsppireDialogActionExamineClass
+{
+  PsppireDialogActionClass parent_class;
+};
+
+
+GType psppire_dialog_action_examine_get_type (void) ;
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_EXAMINE_H__ */
index d131b6469f7c8abad637b2eb13b9d5155e955394..ed8328a5a57bd337600a8ab5ef85d060f8fa4fc2 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "psppire-dialog-action-correlation.h"
 #include "psppire-dialog-action-descriptives.h"
+#include "psppire-dialog-action-examine.h"
 #include "psppire-dialog-action-kmeans.h"
 #include "psppire-dialog-action-means.h"
 #include "psppire-means-layer.h"
@@ -42,6 +43,7 @@ preregister_widgets (void)
 
   psppire_dialog_action_correlation_get_type ();
   psppire_dialog_action_descriptives_get_type ();
+  psppire_dialog_action_examine_get_type ();
   psppire_dialog_action_kmeans_get_type ();
   psppire_dialog_action_means_get_type ();
   psppire_means_layer_get_type ();