/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: 2011-11-30 21:45:54 UTC
  • Revision ID: jelmer@samba.org-20111130214554-5kfx0b5y7t5zh033
Extend branch preferences, show location widget.

Show diffs side-by-side

added added

removed removed

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