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