From: Matthijs Kooijman Date: Mon, 17 Aug 2009 20:17:00 +0000 (+0200) Subject: Merge branch 'master' of git://gitorious.org/mobilegtd/mobilegtd X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=dc0517146e17ffb7d66a52f3c196b03c52f34cac;hp=312b57ff1ad5c031aba6084dab3644eeb62ab113;p=matthijs%2Fupstream%2Fmobilegtd.git Merge branch 'master' of git://gitorious.org/mobilegtd/mobilegtd * 'master' of git://gitorious.org/mobilegtd/mobilegtd: Added documentation to action.py and project.py --- diff --git a/src/config/defaultconfig.py b/src/config/defaultconfig.py index afa0f7e..f750e73 100644 --- a/src/config/defaultconfig.py +++ b/src/config/defaultconfig.py @@ -6,7 +6,7 @@ default_configuration = {"screen":"normal", # Make the path absolute. This is a no-op on Symbian, since it is # already absolute, but helps when running on other systems (some of the # code relies on this path being absolute). -"path": os.path.abspath("C:/Data/GTD/"), +"path": os.path.abspath("C:/Data/GTD") + os.sep, "inactivity_threshold":"7", "read_sms":"1", "action_editor":"form" diff --git a/src/gui/gui.py b/src/gui/gui.py index ec0a7cb..1dc34b2 100644 --- a/src/gui/gui.py +++ b/src/gui/gui.py @@ -103,9 +103,11 @@ def restore_gui(object): class ListView(object): - def __init__(self,title): - self.title = title + def __init__(self): self.view = appuifw.Listbox(self.items(),self.change_entry) + + def set_title(self, title): + self.title = title def change_entry(self): pass @@ -161,9 +163,9 @@ class ListView(object): class WidgetBasedListView(ListView): - def __init__(self,title): + def __init__(self): self.widgets = self.generate_widgets() - super(WidgetBasedListView,self).__init__(title) + super(WidgetBasedListView,self).__init__() self.exit_flag = False def run(self): @@ -192,7 +194,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): @@ -221,12 +236,12 @@ class KeyBindingView(object): self.view.bind(key,no_action) class SearchableListView(WidgetBasedListView): - def __init__(self,title,entry_filters): + def __init__(self,entry_filters): self.current_entry_filter_index = 0 self.entry_filters = entry_filters self.filtered_list = self.entry_filters[0] self.lock = None - super(SearchableListView,self).__init__(title) + super(SearchableListView,self).__init__() def search_item(self): @@ -242,9 +257,9 @@ class SearchableListView(WidgetBasedListView): class EditableListView(SearchableListView,KeyBindingView): - def __init__(self,title,entry_filters,binding_map): - KeyBindingView.__init__(self,binding_map) - super(EditableListView, self).__init__(title,entry_filters) + def __init__(self,entry_filters): + KeyBindingView.__init__(self) + super(EditableListView, self).__init__(entry_filters) 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 bc36d77..f1bc81a 100644 --- a/src/gui/project_details/project_view.py +++ b/src/gui/project_details/project_view.py @@ -21,7 +21,7 @@ import key_codes from gui import * -ACTION_LIST_KEYS_AND_MENU = Configuration(os.path.join(gtd_directory,"actions.cfg")) +ACTION_LIST_KEYS_AND_MENU = Configuration(os.path.join(gtd_directory,"actions.cfg"), default_actions_menu) def ask_for_action(project_name,proposition=None): @@ -63,7 +63,9 @@ 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__([lambda:self.project.actions.with_property(lambda a:a.status==action.active)]) + self.set_keybindings(ACTION_LIST_KEYS_AND_MENU) + self.set_title(self.project.name) 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..80bffec 100644 --- a/src/gui/projects_list/project_list_view.py +++ b/src/gui/projects_list/project_list_view.py @@ -24,7 +24,9 @@ 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__([lambda:projects]) + self.set_keybindings(PROJECT_LIST_KEYS_AND_MENU) + self.set_title(u'Projects') #appuifw.note(u'Before starting thread') # thread.start_new_thread(projects.process,()) #appuifw.note(u'After starting thread %s'%repr(projects.observers))