Adding the file backend as a choice in the UI
[doneit] / src / file_view.py
1 """
2 @todo Remove blocking operations from UI thread
3 """
4
5 import common_view
6
7 import gtk_toolbox
8 import file_backend
9
10
11 class FileView(common_view.CommonView):
12
13         def __init__(self, widgetTree, errorDisplay, defaultPath):
14                 super(FileView, self).__init__(widgetTree, errorDisplay)
15                 self._path = defaultPath
16
17         @staticmethod
18         def name():
19                 return "File"
20
21         def load_settings(self, config):
22                 """
23                 @note Thread Agnostic
24                 """
25                 path = config.get(self.name(), "path")
26                 if path is not None:
27                         self._path
28
29         def save_settings(self, config):
30                 """
31                 @note Thread Agnostic
32                 """
33                 self._manager.save()
34                 config.add_section(self.name())
35                 config.set(self.name(), "path", self._path)
36
37         def login(self):
38                 """
39                 @note UI Thread
40                 """
41                 if self._manager is not None:
42                         return
43
44                 self._manager = file_backend.FileBackend(self._path)
45                 self._manager.load()
46
47         def logout(self):
48                 """
49                 @note Thread Agnostic
50                 """
51                 self._manager.save()
52                 self._manager = None