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

  • Committer: Jelmer Vernooij
  • Date: 2006-09-27 17:49:18 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927174918-0e5c331b574d16a3
Don't pass along dialog context everywhere.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
 
18
import sys
18
19
 
19
20
try:
20
21
    import pygtk
21
22
    pygtk.require("2.0")
22
23
except:
23
24
    pass
24
 
 
25
 
import gtk
26
 
import gtk.glade
 
25
try:
 
26
    import gtk
 
27
    import gtk.glade
 
28
except:
 
29
    sys.exit(1)
27
30
 
28
31
import bzrlib.errors as errors
29
32
 
30
 
from bzrlib.plugins.gtk import _i18n
31
 
from bzrlib.plugins.gtk.dialog import error_dialog, warning_dialog
32
 
from guifiles import GLADEFILENAME
33
 
 
34
 
from bzrlib.plugins.gtk.errors import show_bzr_error
35
 
 
36
 
 
37
33
class OliveMkdir:
38
34
    """ Display the Make directory dialog and perform the needed actions. """
39
 
    def __init__(self, wt, wtpath):
 
35
    def __init__(self, gladefile, wt, wtpath, dialog):
40
36
        """ Initialize the Make directory dialog. """
41
 
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_mkdir', 'olive-gtk')
 
37
        self.gladefile = gladefile
 
38
        self.glade = gtk.glade.XML(self.gladefile, 'window_mkdir', 'olive-gtk')
 
39
        
 
40
        # Dialog object
 
41
        = dialog
42
42
        
43
43
        self.window = self.glade.get_widget('window_mkdir')
44
44
        
48
48
        
49
49
        # Connect the signals to the handlers
50
50
        self.glade.signal_autoconnect(dic)
51
 
        
52
 
        self.wt = wt
53
 
        self.wtpath = wtpath
54
51
 
55
52
    def display(self):
56
53
        """ Display the Make directory dialog. """
57
54
        self.window.show_all()
58
55
 
59
 
    @show_bzr_error
60
56
    def mkdir(self, widget):
61
57
        # Get the widgets
62
58
        entry = self.glade.get_widget('entry_mkdir')
65
61
        dirname = entry.get_text()
66
62
        
67
63
        if dirname == "":
68
 
            error_dialog(_i18n('No directory name given'),
69
 
                         _i18n('Please specify a desired name for the new directory.'))
 
64
            error_dialog(_('No directory name given'),
 
65
                                     _('Please specify a desired name for the new directory.'))
70
66
            return
71
67
        
72
68
        if checkbox.get_active():
73
69
            # Want to create a versioned directory
74
70
            try:
75
 
                os.mkdir(os.path.join(self.wt.basedir, self.wtpath, dirname))
 
71
                from bzrlib.workingtree import WorkingTree
 
72
    
 
73
                os.mkdir(os.path.join(wt.base, wtpath))
76
74
 
77
 
                self.wt.add([os.path.join(self.wtpath, dirname)])
 
75
                wt.add([wtpath])
78
76
            except OSError, e:
79
77
                if e.errno == 17:
80
 
                    error_dialog(_i18n('Directory already exists'),
81
 
                                 _i18n('Please specify another name to continue.'))
 
78
                    error_dialog(_('Directory already exists'),
 
79
                                             _('Please specify another name to continue.'))
82
80
                else:
83
81
                    raise
 
82
            except errors.NotBranchError:
 
83
                warning_dialog(_('Directory is not in a branch'),
 
84
                                           _('You can only create a non-versioned directory.'))
84
85
        else:
85
86
            # Just a simple directory
86
87
            try:
87
 
                os.mkdir(os.path.join(self.wt.basedir, self.wtpath, dirname))
 
88
                os.mkdir(os.path.join(wt.base, wtpath))
88
89
            except OSError, e:
89
90
                if e.errno == 17:
90
 
                    error_dialog(_i18n('Directory already exists'),
91
 
                                 _i18n('Please specify another name to continue.'))
 
91
                    error_dialog(_('Directory already exists'),
 
92
                                             _('Please specify another name to continue.'))
92
93
                    return
93
94
 
94
95
        self.close()
 
96
        self.comm.refresh_right()
95
97
    
96
98
    def close(self, widget=None):
97
99
        self.window.destroy()