aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-03-03 10:44:10 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-03-03 10:44:10 +0100
commit8a1bdd708c6bca61cc35589c132bf4bb98069a64 (patch)
treeeb8327f993a1606ac6f7a4eef118c12cda7fc006
parentacf1752ffbac11c5b0422adc7cc693cc78bac6b9 (diff)
downloadlibayatana-indicator-8a1bdd708c6bca61cc35589c132bf4bb98069a64.tar.gz
libayatana-indicator-8a1bdd708c6bca61cc35589c132bf4bb98069a64.tar.bz2
libayatana-indicator-8a1bdd708c6bca61cc35589c132bf4bb98069a64.zip
IndicatorLoader: Make sure that we load the icon at its original size, if not higher than IMAGE_SIZE
In this way icons such as the battery one won't be shrunk.
-rw-r--r--libindicator/indicator-image-helper.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c
index a38015c..da6a4e8 100644
--- a/libindicator/indicator-image-helper.c
+++ b/libindicator/indicator-image-helper.c
@@ -63,24 +63,24 @@ refresh_image (GtkImage * image)
icon_filename = gtk_icon_info_get_filename(icon_info);
}
- if (icon_filename == NULL && !G_IS_BYTES_ICON (icon_names)) {
+ if (icon_filename == NULL && !G_IS_BYTES_ICON(icon_names)) {
/* show a broken image if we don't have a filename or image data */
- gtk_image_set_from_icon_name (image, "image-missing", GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_image_set_from_icon_name(image, "image-missing", GTK_ICON_SIZE_LARGE_TOOLBAR);
return;
}
if (icon_info != NULL) {
- gtk_image_set_from_gicon (image, icon_names, GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_image_set_from_gicon(image, icon_names, GTK_ICON_SIZE_LARGE_TOOLBAR);
} else if (icon_filename != NULL) {
- gtk_image_set_from_icon_name (image, icon_filename, GTK_ICON_SIZE_LARGE_TOOLBAR);
- } else {
+ gtk_image_set_from_file(image, icon_filename);
+ } else if (G_IS_LOADABLE_ICON(icon_names)) {
/* Build a pixbuf if needed */
GdkPixbuf * pixbuf = NULL;
GError * error = NULL;
- GInputStream * stream = g_loadable_icon_load (G_LOADABLE_ICON (icon_names), ICON_SIZE, NULL, NULL, &error);
+ GInputStream * stream = g_loadable_icon_load(G_LOADABLE_ICON(icon_names), ICON_SIZE, NULL, NULL, &error);
if (stream != NULL) {
- pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, &error);
+ pixbuf = gdk_pixbuf_new_from_stream(stream, NULL, &error);
g_input_stream_close (stream, NULL, NULL);
g_object_unref (stream);
@@ -108,6 +108,19 @@ refresh_image (GtkImage * image)
}
}
+ /* Make sure that we load the icon at its original size, if not higher than IMAGE_SIZE */
+ gint pixel_size = 0;
+
+ if (icon_filename) {
+ gint height;
+ gdk_pixbuf_get_file_info(icon_filename, NULL, &height);
+
+ if (height > ICON_SIZE)
+ pixel_size = ICON_SIZE;
+ }
+
+ gtk_image_set_pixel_size(image, pixel_size);
+
if (icon_info != NULL) {
#if GTK_CHECK_VERSION(3, 8, 0)
g_object_unref(icon_info);