[geany/geany] dd4c85: Fix focusing the Terminal tab in the message window
Colomban Wendling
git-noreply at geany.org
Fri Oct 21 13:37:56 UTC 2016
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Tue, 30 Aug 2016 14:19:58 UTC
Commit: dd4c851cabad8f52c7aba00f71e675740217ffa2
https://github.com/geany/geany/commit/dd4c851cabad8f52c7aba00f71e675740217ffa2
Log Message:
-----------
Fix focusing the Terminal tab in the message window
Use more generic code to not fall into the same issue next time layout
changes, and to potentially support plugin tabs in the message window.
Fixes #1198.
Modified Paths:
--------------
src/keybindings.c
Modified: src/keybindings.c
33 lines changed, 31 insertions(+), 2 deletions(-)
===================================================================
@@ -1738,14 +1738,43 @@ static void focus_sidebar(void)
}
+static GtkWidget *find_focus_widget(GtkWidget *widget)
+{
+ GtkWidget *focus = NULL;
+
+ if (GTK_IS_BIN(widget)) /* optimized simple case */
+ focus = find_focus_widget(gtk_bin_get_child(GTK_BIN(widget)));
+ else if (GTK_IS_CONTAINER(widget))
+ {
+ GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
+ GList *node;
+
+ for (node = children; node && ! focus; node = node->next)
+ focus = find_focus_widget(node->data);
+ g_list_free(children);
+ }
+
+ /* Some containers handled above might not have children and be what we want to focus
+ * (e.g. GtkTreeView), so focus that if possible and we don't have anything better */
+ if (! focus && gtk_widget_get_can_focus(widget))
+ focus = widget;
+
+ return focus;
+}
+
+
static void focus_msgwindow(void)
{
if (ui_prefs.msgwindow_visible)
{
gint page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK(msgwindow.notebook));
- GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(msgwindow.notebook), page_num);
+ GtkWidget *widget = gtk_notebook_get_nth_page(GTK_NOTEBOOK(msgwindow.notebook), page_num);
- gtk_widget_grab_focus(gtk_bin_get_child(GTK_BIN(page)));
+ widget = find_focus_widget(widget);
+ if (widget)
+ gtk_widget_grab_focus(widget);
+ else
+ utils_beep();
}
}
--------------
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