/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: 2011-04-10 18:44:39 UTC
  • mto: This revision was merged to the branch mainline in revision 730.
  • Revision ID: jelmer@samba.org-20110410184439-g7hqaacexqtviq13
Move i18n support to a separate file, so gettext files aren't loaded unless bzr-gtk is used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import gobject
23
23
import webbrowser
24
24
 
 
25
from bzrlib import trace
25
26
from bzrlib.osutils import format_date
26
 
from bzrlib.util.bencode import bdecode
 
27
try:
 
28
    from bzrlib.bencode import bdecode
 
29
except ImportError:
 
30
    from bzrlib.util.bencode import bdecode
27
31
from bzrlib.testament import Testament
28
32
 
29
33
from bzrlib.plugins.gtk import icon_path
30
34
 
 
35
from bzrlib.plugins.gtk.avatarsbox import AvatarsBox
 
36
 
31
37
try:
32
38
    from bzrlib.plugins.gtk import seahorse
33
39
except ImportError:
47
53
            webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
48
54
    webbrowser.open(uri)
49
55
 
50
 
gtk.link_button_set_uri_hook(_open_link)
 
56
if getattr(gtk, 'link_button_set_uri_hook', None) is not None:
 
57
    # Not available before PyGtk-2.10
 
58
    gtk.link_button_set_uri_hook(_open_link)
51
59
 
52
60
class BugsTab(gtk.VBox):
53
61
 
54
62
    def __init__(self):
55
63
        super(BugsTab, self).__init__(False, 6)
56
 
    
 
64
 
57
65
        table = gtk.Table(rows=2, columns=2)
58
66
 
59
67
        table.set_row_spacings(6)
87
95
                (url, status) = bugline.split(" ")
88
96
                if status == "fixed":
89
97
                    self.add_bug(url, status)
90
 
        
 
98
 
91
99
        if self.num_bugs == 0:
92
100
            return
93
101
        elif self.num_bugs == 1:
396
404
 
397
405
    def _set_revision(self, revision):
398
406
        if revision is None: return
399
 
 
 
407
        
 
408
        self.avatarsbox.reset()
 
409
        
400
410
        self._revision = revision
401
411
        if revision.committer is not None:
402
412
            self.committer.set_text(revision.committer)
 
413
            self.avatarsbox.add(revision.committer, "committer")
403
414
        else:
404
415
            self.committer.set_text("")
 
416
            self.avatarsbox.hide()
405
417
        author = revision.properties.get('author', '')
 
418
        self.avatarsbox.merge(revision.get_apparent_authors(), "author")
406
419
        if author != '':
407
420
            self.author.set_text(author)
408
421
            self.author.show()
415
428
            self.timestamp.set_text(format_date(revision.timestamp,
416
429
                                                revision.timezone))
417
430
        try:
418
 
            self.branchnick_label.set_text(revision.properties['branch-nick'])
 
431
            self.branchnick.show()
 
432
            self.branchnick_label.show()
 
433
            self.branchnick.set_text(revision.properties['branch-nick'])
419
434
        except KeyError:
420
 
            self.branchnick_label.set_text("")
 
435
            self.branchnick.hide()
 
436
            self.branchnick_label.hide()
421
437
 
422
438
        self._add_parents_or_children(revision.parent_ids,
423
439
                                      self.parents_widgets,
424
440
                                      self.parents_table)
425
 
        
 
441
 
426
442
        file_info = revision.properties.get('file-info', None)
427
443
        if file_info is not None:
428
 
            file_info = bdecode(file_info.encode('UTF-8'))
 
444
            try:
 
445
                file_info = bdecode(file_info.encode('UTF-8'))
 
446
            except ValueError:
 
447
                trace.note('Invalid per-file info for revision:%s, value: %r',
 
448
                           revision.revision_id, file_info)
 
449
                file_info = None
429
450
 
430
451
        if file_info:
431
452
            if self._file_id is None:
565
586
        self.connect_after('notify::revision', self._update_signature)
566
587
 
567
588
    def _create_headers(self):
 
589
        self.avatarsbox = AvatarsBox()
 
590
        
568
591
        self.table = gtk.Table(rows=5, columns=2)
569
592
        self.table.set_row_spacings(6)
570
593
        self.table.set_col_spacings(6)
571
594
        self.table.show()
 
595
        
 
596
        self.avatarsbox.pack_start(self.table)
 
597
        self.avatarsbox.show()
572
598
 
573
599
        row = 0
574
600
 
617
643
        self.committer.show()
618
644
 
619
645
        row += 1
620
 
        label = gtk.Label()
621
 
        label.set_alignment(1.0, 0.5)
622
 
        label.set_markup("<b>Branch nick:</b>")
623
 
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
624
 
        label.show()
625
 
 
626
646
        self.branchnick_label = gtk.Label()
627
 
        self.branchnick_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
628
 
        self.branchnick_label.set_alignment(0.0, 0.5)
629
 
        self.branchnick_label.set_selectable(True)
630
 
        self.table.attach(self.branchnick_label, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
647
        self.branchnick_label.set_alignment(1.0, 0.5)
 
648
        self.branchnick_label.set_markup("<b>Branch nick:</b>")
 
649
        self.table.attach(self.branchnick_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
631
650
        self.branchnick_label.show()
632
651
 
 
652
        self.branchnick = gtk.Label()
 
653
        self.branchnick.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
654
        self.branchnick.set_alignment(0.0, 0.5)
 
655
        self.branchnick.set_selectable(True)
 
656
        self.table.attach(self.branchnick, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
657
        self.branchnick.show()
 
658
 
633
659
        row += 1
634
660
        label = gtk.Label()
635
661
        label.set_alignment(1.0, 0.5)
659
685
 
660
686
        self.connect('notify::revision', self._add_tags)
661
687
 
662
 
        return self.table
 
688
        self.avatarsbox.show()
 
689
        return self.avatarsbox
663
690
    
664
691
    def _create_parents(self):
665
692
        hbox = gtk.HBox(True, 3)