/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 preferences/plugins.py

  • Committer: Curtis Hovey
  • Date: 2011-07-31 16:50:29 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110731165029-9gixuqypi3lwapzm
Removed import_pygtk because gi does not impicitly call Main(). Inlined checks for gtk availablility.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
class PluginsPage(Gtk.VPaned):
21
21
 
22
22
    def __init__(self):
23
 
        super(PluginsPage, self).__init__()
 
23
        GObject.GObject.__init__(self)
24
24
        self.set_border_width(12)
25
25
        self.set_position(216)
26
26
 
27
27
        scrolledwindow = Gtk.ScrolledWindow()
28
 
        scrolledwindow.set_policy(
29
 
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
 
28
        scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
30
29
        scrolledwindow.set_shadow_type(Gtk.ShadowType.IN)
31
30
        self.model = Gtk.ListStore(str, str)
32
31
        treeview = Gtk.TreeView()
41
40
        treeview.set_headers_visible(False)
42
41
        treeview.set_model(self.model)
43
42
        treeview.connect("row-activated", self.row_selected)
44
 
        treeview.connect("cursor-changed", self.row_selected)
45
43
 
46
44
        cell = Gtk.CellRendererText()
47
45
        column = Gtk.TreeViewColumn()
48
 
        column.pack_start(cell, True)
 
46
        column.pack_start(cell, True, True, 0)
49
47
        column.add_attribute(cell, "text", 0)
50
48
        treeview.append_column(column)
51
49
 
52
50
        cell = Gtk.CellRendererText()
53
51
        column = Gtk.TreeViewColumn()
54
 
        column.pack_start(cell, True)
 
52
        column.pack_start(cell, True, True, 0)
55
53
        column.add_attribute(cell, "text", 1)
56
54
        treeview.append_column(column)
57
55
 
63
61
            self.model.append([name, getattr(plugins[name], '__file__', None)])
64
62
 
65
63
        scrolledwindow = Gtk.ScrolledWindow()
66
 
        scrolledwindow.set_policy(
67
 
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
 
64
        scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
68
65
        scrolledwindow.add_with_viewport(self.table)
69
66
        self.pack2(scrolledwindow, resize=False, shrink=True)
70
67
        self.show()
71
68
 
72
 
    def row_selected(self, tv, path=None, tvc=None):
73
 
        if path is None:
74
 
            (path, focus) = tv.get_cursor()
75
 
        if path is None:
76
 
            # The event was fired as the widget was destroyed.
77
 
            return
 
69
    def row_selected(self, tv, path, tvc):
78
70
        import bzrlib
79
71
        p = bzrlib.plugin.plugins()[self.model[path][0]].module
80
72
        from inspect import getdoc
83
75
            self.table.remove(w)
84
76
 
85
77
        if getattr(p, '__author__', None) is not None:
86
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
78
            align = Gtk.Alignment.new(0.0, 0.5)
87
79
            label = Gtk.Label()
88
80
            label.set_markup("<b>Author:</b>")
89
81
            align.add(label)
91
83
            align.show()
92
84
            label.show()
93
85
 
94
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
86
            align = Gtk.Alignment.new(0.0, 0.5)
95
87
            author = Gtk.Label()
96
88
            author.set_text(p.__author__)
97
89
            author.set_selectable(True)
99
91
            self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
100
92
 
101
93
        if getattr(p, '__version__', None) is not None:
102
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
94
            align = Gtk.Alignment.new(0.0, 0.5)
103
95
            label = Gtk.Label()
104
96
            label.set_markup("<b>Version:</b>")
105
97
            align.add(label)
107
99
            align.show()
108
100
            label.show()
109
101
 
110
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
102
            align = Gtk.Alignment.new(0.0, 0.5)
111
103
            author = Gtk.Label()
112
104
            author.set_text(p.__version__)
113
105
            author.set_selectable(True)
115
107
            self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
116
108
 
117
109
        if getdoc(p) is not None:
118
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
110
            align = Gtk.Alignment.new(0.0, 0.5)
119
111
            description = Gtk.Label()
120
112
            description.set_text(getdoc(p))
121
113
            description.set_selectable(True)
123
115
            self.table.attach(align, 0, 2, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
124
116
 
125
117
        self.table.show_all()
 
118
 
 
119