[Sugar-devel] [PATCH sugar-toolkit-gtk3 v2] Fix the drawing of ColorToolButton, RadioToolButton and ToggleToolButton
Manuel Quiñones
manuq at laptop.org
Thu Aug 23 08:33:59 EDT 2012
Draw a black background in the buttons when the palette is up, as
commit 01a06943 did with the ToolButton. As the comment for that
commit states, we can change the prelight background color in the
theme, but not when the mouse moves over the Palette.
To test the buttons, I provide a patch for HelloWorld activity [1].
They are added in the main toolbar.
Signed-off-by: Manuel Quiñones <manuq at laptop.org>
---
[1] http://dev.laptop.org/~manuq/shell-port/test_gtk3_buttons.patch
v2: Paint the background color as per Simon's feedback.
---
src/sugar3/graphics/colorbutton.py | 20 ++++++++++----------
src/sugar3/graphics/radiotoolbutton.py | 20 ++++++++++----------
src/sugar3/graphics/toggletoolbutton.py | 20 ++++++++++----------
3 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/src/sugar3/graphics/colorbutton.py b/src/sugar3/graphics/colorbutton.py
index 95d023a..823fd61 100644
--- a/src/sugar3/graphics/colorbutton.py
+++ b/src/sugar3/graphics/colorbutton.py
@@ -523,20 +523,20 @@ class ColorToolButton(Gtk.ToolItem):
title = GObject.property(type=str, getter=get_title, setter=set_title)
- def do_expose_event(self, event):
+ def do_draw(self, cr):
child = self.get_child()
allocation = self.get_allocation()
if self._palette and self._palette.is_up():
invoker = self._palette.props.invoker
- invoker.draw_rectangle(event, self._palette)
- elif child.state == Gtk.StateType.PRELIGHT:
- child.style.paint_box(event.window, Gtk.StateType.PRELIGHT,
- Gtk.ShadowType.NONE, event.area,
- child, 'toolbutton-prelight',
- allocation.x, allocation.y,
- allocation.width, allocation.height)
-
- Gtk.ToolButton.do_expose_event(self, event)
+ invoker.draw_rectangle(cr, self._palette)
+
+ allocation = self.get_allocation()
+ # draw a black background, has been done by the engine before
+ cr.set_source_rgb(0, 0, 0)
+ cr.rectangle(0, 0, allocation.width, allocation.height)
+ cr.paint()
+
+ Gtk.ToolButton.do_draw(self, cr)
def __notify_change(self, widget, pspec):
self.notify(pspec.name)
diff --git a/src/sugar3/graphics/radiotoolbutton.py b/src/sugar3/graphics/radiotoolbutton.py
index 8fd01f7..006d167 100644
--- a/src/sugar3/graphics/radiotoolbutton.py
+++ b/src/sugar3/graphics/radiotoolbutton.py
@@ -165,18 +165,18 @@ class RadioToolButton(Gtk.RadioToolButton):
palette_invoker = GObject.property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
- def do_expose_event(self, event):
+ def do_draw(self, cr):
child = self.get_child()
allocation = self.get_allocation()
if self.palette and self.palette.is_up():
invoker = self.palette.props.invoker
- invoker.draw_rectangle(event, self.palette)
- elif child.state == Gtk.StateType.PRELIGHT:
- child.style.paint_box(event.window, Gtk.StateType.PRELIGHT,
- Gtk.ShadowType.NONE, event.area,
- child, 'toolbutton-prelight',
- allocation.x, allocation.y,
- allocation.width, allocation.height)
-
- Gtk.RadioToolButton.do_expose_event(self, event)
+ invoker.draw_rectangle(cr, self.palette)
+
+ allocation = self.get_allocation()
+ # draw a black background, has been done by the engine before
+ cr.set_source_rgb(0, 0, 0)
+ cr.rectangle(0, 0, allocation.width, allocation.height)
+ cr.paint()
+
+ Gtk.RadioToolButton.do_draw(self, cr)
diff --git a/src/sugar3/graphics/toggletoolbutton.py b/src/sugar3/graphics/toggletoolbutton.py
index c865332..f50d2fd 100644
--- a/src/sugar3/graphics/toggletoolbutton.py
+++ b/src/sugar3/graphics/toggletoolbutton.py
@@ -113,20 +113,20 @@ class ToggleToolButton(Gtk.ToggleToolButton):
accelerator = GObject.property(type=str, setter=set_accelerator,
getter=get_accelerator)
- def do_expose_event(self, event):
+ def do_draw(self, cr):
allocation = self.get_allocation()
child = self.get_child()
if self.palette and self.palette.is_up():
invoker = self.palette.props.invoker
- invoker.draw_rectangle(event, self.palette)
- elif child.state == Gtk.StateType.PRELIGHT:
- child.style.paint_box(event.window, Gtk.StateType.PRELIGHT,
- Gtk.ShadowType.NONE, event.area,
- child, 'toolbutton-prelight',
- allocation.x, allocation.y,
- allocation.width, allocation.height)
-
- Gtk.ToggleToolButton.do_expose_event(self, event)
+ invoker.draw_rectangle(cr, self.palette)
+
+ allocation = self.get_allocation()
+ # draw a black background, has been done by the engine before
+ cr.set_source_rgb(0, 0, 0)
+ cr.rectangle(0, 0, allocation.width, allocation.height)
+ cr.paint()
+
+ Gtk.ToggleToolButton.do_draw(self, cr)
palette = property(get_palette, set_palette)
--
1.7.11.4
More information about the Sugar-devel
mailing list