Miscellaneous T Test improvements. See bug #21760
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 13 Dec 2007 07:58:20 +0000 (07:58 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 13 Dec 2007 07:58:20 +0000 (07:58 +0000)
po/de.po
po/en_GB.po
src/ui/gui/ChangeLog
src/ui/gui/dialog-common.c
src/ui/gui/dialog-common.h
src/ui/gui/t-test-independent-samples-dialog.c
src/ui/gui/t-test.glade

index 77a72c4dfa69897a927552d7bf8e1ff628b9b209..ace9ade0deecc683ef3410d0598976e2283e7c1a 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PSPP 0.4.3\n"
 "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2007-12-10 21:25+0900\n"
+"POT-Creation-Date: 2007-12-12 21:07+0900\n"
 "PO-Revision-Date: 2006-07-28 19:32+0800\n"
 "Last-Translator: John Darrington <john@darrington.wattle.id.au>\n"
 "Language-Team: German <pspp-dev@gnu.org>\n"
@@ -5088,7 +5088,7 @@ msgstr "Kennsatz:"
 msgid "Value:"
 msgstr "Werte:"
 
-#: src/ui/gui/data-editor.glade:1814 src/ui/gui/t-test.glade:365
+#: src/ui/gui/data-editor.glade:1814 src/ui/gui/t-test.glade:460
 msgid "Missing Values"
 msgstr "Lösewerten"
 
@@ -5931,50 +5931,48 @@ msgstr ""
 msgid "To End"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:54
-#, fuzzy
-msgid "Grouping Variable:"
-msgstr "Variableansicht"
+#: src/ui/gui/t-test.glade:53 src/ui/gui/t-test.glade:161
+msgid "Define Groups"
+msgstr ""
 
-#: src/ui/gui/t-test.glade:89 src/ui/gui/t-test.glade:545
+#: src/ui/gui/t-test.glade:88 src/ui/gui/t-test.glade:640
 #, fuzzy
 msgid "Test Variable(s):"
 msgstr "Variableansicht"
 
-#: src/ui/gui/t-test.glade:162
-msgid "Define Groups"
+#: src/ui/gui/t-test.glade:174 src/ui/gui/t-test.glade:533
+msgid "Options..."
 msgstr ""
 
-#: src/ui/gui/t-test.glade:175 src/ui/gui/t-test.glade:438
-msgid "Options..."
+#: src/ui/gui/t-test.glade:255
+msgid "_Use specified values:"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:259
+#: src/ui/gui/t-test.glade:273
+msgid "_Cut point:"
+msgstr ""
+
+#: src/ui/gui/t-test.glade:333
 msgid "Group_1 value:"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:270
+#: src/ui/gui/t-test.glade:344
 msgid "Group_2 value:"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:336
+#: src/ui/gui/t-test.glade:431
 msgid "Exclude cases _analysis by analysis"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:347
+#: src/ui/gui/t-test.glade:442
 msgid "Exclude cases _listwise"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:459
+#: src/ui/gui/t-test.glade:554
 #, fuzzy
 msgid "Test Value: "
 msgstr "Werte:"
 
-#: src/ui/gui/t-test-options.c:60
-#, c-format
-msgid "Confidence Interval: %2d %%"
-msgstr ""
-
 #: src/ui/gui/variable-info-dialog.c:88
 #, fuzzy, c-format
 msgid "Label: %s\n"
@@ -6150,3 +6148,7 @@ msgstr "Warnung"
 #, c-format
 msgid "could not access definition for terminal `%s'"
 msgstr ""
+
+#, fuzzy
+#~ msgid "Grouping Variable:"
+#~ msgstr "Variableansicht"
index 340132b80e2ecdf5cb2a9ea94bc0fd5c4955fb01..92b2747f0755e95a766ccfd1712b867f4916e2ad 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PSPP 0.4.3\n"
 "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2007-12-10 21:25+0900\n"
+"POT-Creation-Date: 2007-12-12 21:07+0900\n"
 "PO-Revision-Date: 2007-09-15 08:29+0800\n"
 "Last-Translator: John Darrington <john@darrington.wattle.id.au>\n"
 "Language-Team: John Darrington <john@darrington.wattle.id.au>\n"
@@ -5047,7 +5047,7 @@ msgstr ""
 msgid "Value:"
 msgstr ""
 
-#: src/ui/gui/data-editor.glade:1814 src/ui/gui/t-test.glade:365
+#: src/ui/gui/data-editor.glade:1814 src/ui/gui/t-test.glade:460
 msgid "Missing Values"
 msgstr ""
 
@@ -5837,47 +5837,46 @@ msgstr ""
 msgid "To End"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:54
-msgid "Grouping Variable:"
+#: src/ui/gui/t-test.glade:53 src/ui/gui/t-test.glade:161
+msgid "Define Groups"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:89 src/ui/gui/t-test.glade:545
+#: src/ui/gui/t-test.glade:88 src/ui/gui/t-test.glade:640
 msgid "Test Variable(s):"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:162
-msgid "Define Groups"
+#: src/ui/gui/t-test.glade:174 src/ui/gui/t-test.glade:533
+msgid "Options..."
 msgstr ""
 
-#: src/ui/gui/t-test.glade:175 src/ui/gui/t-test.glade:438
-msgid "Options..."
+#: src/ui/gui/t-test.glade:255
+msgid "_Use specified values:"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:259
+#: src/ui/gui/t-test.glade:273
+msgid "_Cut point:"
+msgstr ""
+
+#: src/ui/gui/t-test.glade:333
 msgid "Group_1 value:"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:270
+#: src/ui/gui/t-test.glade:344
 msgid "Group_2 value:"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:336
+#: src/ui/gui/t-test.glade:431
 msgid "Exclude cases _analysis by analysis"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:347
+#: src/ui/gui/t-test.glade:442
 msgid "Exclude cases _listwise"
 msgstr ""
 
-#: src/ui/gui/t-test.glade:459
+#: src/ui/gui/t-test.glade:554
 msgid "Test Value: "
 msgstr ""
 
-#: src/ui/gui/t-test-options.c:60
-#, c-format
-msgid "Confidence Interval: %2d %%"
-msgstr ""
-
 #: src/ui/gui/variable-info-dialog.c:88
 #, c-format
 msgid "Label: %s\n"
index fa7e052b30cff8549309c5a999499182efbc705c..e4dccd86c0ed869a4888e0f778028c316b76056f 100644 (file)
@@ -1,3 +1,12 @@
+2007-12-13  John Darrington <john@darrington.wattle.id.au>
+
+       * dialog-common.c dialog-common.h (numeric_only): New function.
+
+       * t-test-independent-samples-dialog.c:  Added the ability to specify 
+       groups by a threshold ("Cut Point").  Keep OK/Paste buttons insensitive,
+       until groups are properly defined.  Prevented variables treeview from
+       accepting string variables.
+
 2007-12-08  John Darrington <john@darrington.wattle.id.au>
 
        * data-editor.h data-editor.c: Added hooks for one sample t-test
index 723a65e4a3bf5751b0923961db90bdf36000e989..c6832df4d05d4b783200f6a5e33bdd33fae463f2 100644 (file)
@@ -236,3 +236,59 @@ homogeneous_types (GtkWidget *source, GtkWidget *dest)
   return retval;
 }
 
