[geany/geany] fd6ce2: Fix UI updating after loading a project

Colomban Wendling git-noreply at xxxxx
Fri May 2 22:52:23 UTC 2014


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Fri, 02 May 2014 22:52:23 UTC
Commit:      fd6ce2da11e9f2d20cb96236753662c23feaecb4
             https://github.com/geany/geany/commit/fd6ce2da11e9f2d20cb96236753662c23feaecb4

Log Message:
-----------
Fix UI updating after loading a project

When loading a project and focusing the last document, the UI wouldn't
get properly updated for the displayed file -- because for performance
reasons we disable notebook page switch handlers when loading session
files.  Fix this by synthesizing a notebook page switch event when done
loading.


Modified Paths:
--------------
    src/keyfile.c

Modified: src/keyfile.c
18 lines changed, 12 insertions(+), 6 deletions(-)
===================================================================
@@ -1194,14 +1194,20 @@ void configuration_open_files(void)
 
 	if (failure)
 		ui_set_statusbar(TRUE, _("Failed to load one or more session files."));
-	else if (session_notebook_page >= 0)
+	else
 	{
-		/* explicitly allow notebook switch page callback to be called for window title,
-		 * encoding settings and so other things */
+		/* explicitly trigger a notebook page switch after unsetting main_status.opening_session_files
+		 * for callbacks to run (and update window title, encoding settings, and so on) */
+		gint n_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
+		gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
+		gint target_page = session_notebook_page >= 0 ? session_notebook_page : cur_page;
+
+		/* if target page is current page, switch to another page first to really trigger an event */
+		if (target_page == cur_page)
+			gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), (cur_page + 1) % n_pages);
+
 		main_status.opening_session_files = FALSE;
-		/** TODO if session_notebook_page is equal to the current notebook tab(the last opened)
-		 ** the notebook switch page callback isn't triggered and e.g. menu items are not updated */
-		gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), session_notebook_page);
+		gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), target_page);
 	}
 	main_status.opening_session_files = FALSE;
 }



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list