[gnome-text-editor] focus: avoid overriding grab_focus
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] focus: avoid overriding grab_focus
- Date: Thu, 1 Jul 2021 16:16:26 +0000 (UTC)
commit db92ca59f3aa7eb3a5c70e43ed4eb6e848bad9ab
Author: Christian Hergert <chergert redhat com>
Date: Thu Jul 1 09:13:44 2021 -0700
focus: avoid overriding grab_focus
Otherwise we can break focus movements.
Fixes #91
src/editor-page-actions.c | 2 +-
src/editor-page.c | 2 +-
src/editor-search-bar-private.h | 1 +
src/editor-search-bar.c | 12 ++++--------
src/editor-session.c | 2 +-
src/editor-sidebar.c | 3 ++-
src/editor-window.c | 4 ++--
7 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/src/editor-page-actions.c b/src/editor-page-actions.c
index ca88d63..63d5de8 100644
--- a/src/editor-page-actions.c
+++ b/src/editor-page-actions.c
@@ -50,7 +50,7 @@ editor_page_actions_search_hide (GtkWidget *widget,
g_assert (EDITOR_IS_PAGE (self));
_editor_page_hide_search (self);
- gtk_widget_grab_focus (GTK_WIDGET (self));
+ editor_page_grab_focus (self);
}
static void
diff --git a/src/editor-page.c b/src/editor-page.c
index cbc645a..672a69f 100644
--- a/src/editor-page.c
+++ b/src/editor-page.c
@@ -983,7 +983,7 @@ _editor_page_set_search_visible (EditorPage *self,
gtk_revealer_set_reveal_child (self->search_revealer, search_visible);
if (search_visible)
- gtk_widget_grab_focus (GTK_WIDGET (self->search_bar));
+ _editor_search_bar_grab_focus (self->search_bar);
}
void
diff --git a/src/editor-search-bar-private.h b/src/editor-search-bar-private.h
index 047a5b7..701e708 100644
--- a/src/editor-search-bar-private.h
+++ b/src/editor-search-bar-private.h
@@ -48,5 +48,6 @@ gboolean _editor_search_bar_get_can_replace (EditorSearchBar *self);
gboolean _editor_search_bar_get_can_replace_all (EditorSearchBar *self);
void _editor_search_bar_replace (EditorSearchBar *self);
void _editor_search_bar_replace_all (EditorSearchBar *self);
+void _editor_search_bar_grab_focus (EditorSearchBar *self);
G_END_DECLS
diff --git a/src/editor-search-bar.c b/src/editor-search-bar.c
index 619a1c1..887c01d 100644
--- a/src/editor-search-bar.c
+++ b/src/editor-search-bar.c
@@ -274,14 +274,12 @@ boolean_to_mode (GBinding *binding,
return TRUE;
}
-static gboolean
-editor_search_bar_grab_focus (GtkWidget *widget)
+void
+_editor_search_bar_grab_focus (EditorSearchBar *self)
{
- EditorSearchBar *self = (EditorSearchBar *)widget;
-
- g_assert (EDITOR_IS_SEARCH_BAR (self));
+ g_return_if_fail (EDITOR_IS_SEARCH_BAR (self));
- return gtk_widget_grab_focus (GTK_WIDGET (self->search_entry));
+ gtk_widget_grab_focus (GTK_WIDGET (self->search_entry));
}
static void
@@ -422,8 +420,6 @@ editor_search_bar_class_init (EditorSearchBarClass *klass)
object_class->get_property = editor_search_bar_get_property;
object_class->set_property = editor_search_bar_set_property;
- widget_class->grab_focus = editor_search_bar_grab_focus;
-
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_css_name (widget_class, "searchbar");
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/TextEditor/ui/editor-search-bar.ui");
diff --git a/src/editor-session.c b/src/editor-session.c
index cf9c7e5..62c107e 100644
--- a/src/editor-session.c
+++ b/src/editor-session.c
@@ -707,7 +707,7 @@ editor_session_add_page (EditorSession *self,
gtk_window_present (GTK_WINDOW (window));
- gtk_widget_grab_focus (GTK_WIDGET (page));
+ editor_page_grab_focus (page);
g_signal_emit (self, signals [PAGE_ADDED], 0, window, page);
}
diff --git a/src/editor-sidebar.c b/src/editor-sidebar.c
index 3771429..0c677bb 100644
--- a/src/editor-sidebar.c
+++ b/src/editor-sidebar.c
@@ -189,7 +189,8 @@ editor_sidebar_hide_cb (GtkWidget *widget,
if ((window = gtk_widget_get_ancestor (widget, EDITOR_TYPE_WINDOW)))
{
EditorPage *page = editor_window_get_visible_page (EDITOR_WINDOW (window));
- gtk_widget_grab_focus (GTK_WIDGET (page));
+
+ editor_page_grab_focus (page);
}
}
diff --git a/src/editor-window.c b/src/editor-window.c
index 69eb5c6..a60756d 100644
--- a/src/editor-window.c
+++ b/src/editor-window.c
@@ -165,7 +165,7 @@ editor_window_notify_selected_page_cb (EditorWindow *self,
_editor_window_actions_update (self, page);
if (page != NULL)
- gtk_widget_grab_focus (GTK_WIDGET (page));
+ editor_page_grab_focus (page);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_VISIBLE_PAGE]);
@@ -599,7 +599,7 @@ _editor_window_remove_page (EditorWindow *self,
editor_window_notify_selected_page_cb (self, NULL, self->tab_view);
if (self->visible_page != NULL)
- gtk_widget_grab_focus (GTK_WIDGET (self->visible_page));
+ editor_page_grab_focus (self->visible_page);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]