/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-07-31 15:52:43 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110731155243-ln8istmxbryhb4pz
Mechanical changes made by pygi.convert.sh.

Show diffs side-by-side

added added

removed removed

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