Fix the drawing of ColorToolButton, RadioToolButton and ToggleToolButton
gtk_paint_box is deprecated [1] and now we can use the CSS to change the style of the button's prelight state. To test the buttons, I provide a patch for HelloWorld activity [2]. They are added in the main toolbar. Signed-off-by: Manuel Quiñones <manuq@laptop.org> [1] http://developer.gnome.org/gtk3/stable/GtkStyle.html#gtk-paint-box [2] http://dev.laptop.org/~manuq/shell-port/test_gtk3_buttons.patch
This commit is contained in:
parent
e2ddd70c13
commit
1e6cba8474
@ -523,20 +523,14 @@ 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)
|
||||
invoker.draw_rectangle(cr, self._palette)
|
||||
|
||||
Gtk.ToolButton.do_expose_event(self, event)
|
||||
Gtk.ToolButton.do_draw(self, cr)
|
||||
|
||||
def __notify_change(self, widget, pspec):
|
||||
self.notify(pspec.name)
|
||||
|
@ -165,18 +165,12 @@ 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)
|
||||
invoker.draw_rectangle(cr, self.palette)
|
||||
|
||||
Gtk.RadioToolButton.do_expose_event(self, event)
|
||||
Gtk.RadioToolButton.do_draw(self, cr)
|
||||
|
@ -113,20 +113,14 @@ 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)
|
||||
invoker.draw_rectangle(cr, self.palette)
|
||||
|
||||
Gtk.ToggleToolButton.do_expose_event(self, event)
|
||||
Gtk.ToggleToolButton.do_draw(self, cr)
|
||||
|
||||
palette = property(get_palette, set_palette)
|
||||
|
Loading…
Reference in New Issue
Block a user