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

  • Committer: Jelmer Vernooij
  • Date: 2008-03-28 19:26:53 UTC
  • mto: (450.1.13 trunk)
  • mto: This revision was merged to the branch mainline in revision 458.
  • Revision ID: jelmer@samba.org-20080328192653-trzptkwahx1tulz9
Add module for preferences code.

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
import os
20
26
 
21
 
from bzrlib import (
22
 
    bzrdir,
23
 
    errors,
24
 
    transport,
25
 
    )
26
 
 
27
 
from bzrlib.plugins.gtk.dialog import error_dialog
28
 
from bzrlib.plugins.gtk.errors import show_bzr_error
29
 
from bzrlib.plugins.gtk.i18n import _i18n
30
 
 
31
 
 
32
 
class InitDialog(Gtk.Dialog):
 
27
from dialog import error_dialog
 
28
from errors import show_bzr_error
 
29
 
 
30
from bzrlib import bzrdir
 
31
from bzrlib import transport
 
32
import bzrlib.errors as errors
 
33
 
 
34
class InitDialog(gtk.Dialog):
33
35
    """ Initialize dialog. """
34
 
 
35
36
    def __init__(self, path, parent=None):
36
37
        """ Initialize the Initialize dialog. """
37
 
        GObject.GObject.__init__(self, title="Initialize - Olive",
 
38
        gtk.Dialog.__init__(self, title="Initialize - Olive",
38
39
                                  parent=parent,
39
40
                                  flags=0,
40
 
                                  buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
 
41
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
41
42
        
42
43
        # Get arguments
43
44
        self.path = path
44
45
        
45
46
        # Create the widgets
46
 
        self._button_init = Gtk.Button(_i18n("_Initialize"), use_underline=True)
47
 
        self._label_question = Gtk.Label(label=_i18n("Which directory do you want to initialize?"))
48
 
        self._radio_current = Gtk.RadioButton(None, _i18n("Current directory"))
49
 
        self._radio_custom = Gtk.RadioButton(self._radio_current, _i18n("Create a new directory with the name:"))
50
 
        self._entry_custom = Gtk.Entry()
51
 
        self._hbox_custom = Gtk.HBox()
 
47
        self._button_init = gtk.Button(_("_Initialize"), use_underline=True)
 
48
        self._label_question = gtk.Label(_("Which directory do you want to initialize?"))
 
49
        self._radio_current = gtk.RadioButton(None, _("Current directory"))
 
50
        self._radio_custom = gtk.RadioButton(self._radio_current, _("Create a new directory with the name:"))
 
51
        self._entry_custom = gtk.Entry()
 
52
        self._hbox_custom = gtk.HBox()
52
53
        
53
54
        # Set callbacks
54
55
        self._button_init.connect('clicked', self._on_init_clicked)
63
64
        self._hbox_custom.pack_start(self._radio_custom, False, False)
64
65
        self._hbox_custom.pack_start(self._entry_custom, True, True)
65
66
        
66
 
        self.vbox.pack_start(self._label_question, True, True, 0)
67
 
        self.vbox.pack_start(self._radio_current, True, True, 0)
68
 
        self.vbox.pack_start(self._hbox_custom, True, True, 0)
 
67
        self.vbox.pack_start(self._label_question)
 
68
        self.vbox.pack_start(self._radio_current)
 
69
        self.vbox.pack_start(self._hbox_custom)
69
70
        
70
71
        # Display the dialog
71
72
        self.vbox.show_all()
81
82
    @show_bzr_error
82
83
    def _on_init_clicked(self, widget):
83
84
        if self._radio_custom.get_active() and len(self._entry_custom.get_text()) == 0:
84
 
            error_dialog(_i18n("Directory name not specified"),
85
 
                         _i18n("You should specify a new directory name."))
 
85
            error_dialog(_("Directory name not specified"),
 
86
                         _("You should specify a new directory name."))
86
87
            return
87
88
        
88
89
        if self._radio_current.get_active():
114
115
                branch = existing_bzrdir.create_branch()
115
116
                existing_bzrdir.create_workingtree()
116
117
        
117
 
        self.response(Gtk.ResponseType.OK)
 
118
        self.response(gtk.RESPONSE_OK)