/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/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2008-06-29 19:18:34 UTC
  • mto: This revision was merged to the branch mainline in revision 515.
  • Revision ID: jelmer@samba.org-20080629191834-ha2ecpv5szt96nge
Make sure signed testament matches repository data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import gtk
24
24
 
25
25
from bzrlib.config import GlobalConfig
 
26
from identity import IdentityPage
 
27
from plugins import PluginsPage
26
28
 
27
29
class PreferencesWindow(gtk.Dialog):
28
30
    """Displays global preferences windows."""
 
31
    # Note that we don't allow configuration of aliases or 
 
32
    # default log formats. This is because doing so wouldn't make 
 
33
    # a lot of sense to pure GUI users. Users that need these settings 
 
34
    # will already be familiar with the configuration file.
 
35
 
29
36
    def __init__(self, config=None):
30
37
        """ Initialize the Status window. """
31
38
        super(PreferencesWindow, self).__init__(flags=gtk.DIALOG_MODAL)
34
41
        if self.config is None:
35
42
            self.config = GlobalConfig()
36
43
        self._create()
37
 
 
38
 
    def _create_mainpage(self):
39
 
        table = gtk.Table(rows=4, columns=2)
40
 
        table.set_row_spacings(6)
41
 
        table.set_col_spacings(6)
42
 
 
43
 
        align = gtk.Alignment(1.0, 0.5)
44
 
        label = gtk.Label()
45
 
        label.set_markup("<b>User Id:</b>")
46
 
        align.add(label)
47
 
        table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
48
 
 
49
 
        align = gtk.Alignment(0.0, 0.5)
50
 
        self.username = gtk.Entry()
51
 
        align.add(self.username)
52
 
        self.username.set_text(self.config.username())
53
 
        table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
54
 
 
55
 
        align = gtk.Alignment(1.0, 0.5)
56
 
        label = gtk.Label()
57
 
        label.set_markup("<b>GPG signing command:</b>")
58
 
        align.add(label)
59
 
        table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
60
 
 
61
 
        align = gtk.Alignment(0.0, 0.5)
62
 
        self.email = gtk.Entry()
63
 
        self.email.set_text(self.config.gpg_signing_command())
64
 
        align.add(self.email)
65
 
        table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
66
 
 
67
 
        align = gtk.Alignment(1.0, 0.5)
68
 
        label = gtk.Label()
69
 
        label.set_markup("<b>Check GPG Signatures:</b>")
70
 
        align.add(label)
71
 
        table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
72
 
 
73
 
        align = gtk.Alignment(0.0, 0.5)
74
 
        self.check_sigs = gtk.Entry()
75
 
        #self.check_sigs.set_text(self.config.signature_checking())
76
 
        align.add(self.check_sigs)
77
 
        table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
78
 
 
79
 
        align = gtk.Alignment(1.0, 0.5)
80
 
        label = gtk.Label()
81
 
        label.set_markup("<b>Create GPG Signatures:</b>")
82
 
        align.add(label)
83
 
        table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
84
 
 
85
 
        align = gtk.Alignment(0.0, 0.5)
86
 
        self.create_sigs = gtk.Entry()
87
 
        #self.create_sigs.set_text(self.config.signing_policy())
88
 
        align.add(self.create_sigs)
89
 
        table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
90
 
 
91
 
        return table
92
 
 
93
 
 
94
 
 
95
 
    def _create_pluginpage(self):
96
 
        vbox = gtk.VBox(False, 2)
97
 
        vbox.set_border_width(6)
98
 
 
99
 
        scrolledwindow = gtk.ScrolledWindow()
100
 
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
101
 
        model = gtk.ListStore(str, str)
102
 
        treeview = gtk.TreeView()
103
 
        scrolledwindow.add(treeview)
104
 
 
105
 
        table = gtk.Table(columns=2)
106
 
        table.set_row_spacings(6)
107
 
        table.set_col_spacings(6)
108
 
 
109
 
 
110
 
        def row_selected(tv, path, tvc):
