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

  • Committer: Jelmer Vernooij
  • Date: 2008-01-27 00:58:40 UTC
  • mto: This revision was merged to the branch mainline in revision 448.
  • Revision ID: jelmer@samba.org-20080127005840-ku1n2v9ojqwtq2f7
Move bugs tab to separate widget.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from bzrlib.osutils import format_date
26
26
from bzrlib.util.bencode import bdecode
27
27
 
 
28
def _open_link(widget, uri):
 
29
    subprocess.Popen(['sensible-browser', uri], close_fds=True)
 
30
 
 
31
gtk.link_button_set_uri_hook(_open_link)
 
32
 
 
33
class BugsTab(gtk.Table):
 
34
    def __init__(self):
 
35
        super(BugsTab, self).__init__(rows=5, columns=2)
 
36
        self.set_row_spacings(6)
 
37
        self.set_col_spacings(6)
 
38
        self.hide() # Only shown when there are bugs
 
39
 
 
40
    def clear(self):
 
41
        for c in self.get_children():
 
42
            self.remove(c)
 
43
        self.count = 0
 
44
 
 
45
    def add_bug(self, url, status):
 
46
        button = gtk.LinkButton(url, url)
 
47
        self.attach(button, 0, 1, self.count, self.count + 1,
 
48
                              gtk.EXPAND | gtk.FILL, gtk.FILL)
 
49
        status_label = gtk.Label(status)
 
50
        self.attach(status_label, 1, 2, self.count, self.count + 1,
 
51
                              gtk.EXPAND | gtk.FILL, gtk.FILL)
 
52
        self.count += 1
 
53
 
 
54
 
28
55
class RevisionView(gtk.Notebook):
29
56
    """ Custom widget for commit log details.
30
57
 
128
155
    def get_revision(self):
129
156
        return self.get_property('revision')
130
157
 
131
 
    def _open_link(self, widget, uri):
132
 
        subprocess.Popen(['sensible-browser', uri], close_fds=True)
133
 
 
134
158
    def _set_revision(self, revision):
135
159
        if revision is None: return
136
160
 
186
210
 
187
211
        bugs_text = revision.properties.get('bugs', None)
188
212
        if bugs_text:
189
 
            for c in self.bugs_table.get_children():
190
 
                self.bugs_table.remove(c)
191
 
            idx = 0
192
213
            for bugline in bugs_text.splitlines():
193
214
                (url, status) = bugline.split(" ")
194
 
                button = gtk.LinkButton(url, url)
195
 
                gtk.link_button_set_uri_hook(self._open_link)
196
 
                self.bugs_table.attach(button, 0, 1, idx, idx + 1,
197
 
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
198
 
                status_label = gtk.Label(status)
199
 
                self.bugs_table.attach(status_label, 1, 2, idx, idx + 1,
200
 
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
201
 
                idx += 1
 
215
                self.bugs_table.add_bug(url, status)
202
216
            self.bugs_table.show_all()
203
217
        else:
204
218
            self.bugs_table.hide()
456
470
        return window
457
471
 
458
472
    def _create_bugs(self):
459
 
        self.bugs_table = gtk.Table(rows=5, columns=2)
460
 
        self.bugs_table.set_row_spacings(6)
461
 
        self.bugs_table.set_col_spacings(6)
462
 
        self.bugs_table.hide() # Only shown when there are bugs
 
473
        self.bugs_table = BugsTab()
463
474
        self.append_page(self.bugs_table, tab_label=gtk.Label('Bugs'))
464
475
 
465
476
    def _create_file_info_view(self):