From: Matthijs Kooijman Date: Mon, 17 Aug 2009 18:54:34 +0000 (+0200) Subject: Remove the binding_map argument from KeyBindingView.__init__. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fmobilegtd.git;a=commitdiff_plain;h=218b74c5e7d16bc6aef987d2a74caf0169c121dc Remove the binding_map argument from KeyBindingView.__init__. This prepares for making the constructors involved in the View object hierarchy all argumentless so they can properly be called in the normal way. --- diff --git a/src/gui/gui.py b/src/gui/gui.py index ec0a7cb..b265617 100644 --- a/src/gui/gui.py +++ b/src/gui/gui.py @@ -192,7 +192,20 @@ class WidgetBasedListView(ListView): class KeyBindingView(object): - def __init__(self,binding_map): + def __init__(self): + self.binding_map = {} + + def set_keybindings(self, binding_map): + """ + Set a new map of key bindings. This map maps method names to a + tuple of keyname and description. + + The method name refers to a method on the selected item, or the + current view. + + Example: { 'search_item' : ('0', 'Search item') } + + """ self.binding_map = binding_map def get_menu_entries(self): @@ -242,8 +255,8 @@ class SearchableListView(WidgetBasedListView): class EditableListView(SearchableListView,KeyBindingView): - def __init__(self,title,entry_filters,binding_map): - KeyBindingView.__init__(self,binding_map) + def __init__(self,title,entry_filters): + KeyBindingView.__init__(self) super(EditableListView, self).__init__(title,entry_filters) def key_and_menu_bindings(self,selected_index): diff --git a/src/gui/project_details/project_view.py b/src/gui/project_details/project_view.py index bc36d77..6a8f2f7 100644 --- a/src/gui/project_details/project_view.py +++ b/src/gui/project_details/project_view.py @@ -63,7 +63,8 @@ class ProjectView(EditableListView): def __init__(self,project): self.project = project self.project.observers.append(self) - super(ProjectView, self).__init__(self.project.name, [lambda:self.project.actions.with_property(lambda a:a.status==action.active)], ACTION_LIST_KEYS_AND_MENU) + super(ProjectView, self).__init__(self.project.name, [lambda:self.project.actions.with_property(lambda a:a.status==action.active)]) + self.set_keybindings(ACTION_LIST_KEYS_AND_MENU) def exit(self): self.project.observers.remove(self) diff --git a/src/gui/projects_list/project_list_view.py b/src/gui/projects_list/project_list_view.py index 1288d10..0712a72 100644 --- a/src/gui/projects_list/project_list_view.py +++ b/src/gui/projects_list/project_list_view.py @@ -24,7 +24,8 @@ class ProjectListView(EditableListView): def __init__(self,projects): self.projects = projects self.projects.observers.append(self) - super(ProjectListView, self).__init__(u'Projects', [lambda:projects],PROJECT_LIST_KEYS_AND_MENU) + super(ProjectListView, self).__init__(u'Projects', [lambda:projects]) + self.set_keybindings(PROJECT_LIST_KEYS_AND_MENU) #appuifw.note(u'Before starting thread') # thread.start_new_thread(projects.process,()) #appuifw.note(u'After starting thread %s'%repr(projects.observers))