When adding variables in varsheet, add at the current position.
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 30 Nov 2008 04:08:56 +0000 (13:08 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 30 Nov 2008 04:08:56 +0000 (13:08 +0900)
Previously variables could only be inserted at the start of the dictionary.
Fixes bug #24502

src/ui/gui/psppire-data-editor.c

index d0a6b8088b67c6d17f0cce4fd479e0379889c6bd..592e8aaa455c3ee9faa5d80039c71e334bd94d2d 100644 (file)
@@ -1175,14 +1175,26 @@ psppire_data_editor_sort_descending (PsppireDataEditor *de)
 void
 psppire_data_editor_insert_variable (PsppireDataEditor *de)
 {
-  glong posn = -1;
-
-  if ( de->data_sheet[0]->state == GTK_SHEET_COLUMN_SELECTED )
-    posn = GTK_SHEET (de->data_sheet[0])->range.col0;
-  else
-    posn = GTK_SHEET (de->data_sheet[0])->active_cell.col;
+  glong posn = 0;
 
-  if ( posn == -1 ) posn = 0;
+  switch (gtk_notebook_get_current_page (GTK_NOTEBOOK (de)))
+    {
+    case PSPPIRE_DATA_EDITOR_DATA_VIEW:
+      if ( de->data_sheet[0]->state == GTK_SHEET_COLUMN_SELECTED )
+       posn = GTK_SHEET (de->data_sheet[0])->range.col0;
+      else
+       posn = GTK_SHEET (de->data_sheet[0])->active_cell.col;
+      break;
+    case PSPPIRE_DATA_EDITOR_VARIABLE_VIEW:
+      if ( de->var_sheet->state == GTK_SHEET_ROW_SELECTED )
+       posn = GTK_SHEET (de->var_sheet)->range.row0;
+      else
+       posn = GTK_SHEET (de->var_sheet)->active_cell.row;
+      break;
+    default:
+      g_assert_not_reached ();
+      break;
+    };
 
   psppire_dict_insert_variable (de->data_store->dict, posn, NULL);
 }