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.
This commit is contained in:
parent
1ced93e14b
commit
5802d67ee1
@ -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,8 +239,9 @@ 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(),
|
||||
widget_style = widget.get_style()
|
||||
pixbuf = widget_style.render_icon(
|
||||
icon_source, widget.get_direction(),
|
||||
Gtk.StateType.INSENSITIVE, -1, widget,
|
||||
'sugar-icon')
|
||||
|
||||
@ -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:
|
||||
width = height = self.props.pixel_size
|
||||
pixel_size = style.STANDARD_ICON_SIZE
|
||||
else:
|
||||
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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user