New abstract class PsppireDialogAction
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 25 Jan 2012 20:02:18 +0000 (21:02 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 25 Jan 2012 20:02:18 +0000 (21:02 +0100)
Added a new object PsppireDialogAction which abstracts the behaviour of
dialog boxes.

Converted the Descriptived Dialog and the Variable Info Dialog to use this
new abstraction.

Reviewed-by: Ben Pfaff
15 files changed:
src/ui/gui/automake.mk
src/ui/gui/data-editor.ui
src/ui/gui/descriptives-dialog.c [deleted file]
src/ui/gui/descriptives-dialog.h [deleted file]
src/ui/gui/psppire-data-window.c
src/ui/gui/psppire-dialog-action-descriptives.c [new file with mode: 0644]
src/ui/gui/psppire-dialog-action-descriptives.h [new file with mode: 0644]
src/ui/gui/psppire-dialog-action-var-info.c [new file with mode: 0644]
src/ui/gui/psppire-dialog-action-var-info.h [new file with mode: 0644]
src/ui/gui/psppire-dialog-action.c [new file with mode: 0644]
src/ui/gui/psppire-dialog-action.h [new file with mode: 0644]
src/ui/gui/psppire-dialog.c
src/ui/gui/variable-info-dialog.c [deleted file]
src/ui/gui/variable-info-dialog.h [deleted file]
src/ui/gui/widgets.c

index d64d6df8464247762e9ff40544ecc6f87c019280..477010e7fa80838bb86ac71673f81c7a05c3a2e3 100644 (file)
@@ -162,8 +162,6 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/crosstabs-dialog.h \
        src/ui/gui/customentry.c \
        src/ui/gui/customentry.h \
-       src/ui/gui/descriptives-dialog.c \
-       src/ui/gui/descriptives-dialog.h \
        src/ui/gui/dialog-common.c \
        src/ui/gui/dialog-common.h \
        src/ui/gui/dict-display.h \
@@ -212,6 +210,12 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/psppire-data-window.c \
        src/ui/gui/psppire-data-window.h \
        src/ui/gui/psppire-dialog.h \
+       src/ui/gui/psppire-dialog-action.c \
+       src/ui/gui/psppire-dialog-action.h \
+       src/ui/gui/psppire-dialog-action-descriptives.c \
+       src/ui/gui/psppire-dialog-action-descriptives.h \
+       src/ui/gui/psppire-dialog-action-var-info.c \
+       src/ui/gui/psppire-dialog-action-var-info.h \
        src/ui/gui/psppire-dict.c \
        src/ui/gui/psppire-dict.h \
        src/ui/gui/psppire-dictview.c \
@@ -282,8 +286,6 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/val-labs-dialog.h \
        src/ui/gui/var-display.c \
        src/ui/gui/var-display.h \
-       src/ui/gui/variable-info-dialog.c \
-       src/ui/gui/variable-info-dialog.h \
        src/ui/gui/var-type-dialog.c \
        src/ui/gui/var-type-dialog.h \
        src/ui/gui/weight-cases-dialog.c \
index fcfc8c20d969fbc3dc88388521cae1087cb8e1af..d190a44cf8cbd1a30a7be0b28cd89e112946b622 100644 (file)
           </object>
         </child>
         <child>
-          <object class="GtkAction" id="analyze_descriptives">
+          <object class="PsppireDialogActionDescriptives" id="analyze_descriptives">
+            <property name="manager">uimanager1</property>
             <property name="name">analyze_descriptives</property>
             <property name="label" translatable="yes">_Descriptives...</property>
           </object>
           </object>
         </child>
         <child>
-          <object class="GtkAction" id="utilities_variables">
+          <object class="PsppireDialogActionVarInfo" id="utilities_variables">
+            <property name="manager">uimanager1</property>
             <property name="name">utilities_variables</property>
             <property name="label" translatable="yes">_Variables...</property>
            <property name="tooltip" translatable="yes">Jump to variable</property>
diff --git a/src/ui/gui/descriptives-dialog.c b/src/ui/gui/descriptives-dialog.c
deleted file mode 100644 (file)
index 670f14b..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 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 "descriptives-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
-
-#define DESCRIPTIVE_STATS                       \
-  DS (MEAN, N_("Mean"))                         \
-  DS (STDDEV, N_("Standard deviation"))         \
-  DS (MINIMUM, N_("Minimum"))                   \
-  DS (MAXIMUM, N_("Maximum"))                   \
-  DS (RANGE, N_("Range"))                       \
-  DS (SUM, N_("Sum"))                           \
-  DS (SEMEAN, N_("Standard error"))             \
-  DS (VARIANCE, N_("Variance"))                 \
-  DS (KURTOSIS, N_("Kurtosis"))                 \
-  DS (SKEWNESS, N_("Skewness"))
-
-enum
-  {
-#define DS(NAME, LABEL) DS_##NAME,
-    DESCRIPTIVE_STATS
-#undef DS
-    N_DESCRIPTIVE_STATS
-  };
-
-enum
-  {
-#define DS(NAME, LABEL) B_DS_##NAME = 1u << DS_##NAME,
-    DESCRIPTIVE_STATS
-#undef DS
-    B_DS_ALL = (1u << N_DESCRIPTIVE_STATS) - 1,
-    B_DS_DEFAULT = B_DS_MEAN | B_DS_STDDEV | B_DS_MINIMUM | B_DS_MAXIMUM
-  };
-
-
-static const struct checkbox_entry_item stats[] =
-  {
-#define DS(NAME, LABEL) {#NAME, LABEL},
-    DESCRIPTIVE_STATS
-#undef DS
-  };
-
-struct descriptives_dialog
-{
-  GtkTreeView *stat_vars;
-  GtkTreeModel *stats;
-  PsppireDict *dict;
-  GtkToggleButton *exclude_missing_listwise;
-  GtkToggleButton *include_user_missing;
-  GtkToggleButton *save_z_scores;
-};
-
-static void
-refresh (PsppireDialog *dialog, struct descriptives_dialog *scd)
-{
-  GtkTreeModel *liststore;
-  GtkTreeIter iter;
-  size_t i;
-  bool ok;
-
-  liststore = gtk_tree_view_get_model (scd->stat_vars);
-  gtk_list_store_clear (GTK_LIST_STORE (liststore));
-
-  for (i = 0, ok = gtk_tree_model_get_iter_first (scd->stats, &iter); ok;
-       i++, ok = gtk_tree_model_iter_next (scd->stats, &iter))
-    gtk_list_store_set (GTK_LIST_STORE (scd->stats), &iter,
-                       CHECKBOX_COLUMN_SELECTED,
-                        (B_DS_DEFAULT & (1u << i)) ? true : false, -1);
-
-  gtk_toggle_button_set_active (scd->exclude_missing_listwise, false);
-  gtk_toggle_button_set_active (scd->include_user_missing, false);
-  gtk_toggle_button_set_active (scd->save_z_scores, false);
-}
-
-static char *
-generate_syntax (const struct descriptives_dialog *scd)
-{
-  gchar *text;
-  GString *string;
-  GtkTreeIter iter;
-  unsigned int selected;
-  size_t i;
-  bool listwise, include;
-  bool ok;
-
-  string = g_string_new ("DESCRIPTIVES");
-  g_string_append (string, "\n    /VARIABLES=");
-  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (scd->stat_vars), 0, string);
-
-  listwise = gtk_toggle_button_get_active (scd->exclude_missing_listwise);
-  include = gtk_toggle_button_get_active (scd->include_user_missing);
-  if (listwise || include)
-    {
-      g_string_append (string, "\n    /MISSING=");
-      if (listwise)
-        {
-          g_string_append (string, "LISTWISE");
-          if (include)
-            g_string_append (string, " ");
-        }
-      if (include)
-        g_string_append (string, "INCLUDE");
-    }
-
-  selected = 0;
-  for (i = 0, ok = gtk_tree_model_get_iter_first (scd->stats, &iter); ok;
-       i++, ok = gtk_tree_model_iter_next (scd->stats, &iter))
-    {
-      gboolean toggled;
-      gtk_tree_model_get (scd->stats, &iter,
-                         CHECKBOX_COLUMN_SELECTED, &toggled, -1);
-      if (toggled)
-        selected |= 1u << i;
-    }
-
-  if (selected != B_DS_DEFAULT)
-    {
-      g_string_append (string, "\n    /STATISTICS=");
-      if (selected == B_DS_ALL)
-        g_string_append (string, "ALL");
-      else if (selected == 0)
-        g_string_append (string, "NONE");
-      else
-        {
-          int n = 0;
-          if ((selected & B_DS_DEFAULT) == B_DS_DEFAULT)
-            {
-              g_string_append (string, "DEFAULT");
-              selected &= ~B_DS_DEFAULT;
-              n++;
-            }
-          for (i = 0; i < N_DESCRIPTIVE_STATS; i++)
-            if (selected & (1u << i))
-              {
-                if (n++)
-                  g_string_append (string, " ");
-                g_string_append (string, stats[i].name);
-              }
-        }
-    }
-
-  if (gtk_toggle_button_get_active (scd->save_z_scores))
-    g_string_append (string, "\n    /SAVE");
-
-  g_string_append (string, ".");
-
-  if (gtk_toggle_button_get_active (scd->save_z_scores))
-    g_string_append (string, "\nEXECUTE.");
-
-  text = string->str;
-
-  g_string_free (string, FALSE);
-
-  return text;
-}
-
-
-/* Dialog is valid iff at least one variable has been selected */
-static gboolean
-dialog_state_valid (gpointer data)
-{
-  struct descriptives_dialog *dd = data;
-
-  GtkTreeModel *vars = gtk_tree_view_get_model (dd->stat_vars);
-
-  GtkTreeIter notused;
-
-  return gtk_tree_model_get_iter_first (vars, &notused);
-}
-
-/* Pops up the Descriptives dialog box */
-void
-descriptives_dialog (PsppireDataWindow *de)
-{
-  gint response;
-
-  struct descriptives_dialog scd;
-
-  GtkBuilder *xml = builder_new ("descriptives.ui");
-
-  GtkWidget *dialog = get_widget_assert   (xml, "descriptives-dialog");
-
-
-  GtkWidget *source = get_widget_assert   (xml, "all-variables");
-  GtkWidget *dest =   get_widget_assert   (xml, "stat-variables");
-
-  GtkWidget *stats_treeview = get_widget_assert    (xml, "statistics");
-
-  PsppireVarStore *vs = NULL;
-  PsppireDict *dict;
-
-  g_object_get (de->data_editor, "var-store", &vs, NULL);
-  g_object_get (vs, "dictionary", &dict, NULL);
-
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
-
-
-  g_object_set (source, "model", dict,
-       "predicate", var_is_numeric, NULL);
-
-  put_checkbox_items_in_treeview (GTK_TREE_VIEW (stats_treeview),
-                                 B_DS_DEFAULT,
-                                 N_DESCRIPTIVE_STATS, stats);
-
-  scd.stat_vars = GTK_TREE_VIEW (dest);
-  scd.stats = gtk_tree_view_get_model (GTK_TREE_VIEW (stats_treeview));
-  
-  g_object_get (vs, "dictionary", &scd.dict, NULL);
-  
-  scd.include_user_missing =
-    GTK_TOGGLE_BUTTON (get_widget_assert (xml, "include_user_missing"));
-  scd.exclude_missing_listwise =
-    GTK_TOGGLE_BUTTON (get_widget_assert (xml, "exclude_missing_listwise"));
-  scd.save_z_scores =
-    GTK_TOGGLE_BUTTON (get_widget_assert (xml, "save_z_scores"));
-
-  g_signal_connect (dialog, "refresh", G_CALLBACK (refresh),  &scd);
-
-  psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
-                                     dialog_state_valid, &scd);
-
-  response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
-
-
-  switch (response)
-    {
-    case GTK_RESPONSE_OK:
-      g_free (execute_syntax_string (de, generate_syntax (&scd)));
-      break;
-    case PSPPIRE_RESPONSE_PASTE:
-      g_free (paste_syntax_to_window (generate_syntax (&scd)));
-      break;
-    default:
-      break;
-    }
-
-  g_object_unref (xml);
-}
diff --git a/src/ui/gui/descriptives-dialog.h b/src/ui/gui/descriptives-dialog.h
deleted file mode 100644 (file)
index 1819576..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 __DESCRIPTIVES_DIALOG_H
-#define __DESCRIPTIVES_DIALOG_H
-
-#include "psppire-data-window.h"
-
-void descriptives_dialog (PsppireDataWindow * data);
-
-#endif
index b2607a0ca2dff3ded02cb242f3648d4bab1df2c1..7d58540425a586ecb77fd1380a22e6c129358fe5 100644 (file)
@@ -34,7 +34,6 @@
 #include "ui/gui/correlation-dialog.h"
 #include "ui/gui/count-dialog.h"
 #include "ui/gui/crosstabs-dialog.h"
