/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: Jelmer Vernooij
  • Date: 2011-04-10 18:44:39 UTC
  • mto: This revision was merged to the branch mainline in revision 730.
  • Revision ID: jelmer@samba.org-20110410184439-g7hqaacexqtviq13
Move i18n support to a separate file, so gettext files aren't loaded unless bzr-gtk is used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from gi.repository import Gtk
18
 
 
19
 
 
20
 
class PluginsPage(Gtk.Paned):
 
17
try:
 
18
    import pygtk
 
19
    pygtk.require("2.0")
 
20
except:
 
21
    pass
 
22
 
 
23
import gtk
 
24
 
 
25
 
 
26
class PluginsPage(gtk.VPaned):
21
27
 
22
28
    def __init__(self):
23
 
        super(PluginsPage, self).__init__()
24
 
        self.set_orientation(Gtk.Orientation.VERTICAL)
 
29
        gtk.VPaned.__init__(self)
25
30
        self.set_border_width(12)
26
31
        self.set_position(216)
27
32
 
28
 
        scrolledwindow = Gtk.ScrolledWindow()
29
 
        scrolledwindow.set_policy(
30
 
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
31
 
        scrolledwindow.set_shadow_type(Gtk.ShadowType.IN)
32
 
        self.model = Gtk.ListStore(str, str)
33
 
        treeview = Gtk.TreeView()
 
33
        scrolledwindow = gtk.ScrolledWindow()
 
34
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
35
        scrolledwindow.set_shadow_type(gtk.SHADOW_IN)
 
36
        self.model = gtk.ListStore(str, str)
 
37
        treeview = gtk.TreeView()
34
38
        scrolledwindow.add(treeview)
35
39
        self.pack1(scrolledwindow, resize=True, shrink=False)
36
40
 
37
 
        self.table = Gtk.Table(columns=2)
 
41
        self.table = gtk.Table(columns=2)
38
42
        self.table.set_border_width(12)
39
43
        self.table.set_row_spacings(6)
40
44
        self.table.set_col_spacings(6)
42
46
        treeview.set_headers_visible(False)
43
47
        treeview.set_model(self.model)
44
48
        treeview.connect("row-activated", self.row_selected)
45
 
        treeview.connect("cursor-changed", self.row_selected)
46
49
 
47
 
        cell = Gtk.CellRendererText()
48
 
        column = Gtk.TreeViewColumn()
49
 
        column.pack_start(cell, True)
 
50
        cell = gtk.CellRendererText()
 
51
        column = gtk.TreeViewColumn()
 
52
        column.pack_start(cell, expand=True)
50
53
        column.add_attribute(cell, "text", 0)
51
54
        treeview.append_column(column)
52
55
 
53
 
        cell = Gtk.CellRendererText()
54
 
        column = Gtk.TreeViewColumn()
55
 
        column.pack_start(cell, True)
 
56
        cell = gtk.CellRendererText()
 
57
        column = gtk.TreeViewColumn()
 
58
        column.pack_start(cell, expand=True)
56
59
        column.add_attribute(cell, "text", 1)
57
60
        treeview.append_column(column)
58
61
 
63
66
        for name in plugin_names:
64
67
            self.model.append([name, getattr(plugins[name], '__file__', None)])
65
68
 
66
 
        scrolledwindow = Gtk.ScrolledWindow()
67
 
        scrolledwindow.set_policy(
68
 
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
 
69
        scrolledwindow = gtk.ScrolledWindow()
 
70
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
69
71
        scrolledwindow.add_with_viewport(self.table)
70
72
        self.pack2(scrolledwindow, resize=False, shrink=True)
71
73
        self.show()
72
74
 
73
 
    def row_selected(self, tv, path=None, tvc=None):
74
 
        if path is None:
75
 
            (path, focus) = tv.get_cursor()
76
 
        if path is None:
77
 
            # The event was fired as the widget was destroyed.
78
 
            return
 
75
    def row_selected(self, tv, path, tvc):
79
76
        import bzrlib
80
77
        p = bzrlib.plugin.plugins()[self.model[path][0]].module
81
78
        from inspect import getdoc
84
81
            self.table.remove(w)
85
82
 
86
83
        if getattr(p, '__author__', None) is not None:
87
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
88
 
            label = Gtk.Label()
 
84
            align = gtk.Alignment(0.0, 0.5)
 
85
            label = gtk.Label()
89
86
            label.set_markup("<b>Author:</b>")
90
87
            align.add(label)
91
 
            self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
88
            self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
92
89
            align.show()
93
90
            label.show()
94
91
 
95
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
96
 
            author = Gtk.Label()
 
92
            align = gtk.Alignment(0.0, 0.5)
 
93
            author = gtk.Label()
97
94
            author.set_text(p.__author__)
98
95
            author.set_selectable(True)
99
96
            align.add(author)
100
 
            self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
97
            self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
101
98
 
102
99
        if getattr(p, '__version__', None) is not None:
103
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
104
 
            label = Gtk.Label()
 
100
            align = gtk.Alignment(0.0, 0.5)
 
101
            label = gtk.Label()
105
102
            label.set_markup("<b>Version:</b>")
106
103
            align.add(label)
107
 
            self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
104
            self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
108
105
            align.show()
109
106
            label.show()
110
107
 
111
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
112
 
            author = Gtk.Label()
 
108
            align = gtk.Alignment(0.0, 0.5)
 
109
            author = gtk.Label()
113
110
            author.set_text(p.__version__)
114
111
            author.set_selectable(True)
115
112
            align.add(author)
116
 
            self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
113
            self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
117
114
 
118
115
        if getdoc(p) is not None:
119
 
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
120
 
            description = Gtk.Label()
 
116
            align = gtk.Alignment(0.0, 0.5)
 
117
            description = gtk.Label()
121
118
            description.set_text(getdoc(p))
122
119
            description.set_selectable(True)
123
120
            align.add(description)
124
 
            self.table.attach(align, 0, 2, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
121
            self.table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
125
122
 
126
123
        self.table.show_all()
 
124
 
 
125