import pygtk
pygtk.require('2.0')

import gtk

ui_string = """<ui>
  <menubar name='Menubar'>
    <menu action='FileMenu'>
      <menuitem action='Old'/>
    </menu>
  </menubar>
  <toolbar name='Toolbar'>
    <toolitem action='Old'/>
  </toolbar>
</ui>"""

class Window(gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_title('toolbutton wrong accessible name')
        self.connect('delete-event', self.delete_event_cb)
        self.set_size_request(500, 200)
        vbox = gtk.VBox()
        self.add(vbox)

        self.create_ui()
        toolbar = self.ui.get_widget('/Toolbar')
        toolbar.set_style(gtk.TOOLBAR_ICONS)
        vbox.pack_start(self.ui.get_widget('/Menubar'), expand=False)
        vbox.pack_start(toolbar, expand=False)

    def create_ui(self):
        ag = gtk.ActionGroup('WindowActions')
        actions = [
            ('FileMenu', None, '_File'),
            ('Old',      gtk.STOCK_NEW, '_Old', '<control>N',
             'Create a new file', None)
            ]
        ag.add_actions(actions)
        self.ui = gtk.UIManager()
        self.ui.insert_action_group(ag, 0)
        self.ui.add_ui_from_string(ui_string)
        self.add_accel_group(self.ui.get_accel_group())

    def delete_event_cb(self, window, event):
        gtk.main_quit()

if __name__ == '__main__':
    w = Window()
    w.show_all()
    gtk.main()
