Don't let ListView call a non-existent method on its superclass.
[matthijs/upstream/mobilegtd.git] / src / gui / gui.py
index 30ae4e2745bd6290ac47487bfdffca6d57c748f9..ea288a3d7ef8b876798824aaae955e6c5d78c053 100644 (file)
@@ -137,26 +137,34 @@ class View(object):
     def exit(self):
         self.exit_flag = True
         self.lock.signal()
     def exit(self):
         self.exit_flag = True
         self.lock.signal()
-        super(View, self).exit()
 
     def refresh(self):
         """
         Update the gui after a change in model or some user interaction.
         Should be filled by subclasses.
         """
 
     def refresh(self):
         """
         Update the gui after a change in model or some user interaction.
         Should be filled by subclasses.
         """
-        super(View, self).refresh()
+        pass
+
+    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__()
 
 class ListView(View):
     def __init__(self):
         super(ListView, self).__init__()
-        self.set_view(appuifw.Listbox(self.items(),self.change_entry))
+        self.set_view(appuifw.Listbox(self.items(),self.entry_selected))
 
 
-    def change_entry(self):
+    def entry_selected(self):
         """
         This function is called when the user selects an an entry (e.g.,
         navigates to it and push the ok button).
         """
         """
         This function is called when the user selects an an entry (e.g.,
         navigates to it and push the ok button).
         """
-        super(ListView).change_entry()
+        pass
     
     def update(self,subject=None):
         #logger.log(u'Updated %s'%repr(self))
     
     def update(self,subject=None):
         #logger.log(u'Updated %s'%repr(self))
@@ -188,7 +196,6 @@ class ListView(View):
     def selected_index(self):
         return self.view.current()
 
     def selected_index(self):
         return self.view.current()
 
-
 class WidgetBasedListView(ListView):
     def __init__(self):
         self.widgets = self.generate_widgets()
 class WidgetBasedListView(ListView):
     def __init__(self):
         self.widgets = self.generate_widgets()
@@ -218,7 +225,7 @@ class WidgetBasedListView(ListView):
         return self.widgets[self.selected_index()]
         
 
         return self.widgets[self.selected_index()]
         
 
-class KeyBindingView(object):
+class KeyBindingView(View):
     
     def __init__(self):
         self.binding_map = {}
     
     def __init__(self):
         self.binding_map = {}
@@ -248,7 +255,8 @@ class KeyBindingView(object):
                     description='    '+description
                 menu_entries.append((description,function)) 
         menu_entries.append((u'Exit', self.exit))
                     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()
         
     def set_bindings_for_selection(self,selected_index):
         self.remove_all_key_bindings()
         
@@ -310,7 +318,7 @@ class EditableListView(SearchableListView,KeyBindingView):
             key_and_menu_bindings.append((get_key(key),key,description,execute_and_update_function))
         return key_and_menu_bindings
 
             key_and_menu_bindings.append((get_key(key),key,description,execute_and_update_function))
         return key_and_menu_bindings
 
-    def change_entry(self):
+    def entry_selected(self):
         self.current_widget().change()
         self.refresh()
     def execute_and_update(self,function):
         self.current_widget().change()
         self.refresh()
     def execute_and_update(self,function):