[epiphany] Fix Pinned tabs without favicons are completely empty



commit 446a5965a5c47ea289a4010336a3973787e3806f
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Tue Apr 23 22:02:26 2019 +0200

    Fix Pinned tabs without favicons are completely empty
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/744

 src/ephy-tab-label.c                       | 26 +++++++++++++++++++++---
 src/resources/epiphany.gresource.xml       |  1 +
 src/resources/missing-favicon-symbolic.svg | 32 ++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 3 deletions(-)
---
diff --git a/src/ephy-tab-label.c b/src/ephy-tab-label.c
index 7527287f9..913bff0a5 100644
--- a/src/ephy-tab-label.c
+++ b/src/ephy-tab-label.c
@@ -38,6 +38,7 @@ struct _EphyTabLabel {
 
   gboolean is_pinned;
   gboolean is_loading;
+  gboolean has_icon;
 };
 
 enum {
@@ -71,6 +72,19 @@ ephy_tab_label_set_spinning (EphyTabLabel *tab_label,
   tab_label->is_loading = is_spinning;
 }
 
+static void
+ephy_tab_label_update_icon (EphyTabLabel *self)
+{
+  if (!self->has_icon) {
+    g_autoptr(GdkPixbuf) pixbuf = NULL;
+
+    if (self->is_pinned)
+      pixbuf = gdk_pixbuf_new_from_resource ("/org/gnome/epiphany/missing-favicon-symbolic.svg", NULL);
+
+    gtk_image_set_from_pixbuf (GTK_IMAGE (self->icon), pixbuf);
+  }
+}
+
 static void
 ephy_tab_label_set_property (GObject      *object,
                              guint         prop_id,
@@ -96,13 +110,15 @@ ephy_tab_label_set_property (GObject      *object,
     }
     break;
   case PROP_ICON_BUF:
-    gtk_image_set_from_pixbuf (GTK_IMAGE (self->icon), g_value_get_object(value));
+    gtk_image_set_from_pixbuf (GTK_IMAGE (self->icon), g_value_get_object (value));
+    self->has_icon = g_value_get_object (value) != NULL;
+    ephy_tab_label_update_icon (self);
     break;
   case PROP_SPINNING:
-    ephy_tab_label_set_spinning (self, g_value_get_boolean(value));
+    ephy_tab_label_set_spinning (self, g_value_get_boolean (value));
     break;
   case PROP_AUDIO:
-    gtk_widget_set_visible (self->audio_button, g_value_get_boolean(value));
+    gtk_widget_set_visible (self->audio_button, g_value_get_boolean (value));
     break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -143,6 +159,7 @@ static void
 ephy_tab_label_init (EphyTabLabel *self)
 {
    gtk_widget_init_template (GTK_WIDGET (self));
+   self->has_icon = FALSE;
 }
 
 static void
@@ -285,6 +302,9 @@ ephy_tab_label_set_pinned (GtkWidget *widget,
   EphyTabLabel *self = EPHY_TAB_LABEL (widget);
 
   self->is_pinned = is_pinned;
+
+  ephy_tab_label_update_icon (self);
+
   update_label (self);
 }
 
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index e030ffe38..5da83cc74 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -5,6 +5,7 @@
     <file>computer-fail-symbolic.png</file>
     <file preprocess="xml-stripblanks" compressed="true">private-mode.svg</file>
     <file preprocess="xml-stripblanks" compressed="true">web-watermark.svg</file>
+    <file preprocess="xml-stripblanks" compressed="true">missing-favicon-symbolic.svg</file>
     <file>network-error-symbolic.png</file>
     <file>security-high-symbolic.png</file>
     <file compressed="true">about.ini</file>
diff --git a/src/resources/missing-favicon-symbolic.svg b/src/resources/missing-favicon-symbolic.svg
new file mode 100644
index 000000000..488079151
--- /dev/null
+++ b/src/resources/missing-favicon-symbolic.svg
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   height="16"
+   id="svg7384"
+   version="1.1"
+   width="16">
+  <metadata
+     id="metadata90">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title>Gnome Symbolic Icon Theme</dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <title
+     id="title9167">Gnome Symbolic Icon Theme</title>
+  <defs
+     id="defs7386" />
+  <path
+     
style="color:#bebebe;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#241f31;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-wi
 dth:2;st
 
roke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+     d="M 2.1992188 0 C 0.94446875 0 -2.9605947e-16 1.0997689 0 2.3183594 L 0 4 L 2 4 L 2 2.3183594 C 2 
2.0752625 2.1256288 2 2.1992188 2 L 4 2 L 4 0 L 2.1992188 0 z M 6 0 L 6 2 L 10 2 L 10 0 L 6 0 z M 12 0 L 12 2 
L 13.800781 2 C 13.874371 2 14 2.0752716 14 2.3183594 L 14 4 L 16 4 L 16 2.3183594 C 16 1.0997598 15.055531 
-2.9605947e-16 13.800781 0 L 12 0 z M 0 6 L 0 10 L 2 10 L 2 6 L 0 6 z M 14 6 L 14 10 L 16 10 L 16 6 L 14 6 z 
M 0 12 L 0 13.681641 C 0 14.900231 0.94447875 16 2.1992188 16 L 4 16 L 4 14 L 2.1992188 14 C 2.1256188 14 2 
13.924738 2 13.681641 L 2 12 L 0 12 z M 14 12 L 14 13.681641 C 14 13.924729 13.874381 14 13.800781 14 L 12 14 
L 12 16 L 13.800781 16 C 15.055521 16 16 14.90024 16 13.681641 L 16 12 L 14 12 z M 6 14 L 6 16 L 10 16 L 10 
14 L 6 14 z "
+     id="path983" />
+</svg>


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