Palette updates

This commit is contained in:
Eduardo Silva 2007-05-28 01:05:31 -04:00
parent f98cebd13a
commit d2aaebac38
3 changed files with 18 additions and 10 deletions

View File

@ -13,6 +13,7 @@ sugar_PYTHON = \
menushell.py \
notebook.py \
roundbox.py \
palette.py \
panel.py \
popup.py \
popupcontext.py \

View File

@ -44,8 +44,8 @@ class Palette(gtk.Window):
def __init__(self):
gobject.GObject.__init__(self)
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
gobject.GObject.__init__(self, type=gtk.WINDOW_POPUP)
gtk.Window.__init__(self)
self._palette_label = gtk.Label()
self._palette_label.set_ellipsize(pango.ELLIPSIZE_START)
@ -74,14 +74,9 @@ class Palette(gtk.Window):
self.set_border_width(self._WIN_BORDER)
self.add(vbox)
self.show()
# Set the palette position using as reference the
# parent widget
self._set_palette_position()
def do_set_property(self, pspec, value):
if pspec.name == 'parent':
self._parent_widget = value
elif pspec.name == 'alignment':
@ -89,7 +84,7 @@ class Palette(gtk.Window):
else:
raise AssertionError
def _set_palette_position(self):
def set_position(self):
window_axis = self._parent_widget.window.get_origin()
parent_rectangle = self._parent_widget.get_allocation()
@ -156,3 +151,6 @@ class Palette(gtk.Window):
self._button_bar.pack_start(button, True, True, self._PADDING)
button.show()
def display(self, button):
self.show()
self.set_position()

View File

@ -18,6 +18,7 @@
import gtk
from sugar.graphics.icon import Icon
from sugar.graphics.palette import *
class ToolButton(gtk.ToolButton):
def __init__(self, named_icon=None):
@ -27,4 +28,12 @@ class ToolButton(gtk.ToolButton):
def set_named_icon(self, named_icon):
icon = Icon(named_icon)
self.set_icon_widget(icon)
icon.show()
icon.show()
def set_palette(self, palette):
self.connect('clicked', palette.display)
palette.props.parent = self
palette.props.alignment = ALIGNMENT_BOTTOM_LEFT
def set_tooltip(self, text):
pass