Added some methods to Palette.

This commit is contained in:
Tomeu Vizoso 2007-06-26 18:19:26 +02:00
parent 84127380dc
commit 4f748dba9b
2 changed files with 22 additions and 0 deletions

View File

@ -83,6 +83,23 @@ class Palette(gobject.GObject):
self._separator.show()
self._menu.insert(item, len(self._menu.get_children()) - 2)
def insert_menu_item(self, item, index=-1):
self._separator.show()
if index < 0:
self._menu.insert(item, len(self._menu.get_children()) - 2)
else:
self._menu.insert(item, index + 2)
def remove_menu_item(self, index):
if index > len(self._menu.get_children()) - 4:
raise ValueError('index %i out of range' % index)
self._menu.remove(self._menu.get_children()[index + 2])
if len(self._menu.get_children()) == 0:
self._separator.hide()
def menu_item_count(self):
return len(self._menu.get_children()) - 4
def set_content(self, widget):
self._content.set_widget(widget)
self._content.show()

View File

@ -35,6 +35,9 @@ class ToolButton(gtk.ToolButton):
self.set_icon_widget(icon)
icon.show()
def get_palette(self):
return self._palette
def set_palette(self, palette):
self._palette = palette
self._palette.props.invoker = WidgetInvoker(self.child)
@ -42,3 +45,5 @@ class ToolButton(gtk.ToolButton):
def set_tooltip(self, text):
self._palette = Palette(text)
self._palette.props.invoker = WidgetInvoker(self.child)
palette = property(get_palette, set_palette)