111
 
            p = bzrlib.plugin.all_plugins()[model[path][0]]
112
 
            from inspect import getdoc
113
 
 
114
 
            for w in table.get_children():
115
 
                table.remove(w)
116
 
 
117
 
            if getattr(p, '__author__', None) is not None:
118
 
                align = gtk.Alignment(1.0, 0.5)
119
 
                label = gtk.Label()
120
 
                label.set_markup("<b>Author:</b>")
121
 
                align.add(label)
122
 
                table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
123
 
                align.show()
124
 
                label.show()
125
 
 
126
 
                align = gtk.Alignment(0.0, 0.5)
127
 
                author = gtk.Label()
128
 
                author.set_text(p.__author__)
129
 
                author.set_selectable(True)
130
 
                align.add(author)
131
 
                table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
132
 
 
133
 
            if getattr(p, '__version__', None) is not None:
134
 
                align = gtk.Alignment(1.0, 0.5)
135
 
                label = gtk.Label()
136
 
                label.set_markup("<b>Version:</b>")
137
 
                align.add(label)
138
 
                table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
139
 
                align.show()
140
 
                label.show()
141
 
 
142
 
                align = gtk.Alignment(0.0, 0.5)
143
 
                author = gtk.Label()
144
 
                author.set_text(p.__version__)
145
 
                author.set_selectable(True)
146
 
                align.add(author)
147
 
                table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
148
 
 
149
 
            if getdoc(p) is not None:
150
 
                align = gtk.Alignment(0.0, 0.5)
151
 
                description = gtk.Label()
152
 
                description.set_text(getdoc(p))
153
 
                description.set_selectable(True)
154
 
                align.add(description)
155
 
                table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
156
 
 
157
 
            table.show_all()
158
 
 
159
 
        treeview.set_headers_visible(False)
160
 
        treeview.set_model(model)
161
 
        treeview.connect("row-activated", row_selected)
162
 
 
163
 
        cell = gtk.CellRendererText()
164
 
        column = gtk.TreeViewColumn()
165
 
        column.pack_start(cell, expand=True)
166
 
        column.add_attribute(cell, "text", 0)
167
 
        treeview.append_column(column)
168
 
 
169
 
        cell = gtk.CellRendererText()
170
 
        column = gtk.TreeViewColumn()
171
 
        column.pack_start(cell, expand=True)
172
 
        column.add_attribute(cell, "text", 1)
173
 
        treeview.append_column(column)
174
 
        
175
 
        import bzrlib.plugin
176
 
        for name, plugin in bzrlib.plugin.all_plugins().items():
177
 
            model.append([name, getattr(plugin, '__file__', None)])
178
 
                 
179
 
        vbox.pack_start(scrolledwindow, expand=True, fill=True)
180
 
 
181
 
        vbox.pack_start(table)
182
 
 
183
 
        return vbox
 
44
        self._create_pages()
 
45
 
184
46
 
185
47
    def _create(self):
186
48
        self.set_default_size(600, 600)
187
49
        notebook = gtk.Notebook()
188
 
        notebook.insert_page(self._create_mainpage(), gtk.Label("Main"))
189
 
        notebook.insert_page(self._create_pluginpage(), gtk.Label("Plugins"))
 
50
        for (label, page) in self._create_pages():
 
51
            notebook.insert_page(page, gtk.Label(label))
190
52
        self.vbox.pack_start(notebook, True, True)
191
53
        self.vbox.show_all()
192
54
 
 
55
    def _create_pages(self):
 
56
        return [("Identity", IdentityPage(self.config)), 
 
57
                ("Plugins", PluginsPage())]
 
58
 
193
59
    def display(self):
194
60
        self.window.show_all()
195
61
 
196
62
    def close(self, widget=None):
197
63
        self.window.destroy()
 
64
 
 
65
class BranchPreferencesWindow(gtk.Dialog):
 
66
    """Displays global preferences windows."""
 
67
    def __init__(self, config=None):
 
68
        super(BranchPreferencesWindow, self).__init__(config)
 
69