Rename psppire_dialog_action_get_pointer -> psppire_dialog_action_get_hash_table
[pspp] / src / ui / gui / psppire-dialog-action-examine.c
index 904beec1e810b2abc416bb483a7461c6a7ee39ef..841280a23d24ba15c2ca09c4cfe1768578d96cf2 100644 (file)
@@ -20,6 +20,8 @@
 #include "psppire-dialog-action-examine.h"
 
 #include "psppire-var-view.h"
+#include "dialog-common.h"
+#include "psppire-selector.h"
 #include "psppire-dict.h"
 #include "psppire-dialog.h"
 #include "builder-wrapper.h"
@@ -201,17 +203,41 @@ 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");
+  GHashTable *thing = psppire_dialog_action_get_hash_table (pda);
+  GtkBuilder *xml = g_hash_table_lookup (thing, a);
+  if (!xml)
+    {
+      xml = builder_new ("examine.ui");
+      g_hash_table_insert (thing, a, xml);
+    }
 
   GtkWidget *stats_button = get_widget_assert (xml, "stats-button");
   GtkWidget *opts_button = get_widget_assert (xml, "opts-button");
 
+  GtkWidget *dep_sel = get_widget_assert (xml, "psppire-selector1");
+  GtkWidget *dep_sel2 = get_widget_assert (xml, "psppire-selector2");
+  GtkWidget *dep_sel3 = get_widget_assert (xml, "psppire-selector3");
+  GtkWidget *table = get_widget_assert (xml, "table1");
+
   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");
 
+  /* Setting the focus chain like this is a pain.
+     But the default focus order seems to be somewhat odd. */
+  GList *list = NULL;
+  list = g_list_append (list, get_widget_assert (xml, "scrolledwindow1"));
+  list = g_list_append (list, dep_sel);
+  list = g_list_append (list, get_widget_assert (xml, "frame1"));
+  list = g_list_append (list, dep_sel2);
+  list = g_list_append (list, get_widget_assert (xml, "frame2"));
+  list = g_list_append (list, dep_sel3);
+  list = g_list_append (list, get_widget_assert (xml, "frame3"));
+  gtk_container_set_focus_chain (GTK_CONTAINER (table), list);
+
+
   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"); 
@@ -222,10 +248,7 @@ psppire_dialog_action_examine_activate (GtkAction *a)
   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_selector_set_allow (PSPPIRE_SELECTOR (dep_sel), numeric_only);
 
   psppire_dialog_action_set_valid_predicate (pda, (void *) dialog_state_valid);
   psppire_dialog_action_set_refresh (pda, dialog_refresh);
@@ -235,14 +258,16 @@ psppire_dialog_action_examine_activate (GtkAction *a)
 
   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);
+
+  g_list_free (list);
 }
 
 static void
 psppire_dialog_action_examine_class_init (PsppireDialogActionExamineClass *class)
 {
-  GTK_ACTION_CLASS (class)->activate = psppire_dialog_action_examine_activate;
+  psppire_dialog_action_set_activation (class, psppire_dialog_action_examine_activate);
 
   PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
 }