/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-03-09 19:07:11 UTC
  • mfrom: (423.14.3 bugstab)
  • Revision ID: jelmer@samba.org-20080309190711-vlvco4ztbw949xew
Add bugs tab in branch view.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import gtk
21
21
import pango
22
22
import gobject
 
23
import subprocess
23
24
 
24
25
from bzrlib.osutils import format_date
25
26
from bzrlib.util.bencode import bdecode
26
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.clear()
 
39
 
 
40
    def clear(self):
 
41
        for c in self.get_children():
 
42
            self.remove(c)
 
43
        self.count = 0
 
44
        self.hide_all() # Only shown when there are bugs
 
45
 
 
46
    def add_bug(self, url, status):
 
47
        button = gtk.LinkButton(url, url)
 
48
        self.attach(button, 0, 1, self.count, self.count + 1,
 
49
                              gtk.EXPAND | gtk.FILL, gtk.FILL)
 
50
        status_label = gtk.Label(status)
 
51
        self.attach(status_label, 1, 2, self.count, self.count + 1,
 
52
                              gtk.EXPAND | gtk.FILL, gtk.FILL)
 
53
        self.count += 1
 
54
        self.show_all()
 
55
 
 
56
 
27
57
class RevisionView(gtk.Notebook):
28
58
    """ Custom widget for commit log details.
29
59
 
68
98
        self._create_general()
69
99
        self._create_relations()
70
100
        self._create_file_info_view()
 
101
        self._create_bugs()
71
102
 
72
103
        self.set_current_page(0)
73
104
        
176
207
        else:
177
208
            self.file_info_box.hide()
178
209
 
 
210
        self.bugs_table.clear()
 
211
        bugs_text = revision.properties.get('bugs', None)
 
212
        if bugs_text:
 
213
            for bugline in bugs_text.splitlines():
 
214
                (url, status) = bugline.split(" ")
 
215
                self.bugs_table.add_bug(url, status)
 
216
 
179
217
    def update_tags(self):
180
218
        if self._branch is not None and self._branch.supports_tags():
181
219
            self._tagdict = self._branch.tags.get_reverse_tag_dict()
429
467
        window.show()
430
468
        return window
431
469
 
 
470
    def _create_bugs(self):
 
471
        self.bugs_table = BugsTab()
 
472
        self.append_page(self.bugs_table, tab_label=gtk.Label('Bugs'))
 
473
 
432
474
    def _create_file_info_view(self):
433
475
        self.file_info_box = gtk.VBox(False, 6)
434
476
        self.file_info_box.set_border_width(6)