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



commit cf8b27ef5567d82343c24ee00bb23d77a163bd7f
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]