Added egression dialog
[pspp-builds.git] / src / ui / gui / data-editor.c
index 6e05d27183b254815bc85d99bf751b7997c3fa1f..96f42cc263982657d54bbcfe490711ff8fe63b0c 100644 (file)
 #include "comments-dialog.h"
 #include "variable-info-dialog.h"
 #include "descriptives-dialog.h"
+#include "crosstabs-dialog.h"
 #include "frequencies-dialog.h"
+#include "examine-dialog.h"
 #include "dict-display.h"
+#include "regression-dialog.h"
 #include "clipboard.h"
 
-
 #include "oneway-anova-dialog.h"
 #include "t-test-independent-samples-dialog.h"
 #include "t-test-one-sample.h"
@@ -711,6 +713,34 @@ new_data_editor (void)
   g_signal_connect (de->invoke_frequencies_dialog, "activate",
                    G_CALLBACK (frequencies_dialog), de);
 
+  de->invoke_crosstabs_dialog =
+    gtk_action_new ("crosstabs-dialog",
+                   _("_Crosstabs"),
+                   _("Generate crosstabulations"),
+                   "pspp-crosstabs");
+
+  g_signal_connect (de->invoke_crosstabs_dialog, "activate",
+                   G_CALLBACK (crosstabs_dialog), de);
+
+
+  de->invoke_examine_dialog =
+    gtk_action_new ("examine-dialog",
+                   _("_Explore"),
+                   _("Examine Data by Factors"),
+                   "pspp-examine");
+
+  g_signal_connect (de->invoke_examine_dialog, "activate",
+                   G_CALLBACK (examine_dialog), de);
+
+
+  de->invoke_regression_dialog =
+    gtk_action_new ("regression-dialog",
+                   _("Linear _Regression"),
+                   _("Estimate parameters of the linear model"),
+                   "pspp-regression");
+
+  g_signal_connect (de->invoke_regression_dialog, "activate",
+                   G_CALLBACK (regression_dialog), de);
 
   e->window = GTK_WINDOW (get_widget_assert (de->xml, "data_editor"));
 
@@ -724,7 +754,6 @@ new_data_editor (void)
                            G_CALLBACK (gtk_action_activate),
                            de->action_data_open);
 
-
 #if RECENT_LISTS_AVAILABLE
   {
     GtkRecentManager *rm = gtk_recent_manager_get_default ();
@@ -870,10 +899,23 @@ new_data_editor (void)
                            get_widget_assert (de->xml, "analyze_descriptives")
                            );
 
+  gtk_action_connect_proxy (de->invoke_crosstabs_dialog,
+                           get_widget_assert (de->xml, "crosstabs")
+                           );
+
   gtk_action_connect_proxy (de->invoke_frequencies_dialog,
                            get_widget_assert (de->xml, "analyze_frequencies")
                            );
 
+
+  gtk_action_connect_proxy (de->invoke_examine_dialog,
+                           get_widget_assert (de->xml, "analyze_explore")
+                           );
+
+  gtk_action_connect_proxy (de->invoke_regression_dialog,
+                           get_widget_assert (de->xml, "linear-regression")
+                           );
+
   g_signal_connect (get_widget_assert (de->xml,"help_about"),
                    "activate",
                    G_CALLBACK (about_new),
@@ -1756,6 +1798,7 @@ open_data_dialog (GtkAction *action, struct data_editor *de)
 static gint
 update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
 {
+  GtkEntry *datum_entry;
   GladeXML *data_editor_xml = data;
 
   PsppireDataStore *data_store =
@@ -1763,6 +1806,11 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
 
   g_return_val_if_fail (data_editor_xml, FALSE);
 
+
+  datum_entry =
+    GTK_ENTRY (get_widget_assert (data_editor_xml,
+                                 "datum_entry"));
+
   if (data_store)
     {
       const struct variable *var =
@@ -1772,10 +1820,6 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
       GtkEntry *cell_ref_entry =
        GTK_ENTRY (get_widget_assert (data_editor_xml,
                                      "cell_ref_entry"));
-      GtkEntry *datum_entry =
-       GTK_ENTRY (get_widget_assert (data_editor_xml,
-                                     "datum_entry"));
-
       if ( var )
        {
          gchar *text = g_strdup_printf ("%d: %s", row + FIRST_CASE_NUMBER,
@@ -1790,14 +1834,17 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
          g_free (s);
        }
       else
-       gtk_entry_set_text (cell_ref_entry, "");
-
+       goto blank_entry;
 
       if ( var )
        {
          gchar *text =
            psppire_data_store_get_string (data_store, row,
                                           var_get_dict_index(var));
+
+         if ( ! text )
+           goto blank_entry;
+
          g_strchug (text);
 
          gtk_entry_set_text (datum_entry, text);
@@ -1805,10 +1852,16 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
          free (text);
        }
       else
-       gtk_entry_set_text (datum_entry, "");
+       goto blank_entry;
+
     }
 
   return FALSE;
+
+ blank_entry:
+  gtk_entry_set_text (datum_entry, "");
+
+  return FALSE;
 }