/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: Aaron Bentley
  • Date: 2008-05-22 02:33:40 UTC
  • mfrom: (487.2.8 save-patch)
  • Revision ID: aaron@aaronbentley.com-20080522023340-3x585s8593j6a409
Allow saving from patch window, refactoring, testing.

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():
334
318
        self._create_general()
335
319
        self._create_relations()
336
320
        # Disabled because testaments aren't verified yet:
337
 
        if has_seahorse:
338
 
            self._create_signature()
 
321
        # if has_seahorse:
 
322
        #    self._create_signature()
339
323
        self._create_file_info_view()
340
324
        self._create_bugs()
341
325
 
509
493
        table.resize(max(len(revids), 1), 2)
510
494
 
511
495
        for idx, revid in enumerate(revids):
512
 
            align = gtk.Alignment(0.0, 0.0, 1, 1)
 
496
            align = gtk.Alignment(0.0, 0.0)
513
497
            widgets.append(align)
514
498
            table.attach(align, 1, 2, idx, idx + 1,
515
499
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
532
516
                hbox.pack_start(button, expand=False, fill=True)
533
517
                button.show()
534
518
 
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
            button = gtk.Button(revid)
540
520
            button.connect("clicked",
541
521
                    lambda w, r: self.set_revision(self._repository.get_revision(r)), revid)
542
522
            button.set_use_underline(False)
543
 
            hbox.pack_start(button, expand=True, fill=True)
544
 
            button.show_all()
 
523
            hbox.pack_start(button, expand=False, fill=True)
 
524
            button.show()
545
525
 
546
526
    def _create_general(self):
547
527
        vbox = gtk.VBox(False, 6)
570
550
        self.table.set_col_spacings(6)
571
551
        self.table.show()
572
552
 
573
 
        row = 0
574
 
 
 
553
        align = gtk.Alignment(1.0, 0.5)
575
554
        label = gtk.Label()
576
 
        label.set_alignment(1.0, 0.5)
577
555
        label.set_markup("<b>Revision Id:</b>")
578
 
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
556
        align.add(label)
 
557
        self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
 
558
        align.show()
579
559
        label.show()
580
560
 
 
561
        align = gtk.Alignment(0.0, 0.5)
581
562
        revision_id = gtk.Label()
582
 
        revision_id.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
583
 
        revision_id.set_alignment(0.0, 0.5)
584
563
        revision_id.set_selectable(True)
585
564
        self.connect('notify::revision', 
586
565
                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)
 
566
        align.add(revision_id)
 
567
        self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
568
        align.show()
588
569
        revision_id.show()
589
570
 
590
 
        row += 1
 
571
        align = gtk.Alignment(1.0, 0.5)
591
572
        self.author_label = gtk.Label()
592
 
        self.author_label.set_alignment(1.0, 0.5)
593
573
        self.author_label.set_markup("<b>Author:</b>")
594
 
        self.table.attach(self.author_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
574
        align.add(self.author_label)
 
575
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
 
576
        align.show()
595
577
        self.author_label.show()
596
578
 
 
579
        align = gtk.Alignment(0.0, 0.5)
597
580
        self.author = gtk.Label()
598
 
        self.author.set_ellipsize(pango.ELLIPSIZE_END)
599
 
        self.author.set_alignment(0.0, 0.5)
600
581
        self.author.set_selectable(True)
601
 
        self.table.attach(self.author, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
582
        align.add(self.author)
 
583
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
584
        align.show()
602
585
        self.author.show()
603
586
        self.author.hide()
604
587
 
605
 
        row += 1
 
588
        align = gtk.Alignment(1.0, 0.5)
606
589
        label = gtk.Label()
607
 
        label.set_alignment(1.0, 0.5)
608
590
        label.set_markup("<b>Committer:</b>")
609
 
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
591
        align.add(label)
 
592
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
 
593
        align.show()
610
594
        label.show()
611
595
 
 
596
        align = gtk.Alignment(0.0, 0.5)
612
597
        self.committer = gtk.Label()
613
 
        self.committer.set_ellipsize(pango.ELLIPSIZE_END)
614
 
        self.committer.set_alignment(0.0, 0.5)
615
598
        self.committer.set_selectable(True)
616
 
        self.table.attach(self.committer, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
599
        align.add(self.committer)
 
600
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
601
        align.show()
617
602
        self.committer.show()
618
603
 
619
 
        row += 1
 
604
        align = gtk.Alignment(0.0, 0.5)
620
605
        label = gtk.Label()
621
 
        label.set_alignment(1.0, 0.5)
622
606
        label.set_markup("<b>Branch nick:</b>")
623
 
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
607
        align.add(label)
 
608
        self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
624
609
        label.show()
 
610
        align.show()
625
611
 
 
612
        align = gtk.Alignment(0.0, 0.5)
626
613
        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
614
        self.branchnick_label.set_selectable(True)
630
 
        self.table.attach(self.branchnick_label, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
615
        align.add(self.branchnick_label)
 
616
        self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
631
617
        self.branchnick_label.show()
 
618
        align.show()
632
619
 
633
 
        row += 1
 
620
        align = gtk.Alignment(1.0, 0.5)
634
621
        label = gtk.Label()
635
 
        label.set_alignment(1.0, 0.5)
636
622
        label.set_markup("<b>Timestamp:</b>")
637
 
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
623
        align.add(label)
 
624
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
 
625
        align.show()
638
626
        label.show()
639
627
 
 
628
        align = gtk.Alignment(0.0, 0.5)
640
629
        self.timestamp = gtk.Label()
641
 
        self.timestamp.set_ellipsize(pango.ELLIPSIZE_END)
642
 
        self.timestamp.set_alignment(0.0, 0.5)
643
630
        self.timestamp.set_selectable(True)
644
 
        self.table.attach(self.timestamp, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
631
        align.add(self.timestamp)
 
632
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
633
        align.show()
645
634
        self.timestamp.show()
646
635
 
647
 
        row += 1
 
636
        align = gtk.Alignment(1.0, 0.5)
648
637
        self.tags_label = gtk.Label()
649
 
        self.tags_label.set_alignment(1.0, 0.5)
650
638
        self.tags_label.set_markup("<b>Tags:</b>")
651
 
        self.table.attach(self.tags_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
639
        align.add(self.tags_label)
 
640
        align.show()
 
641
        self.table.attach(align, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
652
642
        self.tags_label.show()
653
643
 
 
644
        align = gtk.Alignment(0.0, 0.5)
654
645
        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)
 
646
        align.add(self.tags_list)
 
647
        self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
648
        align.show()
658
649
        self.tags_list.show()
659
650
 
660
651
        self.connect('notify::revision', self._add_tags)