diff options
author | Victor Kareh <[email protected]> | 2018-04-30 22:02:05 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-05-12 22:34:25 +0200 |
commit | 311ae4eb6690a2d089014622bd340aa79a33409c (patch) | |
tree | 266333cffb7425143f620e87cb2a26854d41653a /cpufreq/src | |
parent | e83811d07c2b598ebe46f9e54cb9dbcc1ea87f18 (diff) | |
download | mate-applets-311ae4eb6690a2d089014622bd340aa79a33409c.tar.bz2 mate-applets-311ae4eb6690a2d089014622bd340aa79a33409c.tar.xz |
Convert applet icons from pixbuf to surfaces
This improves support for HiDPI by loading properly scaled surfaces for applets.
Diffstat (limited to 'cpufreq/src')
-rw-r--r-- | cpufreq/src/cpufreq-applet.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c index 03609bc5..ff04bea4 100644 --- a/cpufreq/src/cpufreq-applet.c +++ b/cpufreq/src/cpufreq-applet.c @@ -62,7 +62,7 @@ struct _CPUFreqApplet { GtkWidget *box; GtkWidget *labels_box; GtkWidget *container; - GdkPixbuf *pixbufs[5]; + cairo_surface_t *surfaces[5]; gint max_label_width; gint max_perc_width; @@ -245,9 +245,9 @@ cpufreq_applet_dispose (GObject *widget) } for (i = 0; i <= 3; i++) { - if (applet->pixbufs[i]) { - g_object_unref (G_OBJECT (applet->pixbufs[i])); - applet->pixbufs[i] = NULL; + if (applet->surfaces[i]) { + cairo_surface_destroy (applet->surfaces[i]); + applet->surfaces[i] = NULL; } } @@ -646,6 +646,8 @@ static void cpufreq_applet_pixmap_set_image (CPUFreqApplet *applet, gint perc) { gint image; + gint scale; + gint size = 24; /* FIXME */ /* 0-29 -> 25% * 30-69 -> 50% @@ -663,12 +665,18 @@ cpufreq_applet_pixmap_set_image (CPUFreqApplet *applet, gint perc) else image = 4; - if (applet->pixbufs[image] == NULL) { - applet->pixbufs[image] = gdk_pixbuf_new_from_file_at_size (cpufreq_icons[image], - 24, 24, NULL); + scale = gtk_widget_get_scale_factor (GTK_WIDGET (applet->icon)); + + if (applet->surfaces[image] == NULL) { + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_scale (cpufreq_icons[image], + size * scale, + size * scale, + TRUE, + NULL); + applet->surfaces[image] = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, NULL); } - gtk_image_set_from_pixbuf (GTK_IMAGE (applet->icon), applet->pixbufs[image]); + gtk_image_set_from_surface (GTK_IMAGE (applet->icon), applet->surfaces[image]); } static gboolean |