+
+
+/* Returns true iff the variable selected by SOURCE is numeric */
+gboolean
+numeric_only (GtkWidget *source, GtkWidget *dest)
+{
+  gboolean ok;
+  GtkTreeIter iter;
+  gboolean retval = TRUE;
+
+  GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (source));
+
+  PsppireDict *dict;
+  GtkTreeSelection *selection;
+  GList *list, *l;
+
+  while (GTK_IS_TREE_MODEL_FILTER (model))
+    {
+      model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
+    }
+
+  dict = PSPPIRE_DICT (model);
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (source));
+
+  list = gtk_tree_selection_get_selected_rows (selection, &model);
+
+  /* Iterate through the selection of the source treeview */
+  for (l = list; l ; l = l->next)
+    {
+      GtkTreePath *path = l->data;
+      GtkTreePath *fpath;
+      gint *idx;
+
+      const struct variable *v;
+
+      fpath = gtk_tree_model_filter_convert_path_to_child_path
+       (GTK_TREE_MODEL_FILTER (model), path);
+
+      idx = gtk_tree_path_get_indices (fpath);
+
+      v = psppire_dict_get_variable (dict, idx[0]);
+
+      if ( var_is_alpha (v))
+       {
+         retval = FALSE;
+         break;
+       }
+    }
+
+  g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
+  g_list_free (list);
+
+  return retval;
+}
+
index 4dd11cb7864822a52045ccd0fe3e9c8b03bfcff1..1e66c8f8ca76a6e8e3367c865146271d8db43fb6 100644 (file)
@@ -65,5 +65,14 @@ void set_dest_model (GtkTreeView *dest, PsppireDict *dict);
 */
 gboolean homogeneous_types (GtkWidget *source, GtkWidget *dest);
 