-#include "ui/gui/descriptives-dialog.h"
 #include "ui/gui/entry-dialog.h"
 #include "ui/gui/examine-dialog.h"
 #include "ui/gui/executor.h"
@@ -69,7 +68,6 @@
 #include "ui/gui/text-data-import-dialog.h"
 #include "ui/gui/transpose-dialog.h"
 #include "ui/gui/univariate-dialog.h"
-#include "ui/gui/variable-info-dialog.h"
 #include "ui/gui/weight-cases-dialog.h"
 #include "ui/syntax-gen.h"
 
@@ -1084,9 +1082,6 @@ psppire_data_window_finish_init (PsppireDataWindow *de,
 
   connect_action (de, "data_weight-cases", G_CALLBACK (weight_cases_dialog));
 
-
-  connect_action (de, "utilities_variables", G_CALLBACK (variable_info_dialog));
   connect_action (de, "oneway-anova", G_CALLBACK (oneway_anova_dialog));
 
   connect_action (de, "indep-t-test", G_CALLBACK (t_test_independent_samples_dialog));
@@ -1105,8 +1100,6 @@ psppire_data_window_finish_init (PsppireDataWindow *de,
  
   connect_action (de, "transform_recode-different", G_CALLBACK (recode_different_dialog));
 
-  connect_action (de, "analyze_descriptives", G_CALLBACK (descriptives_dialog));
   connect_action (de, "analyze_frequencies", G_CALLBACK (frequencies_dialog));
  
   connect_action (de, "crosstabs", G_CALLBACK (crosstabs_dialog));
diff --git a/src/ui/gui/psppire-dialog-action-descriptives.c b/src/ui/gui/psppire-dialog-action-descriptives.c
new file mode 100644 (file)
index 0000000..170604c
--- /dev/null
@@ -0,0 +1,241 @@
+/* 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-descriptives.h"
+
+#include "checkbox-treeview.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_descriptives_class_init      (PsppireDialogActionDescriptivesClass *class);
+
+G_DEFINE_TYPE (PsppireDialogActionDescriptives, psppire_dialog_action_descriptives, PSPPIRE_TYPE_DIALOG_ACTION);
+
+
+#define DESCRIPTIVE_STATS                       \
+  DS (MEAN, N_("Mean"))                         \
+  DS (STDDEV, N_("Standard deviation"))         \
+  DS (MINIMUM, N_("Minimum"))                   \
+  DS (MAXIMUM, N_("Maximum"))                   \
+  DS (RANGE, N_("Range"))                       \
+  DS (SUM, N_("Sum"))                           \
+  DS (SEMEAN, N_("Standard error"))             \
+  DS (VARIANCE, N_("Variance"))                 \
+  DS (KURTOSIS, N_("Kurtosis"))                 \
+  DS (SKEWNESS, N_("Skewness"))
+
+enum
+  {
+#define DS(NAME, LABEL) DS_##NAME,
+    DESCRIPTIVE_STATS
+#undef DS
+    N_DESCRIPTIVE_STATS
+  };
+
+enum
+  {
+#define DS(NAME, LABEL) B_DS_##NAME = 1u << DS_##NAME,
+    DESCRIPTIVE_STATS
+#undef DS
+    B_DS_ALL = (1u << N_DESCRIPTIVE_STATS) - 1,
+    B_DS_DEFAULT = B_DS_MEAN | B_DS_STDDEV | B_DS_MINIMUM | B_DS_MAXIMUM
+  };
+
+
+static const struct checkbox_entry_item stats[] =
+  {
+#define DS(NAME, LABEL) {#NAME, LABEL},
+    DESCRIPTIVE_STATS
+#undef DS
+  };
+
+
+static char *
+generate_syntax (PsppireDialogAction *act)
+{
+  PsppireDialogActionDescriptives *scd = PSPPIRE_DIALOG_ACTION_DESCRIPTIVES (act);
+  gchar *text;
+  GString *string;
+  GtkTreeIter iter;
+  unsigned int selected;
+  size_t i;
+  bool listwise, include;
+  bool ok;
+
+  string = g_string_new ("DESCRIPTIVES");
+  g_string_append (string, "\n    /VARIABLES=");
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (scd->stat_vars), 0, string);
+
+  listwise = gtk_toggle_button_get_active (scd->exclude_missing_listwise);
+  include = gtk_toggle_button_get_active (scd->include_user_missing);
+  if (listwise || include)
+    {
+      g_string_append (string, "\n    /MISSING=");
+      if (listwise)
+        {
+          g_string_append (string, "LISTWISE");
+          if (include)
+            g_string_append (string, " ");
+        }
+      if (include)
+        g_string_append (string, "INCLUDE");
+    }
+
+  selected = 0;
+  for (i = 0, ok = gtk_tree_model_get_iter_first (scd->stats, &iter); ok;
+       i++, ok = gtk_tree_model_iter_next (scd->stats, &iter))
+    {
+      gboolean toggled;
+      gtk_tree_model_get (scd->stats, &iter,
+                         CHECKBOX_COLUMN_SELECTED, &toggled, -1);
+      if (toggled)
+        selected |= 1u << i;
+    }
+
+  if (selected != B_DS_DEFAULT)
+    {
+      g_string_append (string, "\n    /STATISTICS=");
+      if (selected == B_DS_ALL)
+        g_string_append (string, "ALL");
+      else if (selected == 0)
+        g_string_append (string, "NONE");
+      else
+        {
+          int n = 0;
+          if ((selected & B_DS_DEFAULT) == B_DS_DEFAULT)
+            {
+              g_string_append (string, "DEFAULT");
+              selected &= ~B_DS_DEFAULT;
+              n++;
+            }
+          for (i = 0; i < N_DESCRIPTIVE_STATS; i++)
+            if (selected & (1u << i))
+              {
+                if (n++)
+                  g_string_append (string, " ");
+                g_string_append (string, stats[i].name);
+              }
+        }
+    }
+
+  if (gtk_toggle_button_get_active (scd->save_z_scores))
+    g_string_append (string, "\n    /SAVE");
+
+  g_string_append (string, ".");
+
+  if (gtk_toggle_button_get_active (scd->save_z_scores))
+    g_string_append (string, "\nEXECUTE.");
+
+  text = string->str;
+
+  g_string_free (string, FALSE);
+
+  return text;
+}
+
+static gboolean
+dialog_state_valid (gpointer data)
+{
+  PsppireDialogActionDescriptives *dd = data;
+
+  GtkTreeModel *vars = gtk_tree_view_get_model (dd->stat_vars);
+
+  GtkTreeIter notused;
+
+  return gtk_tree_model_get_iter_first (vars, &notused);
+}
+
+static void
+dialog_refresh (PsppireDialogActionDescriptives *scd)
+{
+  GtkTreeModel *liststore;
+  GtkTreeIter iter;
+  size_t i;
+  bool ok;
+
+  liststore = gtk_tree_view_get_model (scd->stat_vars);
+  gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+  for (i = 0, ok = gtk_tree_model_get_iter_first (scd->stats, &iter); ok;
+       i++, ok = gtk_tree_model_iter_next (scd->stats, &iter))
+    gtk_list_store_set (GTK_LIST_STORE (scd->stats), &iter,
+                       CHECKBOX_COLUMN_SELECTED,
+                        (B_DS_DEFAULT & (1u << i)) ? true : false, -1);
+
+  gtk_toggle_button_set_active (scd->exclude_missing_listwise, false);
+  gtk_toggle_button_set_active (scd->include_user_missing, false);
+  gtk_toggle_button_set_active (scd->save_z_scores, false);
+}
+
+static void
+psppire_dialog_action_descriptives_activate (GtkAction *a)
+{
+  PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
+  PsppireDialogActionDescriptives *act = PSPPIRE_DIALOG_ACTION_DESCRIPTIVES (a);
+
+  GtkBuilder *xml = builder_new ("descriptives.ui");
+
+  GtkWidget *stats_treeview = get_widget_assert    (xml, "statistics");
+
+  pda->dialog = get_widget_assert   (xml, "descriptives-dialog");
+  pda->source = get_widget_assert   (xml, "all-variables");
+  act->variables =   get_widget_assert   (xml, "stat-variables");
+
+  g_object_set (pda->source, "model", pda->dict,
+       "predicate", var_is_numeric, NULL);
+
+  put_checkbox_items_in_treeview (GTK_TREE_VIEW (stats_treeview),
+                                 B_DS_DEFAULT,
+                                 N_DESCRIPTIVE_STATS, stats);
+
+  act->stat_vars = GTK_TREE_VIEW (act->variables);
+  act->stats = gtk_tree_view_get_model (GTK_TREE_VIEW (stats_treeview));
+  
+  act->include_user_missing =
+    GTK_TOGGLE_BUTTON (get_widget_assert (xml, "include_user_missing"));
+  act->exclude_missing_listwise =
+    GTK_TOGGLE_BUTTON (get_widget_assert (xml, "exclude_missing_listwise"));
+  act->save_z_scores =
+    GTK_TOGGLE_BUTTON (get_widget_assert (xml, "save_z_scores"));
+
+  psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
+  psppire_dialog_action_set_refresh (pda, dialog_refresh);
+
+  PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_descriptives_parent_class)->activate (pda);
+}
+
+static void
+psppire_dialog_action_descriptives_class_init (PsppireDialogActionDescriptivesClass *class)
+{
+  GTK_ACTION_CLASS (class)->activate = psppire_dialog_action_descriptives_activate;
+
+  PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
+}
+
+static void
+psppire_dialog_action_descriptives_init (PsppireDialogActionDescriptives *act)
+{
+}
diff --git a/src/ui/gui/psppire-dialog-action-descriptives.h b/src/ui/gui/psppire-dialog-action-descriptives.h
new file mode 100644 (file)
index 0000000..f39aedb
--- /dev/null
@@ -0,0 +1,83 @@
+/* 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_DESCRIPTIVES_H__
+#define __PSPPIRE_DIALOG_ACTION_DESCRIPTIVES_H__
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-dialog-action.h"
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES (psppire_dialog_action_descriptives_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION_DESCRIPTIVES(obj)        \
+                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                                                 PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, PsppireDialogActionDescriptives))
+
+#define PSPPIRE_DIALOG_ACTION_DESCRIPTIVES_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_CAST ((klass), \
+                                PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, \
+                                 PsppireDialogActionDescriptivesClass))
+
+
+#define PSPPIRE_IS_DIALOG_ACTION_DESCRIPTIVES(obj) \
+                    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES))
+
+#define PSPPIRE_IS_DIALOG_ACTION_DESCRIPTIVES_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES))
+
+
+#define PSPPIRE_DIALOG_ACTION_DESCRIPTIVES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                                  PSPPIRE_TYPE_DIALOG_ACTION_DESCRIPTIVES, \
+                                  PsppireDialogActionDescriptivesClass))
+
+typedef struct _PsppireDialogActionDescriptives       PsppireDialogActionDescriptives;
+typedef struct _PsppireDialogActionDescriptivesClass  PsppireDialogActionDescriptivesClass;
+
+
+struct _PsppireDialogActionDescriptives
+{
+  PsppireDialogAction parent;
+
+  /*< private >*/
+  gboolean dispose_has_run ;
+
+  GtkWidget *variables;
+  GtkTreeView *stat_vars;
+  GtkTreeModel *stats;
+
+  GtkToggleButton *exclude_missing_listwise;
+  GtkToggleButton *include_user_missing;
+  GtkToggleButton *save_z_scores;
+};
+
+
+struct _PsppireDialogActionDescriptivesClass
+{
+  PsppireDialogActionClass parent_class;
+};
+
+
+GType psppire_dialog_action_descriptives_get_type (void) ;
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_DESCRIPTIVES_H__ */
diff --git a/src/ui/gui/psppire-dialog-action-var-info.c b/src/ui/gui/psppire-dialog-action-var-info.c
new file mode 100644 (file)
index 0000000..226fc58
--- /dev/null
@@ -0,0 +1,231 @@
+/* PSPPIRE - a graphical user interface for PSPP.
+   Copyright (C) 2007, 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 "psppire-dialog-action-var-info.h"
+
+#include <data/variable.h>
+#include <data/format.h>
+#include <data/value-labels.h>
+#include <libpspp/i18n.h>
+
+#include "var-display.h"
+#include "helper.h"
+#include "psppire-var-view.h"
+#include "psppire-dictview.h"
+
+#include "psppire-dialog.h"
+#include "builder-wrapper.h"
+#include "psppire-data-window.h"
+
+static void psppire_dialog_action_var_info_init            (PsppireDialogActionVarInfo      *act);
+static void psppire_dialog_action_var_info_class_init      (PsppireDialogActionVarInfoClass *class);
+
+G_DEFINE_TYPE (PsppireDialogActionVarInfo, psppire_dialog_action_var_info, PSPPIRE_TYPE_DIALOG_ACTION);
+
+#include <gettext.h>
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+
+static const gchar none[] = N_("None");
+
+
+static const gchar *
+label_to_string (const struct variable *var)
+{
+  const char *label = var_get_label (var);
+
+  if (NULL == label) return g_strdup (none);
+
+  return label;
+}
+
+
+static gboolean
+treeview_item_selected (gpointer data)
+{
+  PsppireDialogAction *pda = data;
+  GtkTreeView *tv = GTK_TREE_VIEW (pda->source);
+  GtkTreeModel *model = gtk_tree_view_get_model (tv);
+
+  gint n_rows = gtk_tree_model_iter_n_children  (model, NULL);
+
+  if ( n_rows == 0 )
+    return FALSE;
+
+  return TRUE;
+}
+
+static gchar *
+generate_syntax (PsppireDialogAction *act)
+
+{
+  const struct variable *var =
+    psppire_dict_view_get_selected_variable (PSPPIRE_DICT_VIEW (act->source));
+
+  if ( NULL == var)
+    return g_strdup ("");
+
+  return g_strdup (var_get_name (var));
+}
+
+
+
+static void
+populate_text (PsppireDictView *treeview, gpointer data)
+{
+  gchar *text = NULL;
+  GString *gstring;
+  PsppireDict *dict;
+
+  GtkTextBuffer *textbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (data));
+  const struct variable *var =
+    psppire_dict_view_get_selected_variable (treeview);
+
+  if ( var == NULL)
+    return;
+
+  g_object_get (treeview, "model", &dict,
+               NULL);
+
+  gstring = g_string_sized_new (200);
+  g_string_assign (gstring, var_get_name (var));
+  g_string_append (gstring, "\n");
+
+
+  g_string_append_printf (gstring, _("Label: %s\n"), label_to_string (var));
+  {
+    const struct fmt_spec *fmt = var_get_print_format (var);
+    char buffer[FMT_STRING_LEN_MAX + 1];
+
+    fmt_to_string (fmt, buffer);
+    /* No conversion necessary.  buffer will always be ascii */
+    g_string_append_printf (gstring, _("Type: %s\n"), buffer);
+  }
+
+  text = missing_values_to_string (dict, var, NULL);
+  g_string_append_printf (gstring, _("Missing Values: %s\n"),
+                         text);
+  g_free (text);
+
+  g_string_append_printf (gstring, _("Measurement Level: %s\n"),
+                         measure_to_string (var_get_measure (var)));
+
+
+  /* Value Labels */
+  if ( var_has_value_labels (var))
+    {
+      const struct val_labs *vls = var_get_value_labels (var);
+      const struct val_lab **labels;
+      size_t n_labels;
+      size_t i;
+
+      g_string_append (gstring, "\n");
+      g_string_append (gstring, _("Value Labels:\n"));
+
+      labels = val_labs_sorted (vls);
+      n_labels = val_labs_count (vls);
+      for (i = 0; i < n_labels; i++)
+        {
+          const struct val_lab *vl = labels[i];
+         gchar *const vstr  = value_to_text (vl->value,  var);
+
+         g_string_append_printf (gstring, _("%s %s\n"),
+                                  vstr, val_lab_get_escaped_label (vl));
+
+         g_free (vstr);
+       }
+      free (labels);
+    }
+
+  gtk_text_buffer_set_text (textbuffer, gstring->str, gstring->len);
+
+  g_string_free (gstring, TRUE);
+}
+
+
+static void
+jump_to (PsppireDialog *d, gint response, gpointer data)
+{
+  PsppireDataWindow *dw;
+  PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (data);
+  const struct variable *var;
+
+  if (response !=  PSPPIRE_RESPONSE_GOTO)
+    return;
+
+  var = psppire_dict_view_get_selected_variable (PSPPIRE_DICT_VIEW (pda->source));
+
+  if ( NULL == var)
+    return;
+
+  g_object_get (pda, "top-level", &dw, NULL);
+
+  g_object_set (dw->data_editor,
+               "current-variable", var_get_dict_index (var),
+               NULL);
+}
+
+static void
+psppire_dialog_action_var_info_activate (GtkAction *a)
+{
+  PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
+
+  GtkBuilder *xml = builder_new ("variable-info.ui");
+  GtkWidget *textview = get_widget_assert (xml, "textview1");  
+
+  pda->dialog = get_widget_assert (xml, "variable-info-dialog");
+  pda->source = get_widget_assert (xml, "treeview2");
+
+  g_object_set (pda->source,
+               "selection-mode", GTK_SELECTION_SINGLE,
+               NULL);
+
+  g_signal_connect (pda->source, "cursor-changed", G_CALLBACK (populate_text),
+                   textview);
+
+
+  g_signal_connect (pda->dialog, "response", G_CALLBACK (jump_to),
+                   pda);
+
+  psppire_dialog_action_set_valid_predicate (pda,
+                                            treeview_item_selected);
+
+  g_object_unref (xml);
+
+  if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_var_info_parent_class)->activate)
+    PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_var_info_parent_class)->activate (pda);
+}
+
+static void
+psppire_dialog_action_var_info_class_init (PsppireDialogActionVarInfoClass *class)
+{
+  GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+  action_class->activate = psppire_dialog_action_var_info_activate;
+  PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
+}
+
+
+static void
+psppire_dialog_action_var_info_init (PsppireDialogActionVarInfo *act)
+{
+}
+
diff --git a/src/ui/gui/psppire-dialog-action-var-info.h b/src/ui/gui/psppire-dialog-action-var-info.h
new file mode 100644 (file)
index 0000000..90c8007
--- /dev/null
@@ -0,0 +1,78 @@
+/* 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_VAR_INFO_H__
+#define __PSPPIRE_DIALOG_ACTION_VAR_INFO_H__
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO (psppire_dialog_action_var_info_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION_VAR_INFO(obj)    \
+                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                                                 PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, PsppireDialogActionVarInfo))
+
+#define PSPPIRE_DIALOG_ACTION_VAR_INFO_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_CAST ((klass), \
+                                PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, \
+                                 PsppireDialogActionVarInfoClass))
+
+
+#define PSPPIRE_IS_DIALOG_ACTION_VAR_INFO(obj) \
+                    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO))
+
+#define PSPPIRE_IS_DIALOG_ACTION_VAR_INFO_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO))
+
+
+#define PSPPIRE_DIALOG_ACTION_VAR_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                                  PSPPIRE_TYPE_DIALOG_ACTION_VAR_INFO, \
+                                  PsppireDialogActionVarInfoClass))
+
+typedef struct _PsppireDialogActionVarInfo       PsppireDialogActionVarInfo;
+typedef struct _PsppireDialogActionVarInfoClass  PsppireDialogActionVarInfoClass;
+
+
+struct _PsppireDialogActionVarInfo
+{
+  PsppireDialogAction parent;
+
+  /*< private >*/
+  gboolean dispose_has_run ;
+
+  /* Treeview containing the selected variables */
+  GtkWidget *variables;
+};
+
+
+struct _PsppireDialogActionVarInfoClass
+{
+  PsppireDialogActionClass parent_class;
+};
+
+
+GType psppire_dialog_action_var_info_get_type (void) ;
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_VAR_INFO_H__ */
diff --git a/src/ui/gui/psppire-dialog-action.c b/src/ui/gui/psppire-dialog-action.c
new file mode 100644 (file)
index 0000000..e3ee25b
--- /dev/null
@@ -0,0 +1,188 @@
+/* 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.h"
+#include "psppire-dialog.h"
+#include "executor.h"
+#include "helper.h"
+#include "psppire-data-window.h"
+
+static void psppire_dialog_action_init            (PsppireDialogAction      *act);
+static void psppire_dialog_action_class_init      (PsppireDialogActionClass *class);
+
+G_DEFINE_ABSTRACT_TYPE (PsppireDialogAction, psppire_dialog_action, GTK_TYPE_ACTION);
+
+/* Properties */
+enum
+{
+  PROP_0,
+  PROP_MANAGER,
+  PROP_TOPLEVEL,
+};
+
+static void
+psppire_dialog_action_set_property (GObject         *object,
+                              guint            prop_id,
+                              const GValue    *value,
+                              GParamSpec      *pspec)
+{
+  PsppireDialogAction *act = PSPPIRE_DIALOG_ACTION (object);
+
+  switch (prop_id)
+    {
+    case PROP_MANAGER:
+      {
+
+       GObject *p = g_value_get_object (value);
+       act->uim = GTK_UI_MANAGER (p);
+      }
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    };
+}
+
+
+static void
+psppire_dialog_action_get_property (GObject    *object,
+                              guint            prop_id,
+                              GValue          *value,
+                              GParamSpec      *pspec)
+{
+  PsppireDialogAction *dialog_action = PSPPIRE_DIALOG_ACTION (object);
+
+  switch (prop_id)
+    {
+    case PROP_MANAGER:
+      g_value_take_object (value, dialog_action->uim);
+      break;
+  case PROP_TOPLEVEL:
+      g_value_take_object (value, dialog_action->toplevel);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    };
+}
+
+
+static void
+psppire_dialog_action_activate (PsppireDialogAction *act)
+{
+  gint response;
+
+  PsppireVarStore *vs;
+  PsppireDialogActionClass *class = PSPPIRE_DIALOG_ACTION_GET_CLASS (act);
+
+  GSList *sl = gtk_ui_manager_get_toplevels (act->uim, GTK_UI_MANAGER_MENUBAR | GTK_UI_MANAGER_TOOLBAR);
+  g_return_if_fail (sl);
+
+  act->toplevel = gtk_widget_get_toplevel (GTK_WIDGET (sl->data));
+  g_slist_free (sl);
+
+  vs = PSPPIRE_DATA_WINDOW(act->toplevel)->var_store;
+  
+  g_object_get (vs, "dictionary", &act->dict, NULL);
+  
+  g_object_set (act->source, "model", act->dict, NULL);
+  
+  gtk_window_set_transient_for (GTK_WINDOW (act->dialog), GTK_WINDOW (act->toplevel));
+
+
+  if (GTK_ACTION_CLASS (psppire_dialog_action_parent_class)->activate)
+    GTK_ACTION_CLASS (psppire_dialog_action_parent_class)->activate ( GTK_ACTION (act));
+
+  response = psppire_dialog_run (PSPPIRE_DIALOG (act->dialog));
+
+  if ( class->generate_syntax )
+    {
+      switch (response)
+       {
+       case GTK_RESPONSE_OK:
+         g_free (execute_syntax_string (PSPPIRE_DATA_WINDOW (act->toplevel),
+                                        class->generate_syntax (act)));
+         break;
+       case PSPPIRE_RESPONSE_PASTE:
+         g_free (paste_syntax_to_window (class->generate_syntax (act)));
+         break;
+       default:
+         break;
+       }
+    }
+}
+
+static void
+psppire_dialog_action_class_init (PsppireDialogActionClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  GParamSpec *manager_spec =
+    g_param_spec_object ("manager",
+                        "Manager",
+                        "The GtkUIManager which created this object",
+                        GTK_TYPE_UI_MANAGER,
+                        G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
+
+  GParamSpec *toplevel_spec =
+    g_param_spec_object ("top-level",
+                        "Top Level",
+                        "The top level widget to which this dialog action belongs",
+                        GTK_TYPE_WINDOW,
+                        G_PARAM_READABLE);
+
+  object_class->set_property = psppire_dialog_action_set_property;
+  object_class->get_property = psppire_dialog_action_get_property;
+
+  class->generate_syntax = NULL;
+
+  class->activate = psppire_dialog_action_activate;
+
+  g_object_class_install_property (object_class,
+                                   PROP_MANAGER,
+                                   manager_spec);
+
+  g_object_class_install_property (object_class,
+                                   PROP_TOPLEVEL,
+                                   toplevel_spec);
+}
+
+
+static void
+psppire_dialog_action_init (PsppireDialogAction *act)
+{
+  act->toplevel = NULL;
+  act->dict = NULL;
+}
+
+
+void
+psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act, 
+                                          ContentsAreValid dialog_state_valid)
+{
+  psppire_dialog_set_valid_predicate (act->dialog, dialog_state_valid, act);
+}
+
+void
+psppire_dialog_action_set_refresh (PsppireDialogAction *pda, 
+                                  PsppireDialogActionRefresh refresh)
+{
+  g_signal_connect_swapped (pda->dialog, "refresh", G_CALLBACK (refresh),  pda);
+}
+
diff --git a/src/ui/gui/psppire-dialog-action.h b/src/ui/gui/psppire-dialog-action.h
new file mode 100644 (file)
index 0000000..c0bab64
--- /dev/null
@@ -0,0 +1,101 @@
+/* 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/>. */
+
+/* 
+   This is a an abstract base class, deriving from GtkAction.
+   It's purpose is to abstract the way in which dialog boxes behave.
+   That is, this action will fire whenever a dialog box is to be 
+   popped up.
+   
+   Additionally, most dialog boxes generate syntax to 
+   be run by the pspp back-end.  This provides an abstraction
+   to do that.  The programmer needs only to provide the function
+   to generate the syntax.  This base class looks after the rest.
+*/
+
+#ifndef __PSPPIRE_DIALOG_ACTION_H__
+#define __PSPPIRE_DIALOG_ACTION_H__
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-dict.h"
+#include "psppire-dialog.h"
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION (psppire_dialog_action_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION(obj)     \
+                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                                                 PSPPIRE_TYPE_DIALOG_ACTION, PsppireDialogAction))
+
+#define PSPPIRE_DIALOG_ACTION_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_CAST ((klass), \
+                                PSPPIRE_TYPE_DIALOG_ACTION, \
+                                 PsppireDialogActionClass))
+
+#define PSPPIRE_IS_DIALOG_ACTION(obj) \
+                    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION))
+
+#define PSPPIRE_IS_DIALOG_ACTION_CLASS(klass) \
+                     (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION))
+
+
+#define PSPPIRE_DIALOG_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                                  PSPPIRE_TYPE_DIALOG_ACTION, \
+                                  PsppireDialogActionClass))
+
+typedef struct _PsppireDialogAction       PsppireDialogAction;
+typedef struct _PsppireDialogActionClass  PsppireDialogActionClass;
+
+
+struct _PsppireDialogAction
+{
+  GtkAction parent;
+
+  /*< private >*/
+  GtkUIManager *uim;
+
+  GtkWidget *source;
+  GtkWidget *dialog;
+
+  GtkWidget *toplevel;
+  PsppireDict *dict;
+};
+
+struct _PsppireDialogActionClass
+{
+  GtkActionClass parent_class;
+  void   (*activate) (PsppireDialogAction *);
+  char * (*generate_syntax) (PsppireDialogAction *);
+};
+
+GType psppire_dialog_action_get_type (void) ;
+
+typedef void (*PsppireDialogActionRefresh) (PsppireDialogAction *) ;
+
+void psppire_dialog_action_set_refresh (PsppireDialogAction *pda, 
+                                       PsppireDialogActionRefresh refresh);
+
+void psppire_dialog_action_set_valid_predicate (PsppireDialogAction *act, 
+                                               ContentsAreValid dialog_state_valid);
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_H__ */
index c5ac30b2767b7fe6c11d0de77993edc96355e4b5..c365ab4b8eb47b2d237c9875db4eb92f2664435a 100644 (file)
@@ -31,6 +31,7 @@ static void psppire_dialog_init                (PsppireDialog      *);
 
 
 enum  {DIALOG_REFRESH,
+       RESPONSE,
        VALIDITY_CHANGED,
        DIALOG_HELP,
        n_SIGNALS};
