/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-30 10:21:43 UTC
  • Revision ID: jelmer@samba.org-20060930102143-c0ef64d6ca860c21
Merge some files from Olive and bzr-gtk.

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
27
28
 
28
29
import bzrlib.errors as errors
29
30
 
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
 
 
 
31
from olive import gladefile
36
32
 
37
33
class OliveMkdir:
38
34
    """ Display the Make directory dialog and perform the needed actions. """
39
35
    def __init__(self, wt, wtpath):
40
36
        """ Initialize the Make directory dialog. """
41
 
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_mkdir', 'olive-gtk')
 
37
        self.glade = gtk.glade.XML(gladefile, 'window_mkdir', 'olive-gtk')
42
38
        
43
39
        self.window = self.glade.get_widget('window_mkdir')
44
40
        
48
44
        
49
45
        # Connect the signals to the handlers
50
46
        self.glade.signal_autoconnect(dic)
51
 
        
52
 
        self.wt = wt
53
 
        self.wtpath = wtpath
54
47
 
55
48
    def display(self):
56
49
        """ Display the Make directory dialog. """
57
50
        self.window.show_all()
58
51
 
59
 
    @show_bzr_error
60
52
    def mkdir(self, widget):
61
53
        # Get the widgets
62
54
        entry = self.glade.get_widget('entry_mkdir')
65
57
        dirname = entry.get_text()
66
58
        
67
59
        if dirname == "":
68
 
            error_dialog(_i18n('No directory name given'),
69
 
                         _i18n('Please specify a desired name for the new directory.'))
 
60
            error_dialog(_('No directory name given'),
 
61
                                     _('Please specify a desired name for the new directory.'))
70
62
            return
71
63
        
72
64
        if checkbox.get_active():
73
65
            # Want to create a versioned directory
74
66
            try:
75
 
                os.mkdir(os.path.join(self.wt.basedir, self.wtpath, dirname))
 
67
                from bzrlib.workingtree import WorkingTree
 
68
    
 
69
                os.mkdir(os.path.join(wt.base, wtpath))
76
70
 
77
 
                self.wt.add([os.path.join(self.wtpath, dirname)])
 
71
                wt.add([wtpath])
78
72
            except OSError, e:
79
73
                if e.errno == 17:
80
 
                    error_dialog(_i18n('Directory already exists'),
81
 
                                 _i18n('Please specify another name to continue.'))
 
74
                    error_dialog(_('Directory already exists'),
 
75
                                             _('Please specify another name to continue.'))
82
76
                else:
83
77
                    raise
 
78
            except errors.NotBranchError:
 
79
                warning_dialog(_('Directory is not in a branch'),
 
80
                                           _('You can only create a non-versioned directory.'))
84
81
        else:
85
82
            # Just a simple directory
86
83
            try:
87
 
                os.mkdir(os.path.join(self.wt.basedir, self.wtpath, dirname))
 
84
                os.mkdir(os.path.join(wt.base, wtpath))
88
85
            except OSError, e:
89
86
                if e.errno == 17:
90
 
                    error_dialog(_i18n('Directory already exists'),
91
 
                                 _i18n('Please specify another name to continue.'))
 
87
                    error_dialog(_('Directory already exists'),
 
88
                                             _('Please specify another name to continue.'))
92
89
                    return
93
90
 
94
91
        self.close()
 
92
        self.comm.refresh_right()
95
93
    
96
94
    def close(self, widget=None):
97
95
        self.window.destroy()