Fail more gracefully when selecting cells out of range
[pspp] / src / ui / gui / psppire-data-editor.c
index 147ffcd4c3b50ec4f0ea479d27a2278cd69d241d..80bf587695598398093df776f37dcaa401497188 100644 (file)
@@ -242,6 +242,9 @@ change_data_value (PsppireDataStore *store, gint col, gint row, GValue *value)
 {
   const struct variable *var = psppire_dict_get_variable (store->dict, col);
 
+  if (NULL == var)
+    return;
+
   union value v;
   value_init (&v, var_get_width (var));
   v.f = g_value_get_double (value);
@@ -476,9 +479,10 @@ on_data_selection_change (PsppireDataEditor *de, JmdRange *sel)
     {
       /* A single cell is selected */
       const struct variable *var = psppire_dict_get_variable (de->dict, sel->start_x);
-      
-      ref_cell_text = g_strdup_printf (_("%d : %s"),
-                                      sel->start_y + 1, var_get_name (var));
+
+      if (var)
+       ref_cell_text = g_strdup_printf (_("%d : %s"),
+                                        sel->start_y + 1, var_get_name (var));
     }
   else
     {
@@ -600,15 +604,8 @@ psppire_data_editor_new (PsppireDict *dict,
 void
 psppire_data_editor_show_grid (PsppireDataEditor *de, gboolean grid_visible)
 {
-#if 0
-  GtkTreeViewGridLines grid;
-
-  grid = (grid_visible
-          ? GTK_TREE_VIEW_GRID_LINES_BOTH
-          : GTK_TREE_VIEW_GRID_LINES_NONE);
-
-  pspp_sheet_view_set_grid_lines (PSPP_SHEET_VIEW (de->var_sheet), grid);
-#endif  
+  g_object_set (JMD_SHEET (de->var_sheet), "gridlines", grid_visible, NULL);
+  g_object_set (JMD_SHEET (de->data_sheet), "gridlines", grid_visible, NULL);
 }
 
 
@@ -669,7 +666,7 @@ psppire_data_editor_goto_variable (PsppireDataEditor *de, gint dict_index)
 {
 }
 
-#if 0
+#if SHEET_MERGE
 /* Returns the "active" data sheet in DE.  If DE is in single-paned mode, this
    is the only data sheet.  If DE is in split mode (showing four data sheets),
    this is the focused data sheet or, if none is focused, the data sheet with