From 84e52d2345268f337056e7572d5013b3ef42130d Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 10 Aug 2016 21:44:52 +0200 Subject: [PATCH] Re-enable the goto-case dialog --- src/ui/gui/goto-case-dialog.c | 39 +++++++++++++++++++++++++++++--- src/ui/gui/goto-case-dialog.h | 4 +++- src/ui/gui/psppire-data-window.c | 10 ++++---- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/ui/gui/goto-case-dialog.c b/src/ui/gui/goto-case-dialog.c index 54d8eaf334..de7e977646 100644 --- a/src/ui/gui/goto-case-dialog.c +++ b/src/ui/gui/goto-case-dialog.c @@ -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 @@ -21,14 +21,47 @@ #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); + } + } } diff --git a/src/ui/gui/goto-case-dialog.h b/src/ui/gui/goto-case-dialog.h index 455e2e637c..93fb13a464 100644 --- a/src/ui/gui/goto-case-dialog.h +++ b/src/ui/gui/goto-case-dialog.h @@ -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 diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index a97fd4e436..b781543ac8 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -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)); + } } -- 2.30.2