/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: Jasper Groenewegen
  • Date: 2008-07-27 12:01:40 UTC
  • mfrom: (576.3.2 improve-merge)
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: colbrac@xs4all.nl-20080727120140-1agdlzkc9fumjk5f
Merge merge dialog improvements

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
import webbrowser
24
24
 
25
 
from bzrlib.plugins.gtk import icon_path
26
25
from bzrlib.osutils import format_date
27
26
from bzrlib.util.bencode import bdecode
 
27
from bzrlib.testament import Testament
 
28
 
 
29
from bzrlib.plugins.gtk import icon_path
28
30
 
29
31
try:
30
32
    from bzrlib.plugins.gtk import seahorse
38
40
PAGE_SIGNATURE = 2
39
41
PAGE_BUGS = 3
40
42
 
 
43
 
41
44
def _open_link(widget, uri):
42
 
    subprocess.Popen(['sensible-browser', uri], close_fds=True)
 
45
    for cmd in ['sensible-browser', 'xdg-open']:
 
46
        if webbrowser._iscommand(cmd):
 
47
            webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
 
48
    webbrowser.open(uri)
43
49
 
44
50
gtk.link_button_set_uri_hook(_open_link)
45
51
 
216
222
                                        "This revision has not been signed.")
217
223
 
218
224
    def show_signature(self, crypttext):
219
 
        key = seahorse.verify(crypttext)
 
225
        (cleartext, key) = seahorse.verify(crypttext)
 
226
 
 
227
        assert cleartext is not None
 
228
 
 
229
        inv = self.repository.get_inventory(self.revision.revision_id)
 
230
        expected_testament = Testament(self.revision, inv).as_short_text()
 
231
        if expected_testament != cleartext:
 
232
            self.signature_image.set_from_file(icon_path("sign-bad.png"))
 
233
            self.signature_label.set_markup("<b>Signature does not match repository data</b>\n" +
 
234
                        "The signature plaintext is different from the expected testament plaintext.")
 
235
            return
220
236
 
221
237
        if key and key.is_available():
222
238
            if key.is_trusted():
317
333
 
318
334
        self._create_general()
319
335
        self._create_relations()
 
336
        # Disabled because testaments aren't verified yet:
320
337
        if has_seahorse:
321
338
            self._create_signature()
322
339
        self._create_file_info_view()
492
509
        table.resize(max(len(revids), 1), 2)
493
510
 
494
511
        for idx, revid in enumerate(revids):
495
 
            align = gtk.Alignment(0.0, 0.0)
 
512
            align = gtk.Alignment(0.0, 0.0, 1, 1)
496
513
            widgets.append(align)