+/* Returns TRUE if all of the variable(s) represented by the rows
+   currently selected by SOURCE widget, are numeric. DEST is ignored.
+
+   In other words, this function when passed as the argument to
+   psppire_selector_set_allow, ensures that the selector selects only
+   numeric variables.
+*/
+gboolean numeric_only (GtkWidget *source, GtkWidget *dest);
+
 
 #endif
index 5b3d98f7855139e0d231d34873331d46838e216a..e9b6a169a4a7ffbf2da447d006d94ec5d6b307fd 100644 (file)
 #include <language/syntax-string-source.h>
 #include "syntax-editor.h"
 
+#include <gl/xalloc.h>
+
 #include <gettext.h>
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 
 
+enum group_definition
+  {
+    GROUPS_UNDEF,
+    GROUPS_VALUES,
+    GROUPS_CUT_POINT
+  };
+
+struct tt_groups_dialog
+{
+  GtkWidget *dialog;
+  GtkWidget *label;
+  GtkWidget *table1;
+  GtkWidget *table2;
+  GtkWidget *hbox1;
+
+  GtkWidget *values_toggle_button;
+  GtkWidget *cut_point_toggle_button;
+
+  GtkWidget *grp_entry[2];
+  GtkWidget *cut_point_entry;
+
+  enum group_definition group_defn;
+  gchar *val[2];
+};
+
+static void
+set_group_criterion_type (GtkToggleButton *button,
+                         struct tt_groups_dialog *groups)
+{
+  gboolean by_values = gtk_toggle_button_get_active (button);
+
+  gtk_widget_set_sensitive (groups->label, by_values);
+  gtk_widget_set_sensitive (groups->table2, by_values);
+
+  gtk_widget_set_sensitive (groups->hbox1, !by_values);
+}
+
+static void
+tt_groups_dialog_destroy (struct tt_groups_dialog *grps)
+{
+  g_object_unref (grps->table1);
+  g_object_unref (grps->table2);
+
+  g_free (grps->val[0]);
+  g_free (grps->val[1]);
+
+  g_free (grps);
+}
+
+static struct tt_groups_dialog *
+tt_groups_dialog_create (GladeXML *xml, GtkWindow *parent)
+{
+  struct tt_groups_dialog *grps = xmalloc (sizeof (*grps));
+
+  grps->group_defn = GROUPS_UNDEF;
+
+  grps->dialog = get_widget_assert (xml, "define-groups-dialog");
+  grps->table1 = get_widget_assert (xml, "table1");
+  grps->table2 = get_widget_assert (xml, "table2");
+  grps->label  = get_widget_assert (xml, "label4");
+  grps->hbox1  = get_widget_assert (xml, "hbox1");
+
+  grps->grp_entry[0] = get_widget_assert (xml, "group1-entry");
+  grps->grp_entry[1] = get_widget_assert (xml, "group2-entry");
+  grps->cut_point_entry = get_widget_assert (xml, "cut-point-entry");
+
+  grps->cut_point_toggle_button = get_widget_assert (xml, "radiobutton4");
+  grps->values_toggle_button = get_widget_assert (xml, "radiobutton3");
+
+  g_object_ref (grps->table1);
+  g_object_ref (grps->table2);
+
+  g_signal_connect (grps->values_toggle_button, "toggled",
+                   G_CALLBACK (set_group_criterion_type), grps);
+
+  gtk_window_set_transient_for (parent,
+                               GTK_WINDOW (grps->dialog));
+
+
+
+  grps->val[0] = strdup ("");
+  grps->val[1] = strdup ("");
+
+  return grps;
+}
+
+
 struct tt_indep_samples_dialog
 {
   GladeXML *xml;  /* The xml that generated the widgets */
   GtkWidget *dialog;
   PsppireDict *dict;
-  gboolean groups_defined;
+  GtkWidget *define_groups_button;
+  GtkWidget *groups_entry;
 
+  struct tt_groups_dialog *grps;
   struct tt_options_dialog *opts;
 };
 
 
