Merge branch 'master' of git://gitorious.org/mobilegtd/mobilegtd
authorMatthijs Kooijman <matthijs@stdin.nl>
Mon, 17 Aug 2009 20:17:00 +0000 (22:17 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Mon, 17 Aug 2009 20:17:00 +0000 (22:17 +0200)
* 'master' of git://gitorious.org/mobilegtd/mobilegtd:
  Added documentation to action.py and project.py

src/config/defaultconfig.py
src/gui/gui.py
src/gui/project_details/project_view.py
src/gui/projects_list/project_list_view.py

index afa0f7e911069f0ea330e2372f9556f263ac98c7..f750e73f3d8f3f4aed1c13ccb7cd93356dd4a0f4 100644 (file)
@@ -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"
index ec0a7cb6f04decbb502b0698fa242bd85ef22d8f..1dc34b291ea2d2875aa3405657900e978701188a 100644 (file)
@@ -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=[]
index bc36d77c6b14f83e382f2b0d4702102ed2b7b4a0..f1bc81af93351426d10f2af7b1be522bd61eeb58 100644 (file)
@@ -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)
index 1288d10c65af61a8347b45ce661237528bcfa1c4..80bffec06f1016c1d09c5ccc1608d90bf131c282 100644 (file)
@@ -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))