/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
33
35
else:
34
36
    has_seahorse = True
35
37
 
 
38
PAGE_GENERAL = 0
 
39
PAGE_RELATIONS = 1
 
40
PAGE_SIGNATURE = 2
 
41
PAGE_BUGS = 3
 
42
 
 
43
 
36
44
def _open_link(widget, uri):
37
 
    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)
38
49
 
39
50
gtk.link_button_set_uri_hook(_open_link)
40
51
 
211
222
                                        "This revision has not been signed.")
212
223
 
213
224
    def show_signature(self, crypttext):
214
 
        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
215
236
 
216
237
        if key and key.is_available():
217
238
            if key.is_trusted():
300
321
        )
301
322
    }
302
323
 
303
 
 
304
 
    def __init__(self, branch=None):
 
324
    def __init__(self, branch=None, repository=None):
305
325
        gtk.Notebook.__init__(self)
306
326
 
307
327
        self._revision = None
308
328
        self._branch = branch
 
329
        if branch is not None:
 
330
            self._repository = branch.repository
 
331
        else:
 
332
            self._repository = repository
309
333
 
310
334
        self._create_general()
311
335
        self._create_relations()
 
336
        # Disabled because testaments aren't verified yet:
312
337
        if has_seahorse:
313
338
            self._create_signature()
314
339
        self._create_file_info_view()
315
340
        self._create_bugs()
316
341
 
317
 
        self.set_current_page(0)
 
342
        self.set_current_page(PAGE_GENERAL)
 
343
        self.connect_after('switch-page', self._switch_page_cb)
318
344
        
319
345
        self._show_callback = None
320
346
        self._clicked_callback = None
430
456
        self._add_tags()
431
457
 
432
458
    def _update_signature(self, widget, param):
433
 
        self.signature_table.set_revision(self._revision)
 
459
        if self.get_current_page() == PAGE_SIGNATURE:
 
460
            self.signature_table.set_revision(self._revision)
434
461
 
435
462
    def _update_bugs(self, widget, param):
436
463
        self.bugs_page.set_revision(self._revision)
442
469
                                      self.children_widgets,
443
470
                                      self.children_table)
444
471
 
 
472
    def _switch_page_cb(self, notebook, page, page_num):
 
473
        if page_num == PAGE_SIGNATURE:
 
474
            self.signature_table.set_revision(self._revision)
 
475
 
 
476
 
 
477
 
445
478
    def _show_clicked_cb(self, widget, revid, parentid):
446
479
        """Callback for when the show button for a parent is clicked."""
447
480
        self._show_callback(revid, parentid)
476
509
        table.resize(max(len(revids), 1), 2)
477
510
 
478
511
        for idx, revid in enumerate(revids):
479
 
            align = gtk.Alignment(0.0, 0.0)
 
512
            align = gtk.Alignment(0.0, 0.0, 1, 1)
480
513
            widgets.append(align)
481
514
            table.attach(align, 1, 2, idx, idx + 1,
482
515
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
499
532
                hbox.pack_start(button, expand=False, fill=True)
500
533
                button.show()
501
534
 
502
 
            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)
503
540
            button.connect("clicked",
504
 
                    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)
505
542
            button.set_use_underline(False)
506
 
            hbox.pack_start(button, expand=False, fill=True)
507
 
            button.show()
 
543
            hbox.pack_start(button, expand=True, fill=True)
 
544
            button.show_all()
508
545
 
509
546
    def _create_general(self):
510
547
        vbox = gtk.VBox(False, 6)
523
560
        vbox.show()
524
561
 
525
562
    def _create_signature(self):
526
 
        self.signature_table = SignatureTab(self._branch.repository)
 
563
        self.signature_table = SignatureTab(self._repository)
527
564
        self.append_page(self.signature_table, tab_label=gtk.Label('Signature'))
528
565
        self.connect_after('notify::revision', self._update_signature)
529
566
 
533
570
        self.table.set_col_spacings(6)
534
571
        self.table.show()
535
572
 
536
 
        align = gtk.Alignment(1.0, 0.5)
 
573
        row = 0
 
574
 
537
575
        label = gtk.Label()
 
576
        label.set_alignment(1.0, 0.5)
538
577
        label.set_markup("<b>Revision Id:</b>")
539
 
        align.add(label)
540
 
        self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
541
 
        align.show()
 
578
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
542
579
        label.show()
543
580
 
544
 
        align = gtk.Alignment(0.0, 0.5)
545
581
        revision_id = gtk.Label()
 