+static void
+set_define_groups_sensitivity (GtkEntry *entry,
+                              struct tt_indep_samples_dialog *tt_d)
+{
+  const gchar *text = gtk_entry_get_text (entry);
+
+  const struct variable *v = psppire_dict_lookup_var (tt_d->dict, text);
+
+  gtk_widget_set_sensitive (tt_d->define_groups_button, v != NULL);
+}
+
+
 static gchar *
 generate_syntax (const struct tt_indep_samples_dialog *d)
 {
   struct variable *group_variable;
   gchar *text;
-  GtkWidget *entry =
-    get_widget_assert (d->xml, "indep-samples-t-test-entry");
 
   GtkWidget *tv =
     get_widget_assert (d->xml, "indep-samples-t-test-treeview2");
@@ -69,48 +170,49 @@ generate_syntax (const struct tt_indep_samples_dialog *d)
   g_string_append (str, "\n\t/GROUPS=");
 
   group_variable =
-    psppire_dict_lookup_var (d->dict, gtk_entry_get_text (GTK_ENTRY (entry)));
+    psppire_dict_lookup_var (d->dict,
+                            gtk_entry_get_text (GTK_ENTRY (d->groups_entry)));
 
   g_string_append (str, var_get_name (group_variable));
 
-  if ( d->groups_defined )
+  if (d->grps->group_defn != GROUPS_UNDEF)
     {
-      GtkWidget *entry1 = get_widget_assert (d->xml, "group1-entry");
-      GtkWidget *entry2 = get_widget_assert (d->xml, "group2-entry");
-
-      const gchar *val1 = gtk_entry_get_text (GTK_ENTRY (entry1));
-      const gchar *val2 = gtk_entry_get_text (GTK_ENTRY (entry2));
-
       g_string_append (str, "(");
+
       if ( var_is_alpha (group_variable))
        {
          struct string s;
-         ds_init_cstr (&s, val1);
+         ds_init_cstr (&s, d->grps->val[0]);
          gen_quoted_string (&s);
          g_string_append (str, ds_cstr (&s));
          ds_destroy (&s);
        }
       else
        {
-         g_string_append (str, val1);
-       }
-      g_string_append (str, ",");
-      if ( var_is_alpha (group_variable))
-       {
-         struct string s;
-         ds_init_cstr (&s, val2);
-         gen_quoted_string (&s);
-         g_string_append (str, ds_cstr (&s));
-         ds_destroy (&s);
+         g_string_append (str, d->grps->val[0]);
        }
-      else
+
+      if ( d->grps->group_defn == GROUPS_VALUES )
        {
-         g_string_append (str, val2);
+         g_string_append (str, ",");
+
+         if ( var_is_alpha (group_variable))
+           {
+             struct string s;
+             ds_init_cstr (&s, d->grps->val[1]);
+             gen_quoted_string (&s);
+             g_string_append (str, ds_cstr (&s));
+             ds_destroy (&s);
+           }
+         else
+           {
+             g_string_append (str, d->grps->val[1]);
+           }
        }
+
       g_string_append (str, ")");
     }
 
-
   tt_options_dialog_append_syntax (d->opts, str);
 
   g_string_append (str, ".\n");
@@ -122,38 +224,44 @@ generate_syntax (const struct tt_indep_samples_dialog *d)
   return text;
 }
 
-
-
 static void
