1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """
23 Marker types.
24 """
25
26
27
28
29
30
31 from gettext import gettext as _
32
33
34
35
36
37
38 from gen.lib.grampstype import GrampsType, init_map
39
41 """
42 Class for handling data markers.
43 """
44
45 NONE = -1
46 CUSTOM = 0
47 COMPLETE = 1
48 TODO_TYPE = 2
49
50 _CUSTOM = CUSTOM
51 _DEFAULT = NONE
52
53 _DATAMAP = [
54 (NONE, "", ""),
55 (CUSTOM, _("Custom"), "Custom"),
56 (COMPLETE, _("Complete"), "Complete"),
57 (TODO_TYPE, _("ToDo"), "ToDo"),
58 ]
59
60 _I2SMAP = init_map(_DATAMAP, 0, 1)
61 _S2IMAP = init_map(_DATAMAP, 1, 0)
62 _I2EMAP = init_map(_DATAMAP, 0, 2)
63 _E2IMAP = init_map(_DATAMAP, 2, 0)
64
67
68 - def set(self, value):
69 """
70 Set the marker value.
71 """
72 if isinstance(value, self.__class__):
73 if value.val == self.CUSTOM and value.string == u'':
74 self.val = self.NONE
75 self.string = u''
76 else:
77 self.val = value.val
78 self.string = value.string
79 elif type(value) == tuple:
80 if value[0] == self.CUSTOM and value[1] == u'':
81 self.value = self.NONE
82 self.string = u''
83 else:
84 self.val = value[0]
85 self.string = value[1]
86 elif type(value) == int:
87 self.val = value
88 self.string = u''
89 elif type(value) == str:
90 self.val = self._S2IMAP.get(value, self._CUSTOM)
91 if self.val == self._CUSTOM:
92 self.string = value
93 else:
94 self.string = u''
95 else:
96 self.val = self._DEFAULT
97 self.string = u''
98