@@ -248,6 +249,18 @@ psppire_dialog_class_init (PsppireDialogClass *class)
                  0);
 
 
+  signals [RESPONSE] =
+    g_signal_new ("response",
+                 G_TYPE_FROM_CLASS (class),
+                 G_SIGNAL_RUN_FIRST,
+                 0,
+                 NULL, NULL,
+                 g_cclosure_marshal_VOID__INT,
+                 G_TYPE_NONE,
+                 1,
+                 G_TYPE_INT);
+
+
   signals [VALIDITY_CHANGED] =
     g_signal_new ("validity-changed",
                  G_TYPE_FROM_CLASS (class),
@@ -524,6 +537,8 @@ psppire_dialog_run (PsppireDialog *dialog)
 
   g_main_loop_unref (dialog->loop);
 
+  g_signal_emit (dialog, signals [RESPONSE], 0, dialog->response);
+
   return dialog->response;
 }
 
diff --git a/src/ui/gui/variable-info-dialog.c b/src/ui/gui/variable-info-dialog.c
deleted file mode 100644 (file)
index 1cd9b1d..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 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 <gtk/gtk.h>
-
-#include <data/variable.h>
-#include <data/format.h>
-#include <data/value-labels.h>
-#include <libpspp/i18n.h>
-
-#include "variable-info-dialog.h"
-#include "var-display.h"
-
-#include "psppire-data-window.h"
-#include "psppire-dialog.h"
-#include "psppire-dictview.h"
-#include "psppire-var-store.h"
-#include "builder-wrapper.h"
-#include "helper.h"
-
-
-
-#include <gettext.h>
-#define _(msgid) gettext (msgid)
-#define N_(msgid) msgid
-
-
-static const gchar none[] = N_("None");
-
-
-static const gchar *
-label_to_string (const struct variable *var)
-{
-  const char *label = var_get_label (var);
-
-  if (NULL == label) return g_strdup (none);
-
-  return label;
-}
-
-
-static void
-populate_text (PsppireDictView *treeview, gpointer data)
-{
-  gchar *text = NULL;
-  GString *gstring;
-  PsppireDict *dict;
-
-  GtkTextBuffer *textbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (data));
-  const struct variable *var =
-    psppire_dict_view_get_selected_variable (treeview);
-
-  if ( var == NULL)
-    return;
-
-  g_object_get (treeview, "model", &dict,
-               NULL);
-
-  gstring = g_string_sized_new (200);
-  g_string_assign (gstring, var_get_name (var));
-  g_string_append (gstring, "\n");
-
-
-  g_string_append_printf (gstring, _("Label: %s\n"), label_to_string (var));
-  {
-    const struct fmt_spec *fmt = var_get_print_format (var);
-    char buffer[FMT_STRING_LEN_MAX + 1];
-
-    fmt_to_string (fmt, buffer);
-    /* No conversion necessary.  buffer will always be ascii */
-    g_string_append_printf (gstring, _("Type: %s\n"), buffer);
-  }
-
-  text = missing_values_to_string (dict, var, NULL);
-  g_string_append_printf (gstring, _("Missing Values: %s\n"),
-                         text);
-  g_free (text);
-
-  g_string_append_printf (gstring, _("Measurement Level: %s\n"),
-                         measure_to_string (var_get_measure (var)));
-
-
-  /* Value Labels */
-  if ( var_has_value_labels (var))
-    {
-      const struct val_labs *vls = var_get_value_labels (var);
-      const struct val_lab **labels;
-      size_t n_labels;
-      size_t i;
-
-      g_string_append (gstring, "\n");
-      g_string_append (gstring, _("Value Labels:\n"));
-
-      labels = val_labs_sorted (vls);
-      n_labels = val_labs_count (vls);
-      for (i = 0; i < n_labels; i++)
-        {
-          const struct val_lab *vl = labels[i];
-         gchar *const vstr  = value_to_text (vl->value,  var);
-
-         g_string_append_printf (gstring, _("%s %s\n"),
-                                  vstr, val_lab_get_escaped_label (vl));
-
-         g_free (vstr);
-       }
-      free (labels);
-    }
-
-  gtk_text_buffer_set_text (textbuffer, gstring->str, gstring->len);
-
-  g_string_free (gstring, TRUE);
-}
-
-static gboolean
-treeview_item_selected (gpointer data)
-{
-  GtkTreeView *tv = GTK_TREE_VIEW (data);
-  GtkTreeModel *model = gtk_tree_view_get_model (tv);
-
-  gint n_rows = gtk_tree_model_iter_n_children  (model, NULL);
-
-  if ( n_rows == 0 )
-    return FALSE;
-
-  return TRUE;
-}
-
-
-static gchar * generate_syntax (PsppireDictView *treeview);
-
-
-void
-variable_info_dialog (PsppireDataWindow *de)
-{
-  gint response ;
-
-  GtkBuilder *xml = builder_new ("variable-info.ui");
-
-  GtkWidget *dialog = get_widget_assert (xml, "variable-info-dialog");
-  GtkWidget *treeview = get_widget_assert (xml, "treeview2");
-  GtkWidget *textview = get_widget_assert (xml, "textview1");
-
-  PsppireVarStore *vs = NULL;
-  PsppireDict *dict = NULL;
-
-  g_object_get (de->data_editor, "var-store", &vs, NULL);
-
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
-
-  g_object_get (vs, "dictionary", &dict, NULL);
-  g_object_set (treeview, "model", dict,
-               "selection-mode", GTK_SELECTION_SINGLE,
-               NULL);
-
-  g_signal_connect (treeview, "cursor-changed", G_CALLBACK (populate_text),
-                   textview);
-
-
-  gtk_text_view_set_indent (GTK_TEXT_VIEW (textview), -5);
-
-  psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
-                                     treeview_item_selected, treeview);
-
-  response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
-
-  switch (response)
-    {
-    case PSPPIRE_RESPONSE_GOTO:
-      {
-       const struct variable *var =
-         psppire_dict_view_get_selected_variable (PSPPIRE_DICT_VIEW (treeview));
-
-       if ( NULL == var)
-         goto done;
-
-       g_object_set (de->data_editor,
-                     "current-variable", var_get_dict_index (var),
-                     NULL);
-      }
-
-      break;
-    case PSPPIRE_RESPONSE_PASTE:
-      {
-       gchar *syntax = generate_syntax (PSPPIRE_DICT_VIEW (treeview));
-        paste_syntax_to_window (syntax);
-
-       g_free (syntax);
-      }
-      break;
-    default:
-      break;
-    }
-
- done:
-  g_object_unref (xml);
-}
-
-static gchar *
-generate_syntax (PsppireDictView *treeview)
-{
-  const struct variable *var =
-    psppire_dict_view_get_selected_variable (treeview);
-
-  if ( NULL == var)
-    return g_strdup ("");
-
-  return g_strdup (var_get_name (var));
-}
-
diff --git a/src/ui/gui/variable-info-dialog.h b/src/ui/gui/variable-info-dialog.h
deleted file mode 100644 (file)
index c08f6c9..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007  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 __VARIABLE_DIALOG_H
-#define __VARIABLE_DIALOG_H
-
-#include "psppire-data-window.h"
-
-void variable_info_dialog (PsppireDataWindow * data);
-
-#endif
index 9a634f73f333d005425f630d4283ea946ef587f3..cedab8c085ee0a7af26a776c534aebdd4b7e7aaf 100644 (file)
@@ -13,6 +13,9 @@
 #include "psppire-var-view.h"
 #include "psppire-val-chooser.h"
 
+#include "psppire-dialog-action-descriptives.h"
+#include "psppire-dialog-action-var-info.h"
+
 
 /* Any custom widgets which are to be used in GtkBuilder ui files
    need to be preregistered, otherwise GtkBuilder refuses to 
@@ -29,4 +32,7 @@ preregister_widgets (void)
   psppire_acr_get_type ();
   psppire_dict_view_get_type ();
   psppire_var_view_get_type ();
+
+  psppire_dialog_action_descriptives_get_type ();
+  psppire_dialog_action_var_info_get_type ();
 }