Add a ToolInvoker which position the palette depending
on the toolbar orientation. Make all tool items use it.
This commit is contained in:
parent
8a9bc3b702
commit
8712ab6b58
@ -467,7 +467,6 @@ class Invoker(gobject.GObject):
|
|||||||
|
|
||||||
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._alignments = self.BOTTOM + self.RIGHT + self.TOP + self.LEFT
|
|
||||||
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
|
||||||
@ -516,7 +515,7 @@ class Invoker(gobject.GObject):
|
|||||||
(-1.0, -1.0, 0.0, 0.0),
|
(-1.0, -1.0, 0.0, 0.0),
|
||||||
(-1.0, 0.0, 0.0, 1.0)]
|
(-1.0, 0.0, 0.0, 1.0)]
|
||||||
else:
|
else:
|
||||||
return self._alignments
|
return self.BOTTOM + self.RIGHT + self.TOP + self.LEFT
|
||||||
|
|
||||||
def get_position_for_alignment(self, alignment, palette_dim):
|
def get_position_for_alignment(self, alignment, palette_dim):
|
||||||
rect = self._get_position_for_alignment(alignment, palette_dim)
|
rect = self._get_position_for_alignment(alignment, palette_dim)
|
||||||
@ -648,6 +647,16 @@ class CanvasInvoker(Invoker):
|
|||||||
def get_toplevel(self):
|
def get_toplevel(self):
|
||||||
return hippo.get_canvas_for_item(self._item).get_toplevel()
|
return hippo.get_canvas_for_item(self._item).get_toplevel()
|
||||||
|
|
||||||
|
class ToolInvoker(WidgetInvoker):
|
||||||
|
def get_aligments(self):
|
||||||
|
if self.parent is None:
|
||||||
|
return WidgetInvoker.get_alignments()
|
||||||
|
|
||||||
|
if self.parent.get_orientation() is gtk.ORIENTATION_HORIZONTAL:
|
||||||
|
return self.BOTTOM + self.TOP
|
||||||
|
else:
|
||||||
|
return self.LEFT + self.RIGHT
|
||||||
|
|
||||||
class _PaletteObserver(gobject.GObject):
|
class _PaletteObserver(gobject.GObject):
|
||||||
__gtype_name__ = 'SugarPaletteObserver'
|
__gtype_name__ = 'SugarPaletteObserver'
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from sugar.graphics.icon import Icon
|
from sugar.graphics.icon import Icon
|
||||||
from sugar.graphics.palette import Palette, WidgetInvoker
|
from sugar.graphics.palette import Palette, ToolInvoker
|
||||||
|
|
||||||
class RadioToolButton(gtk.RadioToolButton):
|
class RadioToolButton(gtk.RadioToolButton):
|
||||||
__gtype_name__ = "SugarRadioToolButton"
|
__gtype_name__ = "SugarRadioToolButton"
|
||||||
@ -42,7 +42,7 @@ class RadioToolButton(gtk.RadioToolButton):
|
|||||||
|
|
||||||
def set_palette(self, palette):
|
def set_palette(self, palette):
|
||||||
self._palette = palette
|
self._palette = palette
|
||||||
self._palette.props.invoker = WidgetInvoker(self.child)
|
self._palette.props.invoker = ToolInvoker(self.child)
|
||||||
|
|
||||||
def set_tooltip(self, text):
|
def set_tooltip(self, text):
|
||||||
self.set_palette(Palette(text))
|
self.set_palette(Palette(text))
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from sugar.graphics.icon import Icon
|
from sugar.graphics.icon import Icon
|
||||||
from sugar.graphics.palette import Palette, WidgetInvoker
|
from sugar.graphics.palette import Palette, ToolInvoker
|
||||||
|
|
||||||
class ToggleToolButton(gtk.ToggleToolButton):
|
class ToggleToolButton(gtk.ToggleToolButton):
|
||||||
__gtype_name__ = "SugarToggleToolButton"
|
__gtype_name__ = "SugarToggleToolButton"
|
||||||
@ -38,7 +38,7 @@ class ToggleToolButton(gtk.ToggleToolButton):
|
|||||||
|
|
||||||
def set_palette(self, palette):
|
def set_palette(self, palette):
|
||||||
self._palette = palette
|
self._palette = palette
|
||||||
self._palette.props.invoker = WidgetInvoker(self.child)
|
self._palette.props.invoker = ToolInvoker(self.child)
|
||||||
|
|
||||||
def set_tooltip(self, text):
|
def set_tooltip(self, text):
|
||||||
self.set_palette(Palette(text))
|
self.set_palette(Palette(text))
|
||||||
|
@ -20,7 +20,7 @@ import gobject
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from sugar.graphics.icon import Icon
|
from sugar.graphics.icon import Icon
|
||||||
from sugar.graphics.palette import Palette, WidgetInvoker
|
from sugar.graphics.palette import Palette, ToolInvoker
|
||||||
|
|
||||||
class ToolButton(gtk.ToolButton):
|
class ToolButton(gtk.ToolButton):
|
||||||
__gtype_name__ = "SugarToolButton"
|
__gtype_name__ = "SugarToolButton"
|
||||||
@ -42,7 +42,7 @@ class ToolButton(gtk.ToolButton):
|
|||||||
|
|
||||||
def set_palette(self, palette):
|
def set_palette(self, palette):
|
||||||
self._palette = palette
|
self._palette = palette
|
||||||
self._palette.props.invoker = WidgetInvoker(self.child)
|
self._palette.props.invoker = ToolInvoker(self.child)
|
||||||
|
|
||||||
def set_tooltip(self, text):
|
def set_tooltip(self, text):
|
||||||
self.set_palette(Palette(text))
|
self.set_palette(Palette(text))
|
||||||
|
Loading…
Reference in New Issue
Block a user