From 978053dda1b3dd918e0a814cb5bd282cd2d3774c Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 12 Mar 2016 17:15:18 +0100 Subject: [PATCH] Change view and scroll to position on header double click --- src/ui/gui/psppire-data-editor.c | 20 ++++++++++++++++---- src/ui/gui/psppire-var-sheet-header.c | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 14f2076f35..7838e5f810 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -301,18 +301,27 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass) } -static gboolean +static void on_var_sheet_var_double_clicked (PsppireVarSheet *var_sheet, gint dict_index, PsppireDataEditor *de) { - gtk_notebook_set_current_page (GTK_NOTEBOOK (de), PSPPIRE_DATA_EDITOR_DATA_VIEW); + jmd_sheet_scroll_to (de->data_sheet, dict_index, -1); +} + +static void +on_data_sheet_var_double_clicked (JmdSheet *data_sheet, gint dict_index, + PsppireDataEditor *de) +{ + gtk_notebook_set_current_page (GTK_NOTEBOOK (de), + PSPPIRE_DATA_EDITOR_VARIABLE_VIEW); - return TRUE; + jmd_sheet_scroll_to (de->var_sheet, -1, dict_index); } + /* Refreshes 'de->cell_ref_label' and 'de->datum_entry' from the currently active cell or cells. */ static void @@ -386,9 +395,12 @@ psppire_data_editor_init (PsppireDataEditor *de) gtk_widget_show_all (de->var_sheet); - g_signal_connect (de->var_sheet, "var-double-clicked", + g_signal_connect (de->var_sheet, "row-header-double-clicked", G_CALLBACK (on_var_sheet_var_double_clicked), de); + g_signal_connect (de->data_sheet, "column-header-double-clicked", + G_CALLBACK (on_data_sheet_var_double_clicked), de); + g_object_set (de, "can-focus", FALSE, NULL); if (psppire_conf_get_string (psppire_conf_new (), diff --git a/src/ui/gui/psppire-var-sheet-header.c b/src/ui/gui/psppire-var-sheet-header.c index 5032c38979..8930826aaa 100644 --- a/src/ui/gui/psppire-var-sheet-header.c +++ b/src/ui/gui/psppire-var-sheet-header.c @@ -79,7 +79,7 @@ gi (GListModel *list, guint position) break; default: // g_assert_not_reached (); - g_print ("Bug: Request for item %d", position); + g_print ("Bug: Request for item %d\n", position); break; } -- 2.30.2