Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-07-09 15:44:42 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-07-09 15:44:42 (GMT)
commit57e5bc085f462e566d458773b3e0b3aacb6d733f (patch)
treeae90e4cc0d6a038d275578457dfe7364e0bf586c
parent1166a79a395753cc8e6f5e6a36cf402d8b86f9de (diff)
Removed some redundancy between CanvasIcon and Icon; temp. workaround to EventBox transparency issue
-rw-r--r--src/sugar/graphics/icon.py52
1 files changed, 18 insertions, 34 deletions
diff --git a/src/sugar/graphics/icon.py b/src/sugar/graphics/icon.py
index e8bf09c..2758b58 100644
--- a/src/sugar/graphics/icon.py
+++ b/src/sugar/graphics/icon.py
@@ -29,6 +29,7 @@ import gobject
import gtk
import cairo
+from sugar.graphics import style
from sugar.graphics.xocolor import XoColor
from sugar.util import LRU
@@ -100,8 +101,6 @@ class _IconBuffer(object):
self.cache = False
self.scale = 1.0
- # hippo.cairo_surface_from_gdk_pixbuf(pixbuf) -> pixbuf.cairo_create()
-
def _get_cache_key(self, sensitive):
if self.background_color is None:
color = None
@@ -429,15 +428,6 @@ class Icon(gtk.Image):
y = math.floor(allocation.y + ypad +
(allocation.height - requisition[1]) * yalign)
- '''
- if allocation.x != -1:
- logging.debug('DO_EXPOSE_EVENT (%d %d) (%d %d) (%d %d) (%f %f) (%d, %d)',
- allocation.x, allocation.y,
- allocation.width, allocation.height,
- requisition[0], requisition[1],
- xalign, yalign, x, y)
- '''
-
if self.window is not None:
cr = self.window.cairo_create()
cr.set_source_surface(surface, x, y)
@@ -555,6 +545,10 @@ class CanvasIcon(gtk.EventBox):
gtk.EventBox.__init__(self)
+ # FIXME: This seems to set the bgcolor to White, not transparent
+ self.modify_bg(gtk.STATE_NORMAL,
+ style.COLOR_TRANSPARENT.get_gdk_color())
+
vbox = gtk.VBox()
self.add(vbox)
vbox.show()
@@ -563,6 +557,7 @@ class CanvasIcon(gtk.EventBox):
self._palette_invoker = CanvasInvoker()
# Add an Icon to the EventBox
+ # Kludge: CanvasIcon uses slightly different props names than Icon
if 'file_name' in kwargs:
if 'size' in kwargs:
logging.debug('name %s size %d', kwargs['file_name'],
@@ -591,8 +586,6 @@ class CanvasIcon(gtk.EventBox):
self.connect('destroy', self.__destroy_cb)
- # _buffer belongs to _icon
-
def _emit_paint_needed_icon_area(self):
surface = self._icon._buffer.get_surface()
if surface:
@@ -638,9 +631,7 @@ class CanvasIcon(gtk.EventBox):
\"\"\"
"""
- if self._icon._buffer.file_name != value:
- self._icon._buffer.file_name = value
- self.emit_paint_needed(0, 0, -1, -1)
+ self._icon.set_file(value)
def get_file_name(self):
"""
@@ -653,7 +644,7 @@ class CanvasIcon(gtk.EventBox):
file name :
"""
- return self._icon._buffer.file_name
+ return self._icon.get_file()
file_name = gobject.property(
type=object, getter=get_file_name, setter=set_file_name)
@@ -700,9 +691,7 @@ class CanvasIcon(gtk.EventBox):
None
"""
- if self._icon._buffer.xo_color != value:
- self._icon._buffer.xo_color = value
- self._emit_paint_needed_icon_area()
+ self._icon.set_xo_color(value)
xo_color = gobject.property(
type=object, getter=None, setter=set_xo_color)
@@ -718,9 +707,12 @@ class CanvasIcon(gtk.EventBox):
None
"""
+ '''
if self._icon._buffer.fill_color != value:
self._icon._buffer.fill_color = value
self._emit_paint_needed_icon_area()
+ '''
+ self._icon.set_fill_color(value)
def get_fill_color(self):
"""
@@ -733,7 +725,7 @@ class CanvasIcon(gtk.EventBox):
fill color :
"""
- return self._icon._buffer.fill_color
+ return self._icon.get_fill_color()
fill_color = gobject.property(
type=object, getter=get_fill_color, setter=set_fill_color)
@@ -749,9 +741,7 @@ class CanvasIcon(gtk.EventBox):
None
"""
- if self._icon._buffer.stroke_color != value:
- self._icon._buffer.stroke_color = value
- self._emit_paint_needed_icon_area()
+ self._icon.set_stroke_color(value)
def get_stroke_color(self):
"""
@@ -764,7 +754,7 @@ class CanvasIcon(gtk.EventBox):
stroke color :
"""
- return self._icon._buffer.stroke_color
+ return self._icon.get_stroke_color()
stroke_color = gobject.property(
type=object, getter=get_stroke_color, setter=set_stroke_color)
@@ -811,11 +801,7 @@ class CanvasIcon(gtk.EventBox):
None
"""
- if self._icon._buffer.width != value:
- self._icon._buffer.width = value
- self._icon._buffer.height = value
- self._icon.do_size_request([value, value])
- self.emit_request_changed()
+ self._icon.do_size_request([value, value])
def get_size(self):
"""
@@ -937,9 +923,7 @@ class CanvasIcon(gtk.EventBox):
None
"""
- if self._icon._buffer.badge_name != value:
- self._icon._buffer.badge_name = value
- self.emit_paint_needed(0, 0, -1, -1)
+ self._icon.set_badge_name(value)
def get_badge_name(self):
"""
@@ -952,7 +936,7 @@ class CanvasIcon(gtk.EventBox):
badge name :
"""
- return self._icon._buffer.badge_name
+ return self._icon.get_badge_name()
badge_name = gobject.property(
type=object, getter=get_badge_name, setter=set_badge_name)