/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():
305
321
        )
306
322
    }
307
323
 
308
 
    def __init__(self, branch=None):
 
324
    def __init__(self, branch=None, repository=None):
309
325
        gtk.Notebook.__init__(self)
310
326
 
311
327
        self._revision = None
312
328
        self._branch = branch
 
329
        if branch is not None:
 
330
            self._repository = branch.repository
 
331
        else:
 
332
            self._repository = repository
313
333
 
314
334
        self._create_general()
315
335
        self._create_relations()
 
336
        # Disabled because testaments aren't verified yet:
316
337
        if has_seahorse:
317
338
            self._create_signature()
318
339
        self._create_file_info_view()
488
509
        table.resize(max(len(revids), 1), 2)
489
510
 
490
511
        for idx, revid in enumerate(revids):
491
 
            align = gtk.Alignment(0.0, 0.0)
 
512
            align = gtk.Alignment(0.0, 0.0, 1, 1)
492
513
            widgets.append(align)
493
514
            table.attach(align, 1, 2, idx, idx + 1,
494
515
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
511
532
                hbox.pack_start(button, expand=False, fill=True)
512
533
                button.show()
513
534
 
514
 
            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)
515
540
            button.connect("clicked",
516
 
                    lambda w, r: self.set_revision(self._branch.repository.get_revision(r)), revid)
 
541
                    lambda w, r: self.set_revision(self._repository.get_revision(r)), revid)
517
542
            button.set_use_underline(False)
518
 
            hbox.pack_start(button, expand=False, fill=True)
519
 
            button.show()
 
543
            hbox.pack_start(button, expand=True, fill=True)
 
544
            button.show_all()
520
545
 
521
546
    def _create_general(self):
522
547
        vbox = gtk.VBox(False, 6)
535
560
        vbox.show()
536
561
 
537
562
    def _create_signature(self):
538
 
        self.signature_table = SignatureTab(self._branch.repository)
 
563
        self.signature_table = SignatureTab(self._repository)
539
564
        self.append_page(self.signature_table, tab_label=gtk.Label('Signature'))
540
565
        self.connect_after('notify::revision', self._update_signature)
541
566
 
545
570
        self.table.set_col_spacings(6)
546
571
        self.table.show()
547
572
 
548
 
        align = gtk.Alignment(1.0, 0.5)
 
573
        row = 0
 
574
 
549
575
        label = gtk.Label()
 
576
        label.set_alignment(1.0, 0.5)
550
577
        label.set_markup("<b>Revision Id:</b>")
551
 
        align.add(label)
552
 
        self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
553
 
        align.show()
 
578
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
554
579
        label.show()
555
580
 
556
 
        align = gtk.Alignment(0.0, 0.5)
557
581
        revision_id = gtk.Label()
 
582
        revision_id.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
583
        revision_id.set_alignment(0.0, 0.5)
558
584
        revision_id.set_selectable(True)
559
585
        self.connect('notify::revision', 
560
586
                lambda w, p: revision_id.set_text(self._revision.revision_id))
561
 
        align.add(revision_id)
562
 
        self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
563
 
        align.show()
 
587
        self.table.attach(revision_id, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
564
588
        revision_id.show()
565
589
 
566
 
        align = gtk.Alignment(1.0, 0.5)
 
590
        row += 1
567
591
        self.author_label = gtk.Label()
 
592
        self.author_label.set_alignment(1.0, 0.5)
568
593
        self.author_label.set_markup("<b>Author:</b>")
569
 
        align.add(self.author_label)
570
 
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
571
 
        align.show()
 
594
        self.table.attach(self.author_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
572
595
        self.author_label.show()
573
596
 
574
 
        align = gtk.Alignment(0.0, 0.5)
575
597
        self.author = gtk.Label()
 
598
        self.author.set_ellipsize(pango.ELLIPSIZE_END)
 
599
        self.author.set_alignment(0.0, 0.5)
576
600
        self.author.set_selectable(True)
577
 
        align.add(self.author)
578
 
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
579
 
        align.show()
 
601
        self.table.attach(self.author, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
580
602
        self.author.show()
581
603
        self.author.hide()
582
604
 
583
 
        align = gtk.Alignment(1.0, 0.5)
 
605
        row += 1
584
606
        label = gtk.Label()
 
607
        label.set_alignment(1.0, 0.5)
585
608
        label.set_markup("<b>Committer:</b>")
586
 
        align.add(label)
587
 
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
588
 
        align.show()
 
609
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
589
610
        label.show()
590
611
 
591
 
        align = gtk.Alignment(0.0, 0.5)
592
612
        self.committer = gtk.Label()
 
613
        self.committer.set_ellipsize(pango.ELLIPSIZE_END)
 
614
        self.committer.set_alignment(0.0, 0.5)
593
615
        self.committer.set_selectable(True)
594
 
        align.add(self.committer)
595
 
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
596
 
        align.show()
 
616
        self.table.attach(self.committer, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
597
617
        self.committer.show()
598
618
 
599
 
        align = gtk.Alignment(0.0, 0.5)
 
619
        row += 1
600
620
        label = gtk.Label()
 
621
        label.set_alignment(1.0, 0.5)
601
622
        label.set_markup("<b>Branch nick:</b>")
602
 
        align.add(label)
603
 
        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)
604
624
        label.show()
605
 
        align.show()
606
625
 
607
 
        align = gtk.Alignment(0.0, 0.5)
608
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)
609
629
        self.branchnick_label.set_selectable(True)
610
 
        align.add(self.branchnick_label)
611
 
        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)
612
631
        self.branchnick_label.show()
613
 
        align.show()
614
632
 
615
 
        align = gtk.Alignment(1.0, 0.5)
 
633
        row += 1
616
634
        label = gtk.Label()
 
635
        label.set_alignment(1.0, 0.5)
617
636
        label.set_markup("<b>Timestamp:</b>")
618
 
        align.add(label)
619
 
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
620
 
        align.show()
 
637
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
621
638
        label.show()
622
639
 
623
 
        align = gtk.Alignment(0.0, 0.5)
624
640
        self.timestamp = gtk.Label()
 
641
        self.timestamp.set_ellipsize(pango.ELLIPSIZE_END)
 
642
        self.timestamp.set_alignment(0.0, 0.5)
625
643
        self.timestamp.set_selectable(True)
626
 
        align.add(self.timestamp)
627
 
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
628
 
        align.show()
 
644
        self.table.attach(self.timestamp, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
629
645
        self.timestamp.show()
630
646
 
631
 
        align = gtk.Alignment(1.0, 0.5)
 
647
        row += 1
632
648
        self.tags_label = gtk.Label()
 
649
        self.tags_label.set_alignment(1.0, 0.5)
633
650
        self.tags_label.set_markup("<b>Tags:</b>")
634
 
        align.add(self.tags_label)
635
 
        align.show()
636
 
        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)
637
652
        self.tags_label.show()
638
653
 
639
 
        align = gtk.Alignment(0.0, 0.5)
640
654
        self.tags_list = gtk.Label()
641
 
        align.add(self.tags_list)
642
 
        self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
643
 
        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)
644
658
        self.tags_list.show()
645
659
 
646
660
        self.connect('notify::revision', self._add_tags)