diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-27 16:36:48 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-27 16:36:48 (EDT) |
commit | 6b92277f3003b71c0bc58290a9ce83424f5edc57 (patch) | |
tree | b4b662f61e8452d17224c5f2b2b43f126399b7f2 | |
parent | 63da6387f04743f2509e16e3cc212b7ef6e9aca8 (diff) | |
download | marquee-6b92277f3003b71c0bc58290a9ce83424f5edc57.zip marquee-6b92277f3003b71c0bc58290a9ce83424f5edc57.tar.gz marquee-6b92277f3003b71c0bc58290a9ce83424f5edc57.tar.bz2 |
MqTab: Scale favicon in tab label
-rw-r--r-- | src/tab.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -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 |