1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """statusbar widget used by in admin window"""
23
24 __version__ = "$Rev: 6961 $"
25
26
28 """
29 I implement the status bar used in the admin UI.
30 """
32 """
33 @param widget: a gtk.Statusbar to wrap.
34 """
35 self._widget = widget
36
37 self._cids = {}
38 self._mids = {}
39 self._contexts = ['main', 'notebook']
40
41 for context in self._contexts:
42 self._cids[context] = widget.get_context_id(context)
43 self._mids[context] = []
44
45 - def clear(self, context=None):
46 """
47 Clear the status bar for the given context, or for all contexts
48 if none specified.
49 """
50 if context:
51 self._clearContext(context)
52 return
53
54 for context in self._contexts:
55 self._clearContext(context)
56
57 - def push(self, context, message):
58 """
59 Push the given message for the given context.
60
61 @returns: message id
62 """
63 mid = self._widget.push(self._cids[context], message)
64 self._mids[context].append(mid)
65 return mid
66
67 - def pop(self, context):
68 """
69 Pop the last message for the given context.
70
71 @returns: message id popped, or None
72 """
73 if len(self._mids[context]):
74 mid = self._mids[context].pop()
75 self._widget.remove(self._cids[context], mid)
76 return mid
77
78 return None
79
80 - def set(self, context, message):
81 """
82 Replace the current top message for this context with this new one.
83
84 @returns: the message id of the message pushed
85 """
86 self.pop(context)
87 return self.push(context, message)
88
89 - def remove(self, context, mid):
90 """
91 Remove the message with the given id from the given context.
92
93 @returns: whether or not the given mid was valid.
94 """
95 if not mid in self._mids[context]:
96 return False
97
98 self._mids[context].remove(mid)
99 self._widget.remove(self._cids[context], mid)
100 return True
101
102 - def _clearContext(self, context):
103 if not context in self._cids.keys():
104 return
105
106 for mid in self._mids[context][:]:
107 self.remove(context, mid)
108