/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: Curtis Hovey
  • Date: 2011-08-01 14:51:03 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110801145103-t6gak2rovqofy9xx
Update ProgressBarWindow to gtk3.

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