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