[epiphany] overview: Display a placeholder image on empty overview



commit a3ac79fe8995763447e5858adef7b928f8005cc7
Author: Lorenzo Tilve <ltilve igalia com>
Date:   Mon Jan 25 23:06:22 2016 +0100

    overview: Display a placeholder image on empty overview

 embed/ephy-about-handler.c |   76 +++++++++++++++++++++++++++-----------------
 src/resources/about.css    |   18 ++++++++++
 2 files changed, 65 insertions(+), 29 deletions(-)
---
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index f97f6d7..7773210 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -475,36 +475,54 @@ history_service_query_urls_cb (EphyHistoryService *history,
   if (success) {
     EphySnapshotService *snapshot_service = ephy_snapshot_service_get_default ();
 
-    for (l = urls; l; l = g_list_next (l)) {
-      EphyHistoryURL *url = (EphyHistoryURL *)l->data;
-      const char *snapshot;
-      char *thumbnail_style = NULL;
-
-      snapshot = ephy_snapshot_service_lookup_snapshot_path (snapshot_service, url->url);
-      if (!snapshot) {
-        GetSnapshotPathAsyncData *data = g_new (GetSnapshotPathAsyncData, 1);
-
-        data->url = g_strdup (url->url);
-        data->mtime = url->thumbnail_time;
-        ephy_snapshot_service_get_snapshot_path_for_url_async (ephy_snapshot_service_get_default (),
-                                                               url->url, url->thumbnail_time, NULL,
-                                                               
(GAsyncReadyCallback)got_snapshot_path_for_url_cb,
-                                                               data);
-      } else {
-        thumbnail_style = g_strdup_printf (" style=\"background: url(file://%s) no-repeat;\"", snapshot);
+    if (g_list_length (urls) > 0) {
+      for (l = urls; l; l = g_list_next (l)) {
+        EphyHistoryURL *url = (EphyHistoryURL *)l->data;
+        const char *snapshot;
+        char *thumbnail_style = NULL;
+
+        snapshot = ephy_snapshot_service_lookup_snapshot_path (snapshot_service, url->url);
+        if (!snapshot) {
+          GetSnapshotPathAsyncData *data = g_new (GetSnapshotPathAsyncData, 1);
+
+          data->url = g_strdup (url->url);
+          data->mtime = url->thumbnail_time;
+          ephy_snapshot_service_get_snapshot_path_for_url_async (ephy_snapshot_service_get_default (),
+                                                                 url->url, url->thumbnail_time, NULL,
+                                                                 
(GAsyncReadyCallback)got_snapshot_path_for_url_cb,
+                                                                 data);
+        } else {
+          thumbnail_style = g_strdup_printf (" style=\"background: url(file://%s) no-repeat;\"", snapshot);
+        }
+
+        g_string_append_printf (data_str,
+                                "<li>"
+                                "  <a class=\"overview-item\" title=\"%s\" href=\"%s\">"
+                                "    <div class=\"overview-close-button\" 
onclick=\"removeFromOverview(this.parentNode, event)\" title=\"%s\">&#10006;</div>"
+                                "    <span class=\"overview-thumbnail\"%s></span>"
+                                "    <span class=\"overview-title\">%s</span>"
+                                "  </a>"
+                                "</li>",
+                                g_markup_escape_text (url->title, -1), url->url, _("Remove from overview"),
+                                thumbnail_style ? thumbnail_style : "", url->title);
+        g_free (thumbnail_style);
       }
-
-      g_string_append_printf (data_str,
-                              "<li>"
-                              "  <a class=\"overview-item\" title=\"%s\" href=\"%s\">"
-                              "    <div class=\"overview-close-button\" 
onclick=\"removeFromOverview(this.parentNode, event)\" title=\"%s\">&#10006;</div>"
-                              "    <span class=\"overview-thumbnail\"%s></span>"
-                              "    <span class=\"overview-title\">%s</span>"
-                              "  </a>"
-                              "</li>",
-                              g_markup_escape_text (url->title, -1), url->url, _("Remove from overview"),
-                              thumbnail_style ? thumbnail_style : "", url->title);
-      g_free (thumbnail_style);
+    } else {
+      GtkIconInfo *icon_info;
+      icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
+                                              "web-browser",
+                                              256,
+                                              GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+
+        g_string_append_printf (data_str,
+                                "<li class=\"overview-empty\" >"
+                                "  <img src=\"file://%s\"/>"
+                                "  <h1>%s</h1>"
+                                "</li>",
+                               icon_info ? gtk_icon_info_get_filename (icon_info) : "",
+                                /* Displayed when opening the browser for the first time. */
+                               _("Start browsing and your most-visited sites will appear here"));
+        gtk_icon_info_free(icon_info);
     }
   }
 
diff --git a/src/resources/about.css b/src/resources/about.css
index a4f5e87..9ce676e 100644
--- a/src/resources/about.css
+++ b/src/resources/about.css
@@ -329,3 +329,21 @@ html[dir="rtl"] .overview-close-button {
 html[dir="rtl"] .overview-item {
     float: right;
 }
+
+#overview-grid li.overview-empty {
+    display: flex;
+    align-items: center;
+    margin-left: auto;
+    margin-right: auto;
+    height: 80%;
+    max-width: 800px;
+   -webkit-user-select: none;
+   -webkit-user-drag: none;
+}
+
+.overview-empty img {
+    -webkit-user-select: none;
+    -webkit-user-drag: none;
+    filter: grayscale(100%);
+    opacity: 0.2;
+}


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