From 20115f6f540b158e0c960c5dc39c7c0400a1dc97 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 13 Mar 2007 17:00:12 +0000 Subject: [PATCH] Add 'Switch to last used document' keybinding. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1390 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 3 +++ doc/geany.docbook | 4 ++++ src/callbacks.c | 6 +++++- src/callbacks.h | 8 ++++++++ src/keybindings.c | 12 ++++++++++++ src/keybindings.h | 1 + 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f372ef97..e7228571 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ * src/document.c: Count total replacements made when replacing in a rectangular selection. + * src/keybindings.c, src/keybindings.h, src/callbacks.c, + src/callbacks.h, doc/geany.docbook: + Add 'Switch to last used document' keybinding. 2007-03-12 Enrico Tröger diff --git a/doc/geany.docbook b/doc/geany.docbook index 03649e1b..7e69dcb8 100644 --- a/doc/geany.docbook +++ b/doc/geany.docbook @@ -1406,6 +1406,10 @@ Switch to right document Switches to the next open document. + + Switch to last used document + Switches to the previously selected open document. + Editing operations diff --git a/src/callbacks.c b/src/callbacks.c index 7dbb22fe..15734d4c 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -84,6 +84,8 @@ static gboolean insert_callback_from_menu = FALSE; // the selection-changed signal from tv.tree_openfiles //static gboolean switch_tv_notebook_page = FALSE; +CallbacksData callbacks_data = {-1}; + // real exit function gint destroyapp(GtkWidget *widget, gpointer gdata) @@ -705,6 +707,8 @@ on_notebook1_switch_page (GtkNotebook *notebook, { gint idx; + callbacks_data.last_doc_idx = document_get_cur_idx(); + if (closing_all) return; // guint == -1 seems useless, but it isn't! @@ -749,7 +753,7 @@ on_notebook1_switch_page_after (GtkNotebook *notebook, utils_check_disk_status(idx, FALSE); #ifdef HAVE_VTE - vte_cwd(doc_list[idx].file_name, FALSE); + vte_cwd(doc_list[idx].file_name, FALSE); #endif } } diff --git a/src/callbacks.h b/src/callbacks.h index 20c6802b..d75e03ac 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -21,6 +21,14 @@ * $Id$ */ +typedef struct +{ + gint last_doc_idx; +} CallbacksData; + +extern CallbacksData callbacks_data; + + gint destroyapp (GtkWidget *widget, gpointer gdata); diff --git a/src/keybindings.c b/src/keybindings.c index 12e8bd8d..c3de4d44 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -92,6 +92,7 @@ static void cb_func_switch_scribble(guint key_id); static void cb_func_switch_vte(guint key_id); static void cb_func_switch_tableft(guint key_id); static void cb_func_switch_tabright(guint key_id); +static void cb_func_switch_tablastused(guint key_id); static void cb_func_toggle_sidebar(guint key_id); // common function for editing keybindings, only valid when scintilla has focus. @@ -210,6 +211,8 @@ void keybindings_init(void) GDK_Page_Up, GDK_CONTROL_MASK, "switch_tableft", _("Switch to left document")); keys[GEANY_KEYS_SWITCH_TABRIGHT] = fill(cb_func_switch_tabright, GDK_Page_Down, GDK_CONTROL_MASK, "switch_tabright", _("Switch to right document")); + keys[GEANY_KEYS_SWITCH_TABLASTUSED] = fill(cb_func_switch_tablastused, + GDK_Tab, GDK_CONTROL_MASK, "switch_tablastused", _("Switch to last used document")); keys[GEANY_KEYS_EDIT_DUPLICATELINE] = fill(cb_func_edit, GDK_g, GDK_CONTROL_MASK, "edit_duplicateline", _("Duplicate line or selection")); @@ -760,6 +763,15 @@ static void cb_func_switch_tabright(G_GNUC_UNUSED guint key_id) utils_switch_document(RIGHT); } +static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id) +{ + gint last_doc_idx = callbacks_data.last_doc_idx; + + if (DOC_IDX_VALID(last_doc_idx)) + gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), + document_get_notebook_page(last_doc_idx)); +} + static void cb_func_toggle_sidebar(G_GNUC_UNUSED guint key_id) { static gint active_page = -1; diff --git a/src/keybindings.h b/src/keybindings.h index 73e08e48..85f85724 100644 --- a/src/keybindings.h +++ b/src/keybindings.h @@ -92,6 +92,7 @@ enum GEANY_KEYS_SWITCH_VTE, GEANY_KEYS_SWITCH_TABLEFT, GEANY_KEYS_SWITCH_TABRIGHT, + GEANY_KEYS_SWITCH_TABLASTUSED, GEANY_KEYS_EDIT_TOLOWERCASE, GEANY_KEYS_EDIT_TOUPPERCASE, GEANY_KEYS_EDIT_DUPLICATELINE,