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

  • Committer: matkor
  • Date: 2007-08-23 10:17:40 UTC
  • mto: This revision was merged to the branch mainline in revision 265.
  • Revision ID: matkor@laptop-hp-20070823101740-s17kf9qa383wiuje
Code for "branch update" menuitem and toolbox. Typo fix

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