[gnome-text-editor] page: add focus helper



commit 12860f34029eb32e6a2e1084fdacb0e2e5cd4eef
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jul 1 09:08:26 2021 -0700

    page: add focus helper

 src/editor-page.c | 23 +++++++++--------------
 src/editor-page.h |  1 +
 2 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/src/editor-page.c b/src/editor-page.c
index e86e02c..cbc645a 100644
--- a/src/editor-page.c
+++ b/src/editor-page.c
@@ -300,18 +300,6 @@ editor_page_constructed (GObject *object)
   editor_page_document_notify_language_cb (self, NULL, self->document);
 }
 
-static gboolean
-editor_page_grab_focus (GtkWidget *widget)
-{
-  EditorPage *self = (EditorPage *)widget;
-
-  g_assert (EDITOR_IS_PAGE (self));
-
-  _editor_page_raise (self);
-
-  return gtk_widget_grab_focus (GTK_WIDGET (self->view));
-}
-
 static gboolean
 editor_page_drop_target_drop (EditorPage     *self,
                               const GValue   *value,
@@ -473,8 +461,6 @@ editor_page_class_init (EditorPageClass *klass)
   object_class->get_property = editor_page_get_property;
   object_class->set_property = editor_page_set_property;
 
-  widget_class->grab_focus = editor_page_grab_focus;
-
   properties [PROP_BUSY] =
     g_param_spec_boolean ("busy",
                           "Busy",
@@ -1159,3 +1145,12 @@ _editor_page_discard_changes (EditorPage *self)
   _editor_page_raise (self);
   _editor_page_discard_changes_async (self, NULL, NULL, NULL);
 }
+
+void
+editor_page_grab_focus (EditorPage *self)
+{
+  g_return_if_fail (EDITOR_IS_PAGE (self));
+
+  _editor_page_raise (self);
+  gtk_widget_grab_focus (GTK_WIDGET (self->view));
+}
diff --git a/src/editor-page.h b/src/editor-page.h
index a87b424..c3b8c28 100644
--- a/src/editor-page.h
+++ b/src/editor-page.h
@@ -36,6 +36,7 @@ gboolean        editor_page_get_can_save        (EditorPage     *self);
 gboolean        editor_page_get_is_modified     (EditorPage     *self);
 gboolean        editor_page_is_active           (EditorPage     *self);
 gboolean        editor_page_is_draft            (EditorPage     *self);
+void            editor_page_grab_focus          (EditorPage     *self);
 gchar          *editor_page_dup_title           (EditorPage     *self);
 gchar          *editor_page_dup_subtitle        (EditorPage     *self);
 gchar          *editor_page_dup_position_label  (EditorPage     *self);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]