Make switch to MRU upon tab close configurable

Add configuration option tab_close_switch_to_mru to allow the user
to choose whether to switch to the most recently used tab or to the
next one after closing the current tab.
This commit is contained in:
Colomban Wendling 2011-12-16 19:16:20 +01:00 committed by Jiří Techet
parent f6be8b47d7
commit 23eede5291
4 changed files with 33 additions and 7 deletions

View File

@ -2117,6 +2117,18 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_tab_close_switch_to_mru">
<property name="label" translatable="yes">Switch to last used document after closing a tab</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -62,6 +62,7 @@ typedef struct GeanyFilePrefs
gboolean gio_unsafe_save_backup;
gboolean use_gio_unsafe_file_saving; /* whether to use GIO as the unsafe backend */
gchar *extract_filetype_regex; /* regex to extract filetype on opening */
gboolean tab_close_switch_to_mru;
}
GeanyFilePrefs;

View File

@ -632,15 +632,26 @@ static void on_document_close(GObject *obj, GeanyDocument *doc)
{
if (! main_status.quitting)
{
GeanyDocument *last_doc;
last_doc = g_queue_peek_nth(mru_docs, 1);
if (DOC_VALID(last_doc) && document_get_current() == doc)
/* switch to appropriate page when closing current doc */
if (document_get_current() == doc)
{
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
document_get_notebook_page(last_doc));
gint page;
page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook)) +
(file_prefs.tab_order_ltr ? 1 : -1);
if (file_prefs.tab_close_switch_to_mru)
{
GeanyDocument *last_doc;
last_doc = g_queue_peek_nth(mru_docs, 1);
if (DOC_VALID(last_doc))
page = document_get_notebook_page(last_doc);
}
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), page);
}
g_queue_remove(mru_docs, doc);
/* this prevents the pop up window from showing when there's a single
* document */

View File

@ -139,6 +139,8 @@ static void init_pref_groups(void)
stash_group_add_toggle_button(group, &interface_prefs.notebook_double_click_hides_widgets,
"notebook_double_click_hides_widgets", FALSE, "check_double_click_hides_widgets");
stash_group_add_toggle_button(group, &file_prefs.tab_close_switch_to_mru,
"tab_close_switch_to_mru", FALSE, "check_tab_close_switch_to_mru");
stash_group_add_integer(group, &interface_prefs.tab_pos_sidebar, "tab_pos_sidebar", GTK_POS_TOP);
stash_group_add_radio_buttons(group, &interface_prefs.sidebar_pos,
"sidebar_pos", GTK_POS_LEFT,