From 6b92277f3003b71c0bc58290a9ce83424f5edc57 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 27 Sep 2017 16:36:48 -0400 Subject: MqTab: Scale favicon in tab label --- diff --git a/src/tab.c b/src/tab.c index a29c64d..04ff082 100644 --- a/src/tab.c +++ b/src/tab.c @@ -28,9 +28,9 @@ #include "tab-body.h" static void -update_tab_image(MqTab *tab, cairo_surface_t *favicon) +update_tab_image(MqTab *tab, GdkPixbuf *favicon) { - gtk_image_set_from_surface(GTK_IMAGE(tab->tab_image), favicon); + gtk_image_set_from_pixbuf(GTK_IMAGE(tab->tab_image), favicon); } static void @@ -284,10 +284,24 @@ static void favicon_cb(WebKitWebView __attribute__((unused)) *web_view, GParamSpec __attribute__((unused)) *paramspec, MqTab *tab) { - cairo_surface_t *favicon; - - favicon = webkit_web_view_get_favicon(tab->web_view); - update_tab_image(tab, favicon); + cairo_surface_t *surface; + GdkPixbuf *pixbuf; + GdkPixbuf *scaled_pixbuf; + + surface = webkit_web_view_get_favicon(tab->web_view); + if (surface) { + pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, + cairo_image_surface_get_width(surface), + cairo_image_surface_get_height(surface)); + if (pixbuf) { + scaled_pixbuf = gdk_pixbuf_scale_simple(pixbuf, 16, 16, + GDK_INTERP_BILINEAR); + g_object_unref(pixbuf); + if (scaled_pixbuf) { + update_tab_image(tab, scaled_pixbuf); + } + } + } } static void -- cgit v0.9.1