-refresh (GladeXML *xml)
+refresh (struct tt_indep_samples_dialog *ttd)
 {
-  GtkWidget *entry =
-    get_widget_assert (xml, "indep-samples-t-test-entry");
-
   GtkWidget *tv =
-    get_widget_assert (xml, "indep-samples-t-test-treeview2");
+    get_widget_assert (ttd->xml, "indep-samples-t-test-treeview2");
 
   GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (tv));
 
-  gtk_entry_set_text (GTK_ENTRY (entry), "");
+  gtk_entry_set_text (GTK_ENTRY (ttd->groups_entry), "");
 
   gtk_list_store_clear (GTK_LIST_STORE (model));
+
+  gtk_widget_set_sensitive (ttd->define_groups_button, FALSE);
 }
 
 
+/* Returns TRUE iff the define groups subdialog has a
+   state which defines a valid group criterion */
 static gboolean
 define_groups_state_valid (gpointer data)
 {
-  struct tt_indep_samples_dialog *d = data;
-
-  GtkWidget *entry1 = get_widget_assert (d->xml, "group1-entry");
-  GtkWidget *entry2 = get_widget_assert (d->xml, "group2-entry");
+  struct tt_groups_dialog *d = data;
 
-  if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (entry1))))
-    return FALSE;
+  if ( gtk_toggle_button_get_active
+       (GTK_TOGGLE_BUTTON (d->values_toggle_button)))
+    {
+      if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (d->grp_entry[0]))))
+       return FALSE;
 
-  if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (entry2))))
-    return FALSE;
+      if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (d->grp_entry[1]))))
+       return FALSE;
+    }
+  else
+    {
+      if ( 0 == strcmp ("",
+                       gtk_entry_get_text (GTK_ENTRY (d->cut_point_entry))))
+       return FALSE;
+    }
 
   return TRUE;
 }
@@ -161,19 +269,101 @@ define_groups_state_valid (gpointer data)
 static void
 run_define_groups (struct tt_indep_samples_dialog *ttd)
 {
+  struct tt_groups_dialog *grps = ttd->grps;
+
   gint response;
-  GtkWidget *dialog =
-    get_widget_assert (ttd->xml, "define-groups-dialog");
 
+  GtkWidget *box = get_widget_assert (ttd->xml, "dialog-hbox2");
+
+  const gchar *text = gtk_entry_get_text (GTK_ENTRY (ttd->groups_entry));
+
+  const struct variable *v = psppire_dict_lookup_var (ttd->dict, text);
+
+  if ( grps->table2->parent)
+    gtk_container_remove (GTK_CONTAINER (grps->table2->parent), grps->table2);
+
+  if ( grps->table1->parent)
+    gtk_container_remove (GTK_CONTAINER (grps->table1->parent), grps->table1);
 
-  psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
-                                     define_groups_state_valid, ttd);
 
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (ttd->dialog));
+  if ( var_is_numeric (v))
+    {
+      gtk_table_attach_defaults (GTK_TABLE (grps->table1), grps->table2,
+                                1, 2, 1, 2);
+
+      gtk_container_add (GTK_CONTAINER (box), grps->table1);
+    }
+  else
+    {
+      gtk_container_add (GTK_CONTAINER (box), grps->table2);
+      grps->group_defn = GROUPS_VALUES;
+    }
+
+
+  psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (grps->dialog),
+                                     define_groups_state_valid, grps);
+
+  if ( grps->group_defn != GROUPS_CUT_POINT )
+    {
+      gtk_toggle_button_set_active
+       (GTK_TOGGLE_BUTTON (grps->cut_point_toggle_button), TRUE);
+
+      gtk_toggle_button_set_active
+       (GTK_TOGGLE_BUTTON (grps->values_toggle_button), TRUE);
+
+      gtk_entry_set_text (GTK_ENTRY (grps->grp_entry[0]), grps->val[0]);
+      gtk_entry_set_text (GTK_ENTRY (grps->grp_entry[1]), grps->val[1]);
+
+      gtk_entry_set_text (GTK_ENTRY (grps->cut_point_entry), "");
+    }
+  else
+    {
+      gtk_toggle_button_set_active
+       (GTK_TOGGLE_BUTTON (grps->values_toggle_button), TRUE);
+
+      gtk_toggle_button_set_active
+       (GTK_TOGGLE_BUTTON (grps->cut_point_toggle_button), TRUE);
 
-  response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
+      gtk_entry_set_text (GTK_ENTRY (grps->grp_entry[0]), "");
+      gtk_entry_set_text (GTK_ENTRY (grps->grp_entry[1]), "");
 
-  ttd->groups_defined = (response == PSPPIRE_RESPONSE_CONTINUE);
+      gtk_entry_set_text (GTK_ENTRY (grps->cut_point_entry), grps->val[0]);
+    }
+
+  g_signal_emit_by_name (grps->grp_entry[0], "changed");
+  g_signal_emit_by_name (grps->grp_entry[1], "changed");
+  g_signal_emit_by_name (grps->cut_point_entry, "changed");
+
+  response = psppire_dialog_run (PSPPIRE_DIALOG (grps->dialog));
+
+  if (response == PSPPIRE_RESPONSE_CONTINUE)
+    {
+      g_free (grps->val[0]);
+      g_free (grps->val[1]);
+
+      if (gtk_toggle_button_get_active
+         (GTK_TOGGLE_BUTTON (grps->values_toggle_button)))
+       {
+         grps->group_defn = GROUPS_VALUES;
+
+         grps->val[0] =
+           strdup (gtk_entry_get_text (GTK_ENTRY (grps->grp_entry[0])));
+
+         grps->val[1] =
+           strdup (gtk_entry_get_text (GTK_ENTRY (grps->grp_entry[1])));
+       }
+      else
+       {
+         grps->group_defn = GROUPS_CUT_POINT;
+
+         grps->val[1] = NULL;
+
+         grps->val[0] =
+           strdup (gtk_entry_get_text (GTK_ENTRY (grps->cut_point_entry)));
+       }
+
+      psppire_dialog_notify_change (PSPPIRE_DIALOG (ttd->dialog));
+    }
 }
 
 
