/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: Andrew Starr-Bochicchio
  • Date: 2011-02-15 00:15:40 UTC
  • mfrom: (709 bzr-gtk)
  • mto: This revision was merged to the branch mainline in revision 711.
  • Revision ID: a.starr.b@gmail.com-20110215001540-ivb00xv8s8ma1vn1
Re-merge on trunk, resolving one conflict.

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
47
51
            webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
48
52
    webbrowser.open(uri)
49
53
 
50
 
gtk.link_button_set_uri_hook(_open_link)
 
54
if getattr(gtk, 'link_button_set_uri_hook', None) is not None:
 
55
    # Not available before PyGtk-2.10
 
56
    gtk.link_button_set_uri_hook(_open_link)
51
57
 
52
58
class BugsTab(gtk.VBox):
53
59
 
54
60
    def __init__(self):
55
61
        super(BugsTab, self).__init__(False, 6)
56
 
    
 
62
 
57
63
        table = gtk.Table(rows=2, columns=2)
58
64
 
59
65
        table.set_row_spacings(6)
415
421
            self.timestamp.set_text(format_date(revision.timestamp,
416
422
                                                revision.timezone))
417
423
        try:
418
 
            self.branchnick_label.set_text(revision.properties['branch-nick'])
 
424
            self.branchnick.show()
 
425
            self.branchnick_label.show()
 
426
            self.branchnick.set_text(revision.properties['branch-nick'])
419
427
        except KeyError:
420
 
            self.branchnick_label.set_text("")
 
428
            self.branchnick.hide()
 
429
            self.branchnick_label.hide()
421
430
 
422
431
        self._add_parents_or_children(revision.parent_ids,
423
432
                                      self.parents_widgets,
424
433
                                      self.parents_table)
425
 
        
 
434
 
426
435
        file_info = revision.properties.get('file-info', None)
427
436
        if file_info is not None:
428
 
            file_info = bdecode(file_info.encode('UTF-8'))
 
437
            try:
 
438
                file_info = bdecode(file_info.encode('UTF-8'))
 
439
            except ValueError:
 
440
                trace.note('Invalid per-file info for revision:%s, value: %r',
 
441
                           revision.revision_id, file_info)
 
442
                file_info = None
429
443
 
430
444
        if file_info:
431
445
            if self._file_id is None:
509
523
        table.resize(max(len(revids), 1), 2)
510
524
 
511
525
        for idx, revid in enumerate(revids):
512
 
            align = gtk.Alignment(0.0, 0.0)
 
526
            align = gtk.Alignment(0.0, 0.0, 1, 1)
513
527
            widgets.append(align)
