diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-07-17 00:59:34 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-07-17 00:59:34 -0400 |
commit | f3ef3165df34ab509a7165165360680bf30dd0cb (patch) | |
tree | f2b2168a6bc5d62f5c6f1b7e34e22406a8c74886 /gtk/gtkicontheme.c | |
parent | a80e77ff95b6c87d54f4e63be9f802b1d5474def (diff) | |
download | gtk+-f3ef3165df34ab509a7165165360680bf30dd0cb.tar.gz |
GtkIconTheme: Make spinners scale in hi-dpi
The Adwaita icon theme ships spinners in a scalable directory
with MaxSize=32 and Scale=1. One way to make them scale up in
hi-dpi would be to add an @2 directory with MaxSize=32 and Scale=2,
but that directory would also be consulted in non hi-dpi situations
and give us an effective spinner max size of 64.
Instead, treat svg icons implicitly as hi-dpi, and scale them
up to MaxSize * 2 when in hi-dpi.
Diffstat (limited to 'gtk/gtkicontheme.c')
-rw-r--r-- | gtk/gtkicontheme.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 465970d559..e4e30d76b9 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -3768,6 +3768,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info) gint image_width, image_height, image_size; gint scaled_desired_size; GdkPixbuf *source_pixbuf; + gdouble dir_scale; if (icon_info->pixbuf) { @@ -3783,6 +3784,8 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info) scaled_desired_size = icon_info->desired_size * icon_info->desired_scale; + dir_scale = icon_info->dir_scale; + /* In many cases, the scale can be determined without actual access * to the icon file. This is generally true when we have a size * for the directory where the icon is; the image size doesn't @@ -3796,12 +3799,20 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info) icon_info->scale = icon_info->unscaled_scale; else if (icon_info->dir_type == ICON_THEME_DIR_SCALABLE) { - if (scaled_desired_size < icon_info->min_size * icon_info->dir_scale) + /* For svg icons, treat scalable directories as if they had + * a Scale=<desired_scale> entry. In particular, this means + * spinners that are restriced to size 32 will loaded at size + * up to 64 with Scale=2. + */ + if (icon_info->is_svg) + dir_scale = icon_info->desired_scale; + + if (scaled_desired_size < icon_info->min_size * dir_scale) icon_info->scale = (gdouble) icon_info->min_size / (gdouble) icon_info->dir_size; - else if (scaled_desired_size > icon_info->max_size * icon_info->dir_scale) + else if (scaled_desired_size > icon_info->max_size * dir_scale) icon_info->scale = (gdouble) icon_info->max_size / (gdouble) icon_info->dir_size; else - icon_info->scale = (gdouble) scaled_desired_size / (icon_info->dir_size * icon_info->dir_scale); + icon_info->scale = (gdouble) scaled_desired_size / (icon_info->dir_size * dir_scale); } /* At this point, we need to actually get the icon; either from the @@ -3819,7 +3830,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info) if (icon_info->forced_size) size = scaled_desired_size; else - size = icon_info->dir_size * icon_info->dir_scale * icon_info->scale; + size = icon_info->dir_size * dir_scale * icon_info->scale; source_pixbuf = gdk_pixbuf_new_from_resource_at_scale (icon_info->filename, size, size, TRUE, &icon_info->load_error); @@ -3849,7 +3860,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info) if (icon_info->forced_size) size = scaled_desired_size; else - size = icon_info->dir_size * icon_info->dir_scale * icon_info->scale; + size = icon_info->dir_size * dir_scale * icon_info->scale; source_pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, size, size, TRUE, NULL, |