[gnome-notes/wip/igaldino/new-note-title: 6/9] main-toolbar: Grab focus to title



commit 5277f0ce056a3d99b553e559296705da0cbf74d6
Author: Isaque Galdino <igaldino gmail com>
Date:   Sun Jun 9 21:52:27 2019 -0300

    main-toolbar: Grab focus to title

 data/bijiben.js                | 4 ----
 data/resources/main-toolbar.ui | 1 +
 src/bjb-main-toolbar.c         | 6 ++++++
 src/bjb-main-toolbar.h         | 2 ++
 src/bjb-window-base.c          | 1 +
 5 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/data/bijiben.js b/data/bijiben.js
index 5ac50b8..8c0a74b 100644
--- a/data/bijiben.js
+++ b/data/bijiben.js
@@ -1,7 +1,3 @@
-window.onload = function () {
-    document.getElementById('editable').focus();
-};
-
 var domModifiedTimerID = -1;
 document.addEventListener("DOMSubtreeModified", function () {
     if (domModifiedTimerID == -1) {
diff --git a/data/resources/main-toolbar.ui b/data/resources/main-toolbar.ui
index c6740e2..811ba6b 100644
--- a/data/resources/main-toolbar.ui
+++ b/data/resources/main-toolbar.ui
@@ -434,6 +434,7 @@
 
   <object class="GtkEntry" id="title_entry">
     <property name="visible">True</property>
+    <property name="can_focus">True</property>
     <property name="max-width-chars">60</property>
   </object>
 
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 04ef2f8..89958b4 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -830,3 +830,9 @@ bjb_main_toolbar_new (BjbMainView *parent,
   populate_main_toolbar(self);
   return self;
 }
+
+void
+bjb_main_toolbar_title_focus (BjbMainToolbar *self)
+{
+  gtk_widget_grab_focus (self->title_entry);
+}
diff --git a/src/bjb-main-toolbar.h b/src/bjb-main-toolbar.h
index e4dd0d7..00deea0 100644
--- a/src/bjb-main-toolbar.h
+++ b/src/bjb-main-toolbar.h
@@ -32,4 +32,6 @@ G_DECLARE_FINAL_TYPE (BjbMainToolbar, bjb_main_toolbar, BJB, MAIN_TOOLBAR, GtkHe
 BjbMainToolbar        *bjb_main_toolbar_new                       (BjbMainView *parent,
                                                                    BjbController *controller);
 
+void                   bjb_main_toolbar_title_focus               (BjbMainToolbar *self);
+
 G_END_DECLS
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index 9cd0dab..e333a82 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -632,6 +632,7 @@ bjb_window_base_switch_to_item (BjbWindowBase *self, BijiItem *item)
     bjb_window_base_switch_to (self, BJB_WINDOW_BASE_NOTE_VIEW);
     gtk_widget_show (w);
     bjb_note_view_grab_focus (self->note_view);
+    bjb_main_toolbar_title_focus (self->main_toolbar);
   }
 }
 


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