/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 Bennetts
  • Date: 2008-04-29 08:17:01 UTC
  • mto: This revision was merged to the branch mainline in revision 476.
  • Revision ID: andrew@puzzling.org-20080429081701-2pu9uteic8o88nre
Simple hack to fix gannotate.

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