[epiphany] bookmark-row: Display URL for bookmarks without title



commit e5051738393947c85b3fd1af583e5ef568e0bcaf
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Fri Dec 29 14:31:00 2017 -0600

    bookmark-row: Display URL for bookmarks without title
    
    Bookmarks don't have to have a title. In that case, we should fall back
    to displaying the URL.
    
    Bookmarks don't have to have a URL either, but in that case, blank is
    probably the best we can do.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792048

 src/bookmarks/ephy-bookmark-row.c |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmark-row.c b/src/bookmarks/ephy-bookmark-row.c
index 5027444..7ac417a 100644
--- a/src/bookmarks/ephy-bookmark-row.c
+++ b/src/bookmarks/ephy-bookmark-row.c
@@ -157,6 +157,31 @@ favicon_image_destroyed (EphyBookmarkRow *self,
   self->favicon_image = NULL;
 }
 
+static gboolean
+transform_bookmark_title (GBinding     *binding,
+                          const GValue *from_value,
+                          GValue       *to_value,
+                          gpointer      user_data)
+{
+  const char *title;
+
+  title = g_value_get_string (from_value);
+
+  if (strlen (title) == 0) {
+    EphyBookmark *bookmark;
+    const char *url;
+
+    bookmark = EPHY_BOOKMARK (user_data);
+    url = ephy_bookmark_get_url (bookmark);
+
+    g_value_set_string (to_value, url);
+  } else {
+    g_value_set_string (to_value, title);
+  }
+
+  return TRUE;
+}
+
 static void
 ephy_bookmark_row_constructed (GObject *object)
 {
@@ -166,9 +191,12 @@ ephy_bookmark_row_constructed (GObject *object)
 
   G_OBJECT_CLASS (ephy_bookmark_row_parent_class)->constructed (object);
 
-  g_object_bind_property (self->bookmark, "title",
-                          self->title_label, "label",
-                          G_BINDING_SYNC_CREATE);
+  g_object_bind_property_full (self->bookmark, "title",
+                               self->title_label, "label",
+                               G_BINDING_SYNC_CREATE,
+                               transform_bookmark_title,
+                               NULL,
+                               self->bookmark, NULL);
 
   database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
   webkit_favicon_database_get_favicon (database,


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