summaryrefslogtreecommitdiffstats
path: root/src/widgets/icon.cpp
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2009-03-31 08:52:55 +0000
committerjoncruz <joncruz@users.sourceforge.net>2009-03-31 08:52:55 +0000
commit8a93483aa38d878c1631afbc388f9ffac87e5b85 (patch)
tree533e30a07c15a8e20bfd0ec319ddc9ad9787d071 /src/widgets/icon.cpp
parent* [INTL:*] update_po_files.sh (diff)
downloadinkscape-8a93483aa38d878c1631afbc388f9ffac87e5b85.tar.gz
inkscape-8a93483aa38d878c1631afbc388f9ffac87e5b85.zip
Fixed icon blurriness due to theme changing icon sizes
(bzr r7596)
Diffstat (limited to 'src/widgets/icon.cpp')
-rw-r--r--src/widgets/icon.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 220ffc722..48ea1b457 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -217,7 +217,7 @@ void sp_icon_fetch_pixbuf( SPIcon *icon )
icon->psize = sp_icon_get_phys_size(icon->lsize);
GdkPixbuf *pb;
-
+
pb = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), icon->name, icon->psize,
(GtkIconLookupFlags) 0, NULL);
if (!pb) {
@@ -566,6 +566,18 @@ int sp_icon_get_phys_size(int size)
init = true;
}
+ // Fixup workaround
+ if ((size == GTK_ICON_SIZE_MENU) || (size == GTK_ICON_SIZE_SMALL_TOOLBAR) || (size == GTK_ICON_SIZE_LARGE_TOOLBAR)) {
+ gint width = 0;
+ gint height = 0;
+ if ( gtk_icon_size_lookup( static_cast<GtkIconSize>(size), &width, &height ) ) {
+ int newSize = std::max( width, height );
+ if (newSize != vals[size]) {
+ vals[size] = newSize;
+ }
+ }
+ }
+
return vals[size];
}
@@ -955,7 +967,7 @@ bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize)
}
if (!pb) {
if (dump) {
- g_message("prerender_icon [%s] %d", name, psize);
+ g_message("prerender_icon [%s] %d:%d", name, lsize, psize);
}
guchar* px = load_svg_pixels(name, lsize, psize);
if ( !px ) {
@@ -1014,21 +1026,23 @@ static GdkPixbuf *sp_icon_image_load_svg(gchar const *name, GtkIconSize lsize, u
void sp_icon_overlay_pixels(guchar *px, int width, int height, int stride,
unsigned r, unsigned g, unsigned b)
{
- for ( int y = 0; y < height; y += 4 ) {
+ int bytesPerPixel = 4;
+ int spacing = 4;
+ for ( int y = 0; y < height; y += spacing ) {
guchar *ptr = px + y * stride;
- for ( int x = 0; x < width; x += 4 ) {
+ for ( int x = 0; x < width; x += spacing ) {
*(ptr++) = r;
*(ptr++) = g;
*(ptr++) = b;
*(ptr++) = 0xff;
- ptr += 4 * 3;
+ ptr += bytesPerPixel * (spacing - 1);
}
}
if ( width > 1 && height > 1 ) {
// point at the last pixel
- guchar *ptr = px + ((height-1) * stride) + ((width - 1) * 4);
+ guchar *ptr = px + ((height-1) * stride) + ((width - 1) * bytesPerPixel);
if ( width > 2 ) {
px[4] = r;