/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: Daniel Schierbeck
  • Date: 2008-04-01 22:05:41 UTC
  • mto: (461.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 462.
  • Revision ID: daniel.schierbeck@gmail.com-20080401220541-kyqyda8yhp8skurp
Made bug tab prettier.

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