@@ -183,9 +373,6 @@ dialog_state_valid (gpointer data)
 {
   struct tt_indep_samples_dialog *tt_d = data;
 
-  GtkWidget *entry =
-    get_widget_assert (tt_d->xml, "indep-samples-t-test-entry");
-
   GtkWidget *tv_vars =
     get_widget_assert (tt_d->xml, "indep-samples-t-test-treeview2");
 
@@ -193,17 +380,18 @@ dialog_state_valid (gpointer data)
 
   GtkTreeIter notused;
 
-  if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (entry))))
+  if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (tt_d->groups_entry))))
     return FALSE;
 
-
   if ( 0 == gtk_tree_model_get_iter_first (vars, &notused))
     return FALSE;
 
+  if ( tt_d->grps->group_defn == GROUPS_UNDEF)
+    return FALSE;
+
   return TRUE;
 }
 
-
 /* Pops up the dialog box */
 void
 t_test_independent_samples_dialog (GObject *o, gpointer data)
@@ -231,12 +419,6 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
   GtkWidget *selector1 =
     get_widget_assert (xml, "indep-samples-t-test-selector1");
 
-  GtkWidget *entry =
-    get_widget_assert (xml, "indep-samples-t-test-entry");
-
-  GtkWidget *define_groups_button =
-    get_widget_assert (xml, "define-groups-button");
-
   GtkWidget *options_button =
     get_widget_assert (xml, "options-button");
 
@@ -245,8 +427,12 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
   tt_d.dialog = get_widget_assert (xml, "t-test-independent-samples-dialog");
   tt_d.xml = xml;
   tt_d.dict = vs->dict;
-  tt_d.groups_defined = FALSE;
+
+  tt_d.define_groups_button = get_widget_assert (xml, "define-groups-button");
+  tt_d.groups_entry = get_widget_assert (xml, "indep-samples-t-test-entry");
   tt_d.opts = tt_options_dialog_create (xml, de->parent.window);
+  tt_d.grps = tt_groups_dialog_create (xml, de->parent.window);
+
 
   gtk_window_set_transient_for (GTK_WINDOW (tt_d.dialog), de->parent.window);
 
