# 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 from gettext import gettext as _ import zavai import gtk class MenuButton(gtk.Button): def __init__(self, *args, **kw): super(MenuButton, self).__init__(*args, **kw) # TODO: take this from the configuration self.set_size_request(0, 80) class Menu(gtk.VBox, zavai.Resource): def __init__(self, registry, name, parent = None, *args, **kw): super(Menu, self).__init__() self.vbox = self if parent is not None: self.vbox = gtk.VBox() self.pack_start(self.vbox, False, False) self.pack_start(gtk.Label(""), True, True) self.pack_start(LinkButton(registry, parent, _("Back")), False, False) def add_child(self, widget): self.vbox.pack_start(widget, False, False) class LinkButton(MenuButton, zavai.Resource): def __init__(self, registry, targetName, label): super(LinkButton, self).__init__(label) self.target = targetName self.registry = registry self.connect("clicked", self.on_click) def on_click(self, *args): self.registry.resource("app").show_widget(self.target)