diff options
author | Matthias Clasen <mclasen@redhat.com> | 2004-08-16 18:38:55 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-08-16 18:38:55 +0000 |
commit | 517c3c9db2ce5d9dbf41cca97c48a33543242431 (patch) | |
tree | ea9dcd9fd9e13ef87b0a7ade475e4e35df8eea3a /gtk/gtkiconfactory.c | |
parent | 7a3114d73a54ebcdeffd1f86bd00c7921565aba6 (diff) | |
download | gtk+-517c3c9db2ce5d9dbf41cca97c48a33543242431.tar.gz |
Doc update.
2004-08-16 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkwidget.c (gtk_widget_render_icon): Doc update.
* gtk/gtkiconfactory.c (render_icon_name_pixbuf): When the size is -1,
use the available size closest to 48. (#150147)
* gtk/gtkicontheme.c (gtk_icon_theme_get_icon_sizes): Actually return
a pointer to the beginning of the sizes array, not the end.
Diffstat (limited to 'gtk/gtkiconfactory.c')
-rw-r--r-- | gtk/gtkiconfactory.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index b3915571c1..5a93420c1c 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -1649,6 +1649,7 @@ render_icon_name_pixbuf (GtkIconSource *icon_source, GtkIconTheme *icon_theme; GtkSettings *settings; gint width, height, pixel_size; + gint *sizes, *s, dist; GError *error = NULL; if (widget && gtk_widget_has_screen (widget)) @@ -1667,8 +1668,45 @@ render_icon_name_pixbuf (GtkIconSource *icon_source, if (!gtk_icon_size_lookup_for_settings (settings, size, &width, &height)) { - g_warning ("Invalid icon size %d\n", size); - width = height = 24; + if (size == -1) + { + /* Find an available size close to 48 + */ + sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_source->source.icon_name); + dist = 1000; + width = height = 48; + for (s = sizes; *s; s++) + { + if (*s == -1) + { + width = height = 48; + break; + } + if (*s < 48) + { + if (48 - *s < dist) + { + width = height = *s; + dist = 48 - *s; + } + } + else + { + if (*s - 48 < dist) + { + width = height = *s; + dist = *s - 48; + } + } + } + + g_free (sizes); + } + else + { + g_warning ("Invalid icon size %d\n", size); + width = height = 24; + } } pixel_size = MIN (width, height); |