Hookup the new palette creation in the toolbuttons.
This commit is contained in:
parent
685a9e3462
commit
bbd3404310
@ -724,13 +724,14 @@ class Invoker(gobject.GObject):
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
gobject.GObject.__init__(self)
|
gobject.GObject.__init__(self)
|
||||||
|
|
||||||
|
self.parent = parent
|
||||||
|
|
||||||
self._screen_area = gtk.gdk.Rectangle(0, 0, gtk.gdk.screen_width(),
|
self._screen_area = gtk.gdk.Rectangle(0, 0, gtk.gdk.screen_width(),
|
||||||
gtk.gdk.screen_height())
|
gtk.gdk.screen_height())
|
||||||
self._position_hint = self.ANCHORED
|
self._position_hint = self.ANCHORED
|
||||||
self._cursor_x = -1
|
self._cursor_x = -1
|
||||||
self._cursor_y = -1
|
self._cursor_y = -1
|
||||||
self._palette = None
|
self._palette = None
|
||||||
self._parent = parent
|
|
||||||
|
|
||||||
def _get_position_for_alignment(self, alignment, palette_dim):
|
def _get_position_for_alignment(self, alignment, palette_dim):
|
||||||
palette_halign = alignment[0]
|
palette_halign = alignment[0]
|
||||||
|
@ -29,11 +29,12 @@ class RadioToolButton(gtk.RadioToolButton):
|
|||||||
def __init__(self, named_icon=None, group=None, xo_color=None, **kwargs):
|
def __init__(self, named_icon=None, group=None, xo_color=None, **kwargs):
|
||||||
self._accelerator = None
|
self._accelerator = None
|
||||||
self._tooltip = None
|
self._tooltip = None
|
||||||
self._palette = None
|
|
||||||
self._xo_color = xo_color
|
self._xo_color = xo_color
|
||||||
|
|
||||||
gobject.GObject.__init__(self, **kwargs)
|
gobject.GObject.__init__(self, **kwargs)
|
||||||
|
|
||||||
|
self._palette_invoker = ToolInvoker(self)
|
||||||
|
|
||||||
if named_icon:
|
if named_icon:
|
||||||
self.set_named_icon(named_icon)
|
self.set_named_icon(named_icon)
|
||||||
if group:
|
if group:
|
||||||
@ -74,17 +75,27 @@ class RadioToolButton(gtk.RadioToolButton):
|
|||||||
self.set_icon_widget(icon)
|
self.set_icon_widget(icon)
|
||||||
icon.show()
|
icon.show()
|
||||||
|
|
||||||
|
def create_palette(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def get_palette(self):
|
def get_palette(self):
|
||||||
return self._palette
|
return self._palette_invoker.palette
|
||||||
|
|
||||||
def set_palette(self, palette):
|
def set_palette(self, palette):
|
||||||
if self._palette is not None:
|
self._palette_invoker.palette = palette
|
||||||
self._palette.props.invoker = None
|
|
||||||
self._palette = palette
|
|
||||||
self._palette.props.invoker = ToolInvoker(self)
|
|
||||||
|
|
||||||
palette = gobject.property(
|
palette = gobject.property(
|
||||||
type=object, setter=set_palette, getter=get_palette)
|
type=object, setter=set_palette, getter=get_palette)
|
||||||
|
|
||||||
|
def get_palette_invoker(self):
|
||||||
|
return self._palette_invoker
|
||||||
|
|
||||||
|
def set_palette_invoker(self, palette_invoker):
|
||||||
|
self._palette_invoker.detach()
|
||||||
|
self._palette_invoker = palette_invoker
|
||||||
|
|
||||||
|
palette_invoker = gobject.property(
|
||||||
|
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
|
||||||
|
|
||||||
def do_expose_event(self, event):
|
def do_expose_event(self, event):
|
||||||
child = self.get_child()
|
child = self.get_child()
|
||||||
|
@ -25,7 +25,8 @@ class ToggleToolButton(gtk.ToggleToolButton):
|
|||||||
|
|
||||||
def __init__(self, named_icon=None):
|
def __init__(self, named_icon=None):
|
||||||
gtk.ToggleToolButton.__init__(self)
|
gtk.ToggleToolButton.__init__(self)
|
||||||
self._palette = None
|
|
||||||
|
self._palette_invoker = ToolInvoker(self)
|
||||||
self.set_named_icon(named_icon)
|
self.set_named_icon(named_icon)
|
||||||
|
|
||||||
def set_named_icon(self, named_icon):
|
def set_named_icon(self, named_icon):
|
||||||
@ -33,14 +34,27 @@ class ToggleToolButton(gtk.ToggleToolButton):
|
|||||||
self.set_icon_widget(icon)
|
self.set_icon_widget(icon)
|
||||||
icon.show()
|
icon.show()
|
||||||
|
|
||||||
|
def create_palette(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def get_palette(self):
|
def get_palette(self):
|
||||||
return self._palette
|
return self._palette_invoker.palette
|
||||||
|
|
||||||
def set_palette(self, palette):
|
def set_palette(self, palette):
|
||||||
if self._palette is not None:
|
self._palette_invoker.palette = palette
|
||||||
self._palette.props.invoker = None
|
|
||||||
self._palette = palette
|
palette = gobject.property(
|
||||||
self._palette.props.invoker = ToolInvoker(self)
|
type=object, setter=set_palette, getter=get_palette)
|
||||||
|
|
||||||
|
def get_palette_invoker(self):
|
||||||
|
return self._palette_invoker
|
||||||
|
|
||||||
|
def set_palette_invoker(self, palette_invoker):
|
||||||
|
self._palette_invoker.detach()
|
||||||
|
self._palette_invoker = palette_invoker
|
||||||
|
|
||||||
|
palette_invoker = gobject.property(
|
||||||
|
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
|
||||||
|
|
||||||
def set_tooltip(self, text):
|
def set_tooltip(self, text):
|
||||||
self.set_palette(Palette(text))
|
self.set_palette(Palette(text))
|
||||||
|
@ -55,10 +55,11 @@ class ToolButton(gtk.ToolButton):
|
|||||||
def __init__(self, icon_name=None, **kwargs):
|
def __init__(self, icon_name=None, **kwargs):
|
||||||
self._accelerator = None
|
self._accelerator = None
|
||||||
self._tooltip = None
|
self._tooltip = None
|
||||||
self._palette = None
|
|
||||||
|
|
||||||
gobject.GObject.__init__(self, **kwargs)
|
gobject.GObject.__init__(self, **kwargs)
|
||||||
|
|
||||||
|
self._palette_invoker = ToolInvoker(self)
|
||||||
|
|
||||||
if icon_name:
|
if icon_name:
|
||||||
self.set_icon(icon_name)
|
self.set_icon(icon_name)
|
||||||
|
|
||||||
@ -97,24 +98,34 @@ class ToolButton(gtk.ToolButton):
|
|||||||
self.set_icon_widget(icon)
|
self.set_icon_widget(icon)
|
||||||
icon.show()
|
icon.show()
|
||||||
|
|
||||||
|
def create_palette(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def get_palette(self):
|
def get_palette(self):
|
||||||
return self._palette
|
return self._palette_invoker.palette
|
||||||
|
|
||||||
def set_palette(self, palette):
|
def set_palette(self, palette):
|
||||||
if self._palette is not None:
|
self._palette_invoker.palette = palette
|
||||||
self._palette.props.invoker = None
|
|
||||||
self._palette = palette
|
|
||||||
self._palette.props.invoker = ToolInvoker(self)
|
|
||||||
|
|
||||||
palette = gobject.property(
|
palette = gobject.property(
|
||||||
type=object, setter=set_palette, getter=get_palette)
|
type=object, setter=set_palette, getter=get_palette)
|
||||||
|
|
||||||
|
def get_palette_invoker(self):
|
||||||
|
return self._palette_invoker
|
||||||
|
|
||||||
|
def set_palette_invoker(self, palette_invoker):
|
||||||
|
self._palette_invoker.detach()
|
||||||
|
self._palette_invoker = palette_invoker
|
||||||
|
|
||||||
|
palette_invoker = gobject.property(
|
||||||
|
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
|
||||||
|
|
||||||
def do_expose_event(self, event):
|
def do_expose_event(self, event):
|
||||||
child = self.get_child()
|
child = self.get_child()
|
||||||
allocation = self.get_allocation()
|
allocation = self.get_allocation()
|
||||||
if self._palette and self._palette.is_up():
|
if self.palette and self.palette.is_up():
|
||||||
invoker = self._palette.props.invoker
|
invoker = self.palette.props.invoker
|
||||||
invoker.draw_rectangle(event, self._palette)
|
invoker.draw_rectangle(event, self.palette)
|
||||||
elif child.state == gtk.STATE_PRELIGHT:
|
elif child.state == gtk.STATE_PRELIGHT:
|
||||||
child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||||
gtk.SHADOW_NONE, event.area,
|
gtk.SHADOW_NONE, event.area,
|
||||||
@ -125,6 +136,6 @@ class ToolButton(gtk.ToolButton):
|
|||||||
gtk.ToolButton.do_expose_event(self, event)
|
gtk.ToolButton.do_expose_event(self, event)
|
||||||
|
|
||||||
def __button_clicked_cb(self, widget):
|
def __button_clicked_cb(self, widget):
|
||||||
if self._palette:
|
if self.palette:
|
||||||
self._palette.popdown(True)
|
self.palette.popdown(True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user