[gnome-notes/wip/igaldino/new-note-title: 17/17] main-toolbar: Handle empty title



commit 57d82eb969ec571939c3176bd860324f044d42b1
Author: Isaque Galdino <igaldino gmail com>
Date:   Tue Jul 30 01:08:11 2019 -0300

    main-toolbar: Handle empty title

 src/bjb-main-toolbar.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index d89475d..18fdd6b 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -386,7 +386,7 @@ on_note_renamed (BijiItem *note,
   const gchar *str;
 
   str = biji_item_get_title (note);
-  if (str == NULL)
+  if (str == NULL || strlen(str) == 0)
     str = _("Untitled");
 
   gtk_header_bar_set_title (GTK_HEADER_BAR (self), str);
@@ -439,7 +439,9 @@ static void
 on_title_changed (BjbMainToolbar *self,
                   GtkEntry       *title)
 {
-  biji_note_obj_set_title (self->note, gtk_entry_get_text (title));
+  const char *str = gtk_entry_get_text (title);
+  if (strlen (str) > 0)
+    biji_note_obj_set_title (self->note, str);
 }
 
 static void
@@ -844,5 +846,5 @@ bjb_main_toolbar_new (BjbMainView *parent,
 void
 bjb_main_toolbar_title_focus (BjbMainToolbar *self)
 {
-  gtk_widget_grab_focus (self->title_entry);
+  gtk_entry_grab_focus_without_selecting (GTK_ENTRY (self->title_entry));
 }


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