[gnome-text-editor] window: keep focus in sourceview when closing context menu
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] window: keep focus in sourceview when closing context menu
- Date: Sat, 13 Nov 2021 00:32:09 +0000 (UTC)
commit dd95474f6a68a68a8b155e2c99f53f1ce8b37989
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 12 16:32:05 2021 -0800
window: keep focus in sourceview when closing context menu
Fixes #221
src/editor-window.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
---
diff --git a/src/editor-window.c b/src/editor-window.c
index bb21597..ebd088a 100644
--- a/src/editor-window.c
+++ b/src/editor-window.c
@@ -539,6 +539,22 @@ on_tab_view_create_window_cb (EditorWindow *self,
return ret;
}
+static void
+notify_focus_widget_cb (EditorWindow *self)
+{
+ GtkWidget *widget;
+
+ g_assert (EDITOR_IS_WINDOW (self));
+
+ if (!(widget = gtk_root_get_focus (GTK_ROOT (self))))
+ {
+ EditorPage *page = editor_window_get_visible_page (self);
+
+ if (page != NULL)
+ gtk_root_set_focus (GTK_ROOT (self), GTK_WIDGET (page));
+ }
+}
+
static void
editor_window_dispose (GObject *object)
{
@@ -694,6 +710,11 @@ editor_window_init (EditorWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+ g_signal_connect (self,
+ "notify::focus-widget",
+ G_CALLBACK (notify_focus_widget_cb),
+ NULL);
+
gtk_window_set_title (GTK_WINDOW (self), _(PACKAGE_NAME));
gtk_window_set_default_size (GTK_WINDOW (self), 700, 520);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]