Skip to content

Commit

Permalink
Fix emission of document-activate signal and various related GUI glit…
Browse files Browse the repository at this point in the history
…ches

PR #3267 removed the special handling
of the situation when no tab change happens after setting an active
document after session load. This happens in the situation where

1. There's just a single document
2. Depending on the tab opening logic, the active tab saved into the session
   file corresponds to the already active tab

This patch tries to restore the previous behavior where switch-page" was
synthetically emitted in such situations.

Fixes #3684.
  • Loading branch information
techee committed May 11, 2024
1 parent de4f029 commit 3ccd8fb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,8 +1286,24 @@ static gboolean show_tab_cb(gpointer data)
show_tab_idle = 0;
/* doc might not be valid e.g. if user closed a tab whilst Geany is opening files */
if (DOC_VALID(doc))
{
gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
gint new_page;

document_show_tab(doc);

new_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
if (cur_page == new_page)
{
/* make sure to emit the "switch-page" signal also when the correct tab
* is already selected - various UI updates and "document-activate"
* emission depend on it in on_notebook1_switch_page_after() */
g_signal_emit_by_name(GTK_NOTEBOOK(main_widgets.notebook), "switch-page",
gtk_notebook_get_nth_page(GTK_NOTEBOOK(main_widgets.notebook), cur_page),
cur_page);
}
}

return G_SOURCE_REMOVE;
}

Expand Down

0 comments on commit 3ccd8fb

Please sign in to comment.