# menu - zavai menus # # Copyright (C) 2009 Enrico Zini # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys import zavai import gtk class Menu(gtk.VBox, zavai.Resource): def __init__(self, registry, name, *args, **kw): super(Menu, self).__init__() self.vbox = self parent = None pos = name.rfind(".") if pos != -1: parent = name[:pos] if parent == "menu": parent = None if parent is not None: self.vbox = gtk.VBox() self.pack_start(self.vbox) self.pack_start(registry.menu_link(parent, "Back"), True, True) def add_child(self, widget): self.vbox.pack_start(widget, True, True) class MenuLink(gtk.Button, zavai.Resource): def __init__(self, registry, targetName, label): super(MenuLink, self).__init__(label) self.target = "menu." + targetName self.registry = registry self.connect("clicked", self.on_click) def on_click(self, *args): self.registry.resource("app").show_widget(self.target)