Define (a dummy) get_menu_entries in View.
authorMatthijs Kooijman <matthijs@stdin.nl>
Sun, 30 Aug 2009 07:30:54 +0000 (09:30 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Sun, 30 Aug 2009 07:30:54 +0000 (09:30 +0200)
Also, make KeyBindingView call the next get_menu_entries method,
allowing for other classes to override the method as well.

src/gui/gui.py

index 2661286b881b63d728b36526f7380113e80a36e5..33f8973fa8ddaafaa9b6f1cac3d8161d901018b3 100644 (file)
@@ -146,6 +146,15 @@ class View(object):
         """
         super(View, self).refresh()
 
+    def get_menu_entries(self):
+        """ Returns a list of menu entries to display. Will be
+        automatically updated on each refresh.
+
+        Each menu entry is a tuple of a title for the entry and a
+        function to call when the entry is selected.
+        """
+        return []
+
 class ListView(View):
     def __init__(self):
         super(ListView, self).__init__()
@@ -188,7 +197,6 @@ class ListView(View):
     def selected_index(self):
         return self.view.current()
 
-
 class WidgetBasedListView(ListView):
     def __init__(self):
         self.widgets = self.generate_widgets()
@@ -248,7 +256,8 @@ class KeyBindingView(View):
                     description='    '+description
                 menu_entries.append((description,function)) 
         menu_entries.append((u'Exit', self.exit))
-        return menu_entries       
+        return menu_entries + super(KeyBindingView, self).get_menu_entries()
+
     def set_bindings_for_selection(self,selected_index):
         self.remove_all_key_bindings()