514
528
            table.attach(align, 1, 2, idx, idx + 1,
515
529
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
532
546
                hbox.pack_start(button, expand=False, fill=True)
533
547
                button.show()
534
548
 
535
 
            button = gtk.Button(revid)
 
549
            button = gtk.Button()
 
550
            revid_label = gtk.Label(str(revid))
 
551
            revid_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
552
            revid_label.set_alignment(0.0, 0.5)
 
553
            button.add(revid_label)
536
554
            button.connect("clicked",
537
555
                    lambda w, r: self.set_revision(self._repository.get_revision(r)), revid)
538
556
            button.set_use_underline(False)
539
 
            hbox.pack_start(button, expand=False, fill=True)
540
 
            button.show()
 
557
            hbox.pack_start(button, expand=True, fill=True)
 
558
            button.show_all()
541
559
 
542
560
    def _create_general(self):
543
561
        vbox = gtk.VBox(False, 6)
566
584
        self.table.set_col_spacings(6)
567
585
        self.table.show()
568
586
 
569
 
        align = gtk.Alignment(1.0, 0.5)
 
587
        row = 0
 
588
 
570
589
        label = gtk.Label()
 
590
        label.set_alignment(1.0, 0.5)
571
591
        label.set_markup("<b>Revision Id:</b>")
572
 
        align.add(label)
573
 
        self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
574
 
        align.show()
 
592
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
575
593
        label.show()
576
594
 
577
 
        align = gtk.Alignment(0.0, 0.5)
578
595
        revision_id = gtk.Label()
 
596
        revision_id.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
597
        revision_id.set_alignment(0.0, 0.5)
579
598
        revision_id.set_selectable(True)
580
599
        self.connect('notify::revision', 
581
600
                lambda w, p: revision_id.set_text(self._revision.revision_id))
582
 
        align.add(revision_id)
583
 
        self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
584
 
        align.show()
 
601
        self.table.attach(revision_id, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
585
602
        revision_id.show()
586
603
 
587
 
        align = gtk.Alignment(1.0, 0.5)
 
604
        row += 1
588
605
        self.author_label = gtk.Label()
 
606
        self.author_label.set_alignment(1.0, 0.5)
589
607
        self.author_label.set_markup("<b>Author:</b>")
590
 
        align.add(self.author_label)
591
 
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
592
 
        align.show()
 
608
        self.table.attach(self.author_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
593
609
        self.author_label.show()
594
610
 
595
 
        align = gtk.Alignment(0.0, 0.5)
596
611
        self.author = gtk.Label()
 
612
        self.author.set_ellipsize(pango.ELLIPSIZE_END)
 
613
        self.author.set_alignment(0.0, 0.5)
597
614
        self.author.set_selectable(True)
598
 
        align.add(self.author)
599
 
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
600
 
        align.show()
 
615
        self.table.attach(self.author, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
601
616
        self.author.show()
602
617
        self.author.hide()
603
618
 
604
 
        align = gtk.Alignment(1.0, 0.5)
 
619
        row += 1
605
620
        label = gtk.Label()
 
621
        label.set_alignment(1.0, 0.5)
606
622
        label.set_markup("<b>Committer:</b>")
607
 
        align.add(label)
608
 
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
609
 
        align.show()
 
623
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
610
624
        label.show()
611
625
 
612
 
        align = gtk.Alignment(0.0, 0.5)
613
626
        self.committer = gtk.Label()
 
627
        self.committer.set_ellipsize(pango.ELLIPSIZE_END)
 
628
        self.committer.set_alignment(0.0, 0.5)
614
629
        self.committer.set_selectable(True)
615
 
        align.add(self.committer)
616
 
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
617
 
        align.show()
 
630
        self.table.attach(self.committer, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
618
631
        self.committer.show()
619
632
 
620
 
        align = gtk.Alignment(0.0, 0.5)
621
 
        label = gtk.Label()
622
 
        label.set_markup("<b>Branch nick:</b>")
623
 
        align.add(label)
624
 
        self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
625
 
        label.show()
626
 
        align.show()
627
 
 
628
 
        align = gtk.Alignment(0.0, 0.5)
 
633
        row += 1
629
634
        self.branchnick_label = gtk.Label()
630
 
        self.branchnick_label.set_selectable(True)
631
 
        align.add(self.branchnick_label)
632
 
        self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
635
        self.branchnick_label.set_alignment(1.0, 0.5)
 
636
        self.branchnick_label.set_markup("<b>Branch nick:</b>")
 
637
        self.table.attach(self.branchnick_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
633
638
        self.branchnick_label.show()
634
 
        align.show()
635
 
 
636
 
        align = gtk.Alignment(1.0, 0.5)
 
639
 
 
640
        self.branchnick = gtk.Label()
 
641
        self.branchnick.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
642
        self.branchnick.set_alignment(0.0, 0.5)
 
643
        self.branchnick.set_selectable(True)
 
644
        self.table.attach(self.branchnick, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
645
        self.branchnick.show()
 
646
 
 
647
        row += 1
637
648
        label = gtk.Label()
 
649
        label.set_alignment(1.0, 0.5)
638
650
        label.set_markup("<b>Timestamp:</b>")
639
 
        align.add(label)
640
 
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
641
 
        align.show()
 
651
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
642
652
        label.show()
643
653
 
644
 
        align = gtk.Alignment(0.0, 0.5)
645
654
        self.timestamp = gtk.Label()
 
655
        self.timestamp.set_ellipsize(pango.ELLIPSIZE_END)
 
656
        self.timestamp.set_alignment(0.0, 0.5)
646
657
        self.timestamp.set_selectable(True)
647
 
        align.add(self.timestamp)
648
 
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
649
 
        align.show()
 
658
        self.table.attach(self.timestamp, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
650
659
        self.timestamp.show()
651
660
 
652
 
        align = gtk.Alignment(1.0, 0.5)
 
661
        row += 1
653
662
        self.tags_label = gtk.Label()
 
663
        self.tags_label.set_alignment(1.0, 0.5)
654
664
        self.tags_label.set_markup("<b>Tags:</b>")
655
 
        align.add(self.tags_label)
656
 
        align.show()
657
 
        self.table.attach(align, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
 
665
        self.table.attach(self.tags_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
658
666
        self.tags_label.show()
659
667
 
660
 
        align = gtk.Alignment(0.0, 0.5)
661
668
        self.tags_list = gtk.Label()
662
 
        align.add(self.tags_list)
663
 
        self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
664
 
        align.show()
 
669
        self.tags_list.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
670
        self.tags_list.set_alignment(0.0, 0.5)
 
671
        self.table.attach(self.tags_list, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
665
672
        self.tags_list.show()
666
673
 
667
674
        self.connect('notify::revision', self._add_tags)