/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: Jelmer Vernooij
  • Date: 2012-07-09 15:23:26 UTC
  • mto: This revision was merged to the branch mainline in revision 794.
  • Revision ID: jelmer@samba.org-20120709152326-dzxb8zoz0btull7n
Remove bzr-notify.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from bzrlib import trace
24
24
from bzrlib.osutils import format_date
25
 
try:
26
 
    from bzrlib.bencode import bdecode
27
 
except ImportError:
28
 
    from bzrlib.util.bencode import bdecode
 
25
from bzrlib.bencode import bdecode
29
26
from bzrlib.testament import Testament
30
27
 
31
28
from bzrlib.plugins.gtk import icon_path
51
48
            webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
52
49
    webbrowser.open(uri)
53
50
 
54
 
if getattr(gtk, 'link_button_set_uri_hook', None) is not None:
55
 
    Gtk.link_button_set_uri_hook(_open_link)
56
51
 
57
52
class BugsTab(Gtk.VBox):
58
53
 
59
54
    def __init__(self):
60
 
        super(BugsTab, self).__init__(False, 6)
 
55
        super(BugsTab, self).__init__(homogeneous=False, spacing=6)
61
56
 
62
57
        table = Gtk.Table(rows=2, columns=2)
63
58
 
68
63
        image.set_from_file(icon_path("bug.png"))
69
64
        table.attach(image, 0, 1, 0, 1, Gtk.AttachOptions.FILL)
70
65
 
71
 
        align = Gtk.Alignment.new(0.0, 0.1)
 
66
        align = Gtk.Alignment.new(0.0, 0.1, 0, 0)
72
67
        self.label = Gtk.Label()
73
68
        align.add(self.label)
74
69
        table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.FILL)
106
101
 
107
102
    def construct_treeview(self):
108
103
        self.bugs = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
109
 
        self.treeview = Gtk.TreeView(self.bugs)
 
104
        self.treeview = Gtk.TreeView(model=self.bugs)
110
105
        self.treeview.set_headers_visible(False)
111
106
 
112
107
        uri_column = Gtk.TreeViewColumn('Bug URI', Gtk.CellRendererText(), text=0)
148
143
        self.revision = None
149
144
        self.repository = repository
150
145
 
151
 
        super(SignatureTab, self).__init__(False, 6)
 
146
        super(SignatureTab, self).__init__(homogeneous=False, spacing=6)
152
147
        signature_box = Gtk.Table(rows=3, columns=3)
153
148
        signature_box.set_col_spacing(0, 16)
154
149
        signature_box.set_col_spacing(1, 12)
157
152
        self.signature_image = Gtk.Image()
158
153
        signature_box.attach(self.signature_image, 0, 1, 0, 1, Gtk.AttachOptions.FILL)
159
154
 
160
 
        align = Gtk.Alignment.new(0.0, 0.1)
 
155
        align = Gtk.Alignment.new(0.0, 0.1, 0.0, 0.0)
161
156
        self.signature_label = Gtk.Label()
162
157
        align.add(self.signature_label)
163
158
        signature_box.attach(align, 1, 3, 0, 1, Gtk.AttachOptions.FILL)
164
159
 
165
 
        align = Gtk.Alignment.new(0.0, 0.5)
 
160
        align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
166
161
        self.signature_key_id_label = Gtk.Label()
167
162
        self.signature_key_id_label.set_markup("<b>Key Id:</b>")
168
163
        align.add(self.signature_key_id_label)
