From 2feabc7ca2157bc6b819f22590c6bd5376498e60 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Wed, 22 Jul 2020 10:00:01 +0100 Subject: [PATCH] Bug 797787 - Create new plugin page next to current page Currently new pages are created in the last position which could result in a lot of scrolling if a large number of tabs are open. This commit changes that so new pages are created next to the current page. --- gnucash/gnome-utils/gnc-main-window.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c index 36c5a85ba8..312d121318 100644 --- a/gnucash/gnome-utils/gnc-main-window.c +++ b/gnucash/gnome-utils/gnc-main-window.c @@ -2809,17 +2809,20 @@ gnc_main_window_connect (GncMainWindow *window, { GncMainWindowPrivate *priv; GtkNotebook *notebook; + gint current_position = -1; page->window = GTK_WIDGET(window); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); notebook = GTK_NOTEBOOK (priv->notebook); - priv->installed_pages = g_list_append (priv->installed_pages, page); + current_position = g_list_index (priv->installed_pages, priv->current_page) + 1; + priv->installed_pages = g_list_insert (priv->installed_pages, page, current_position); priv->usage_order = g_list_prepend (priv->usage_order, page); - gtk_notebook_append_page_menu (notebook, page->notebook_page, - tab_hbox, menu_label); + gtk_notebook_insert_page_menu (notebook, page->notebook_page, + tab_hbox, menu_label, current_position); gtk_notebook_set_tab_reorderable (notebook, page->notebook_page, TRUE); gnc_plugin_page_inserted (page); - gtk_notebook_set_current_page (notebook, -1); + gtk_notebook_set_current_page (notebook, current_position); + if (GNC_PLUGIN_PAGE_GET_CLASS(page)->window_changed) (GNC_PLUGIN_PAGE_GET_CLASS(page)->window_changed)(page, GTK_WIDGET(window)); g_signal_emit (window, main_window_signals[PAGE_ADDED], 0, page);