@@ -262,13 +448,16 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
                                 insert_source_row_into_tree_view,
                                 NULL);
 
+  psppire_selector_set_allow (PSPPIRE_SELECTOR (selector1),
+                             numeric_only);
+
 
   psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector2),
-                                dict_view, entry,
+                                dict_view, tt_d.groups_entry,
                                 insert_source_row_into_entry,
                                 is_currently_in_entry);
 
-  g_signal_connect_swapped (define_groups_button, "clicked",
+  g_signal_connect_swapped (tt_d.define_groups_button, "clicked",
                            G_CALLBACK (run_define_groups), &tt_d);
 
 
@@ -276,7 +465,11 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
                            G_CALLBACK (tt_options_dialog_run), tt_d.opts);
 
 
-  g_signal_connect_swapped (tt_d.dialog, "refresh", G_CALLBACK (refresh),  xml);
+  g_signal_connect_swapped (tt_d.dialog, "refresh", G_CALLBACK (refresh),
+                           &tt_d);
+
+  g_signal_connect (tt_d.groups_entry, "changed",
+                   G_CALLBACK (set_define_groups_sensitivity), &tt_d);
 
 
   psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (tt_d.dialog),
@@ -312,6 +505,8 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
     }
 
   tt_options_dialog_destroy (tt_d.opts);
+  tt_groups_dialog_destroy (tt_d.grps);
+
   g_object_unref (xml);
 }
 
index afa954e4c2544afdf04e44ba0d75a0bb949d2766..4ddf65be0a122da5a63f0ecfbef3d41bdfefa3ff 100644 (file)
@@ -50,8 +50,7 @@
                       <widget class="GtkLabel" id="label36">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Grouping Variable:</property>
+                        <property name="label" translatable="yes">Define Groups</property>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
           <widget class="GtkTable" id="table1">
             <property name="visible">True</property>
             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="n_rows">2</property>
+            <property name="n_rows">3</property>
             <property name="n_columns">2</property>
             <property name="column_spacing">5</property>
+            <property name="row_spacing">5</property>
+            <child>
+              <placeholder/>
+            </child>
             <child>
-              <widget class="GtkEntry" id="group1-entry">
+              <widget class="GtkRadioButton" id="radiobutton4">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+                <property name="group">radiobutton3</property>
               </widget>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options"></property>
+                <property name="y_options"></property>
               </packing>
             </child>
             <child>
-              <widget class="GtkEntry" id="group2-entry">
+              <widget class="GtkLabel" id="label4">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">_Use specified values:</property>
+                <property name="use_underline">True</property>
               </widget>
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="y_options"></property>
               </packing>
             </child>
             <child>
-              <widget class="GtkLabel" id="label1">
+              <widget class="GtkHBox" id="hbox1">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Group_1 value:</property>
-                <property name="use_underline">True</property>
+                <child>
+                  <widget class="GtkLabel" id="label5">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">_Cut point:</property>
+                    <property name="use_underline">True</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="cut-point-entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
               </widget>
               <packing>
-                <property name="x_options"></property>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="y_options"></property>
+                <property name="y_padding">5</property>
               </packing>
             </child>
             <child>
-              <widget class="GtkLabel" id="label2">
+              <widget class="GtkTable" id="table2">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Group_2 value:</property>
-                <property name="use_underline">True</property>
+                <property name="n_rows">2</property>
+                <property name="n_columns">2</property>
+                <property name="column_spacing">5</property>
+                <property name="row_spacing">5</property>
+                <child>
+                  <widget class="GtkEntry" id="group1-entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="group2-entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">Group_1 value:</property>
+                    <property name="use_underline">True</property>
+                  </widget>
+                  <packing>
+                    <property name="x_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label2">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">Group_2 value:</property>
+                    <property name="use_underline">True</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options"></property>
+                  </packing>
+                </child>
               </widget>
               <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
+                <property name="y_options">GTK_EXPAND</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkRadioButton" id="radiobutton3">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+              </widget>
+              <packing>
                 <property name="x_options"></property>
               </packing>
             </child>