Make CanvasIcon use IconBuffer. Change the API to use

a separate property for icon_name and file_name.
This commit is contained in:
Marco Pesenti Gritti
2007-08-26 14:16:09 +02:00
parent f44c340b3a
commit 98157bbccb
13 changed files with 102 additions and 366 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ class ColorPicker(hippo.CanvasBox, hippo.CanvasItem):
self.props.orientation = hippo.ORIENTATION_HORIZONTAL
self._xo = CanvasIcon(size=style.XLARGE_ICON_SIZE,
icon_name='theme:computer-xo')
icon_name='computer-xo')
self._set_random_colors()
self._xo.connect('activated', self._xo_activated_cb)
self.append(self._xo)
+1 -1
View File
@@ -20,7 +20,7 @@ from view.BuddyMenu import BuddyMenu
class BuddyIcon(CanvasIcon):
def __init__(self, shell, buddy):
CanvasIcon.__init__(self, icon_name='theme:computer-xo',
CanvasIcon.__init__(self, icon_name='computer-xo',
xo_color=buddy.get_color())
self._shell = shell
+1 -1
View File
@@ -47,7 +47,7 @@ class DeviceView(CanvasIcon):
# Update palette
if self._model.props.charging:
status = _STATUS_CHARGING
self.props.badge_name = 'theme:badge-charging'
self.props.badge_name = 'badge-charging'
elif self._model.props.discharging:
status = _STATUS_DISCHARGING
self.props.badge_name = None
+5 -5
View File
@@ -22,7 +22,7 @@ from model.devices import device
class DeviceView(canvasicon.CanvasIcon):
def __init__(self, model):
canvasicon.CanvasIcon.__init__(self, size=style.MEDIUM_ICON_SIZE,
icon_name='theme:network-mesh')
icon_name='network-mesh')
self._model = model
model.connect('notify::state', self._state_changed_cb)
@@ -35,11 +35,11 @@ class DeviceView(canvasicon.CanvasIcon):
# FIXME Change icon colors once we have real icons
state = self._model.props.state
if state == device.STATE_ACTIVATING:
self.props.fill_color = style.COLOR_INACTIVE_FILL
self.props.stroke_color = style.COLOR_INACTIVE_STROKE
self.props.fill_color = style.COLOR_INACTIVE_FILL.get_svg()
self.props.stroke_color = style.COLOR_INACTIVE_STROKE.get_svg()
elif state == device.STATE_ACTIVATED:
self.props.fill_color = None
self.props.stroke_color = None
elif state == device.STATE_INACTIVE:
self.props.fill_color = style.COLOR_INACTIVE_FILL
self.props.stroke_color = style.COLOR_INACTIVE_STROKE
self.props.fill_color = style.COLOR_INACTIVE_FILL.get_svg()
self.props.stroke_color = style.COLOR_INACTIVE_STROKE.get_svg()
+1 -1
View File
@@ -19,4 +19,4 @@ from view.devices import deviceview
class DeviceView(deviceview.DeviceView):
def __init__(self, model):
deviceview.DeviceView.__init__(self, model)
self.props.icon_name = 'theme:network-wired'
self.props.icon_name = 'network-wired'
+4 -5
View File
@@ -18,7 +18,6 @@
from sugar.graphics.icon import get_icon_state
from sugar.graphics.icon import CanvasIcon
from sugar.graphics import style
from sugar.graphics import style
from model.devices.network import wireless
from model.devices import device
@@ -56,11 +55,11 @@ class DeviceView(CanvasIcon):
# FIXME Change icon colors once we have real icons
state = self._model.props.state
if state == device.STATE_ACTIVATING:
self.props.fill_color = style.COLOR_INACTIVE_FILL
self.props.stroke_color = style.COLOR_INACTIVE_STROKE
self.props.fill_color = style.COLOR_INACTIVE_FILL.get_svg()
self.props.stroke_color = style.COLOR_INACTIVE_STROKE.get_svg()
elif state == device.STATE_ACTIVATED:
self.props.fill_color = None
self.props.stroke_color = None
elif state == device.STATE_INACTIVE:
self.props.fill_color = style.COLOR_INACTIVE_FILL
self.props.stroke_color = style.COLOR_INACTIVE_STROKE
self.props.fill_color = style.COLOR_INACTIVE_FILL.get_svg()
self.props.stroke_color = style.COLOR_INACTIVE_STROKE.get_svg()
+3 -3
View File
@@ -28,9 +28,9 @@ from frameinvoker import FrameCanvasInvoker
class ActivityButton(IconButton):
def __init__(self, activity_info):
IconButton.__init__(self, icon_name=activity_info.icon,
stroke_color=style.COLOR_WHITE,
fill_color=style.COLOR_TRANSPARENT)
IconButton.__init__(self, file_name=activity_info.icon,
stroke_color=style.COLOR_WHITE.get_svg(),
fill_color=style.COLOR_TRANSPARENT.get_svg())
palette = Palette(activity_info.name)
palette.props.invoker = FrameCanvasInvoker(self)
+4 -4
View File
@@ -30,7 +30,7 @@ class ZoomBox(hippo.CanvasBox):
self._shell = shell
icon = IconButton(icon_name='theme:zoom-mesh')
icon = IconButton(icon_name='zoom-mesh')
icon.connect('activated',
self._level_clicked_cb,
ShellModel.ZOOM_MESH)
@@ -41,7 +41,7 @@ class ZoomBox(hippo.CanvasBox):
palette.set_group_id('frame')
icon.set_palette(palette)
icon = IconButton(icon_name='theme:zoom-friends')
icon = IconButton(icon_name='zoom-friends')
icon.connect('activated',
self._level_clicked_cb,
ShellModel.ZOOM_FRIENDS)
@@ -52,7 +52,7 @@ class ZoomBox(hippo.CanvasBox):
palette.set_group_id('frame')
icon.set_palette(palette)
icon = IconButton(icon_name='theme:zoom-home')
icon = IconButton(icon_name='zoom-home')
icon.connect('activated',
self._level_clicked_cb,
ShellModel.ZOOM_HOME)
@@ -63,7 +63,7 @@ class ZoomBox(hippo.CanvasBox):
palette.set_group_id('frame')
icon.set_palette(palette)
icon = IconButton(icon_name='theme:zoom-activity')
icon = IconButton(icon_name='zoom-activity')
icon.connect('activated',
self._level_clicked_cb,
ShellModel.ZOOM_ACTIVITY)
+12 -12
View File
@@ -94,33 +94,33 @@ class AccessPointView(PulsingIcon):
if self._model.props.state == accesspointmodel.STATE_CONNECTING:
self.props.pulse_time = 1.0
self.props.colors = [
[ style.Color(self._device_stroke),
style.Color(self._device_fill) ],
[ style.Color(self._device_stroke),
style.Color('#e2e2e2') ]
[ style.Color(self._device_stroke).get_svg(),
style.Color(self._device_fill).get_svg() ],
[ style.Color(self._device_stroke).get_svg(),
'#e2e2e2' ]
]
elif self._model.props.state == accesspointmodel.STATE_CONNECTED:
self.props.pulse_time = 2.0
self.props.colors = [
[ style.Color(self._device_stroke),
style.Color(self._device_fill) ],
[ style.Color('#ffffff'),
style.Color(self._device_fill) ]
[ style.Color(self._device_stroke).get_svg(),
style.Color(self._device_fill).get_svg() ],
[ '#ffffff',
style.Color(self._device_fill).get_svg() ]
]
elif self._model.props.state == accesspointmodel.STATE_NOTCONNECTED:
self.props.pulse_time = 0.0
self.props.colors = [
[ style.Color(self._device_stroke),
style.Color(self._device_fill) ]
[ style.Color(self._device_stroke).get_svg(),
style.Color(self._device_fill).get_svg() ]
]
_MESH_ICON_NAME = 'theme:network-mesh'
_MESH_ICON_NAME = 'network-mesh'
class MeshDeviceView(PulsingIcon):
def __init__(self, nm_device):
PulsingIcon.__init__(self, size=style.MEDIUM_ICON_SIZE,
icon_name=_MESH_ICON_NAME)
icon_name=_MESH_ICON_NAME)
self._nm_device = nm_device
self.set_tooltip(_("Mesh Network"))
+1 -1
View File
@@ -20,5 +20,5 @@ from sugar import profile
class MyIcon(CanvasIcon):
def __init__(self, size):
CanvasIcon.__init__(self, size=size,
icon_name='theme:computer-xo',
icon_name='computer-xo',
xo_color=profile.get_color())
+2 -4
View File
@@ -73,8 +73,8 @@ class ActivityIcon(CanvasIcon):
self._level = self._level_max
color = self._icon_colors[self._level]
CanvasIcon.__init__(self, icon_name=icon_name, xo_color=color,
size=style.MEDIUM_ICON_SIZE, cache=True)
CanvasIcon.__init__(self, file_name=icon_name, xo_color=color,
size=style.MEDIUM_ICON_SIZE)
self._activity = activity
self._pulse_id = 0
@@ -119,8 +119,6 @@ class ActivityIcon(CanvasIcon):
if self._pulse_id:
gobject.source_remove(self._pulse_id)
self._pulse_id = 0
# dispose of all rendered icons from launch feedback
self._clear_buffers()
def _compute_icon_colors(self):
_LEVEL_MAX = 1.6