From 5802d67ee107ef82963770257071a779c4741a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= Date: Mon, 13 Jan 2014 16:57:22 -0300 Subject: [PATCH] Icon: deprecate icon_size pixel_size should be always used now. Change SMALL_ICON_SIZE to cover the other sizes at settings.ini. Adds a transformation to keep backwards compatibility for some time. This will be removed in the future. --- src/sugar3/graphics/icon.py | 30 ++++++++++++++++++++++++------ src/sugar3/graphics/style.py | 2 +- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py index ed499d2c..8ae1b34c 100644 --- a/src/sugar3/graphics/icon.py +++ b/src/sugar3/graphics/icon.py @@ -32,6 +32,7 @@ from gi.repository import GdkPixbuf from gi.repository import Rsvg import cairo +from sugar3.graphics import style from sugar3.graphics.xocolor import XoColor from sugar3.util import LRU @@ -238,10 +239,11 @@ class _IconBuffer(object): icon_source.set_direction_wildcarded(False) icon_source.set_size_wildcarded(False) - style = widget.get_style() - pixbuf = style.render_icon(icon_source, widget.get_direction(), - Gtk.StateType.INSENSITIVE, -1, widget, - 'sugar-icon') + widget_style = widget.get_style() + pixbuf = widget_style.render_icon( + icon_source, widget.get_direction(), + Gtk.StateType.INSENSITIVE, -1, widget, + 'sugar-icon') return pixbuf @@ -335,6 +337,10 @@ class Icon(Gtk.Image): __gtype_name__ = 'SugarIcon' + #FIXME: deprecate icon_size + _MENU_SIZES = (Gtk.IconSize.MENU, Gtk.IconSize.DND, + Gtk.IconSize.SMALL_TOOLBAR, Gtk.IconSize.BUTTON) + def __init__(self, **kwargs): self._buffer = _IconBuffer() # HACK: need to keep a reference to the path so it doesn't get garbage @@ -344,6 +350,10 @@ class Icon(Gtk.Image): self._alpha = 1.0 self._scale = 1.0 + #FIXME: deprecate icon_size + if 'icon_size' in kwargs: + logging.warning("icon_size is deprecated. Use pixel_size instead.") + GObject.GObject.__init__(self, **kwargs) def get_file(self): @@ -362,10 +372,18 @@ class Icon(Gtk.Image): if self._buffer.file_name != self.props.file: self._buffer.file_name = self.props.file + #FIXME: deprecate icon_size + pixel_size = None if self.props.pixel_size == -1: - valid_, width, height = Gtk.icon_size_lookup(self.props.icon_size) + if self.props.icon_size in self._MENU_SIZES: + pixel_size = style.SMALL_ICON_SIZE + else: + pixel_size = style.STANDARD_ICON_SIZE else: - width = height = self.props.pixel_size + pixel_size = self.props.pixel_size + + width = height = pixel_size + if self._buffer.width != width or self._buffer.height != height: self._buffer.width = width self._buffer.height = height diff --git a/src/sugar3/graphics/style.py b/src/sugar3/graphics/style.py index bc6ab5a0..54705e10 100644 --- a/src/sugar3/graphics/style.py +++ b/src/sugar3/graphics/style.py @@ -110,7 +110,7 @@ GRID_CELL_SIZE = zoom(75) LINE_WIDTH = zoom(2) STANDARD_ICON_SIZE = zoom(55) -SMALL_ICON_SIZE = zoom(55 * 0.5) +SMALL_ICON_SIZE = zoom(33) MEDIUM_ICON_SIZE = zoom(55 * 1.5) LARGE_ICON_SIZE = zoom(55 * 2.0) XLARGE_ICON_SIZE = zoom(55 * 2.75)