/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: Mateusz Korniak
  • Date: 2007-09-02 15:42:18 UTC
  • mto: This revision was merged to the branch mainline in revision 274.
  • Revision ID: matkor@laptop-hp-20070902154218-nba0woaqjsn20f9n
Ignoring eric3 project files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005 Dan Loda <danloda@gmail.com>
 
2
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
2
3
 
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
29
30
    start.
30
31
    """
31
32
 
32
 
    def __init__(self, revision=None):
33
 
        gtk.ScrolledWindow.__init__(self)
34
 
        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
33
    def __init__(self, revision=None, scroll=True, tags=[]):
 
34
        super(LogView, self).__init__()
 
35
        if scroll:
 
36
            self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
 
37
        else:
 
38
            self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
35
39
        self.set_shadow_type(gtk.SHADOW_NONE)
36
40
        self._create()
37
41
        self._show_callback = None
39
43
        self._clicked_callback = None
40
44
 
41
45
        if revision is not None:
42
 
            self.set_revision(revision)
 
46
            self.set_revision(revision, tags=tags)
43
47
 
44
48
    def set_show_callback(self, callback):
45
49
        self._show_callback = callback
47
51
    def set_go_callback(self, callback):
48
52
        self._go_callback = callback
49
53
 
50
 
    def set_revision(self, revision):
 
54
    def set_revision(self, revision, tags=[]):
51
55
        self._revision = revision
52
56
        self.revision_id.set_text(revision.revision_id)
53
 
        self.committer.set_text(revision.committer)
54
 
        self.timestamp.set_text(format_date(revision.timestamp,
55
 
                                            revision.timezone))
 
57
        if revision.committer is not None:
 
58
            self.committer.set_text(revision.committer)
 
59
        else:
 
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
 
 
70
        if revision.timestamp is not None:
 
71
            self.timestamp.set_text(format_date(revision.timestamp,
 
72
                                                revision.timezone))
56
73
        self.message_buffer.set_text(revision.message)
57
74
        try:
58
75
            self.branchnick_label.set_text(revision.properties['branch-nick'])
60
77
            self.branchnick_label.set_text("")
61
78
 
62
79
        self._add_parents(revision.parent_ids)
 
80
        self._add_tags(tags)
63
81
 
64
82
    def _show_clicked_cb(self, widget, revid, parentid):
65
83
        """Callback for when the show button for a parent is clicked."""
69
87
        """Callback for when the go button for a parent is clicked."""
70
88
        self._go_callback(revid)
71
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
 
72
110
    def _add_parents(self, parent_ids):
73
111
        for widget in self.parents_widgets:
74
112
            self.parents_table.remove(widget)
119
157
        vbox.show()
120
158
 
121
159
    def _create_headers(self):
122
 
        self.table = gtk.Table(rows=4, columns=2)
 
160
        self.table = gtk.Table(rows=5, columns=2)
123
161
        self.table.set_row_spacings(6)
124
162
        self.table.set_col_spacings(6)
125
163
        self.table.show()
141
179
        self.revision_id.show()
142
180
 
143
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)
144
199
        label = gtk.Label()
145
200
        label.set_markup("<b>Committer:</b>")
146
201
        align.add(label)
147
 
        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)
148
203
        align.show()
149
204
        label.show()
150
205
 
152
207
        self.committer = gtk.Label()
153
208
        self.committer.set_selectable(True)
154
209
        align.add(self.committer)
155
 
        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)
156
211
        align.show()
157
212
        self.committer.show()
158
213
 
160
215
        label = gtk.Label()
161
216
        label.set_markup("<b>Branch nick:</b>")
162
217
        align.add(label)
163
 
        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)
164
219
        label.show()
165
220
        align.show()
166
221
 
168
223
        self.branchnick_label = gtk.Label()
169
224
        self.branchnick_label.set_selectable(True)
170
225
        align.add(self.branchnick_label)
171
 
        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)
172
227
        self.branchnick_label.show()
173
228
        align.show()
174
229
 
176
231
        label = gtk.Label()
177
232
        label.set_markup("<b>Timestamp:</b>")
178
233
        align.add(label)
179
 
        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)
180
235
        align.show()
181
236
        label.show()
182
237
 
184
239
        self.timestamp = gtk.Label()
185
240
        self.timestamp.set_selectable(True)
186
241
        align.add(self.timestamp)
187
 
        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)
188
243
        align.show()
189
244
        self.timestamp.show()
190
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, 5, 6, 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, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
258
        align.show()
 
259
        self.tags_list.show()
 
260
        self.tags_widgets = []
 
261
 
191
262
        return self.table
192
263
 
193
264
    def _create_parents_table(self):