[gtk+] header bar: Show a non-pixellated app icon



commit 84c7f6c747e646e45c0a2297ebd30a198b394b5a
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 30 18:42:20 2015 -0400

    header bar: Show a non-pixellated app icon
    
    Load a hi-dpi icon when we are running with scale=2.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751787

 gtk/gtkheaderbar.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 7589e1f..042bb42 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -220,18 +220,25 @@ _gtk_header_bar_update_window_icon (GtkHeaderBar *bar,
 {
   GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
   GdkPixbuf *pixbuf;
+  gint scale;
 
   if (priv->titlebar_icon == NULL)
     return FALSE;
 
+  scale = gtk_widget_get_scale_factor (priv->titlebar_icon);
   if (GTK_IS_BUTTON (gtk_widget_get_parent (priv->titlebar_icon)))
-    pixbuf = gtk_window_get_icon_for_size (window, 16);
+    pixbuf = gtk_window_get_icon_for_size (window, scale * 16);
   else
-    pixbuf = gtk_window_get_icon_for_size (window, 20);
+    pixbuf = gtk_window_get_icon_for_size (window, scale * 20);
 
   if (pixbuf)
     {
-      gtk_image_set_from_pixbuf (GTK_IMAGE (priv->titlebar_icon), pixbuf);
+      cairo_surface_t *surface;
+
+      surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, gtk_widget_get_window 
(priv->titlebar_icon));
+
+      gtk_image_set_from_surface (GTK_IMAGE (priv->titlebar_icon), surface);
+      cairo_surface_destroy (surface);
       g_object_unref (pixbuf);
       gtk_widget_show (priv->titlebar_icon);
 


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