diff --git a/eek/eek-gtk-renderer.c b/eek/eek-gtk-renderer.c index 6904b43093eb315475faf396c2459536455a3308..b00d2361c0bb1b6771a23b9ad38a6dd6328272a7 100644 --- a/eek/eek-gtk-renderer.c +++ b/eek/eek-gtk-renderer.c @@ -57,10 +57,9 @@ eek_gtk_renderer_real_get_icon_surface (EekRenderer *self, gint size) { GdkPixbuf *pixbuf; - GError *error; + GError *error = NULL; cairo_surface_t *surface; - error = NULL; pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), icon_name, size, diff --git a/eek/eek-renderer.c b/eek/eek-renderer.c index bd0d9b2e2a149a70fdd503ac67d1bfa509503d93..fb38f320e1dd9298dfbb36e920edec4545957e75 100644 --- a/eek/eek-renderer.c +++ b/eek/eek-renderer.c @@ -1,17 +1,17 @@ -/* +/* * Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org> * Copyright (C) 2010-2011 Red Hat, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA @@ -109,7 +109,7 @@ create_keyboard_surface_key_callback (EekElement *element, cairo_save (data->cr); eek_element_get_bounds (element, &bounds); - cairo_translate (data->cr, bounds.x * priv->scale, bounds.y * priv->scale); + cairo_translate (data->cr, bounds.x * priv->scale, bounds.y * priv->scale); cairo_rectangle (data->cr, 0.0, 0.0, @@ -137,7 +137,7 @@ create_keyboard_surface_section_callback (EekElement *element, angle = eek_section_get_angle (EEK_SECTION(element)); cairo_rotate (data->cr, angle * G_PI / 180); - + eek_container_foreach_child (EEK_CONTAINER(element), create_keyboard_surface_key_callback, data); @@ -213,7 +213,7 @@ render_key_outline (EekRenderer *renderer, outline = eek_keyboard_get_outline (priv->keyboard, oref); if (outline == NULL) return; - + theme_node = g_object_get_data (G_OBJECT(key), active ? "theme-node-pressed" : @@ -459,7 +459,8 @@ render_key (EekRenderer *self, if (!outline_surface) { cairo_t *cr; - // Outline will be drawn on the outside of the button, so the surface needs to be bigger than the button + // Outline will be drawn on the outside of the button, so the + // surface needs to be bigger than the button outline_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int)ceil(bounds.width) + 10, @@ -485,44 +486,31 @@ render_key (EekRenderer *self, cairo_set_source_surface (cr, outline_surface, 0.0, 0.0); cairo_paint (cr); + eek_renderer_get_foreground_color (self, EEK_ELEMENT(key), &foreground); /* render icon (if any) */ symbol = eek_key_get_symbol_with_fallback (key, 0, 0); if (!symbol) return; + #define SCALE 0.8 if (eek_symbol_get_icon_name (symbol)) { + cairo_surface_t *icon_surface = eek_renderer_get_icon_surface (self, eek_symbol_get_icon_name (symbol), - MIN(bounds.width, bounds.height) * 0.5); + MIN(bounds.width, bounds.height)); if (icon_surface) { gint width = cairo_image_surface_get_width (icon_surface); gint height = cairo_image_surface_get_height (icon_surface); - gdouble scale; - - if (width < bounds.width && height < bounds.height) - scale = 1; - else { - if (height * bounds.width / width <= bounds.height) - scale = bounds.width / width; - else if (width * bounds.height / height <= bounds.width) - scale = bounds.height / height; - else { - if (width * bounds.height < height * bounds.width) - scale = width / bounds.width; - else - scale = height / bounds.height; - } - } cairo_save (cr); cairo_translate (cr, - (bounds.width - width * scale) / 2, - (bounds.height - height * scale) / 2); + (bounds.width - width * SCALE) / 2, + (bounds.height - height * SCALE) / 2); cairo_rectangle (cr, 0, 0, width, height); + cairo_scale (cr, SCALE, SCALE); cairo_clip (cr); /* Draw the shape of the icon using the foreground color */ - eek_renderer_get_foreground_color (self, EEK_ELEMENT(key), &foreground); cairo_set_source_rgba (cr, foreground.red, foreground.green, foreground.blue, @@ -546,7 +534,6 @@ render_key (EekRenderer *self, (bounds.width - extents.width / PANGO_SCALE) / 2, (bounds.height - extents.height / PANGO_SCALE) / 2); - eek_renderer_get_foreground_color (self, EEK_ELEMENT(key), &foreground); cairo_set_source_rgba (cr, foreground.red, foreground.green,