582
        revision_id.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
 
583
        revision_id.set_alignment(0.0, 0.5)
546
584
        revision_id.set_selectable(True)
547
585
        self.connect('notify::revision', 
548
586
                lambda w, p: revision_id.set_text(self._revision.revision_id))
549
 
        align.add(revision_id)
550
 
        self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
551
 
        align.show()
 
587
        self.table.attach(revision_id, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
552
588
        revision_id.show()
553
589
 
554
 
        align = gtk.Alignment(1.0, 0.5)
 
590
        row += 1
555
591
        self.author_label = gtk.Label()
 
592
        self.author_label.set_alignment(1.0, 0.5)
556
593
        self.author_label.set_markup("<b>Author:</b>")
557
 
        align.add(self.author_label)
558
 
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
559
 
        align.show()
 
594
        self.table.attach(self.author_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
560
595
        self.author_label.show()
561
596
 
562
 
        align = gtk.Alignment(0.0, 0.5)
563
597
        self.author = gtk.Label()
 
598
        self.author.set_ellipsize(pango.ELLIPSIZE_END)
 
599
        self.author.set_alignment(0.0, 0.5)
564
600
        self.author.set_selectable(True)
565
 
        align.add(self.author)
566
 
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
567
 
        align.show()
 
601
        self.table.attach(self.author, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
568
602
        self.author.show()
569
603
        self.author.hide()
570
604
 
571
 
        align = gtk.Alignment(1.0, 0.5)
 
605
        row += 1
572
606
        label = gtk.Label()
 
607
        label.set_alignment(1.0, 0.5)
573
608
        label.set_markup("<b>Committer:</b>")
574
 
        align.add(label)
575
 
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
576
 
        align.show()
 
609
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
577
610
        label.show()
578
611
 
579
 
        align = gtk.Alignment(0.0, 0.5)
580
612
        self.committer = gtk.Label()
 
613
        self.committer.set_ellipsize(pango.ELLIPSIZE_END)
 
614
        self.committer.set_alignment(0.0, 0.5)
581
615
        self.committer.set_selectable(True)
582
 
        align.add(self.committer)
583
 
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
584
 
        align.show()
 
616
        self.table.attach(self.committer, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
585
617
        self.committer.show()
586
618
 
587
 
        align = gtk.Alignment(0.0, 0.5)
 
619
        row += 1
588
620
        label = gtk.Label()
 
621
        label.set_alignment(1.0, 0.5)
589
622
        label.set_markup("<b>Branch nick:</b>")
590
 
        align.add(label)
591
 
        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)
592
624
        label.show()
593
 
        align.show()
594
625
 
595
 
        align = gtk.Alignment(0.0, 0.5)
596
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)
597
629
        self.branchnick_label.set_selectable(True)
598
 
        align.add(self.branchnick_label)
599
 
        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)
600
631
        self.branchnick_label.show()
601
 
        align.show()
602
632
 
603
 
        align = gtk.Alignment(1.0, 0.5)
 
633
        row += 1
604
634
        label = gtk.Label()
 
635
        label.set_alignment(1.0, 0.5)
605
636
        label.set_markup("<b>Timestamp:</b>")
606
 
        align.add(label)
607
 
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
608
 
        align.show()
 
637
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
609
638
        label.show()
610
639
 
611
 
        align = gtk.Alignment(0.0, 0.5)
612
640
        self.timestamp = gtk.Label()
 
641
        self.timestamp.set_ellipsize(pango.ELLIPSIZE_END)
 
642
        self.timestamp.set_alignment(0.0, 0.5)
613
643
        self.timestamp.set_selectable(True)
614
 
        align.add(self.timestamp)
615
 
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
616
 
        align.show()
 
644
        self.table.attach(self.timestamp, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
617
645
        self.timestamp.show()
618
646
 
619
 
        align = gtk.Alignment(1.0, 0.5)
 
647
        row += 1
620
648
        self.tags_label = gtk.Label()
 
649
        self.tags_label.set_alignment(1.0, 0.5)
621
650
        self.tags_label.set_markup("<b>Tags:</b>")
622
 
        align.add(self.tags_label)
623
 
        align.show()
624
 
        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)
625
652
        self.tags_label.show()
626
653
 
627
 
        align = gtk.Alignment(0.0, 0.5)
628
654
        self.tags_list = gtk.Label()
629
 
        align.add(self.tags_list)
630
 
        self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
631
 
        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)
632
658
        self.tags_list.show()
633
659
 
634
660
        self.connect('notify::revision', self._add_tags)