1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# Copyright (C) 2007 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
try:
import pygtk
pygtk.require("2.0")
except:
pass
import gtk
from errors import show_bzr_error
class InitDialog(gtk.Dialog):
""" Initialize dialog. """
def __init__(self, path, parent=None):
""" Initialize the Initialize dialog. """
gtk.Dialog.__init__(self, title="Initialize - Olive",
parent=parent,
flags=0,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
# Get arguments
self.path = path
# Create the widgets
self._button_init = gtk.Button(_("_Initialize"), use_underline=True)
self._label_question = gtk.Label(_("Which directory do you want to initialize?"))
self._radio_current = gtk.RadioButton(None, _("Current directory"))
self._radio_custom = gtk.RadioButton(self._radio_current, _("Create a new directory with the name:"))
self._entry_custom = gtk.Entry()
self._hbox_custom = gtk.HBox()
# Set callbacks
self._button_init.connect('clicked', self._on_init_clicked)
self._radio_custom.connect('toggled', self._on_custom_toggled)
# Set properties
self._entry_custom.set_sensitive(False)
# Construct the dialog
self.action_area.pack_end(self._button_init)
self._hbox_custom.pack_start(self._radio_custom, False, False)
self._hbox_custom.pack_start(self._entry_custom, True, True)
self.vbox.pack_start(self._label_question)
self.vbox.pack_start(self._radio_current)
self.vbox.pack_start(self._hbox_custom)
# Display the dialog
self.vbox.show_all()
def _on_custom_toggled(self, widget):
""" Occurs if the Custom radiobutton is toggled. """
if self._radio_custom.get_active() == True:
self._entry_custom.set_sensitive(True)
self._entry_custom.grab_focus()
else:
self._entry_custom.set_sensitive(False)
def _on_init_clicked(self, widget):
self.response(gtk.RESPONSE_OK)
|