Re-enable the goto-case dialog
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 10 Aug 2016 19:44:52 +0000 (21:44 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 10 Aug 2016 19:44:52 +0000 (21:44 +0200)
src/ui/gui/goto-case-dialog.c
src/ui/gui/goto-case-dialog.h
src/ui/gui/psppire-data-window.c

index 54d8eaf3349205b850901d2ff8ffce303dbfe74c..de7e97764621e23329f25b8b1cfa1587444e4ab1 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2011, 2012  Free Software Foundation
+   Copyright (C) 2007, 2011, 2012, 2016  Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include "psppire-dialog.h"
 #include "psppire-data-window.h"
 #include "psppire-data-store.h"
+#include "ui/gui/efficient-sheet/jmd-sheet.h"
 
 
 static void
-refresh (GtkWidget *ds, GtkBuilder *xml)
+refresh (JmdSheet *ds, GtkBuilder *xml)
 {
+  GtkWidget *case_num_entry = get_widget_assert (xml, "goto-case-case-num-entry");
+  casenumber case_count =  gtk_tree_model_iter_n_children (ds->data_model, NULL);
+
+  gtk_spin_button_set_range (GTK_SPIN_BUTTON (case_num_entry), 1, case_count);
 }
 
 void
-goto_case_dialog (void *ds)
+goto_case_dialog (JmdSheet *ds)
 {
+  GtkWindow *top_level;
+  gint response;
+  GtkBuilder *xml = builder_new ("goto-case.ui");
+  GtkWidget *dialog = get_widget_assert   (xml, "goto-case-dialog");
+
+  top_level = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (ds)));
+  gtk_window_set_transient_for (GTK_WINDOW (dialog), top_level);
+
+  refresh (ds, xml);
+
+  response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
+
+  if (response == PSPPIRE_RESPONSE_GOTO)
+    {
+      GtkWidget *case_num_entry =
+       get_widget_assert (xml, "goto-case-case-num-entry");
+
+      glong case_num =
+       gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (case_num_entry))
+       - FIRST_CASE_NUMBER ;
+
+      if (case_num >= 0 && 
+         case_num < gtk_tree_model_iter_n_children (ds->data_model, NULL))
+      {
+       jmd_sheet_scroll_to (ds, -1, case_num);
+       jmd_sheet_set_active_cell (ds, -1, case_num, 0);
+      }
+    }
 }
index 455e2e637c06ae9977ba34e92df6e155f379e3b9..93fb13a464d2aea8fde7d0d9d82abef6cc463263 100644 (file)
@@ -17,7 +17,9 @@
 #ifndef __GOTO_CASE_DIALOG_H
 #define __GOTO_CASE_DIALOG_H
 
+#include "ui/gui/efficient-sheet/jmd-sheet.h"
 
-void goto_case_dialog (void *ds);
+
+void goto_case_dialog (JmdSheet *ds);
 
 #endif
index a97fd4e436e2520103cd5c8f47271a0f94da202d..b781543ac83bf6da3bacf6c390034d9fa7d8a029 100644 (file)
@@ -1226,11 +1226,11 @@ insert_case_at_row (PsppireDataWindow *dw)
 static void
 goto_case (PsppireDataWindow *dw)
 {
-#if SHEET_MERGE
-  PsppireDataSheet *ds = psppire_data_editor_get_active_data_sheet (dw->data_editor);
-
-  goto_case_dialog (ds);
-#endif
+  int p = gtk_notebook_get_current_page (GTK_NOTEBOOK (dw->data_editor));
+  if (p == 0)
+    {
+      goto_case_dialog (JMD_SHEET (dw->data_editor->data_sheet));
+    }
 }