497
514
            table.attach(align, 1, 2, idx, idx + 1,
498
515
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
515
532
                hbox.pack_start(button, expand=False, fill=True)
516
533
                button.show()
517
534
 
518
 
            button = gtk.Button(revid)
 
535
            button = gtk.Button()
 
536
            revid_label = gtk.Label(str(revid))
 
537
            revid_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
538
            revid_label.set_alignment(0.0, 0.5)
 
539
            button.add(revid_label)
519
540
            button.connect("clicked",
520
541
                    lambda w, r: self.set_revision(self._repository.get_revision(r)), revid)
521
542
            button.set_use_underline(False)
522
 
            hbox.pack_start(button, expand=False, fill=True)
523
 
            button.show()
 
543
            hbox.pack_start(button, expand=True, fill=True)
 
544
            button.show_all()
524
545
 
525
546
    def _create_general(self):
526
547
        vbox = gtk.VBox(False, 6)
549
570
        self.table.set_col_spacings(6)
550
571
        self.table.show()
551
572
 
552
 
        align = gtk.Alignment(1.0, 0.5)
 
573
        row = 0
 
574
 
553
575
        label = gtk.Label()
 
576
        label.set_alignment(1.0, 0.5)
554
577
        label.set_markup("<b>Revision Id:</b>")
555
 
        align.add(label)
556
 
        self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
557
 
        align.show()
 
578
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
558
579
        label.show()
559
580
 
560
 
        align = gtk.Alignment(0.0, 0.5)
561
581
        revision_id = gtk.Label()
 
582
        revision_id.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
583
        revision_id.set_alignment(0.0, 0.5)
562
584
        revision_id.set_selectable(True)
563
585
        self.connect('notify::revision', 
564
586
                lambda w, p: revision_id.set_text(self._revision.revision_id))
565
 
        align.add(revision_id)
566
 
        self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
567
 
        align.show()
 
587
        self.table.attach(revision_id, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
568
588
        revision_id.show()
569
589
 
570
 
        align = gtk.Alignment(1.0, 0.5)
 
590
        row += 1
571
591
        self.author_label = gtk.Label()
 
592
        self.author_label.set_alignment(1.0, 0.5)
572
593
        self.author_label.set_markup("<b>Author:</b>")
573
 
        align.add(self.author_label)
574
 
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
575
 
        align.show()
 
594
        self.table.attach(self.author_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
576
595
        self.author_label.show()
577
596
 
578
 
        align = gtk.Alignment(0.0, 0.5)
579
597
        self.author = gtk.Label()
 
598
        self.author.set_ellipsize(pango.ELLIPSIZE_END)
 
599
        self.author.set_alignment(0.0, 0.5)
580
600
        self.author.set_selectable(True)
581
 
        align.add(self.author)
582
 
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
583
 
        align.show()
 
601
        self.table.attach(self.author, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
584
602
        self.author.show()
585
603
        self.author.hide()
586
604
 
587
 
        align = gtk.Alignment(1.0, 0.5)
 
605
        row += 1
588
606
        label = gtk.Label()
 
607
        label.set_alignment(1.0, 0.5)
589
608
        label.set_markup("<b>Committer:</b>")
590
 
        align.add(label)
591
 
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
592
 
        align.show()
 
609
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
593
610
        label.show()
594
611
 
595
 
        align = gtk.Alignment(0.0, 0.5)
596
612
        self.committer = gtk.Label()
 
613
        self.committer.set_ellipsize(pango.ELLIPSIZE_END)
 
614
        self.committer.set_alignment(0.0, 0.5)
597
615
        self.committer.set_selectable(True)
598
 
        align.add(self.committer)
599
 
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
600
 
        align.show()
 
616
        self.table.attach(self.committer, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
601
617
        self.committer.show()
602
618
 
603
 
        align = gtk.Alignment(0.0, 0.5)
 
619
        row += 1
604
620
        label = gtk.Label()
 
621
        label.set_alignment(1.0, 0.5)
605
622
        label.set_markup("<b>Branch nick:</b>")
606
 
        align.add(label)
607
 
        self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
 
623
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
608
624
        label.show()
609
 
        align.show()
610
625
 
611
 
        align = gtk.Alignment(0.0, 0.5)
612
626
        self.branchnick_label = gtk.Label()
 
627
        self.branchnick_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
628
        self.branchnick_label.set_alignment(0.0, 0.5)
613
629
        self.branchnick_label.set_selectable(True)
614
 
        align.add(self.branchnick_label)
615
 
        self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
630
        self.table.attach(self.branchnick_label, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
616
631
        self.branchnick_label.show()
617
 
        align.show()
618
632
 
619
 
        align = gtk.Alignment(1.0, 0.5)
 
633
        row += 1
620
634
        label = gtk.Label()
 
635
        label.set_alignment(1.0, 0.5)
621
636
        label.set_markup("<b>Timestamp:</b>")
622
 
        align.add(label)
623
 
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
624
 
        align.show()
 
637
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
625
638
        label.show()
626
639
 
627
 
        align = gtk.Alignment(0.0, 0.5)
628
640
        self.timestamp = gtk.Label()
 
641
        self.timestamp.set_ellipsize(pango.ELLIPSIZE_END)
 
642
        self.timestamp.set_alignment(0.0, 0.5)
629
643
        self.timestamp.set_selectable(True)
630
 
        align.add(self.timestamp)
631
 
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
632
 
        align.show()
 
644
        self.table.attach(self.timestamp, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
633
645
        self.timestamp.show()
634
646
 
635
 
        align = gtk.Alignment(1.0, 0.5)
 
647
        row += 1
636
648
        self.tags_label = gtk.Label()
 
649
        self.tags_label.set_alignment(1.0, 0.5)
637
650
        self.tags_label.set_markup("<b>Tags:</b>")
638
 
        align.add(self.tags_label)
639
 
        align.show()
640
 
        self.table.attach(align, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
 
651
        self.table.attach(self.tags_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
641
652
        self.tags_label.show()
642
653
 
643
 
        align = gtk.Alignment(0.0, 0.5)
644
654
        self.tags_list = gtk.Label()
645
 
        align.add(self.tags_list)
646
 
        self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
647
 
        align.show()
 
655
        self.tags_list.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
656
        self.tags_list.set_alignment(0.0, 0.5)
 
657
        self.table.attach(self.tags_list, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
648
658
        self.tags_list.show()
649
659
 
650
660
        self.connect('notify::revision', self._add_tags)