00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 import gtk
00029
00030
00031 class Bar(object):
00032 def __init__(self, toolbar):
00033 self.__toolbar = toolbar
00034
00035
00036 def add_space(self):
00037 try:
00038 self.__toolbar.insert(gtk.SeparatorToolItem(), -1)
00039 except:
00040 self.__toolbar.append_space()
00041
00042
00043 def add_widget(self, widget, tip_text, private_text):
00044 try:
00045 toolitem = gtk.ToolItem()
00046 toolitem.add(widget)
00047 toolitem.set_expand(False)
00048 toolitem.set_homogeneous(False)
00049 toolitem.set_tooltip(gtk.Tooltips(), tip_text, private_text)
00050 self.__toolbar.insert(toolitem, -1)
00051 except:
00052 self.__toolbar.append_element(
00053 gtk.TOOLBAR_CHILD_WIDGET,
00054 widget,
00055 tip_text,
00056 private_text,
00057 None,
00058 None,
00059 None,
00060 None)
00061
00062
00063 def add_stock(self, name, stock_id, label, tip_text, important, cb):
00064 try:
00065 toolitem = gtk.ToolButton(stock_id)
00066 toolitem.connect('clicked', cb)
00067 toolitem.set_tooltip(gtk.Tooltips(), tip_text, tip_text)
00068 toolitem.set_name('tool_' + name)
00069 toolitem.set_label(label)
00070 toolitem.set_is_important(important)
00071 self.__toolbar.insert(toolitem,-1)
00072 except:
00073 icon = gtk.Image()
00074 icon.set_from_stock(stock_id, gtk.ICON_SIZE_SMALL_TOOLBAR)
00075 w = self.__toolbar.insert_item(
00076 label,
00077 tip_text,
00078 tip_text,
00079 icon,
00080 cb,
00081 None,
00082 -1)
00083 w.set_name('tool_' + name)
00084