/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: 2012-03-23 15:02:38 UTC
  • Revision ID: jelmer@samba.org-20120323150238-kan2r255chh2z2v6
Fix searching in tree views.

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
 
try:
18
 
    import pygtk
19
 
    pygtk.require("2.0")
20
 
except:
21
 
    pass
22
 
 
23
 
import gtk
 
17
from gi.repository import GObject
 
18
from gi.repository import Gtk
24
19
 
25
20
import os
26
21
 
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):
 
22
from bzrlib import (
 
23
    bzrdir,
 
24
    errors,
 
25
    transport,
 
26
    )
 
27
 
 
28
from bzrlib.plugins.gtk.dialog import error_dialog
 
29
from bzrlib.plugins.gtk.errors import show_bzr_error
 
30
from bzrlib.plugins.gtk.i18n import _i18n
 
31
 
 
32
 
 
33
class InitDialog(Gtk.Dialog):
35
34
    """ Initialize dialog. """
 
35
 
36
36
    def __init__(self, path, parent=None):
37
37
        """ Initialize the Initialize dialog. """
38
 
        gtk.Dialog.__init__(self, title="Initialize - Olive",
39
 
                                  parent=parent,
40
 
                                  flags=0,
41
 
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
38
        super(InitDialog, self).__init__(
 
39
            title="Initialize - Olive", parent=parent, flags=0,
 
40
            buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
42
41
        
43
42
        # Get arguments
44
43
        self.path = path
45
44
        
46
45
        # Create the widgets
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()
 
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.new_with_label(
 
49
            None, _i18n("Current directory"))
 
50
        self._radio_custom = Gtk.RadioButton.new_with_label_from_widget(
 
51
            self._radio_current, _i18n("Create a new directory with the name:"))
 
52
        self._entry_custom = Gtk.Entry()
 
53
        self._hbox_custom = Gtk.HBox()
53
54
        
54
55
        # Set callbacks
55
56
        self._button_init.connect('clicked', self._on_init_clicked)
59
60
        self._entry_custom.set_sensitive(False)
60
61
        
61
62
        # Construct the dialog
62
 
        self.action_area.pack_end(self._button_init)
63
 
        
64
 
        self._hbox_custom.pack_start(self._radio_custom, False, False)
65
 
        self._hbox_custom.pack_start(self._entry_custom, True, True)
66
 
        
67
 
        self.vbox.pack_start(self._label_question)
68
 
        self.vbox.pack_start(self._radio_current)
69
 
        self.vbox.pack_start(self._hbox_custom)
 
63
        self.action_area.pack_end(self._button_init, False, False, 0)
 
64
        
 
65
        self._hbox_custom.pack_start(self._radio_custom, False, False, 0)
 
66
        self._hbox_custom.pack_start(self._entry_custom, True, True, 0)
 
67
        
 
68
        content_area = self.get_content_area()
 
69
        content_area.pack_start(self._label_question, True, True, 0)
 
70
        content_area.pack_start(self._radio_current, True, True, 0)
 
71
        content_area.pack_start(self._hbox_custom, True, True, 0)
70
72
        
71
73
        # Display the dialog
72
 
        self.vbox.show_all()
 
74
        content_area.show_all()
73
75
    
74
76
    def _on_custom_toggled(self, widget):
75
77
        """ Occurs if the Custom radiobutton is toggled. """
82
84
    @show_bzr_error
83
85
    def _on_init_clicked(self, widget):
84
86
        if self._radio_custom.get_active() and len(self._entry_custom.get_text()) == 0:
85
 
            error_dialog(_("Directory name not specified"),
86
 
                         _("You should specify a new directory name."))
 
87
            error_dialog(_i18n("Directory name not specified"),
 
88
                         _i18n("You should specify a new directory name."))
87
89
            return
88
90
        
89
91
        if self._radio_current.get_active():
115
117
                branch = existing_bzrdir.create_branch()
116
118
                existing_bzrdir.create_workingtree()
117
119
        
118
 
        self.response(gtk.RESPONSE_OK)
 
120
        self.response(Gtk.ResponseType.OK)