/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 logview.py

  • Committer: Aaron Bentley
  • Date: 2007-08-16 14:31:02 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070816143102-27yzfhdgdv3ggo6e
Fix hue selection to use author in gannotate

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    start.
31
31
    """
32
32
 
33
 
    def __init__(self, revision=None, scroll=True):
 
33
    def __init__(self, revision=None, scroll=True, tags=[]):
34
34
        super(LogView, self).__init__()
35
35
        if scroll:
36
36
            self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
43
43
        self._clicked_callback = None
44
44
 
45
45
        if revision is not None:
46
 
            self.set_revision(revision)
 
46
            self.set_revision(revision, tags=tags)
47
47
 
48
48
    def set_show_callback(self, callback):
49
49
        self._show_callback = callback
51
51
    def set_go_callback(self, callback):
52
52
        self._go_callback = callback
53
53
 
54
 
    def set_revision(self, revision):
 
54
    def set_revision(self, revision, tags=[]):
55
55
        self._revision = revision
56
56
        self.revision_id.set_text(revision.revision_id)
57
57
        if revision.committer is not None:
58
58
            self.committer.set_text(revision.committer)
59
59
        else:
60
60
            self.committer.set_text("")
 
61
        author = revision.properties.get('author', '')
 
62
        if author != '':
 
63
            self.author.set_text(author)
 
64
            self.author.show()
 
65
            self.author_label.show()
 
66
        else:
 
67
            self.author.hide()
 
68
            self.author_label.hide()
 
69
 
61
70
        if revision.timestamp is not None:
62
71
            self.timestamp.set_text(format_date(revision.timestamp,
63
72
                                                revision.timezone))
68
77
            self.branchnick_label.set_text("")
69
78
 
70
79
        self._add_parents(revision.parent_ids)
 
80
        self._add_tags(tags)
71
81
 
72
82
    def _show_clicked_cb(self, widget, revid, parentid):
73
83
        """Callback for when the show button for a parent is clicked."""
77
87
        """Callback for when the go button for a parent is clicked."""
78
88
        self._go_callback(revid)
79
89
 
 
90
    def _add_tags(self, tags):
 
91
        if tags == []:
 
92
            self.tags_list.hide()
 
93
            self.tags_label.hide()
 
94
            return
 
95
 
 
96
        for widget in self.tags_widgets:
 
97
            self.tags_list.remove(widget)
 
98
 
 
99
        self.tags_widgets = []
 
100
 
 
101
        for tag in tags:
 
102
            widget = gtk.Label(tag)
 
103
            widget.set_selectable(True)
 
104
            self.tags_widgets.append(widget)
 
105
            self.tags_list.add(widget)
 
106
        self.tags_list.show_all()
 
107
        self.tags_label.show_all()
 
108
        
 
109
 
80
110
    def _add_parents(self, parent_ids):
81
111
        for widget in self.parents_widgets:
82
112
            self.parents_table.remove(widget)
127
157
        vbox.show()
128
158
 
129
159
    def _create_headers(self):
130
 
        self.table = gtk.Table(rows=4, columns=2)
 
160
        self.table = gtk.Table(rows=5, columns=2)
131
161
        self.table.set_row_spacings(6)
132
162
        self.table.set_col_spacings(6)
133
163
        self.table.show()
149
179
        self.revision_id.show()
150
180
 
151
181
        align = gtk.Alignment(1.0, 0.5)
 
182
        self.author_label = gtk.Label()
 
183
        self.author_label.set_markup("<b>Author:</b>")
 
184
        align.add(self.author_label)
 
185
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
 
186
        align.show()
 
187
        self.author_label.show()
 
188
 
 
189
        align = gtk.Alignment(0.0, 0.5)
 
190
        self.author = gtk.Label()
 
191
        self.author.set_selectable(True)
 
192
        align.add(self.author)
 
193
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
194
        align.show()
 
195
        self.author.show()
 
196
        self.author.hide()
 
197
 
 
198
        align = gtk.Alignment(1.0, 0.5)
152
199
        label = gtk.Label()
153
200
        label.set_markup("<b>Committer:</b>")
154
201
        align.add(label)
155
 
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
 
202
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
156
203
        align.show()
157
204
        label.show()
158
205
 
160
207
        self.committer = gtk.Label()
161
208
        self.committer.set_selectable(True)
162
209
        align.add(self.committer)
163
 
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
210
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
164
211
        align.show()
165
212
        self.committer.show()
166
213
 
168
215
        label = gtk.Label()
169
216
        label.set_markup("<b>Branch nick:</b>")
170
217
        align.add(label)
171
 
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
 
218
        self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
172
219
        label.show()
173
220
        align.show()
174
221
 
176
223
        self.branchnick_label = gtk.Label()
177
224
        self.branchnick_label.set_selectable(True)
178
225
        align.add(self.branchnick_label)
179
 
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
226
        self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
180
227
        self.branchnick_label.show()
181
228
        align.show()
182
229
 
184
231
        label = gtk.Label()
185
232
        label.set_markup("<b>Timestamp:</b>")
186
233
        align.add(label)
187
 
        self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
 
234
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
188
235
        align.show()
189
236
        label.show()
190
237
 
192
239
        self.timestamp = gtk.Label()
193
240
        self.timestamp.set_selectable(True)
194
241
        align.add(self.timestamp)
195
 
        self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
242
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
196
243
        align.show()
197
244
        self.timestamp.show()
198
245
 
 
246
        align = gtk.Alignment(1.0, 0.5)
 
247
        self.tags_label = gtk.Label()
 
248
        self.tags_label.set_markup("<b>Tags:</b>")
 
249
        align.add(self.tags_label)
 
250
        align.show()
 
251
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
 
252
        self.tags_label.show()
 
253
 
 
254
        align = gtk.Alignment(0.0, 0.5)
 
255
        self.tags_list = gtk.VBox()
 
256
        align.add(self.tags_list)
 
257
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
258
        align.show()
 
259
        self.tags_list.show()
 
260
        self.tags_widgets = []
 
261
 
199
262
        return self.table
200
263
 
201
264
    def _create_parents_table(self):