/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to spanselector.py

  • Committer: Dan Loda
  • Date: 2005-11-06 07:01:31 UTC
  • mto: (0.1.25 gannotate)
  • mto: This revision was merged to the branch mainline in revision 49.
  • Revision ID: danloda@gmail.com-20051106070131-c81d61d9a762d4c8
Remember custom spans across sessions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    """
38
38
    
39
39
    max_custom_spans = 4
40
 
    num_custom_spans = 0
 
40
    custom_spans = []
41
41
    last_selected = None
42
42
 
43
43
    def __init__(self, homogeneous=False, spacing=6):
111
111
            self.activate_last_selected()
112
112
            return
113
113
 
114
 
        if self.num_custom_spans == 0:
 
114
        self.add_custom_span(span)
 
115
        self.emit("custom-span-added", span)
 
116
 
 
117
        self.activate(self.custom_iter)
 
118
 
 
119
    def add_custom_span(self, span):
 
120
        if not len(self.custom_spans):
115
121
            self.custom_iter = self.model.insert_after(self.custom_iter,
116
122
                                                       self.separator)
117
123
            self.custom_iter_top = self.custom_iter.copy()
118
 
 
119
 
        if self.num_custom_spans == self.max_custom_spans:
120
 
            self.num_custom_spans -= 1
 
124
        
 
125
        if len(self.custom_spans) == self.max_custom_spans:
 
126
            self.custom_spans.pop(0)
121
127
            self.model.remove(self.model.iter_next(self.custom_iter_top))
122
 
 
123
 
        self.num_custom_spans += 1
 
128
        
 
129
        self.custom_spans.append(span)
124
130
        self.custom_iter = self.model.insert_after(
125
131
            self.custom_iter, [span, "%.2f Days" % span, False, False])
126
132
 
127
 
        self.activate(self.custom_iter)
128
 
 
129
133
    def _request_custom_span(self):
130
134
        self.combo.hide()
131
135
        self.entry.show_all()
181
185
 
182
186
        return entry
183
187
 
 
188
 
184
189
"""The "span-changed" signal is emitted when a new span has been selected or
185
190
entered.
186
191
 
187
 
Callback signature: def callback(SpanSelector, span, user_param, ...)
 
192
Callback signature: def callback(SpanSelector, span, [user_param, ...])
188
193
"""
189
194
gobject.signal_new("span-changed", SpanSelector,
190
195
                   gobject.SIGNAL_RUN_LAST,
191
196
                   gobject.TYPE_NONE,
192
197
                   (gobject.TYPE_FLOAT,))
193
198
 
 
199
"""The "custom-span-added" signal is emitted after a custom span has been
 
200
added, but before it has been selected.
 
201
 
 
202
Callback signature: def callback(SpanSelector, span, [user_param, ...])
 
203
"""
 
204
gobject.signal_new("custom-span-added", SpanSelector,
 
205
                   gobject.SIGNAL_RUN_LAST,
 
206
                   gobject.TYPE_NONE,
 
207
                   (gobject.TYPE_FLOAT,))
 
208