From: Matthijs Kooijman Date: Mon, 17 Aug 2009 21:41:08 +0000 (+0200) Subject: Remove the entry_filters argument from *View constructors. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=8b301d4e5f3dd8c3cc73ae23a41cd66f629c7625;p=matthijs%2Fupstream%2Fmobilegtd.git Remove the entry_filters argument from *View constructors. --- diff --git a/src/gui/gui.py b/src/gui/gui.py index 1dc34b2..0247175 100644 --- a/src/gui/gui.py +++ b/src/gui/gui.py @@ -236,13 +236,26 @@ class KeyBindingView(object): self.view.bind(key,no_action) class SearchableListView(WidgetBasedListView): - def __init__(self,entry_filters): - self.current_entry_filter_index = 0 - self.entry_filters = entry_filters - self.filtered_list = self.entry_filters[0] + def __init__(self): + self.current_entry_filter_index = -1 + self.entry_filters = [] + self.filtered_list = lambda:[] self.lock = None super(SearchableListView,self).__init__() + def set_filters(self, entry_filters): + """ + Set the filters that could be applied to this list. Each filter + can be applied in turn by calling switch_entry_filter (for + example from a key binding). + + The entry_filters argument should be a list of filters. The + active filter is stored into self.filtered_list and should be + processed by generate_widgets in the subclass. + """ + self.current_entry_filter_index = 0 + self.entry_filters = entry_filters + self.filtered_list = self.entry_filters[0] def search_item(self): selected_item = appuifw.selection_list(self.all_widget_texts(),search_field=1) @@ -250,6 +263,7 @@ class SearchableListView(WidgetBasedListView): selected_item = self.selected_index() self.view.set_list(self.items(),selected_item) self.set_bindings_for_selection(selected_item) + def switch_entry_filter(self): self.current_entry_filter_index += 1 self.filtered_list = self.entry_filters[self.current_entry_filter_index % len(self.entry_filters)] @@ -257,9 +271,9 @@ class SearchableListView(WidgetBasedListView): class EditableListView(SearchableListView,KeyBindingView): - def __init__(self,entry_filters): + def __init__(self): KeyBindingView.__init__(self) - super(EditableListView, self).__init__(entry_filters) + super(EditableListView, self).__init__() def key_and_menu_bindings(self,selected_index): key_and_menu_bindings=[] diff --git a/src/gui/project_details/project_view.py b/src/gui/project_details/project_view.py index f1bc81a..7827009 100644 --- a/src/gui/project_details/project_view.py +++ b/src/gui/project_details/project_view.py @@ -63,9 +63,10 @@ class ProjectView(EditableListView): def __init__(self,project): self.project = project self.project.observers.append(self) - super(ProjectView, self).__init__([lambda:self.project.actions.with_property(lambda a:a.status==action.active)]) + super(ProjectView, self).__init__() self.set_keybindings(ACTION_LIST_KEYS_AND_MENU) self.set_title(self.project.name) + self.set_filters([lambda:self.project.actions.with_property(lambda a:a.status==action.active)]) 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 80bffec..bbb81f6 100644 --- a/src/gui/projects_list/project_list_view.py +++ b/src/gui/projects_list/project_list_view.py @@ -24,9 +24,10 @@ class ProjectListView(EditableListView): def __init__(self,projects): self.projects = projects self.projects.observers.append(self) - super(ProjectListView, self).__init__([lambda:projects]) + super(ProjectListView, self).__init__() self.set_keybindings(PROJECT_LIST_KEYS_AND_MENU) self.set_title(u'Projects') + self.set_filters([lambda:projects]) #appuifw.note(u'Before starting thread') # thread.start_new_thread(projects.process,()) #appuifw.note(u'After starting thread %s'%repr(projects.observers))