169
164
        signature_box.attach(align, 1, 2, 1, 2, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
170
165
 
171
 
        align = Gtk.Alignment.new(0.0, 0.5)
 
166
        align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
172
167
        self.signature_key_id = Gtk.Label()
173
168
        self.signature_key_id.set_selectable(True)
174
169
        align.add(self.signature_key_id)
175
170
        signature_box.attach(align, 2, 3, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
176
171
 
177
 
        align = Gtk.Alignment.new(0.0, 0.5)
 
172
        align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
178
173
        self.signature_fingerprint_label = Gtk.Label()
179
174
        self.signature_fingerprint_label.set_markup("<b>Fingerprint:</b>")
180
175
        align.add(self.signature_fingerprint_label)
181
176
        signature_box.attach(align, 1, 2, 2, 3, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
182
177
 
183
 
        align = Gtk.Alignment.new(0.0, 0.5)
 
178
        align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
184
179
        self.signature_fingerprint = Gtk.Label()
185
180
        self.signature_fingerprint.set_selectable(True)
186
181
        align.add(self.signature_fingerprint)
187
182
        signature_box.attach(align, 2, 3, 2, 3, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
188
183
 
189
 
        align = Gtk.Alignment.new(0.0, 0.5)
 
184
        align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
190
185
        self.signature_trust_label = Gtk.Label()
191
186
        self.signature_trust_label.set_markup("<b>Trust:</b>")
192
187
        align.add(self.signature_trust_label)
193
188
        signature_box.attach(align, 1, 2, 3, 4, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
194
189
 
195
 
        align = Gtk.Alignment.new(0.0, 0.5)
 
190
        align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
196
191
        self.signature_trust = Gtk.Label()
197
192
        self.signature_trust.set_selectable(True)
198
193
        align.add(self.signature_trust)
327
322
    }
328
323
 
329
324
    def __init__(self, branch=None, repository=None):
330
 
        GObject.GObject.__init__(self)
 
325
        super(RevisionView, self).__init__()
331
326
 
332
327
        self._revision = None
333
328
        self._branch = branch
335
330
            self._repository = branch.repository
336
331
        else:
337
332
            self._repository = repository
 
333
        self.signature_table = None
338
334
 
339
335
        self._create_general()
340
336
        self._create_relations()
474
470
        self._add_tags()
475
471
 
476
472
    def _update_signature(self, widget, param):
 
473
        if not has_seahorse:
 
474
            return
477
475
        if self.get_current_page() == PAGE_SIGNATURE:
478
476
            self.signature_table.set_revision(self._revision)
479
477
 
488
486
                                      self.children_table)
489
487
 
490
488
    def _switch_page_cb(self, notebook, page, page_num):
 
489
        if not has_seahorse:
 
490
            return
491
491
        if page_num == PAGE_SIGNATURE:
492
492
            self.signature_table.set_revision(self._revision)
493
493
 
533
533
                                      Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
534
534
            align.show()
535
535
 
536
 
            hbox = Gtk.HBox(False, spacing=6)
 
536
            hbox = Gtk.HBox(homogeneous=False, spacing=6)
537
537
            align.add(hbox)
538
538
            hbox.show()
539
539
 
547
547
                button.add(image)
548
548
                button.connect("clicked", self._show_clicked_cb,
549
549
                               self._revision.revision_id, revid)
550
 
                hbox.pack_start(button, expand=False, fill=True)
 
550
                hbox.pack_start(button, False, True, 0)
551
551
                button.show()
552
552
 
553
553
            button = Gtk.Button()
556
556
            revid_label.set_alignment(0.0, 0.5)
557
557
            button.add(revid_label)
558
558
            button.connect("clicked",
559
 
                    lambda w, r: self.set_revision(self._repository.get_revision(r)), revid)
 
559
                    lambda w, r: self.set_revision(
 
560
                        self._repository.get_revision(r)), revid)
560
561
            button.set_use_underline(False)
561
 
            hbox.pack_start(button, expand=True, fill=True)
 
562
            hbox.pack_start(button, True, True, 0)
562
563
            button.show_all()
563
564
 
564
565
    def _create_general(self):
565
 
        vbox = Gtk.VBox(False, 6)
 
566
        vbox = Gtk.VBox(homogeneous=False, spacing=6)
566
567
        vbox.set_border_width(6)
567
 
        vbox.pack_start(self._create_headers(, True, True, 0), expand=False, fill=True)
568
 
        vbox.pack_start(self._create_message_view(, True, True, 0))
569
 
        self.append_page(vbox, tab_label=Gtk.Label(label="General"))
 
568
        vbox.pack_start(self._create_headers(), False, True, 0)
 
569
        vbox.pack_start(self._create_message_view(), True, True, 0)
 
570
        self.append_page(vbox, Gtk.Label(label="General"))
570
571
        vbox.show()
571
572
 
572
573
    def _create_relations(self):
573
 
        vbox = Gtk.VBox(False, 6)
 
574
        vbox = Gtk.VBox(homogeneous=False, spacing=6)
574
575
        vbox.set_border_width(6)
575
 
        vbox.pack_start(self._create_parents(, True, True, 0), expand=False, fill=True)
576
 
        vbox.pack_start(self._create_children(, True, True, 0), expand=False, fill=True)
577
 
        self.append_page(vbox, tab_label=Gtk.Label(label="Relations"))
 
576
        vbox.pack_start(self._create_parents(), False, True, 0)
 
577
        vbox.pack_start(self._create_children(), False, True, 0)
 
578
        self.append_page(vbox, Gtk.Label(label="Relations"))
578
579
        vbox.show()
579
580
 
580
581
    def _create_signature(self):
581
582
        self.signature_table = SignatureTab(self._repository)
582
 
        self.append_page(self.signature_table, tab_label=Gtk.Label(label='Signature'))
 
583
        self.append_page(
 
584
            self.signature_table, Gtk.Label(label='Signature'))
583
585
        self.connect_after('notify::revision', self._update_signature)
584
586
 
585
587
    def _create_headers(self):
682
684
 
683
685
        self.connect('notify::revision', self._add_tags)
684
686
 
685
 
        self.avatarsbox.show()
686
687
        return self.avatarsbox
687
688
    
688
689
    def _create_parents(self):
689
 
        hbox = Gtk.HBox(True, 3)
 
690
        hbox = Gtk.HBox(homogeneous=True, spacing=3)
690
691
        
691
692
        self.parents_table = self._create_parents_or_children_table(
692
693
            "<b>Parents:</b>")
697
698
        return hbox
698
699
 
699
700
    def _create_children(self):
700
 
        hbox = Gtk.HBox(True, 3)
 
701
        hbox = Gtk.HBox(homogeneous=True, spacing=3)
701
702
        self.children_table = self._create_parents_or_children_table(
702
703
            "<b>Children:</b>")
703
704
        self.children_widgets = []
713
714
 
714
715
        label = Gtk.Label()
715
716
        label.set_markup(text)
716
 
        align = Gtk.Alignment.new(0.0, 0.5)
 
717
        align = Gtk.Alignment.new(0.0, 0.5, 0, 0)
717
718
        align.add(label)
718
719
        table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
719
720
        label.show()
728
729
        window = Gtk.ScrolledWindow()
729
730
        window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
730
731
        window.set_shadow_type(Gtk.ShadowType.IN)
731
 
        tv = Gtk.TextView(msg_buffer)
 
732
        tv = Gtk.TextView(buffer=msg_buffer)
732
733
        tv.set_editable(False)
733
734
        tv.set_wrap_mode(Gtk.WrapMode.WORD)
734
735
 
741
742
    def _create_bugs(self):
742
743
        self.bugs_page = BugsTab()
743
744
        self.connect_after('notify::revision', self._update_bugs) 
744
 
        self.append_page(self.bugs_page, tab_label=Gtk.Label(label='Bugs'))
 
745
        self.append_page(self.bugs_page, Gtk.Label(label='Bugs'))
745
746
 
746
747
    def _create_file_info_view(self):
747
 
        self.file_info_box = Gtk.VBox(False, 6)
 
748
        self.file_info_box = Gtk.VBox(homogeneous=False, spacing=6)
748
749
        self.file_info_box.set_border_width(6)
749
750
        self.file_info_buffer = Gtk.TextBuffer()
750
751
        window = Gtk.ScrolledWindow()
751
752
        window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
752
753
        window.set_shadow_type(Gtk.ShadowType.IN)
753
 
        tv = Gtk.TextView(self.file_info_buffer)
 
754
        tv = Gtk.TextView(buffer=self.file_info_buffer)
754
755
        tv.set_editable(False)
755
756
        tv.set_wrap_mode(Gtk.WrapMode.WORD)
756
757
        tv.modify_font(Pango.FontDescription("Monospace"))
759
760
        window.show()
760
761
        self.file_info_box.pack_start(window, True, True, 0)
761
762
        self.file_info_box.hide() # Only shown when there are per-file messages
762
 
        self.append_page(self.file_info_box, tab_label=Gtk.Label(label='Per-file'))
 
763
        self.append_page(self.file_info_box, Gtk.Label(label='Per-file'))
763
764