/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-29 20:59:52 UTC
  • mfrom: (0.8.92 merge)
  • Revision ID: jelmer@samba.org-20060929205952-32ce1f02b7cf334b
MergeĀ OliveĀ code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    pygtk.require("2.0")
23
23
except:
24
24
    pass
25
 
try:
26
 
    import gtk
27
 
    import gtk.glade
28
 
except:
29
 
    sys.exit(1)
30
 
 
31
 
import olive.backend.errors as errors
32
 
import olive.backend.fileops as fileops
 
25
 
 
26
import gtk
 
27
import gtk.glade
 
28
 
 
29
import bzrlib.errors as errors
 
30
 
 
31
from olive import gladefile
33
32
 
34
33
class OliveMkdir:
35
34
    """ Display the Make directory dialog and perform the needed actions. """
36
 
    def __init__(self, gladefile, comm, dialog):
 
35
    def __init__(self, wt, wtpath):
37
36
        """ Initialize the Make directory dialog. """
38
 
        self.gladefile = gladefile
39
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_mkdir', 'olive-gtk')
40
 
        
41
 
        # Communication object
42
 
        self.comm = comm
43
 
        # Dialog object
44
 
        self.dialog = dialog
 
37
        self.glade = gtk.glade.XML(gladefile, 'window_mkdir', 'olive-gtk')
45
38
        
46
39
        self.window = self.glade.get_widget('window_mkdir')
47
40
        
64
57
        dirname = entry.get_text()
65
58
        
66
59
        if dirname == "":
67
 
            self.dialog.error_dialog(_('No directory name given'),
 
60
            error_dialog(_('No directory name given'),
68
61
                                     _('Please specify a desired name for the new directory.'))
69
62
            return
70
63
        
71
 
        newdir = self.comm.get_path() + '/' + dirname
72
 
        
73
64
        if checkbox.get_active():
74
65
            # Want to create a versioned directory
75
66
            try:
76
 
                fileops.mkdir(newdir)
77
 
            except errors.DirectoryAlreadyExists:
78
 
                self.dialog.error_dialog(_('Directory already exists'),
79
 
                                         _('Please specify another name to continue.'))
80
 
                return
 
67
                from bzrlib.workingtree import WorkingTree
 
68
    
 
69
                os.mkdir(os.path.join(wt.base, wtpath))
 
70
 
 
71
                wt.add([wtpath])
 
72
            except OSError, e:
 
73
                if e.errno == 17:
 
74
                    error_dialog(_('Directory already exists'),
 
75
                                             _('Please specify another name to continue.'))
 
76
                else:
 
77
                    raise
81
78
            except errors.NotBranchError:
82
 
                self.dialog.warning_dialog(_('Directory is not in a branch'),
 
79
                warning_dialog(_('Directory is not in a branch'),
83
80
                                           _('You can only create a non-versioned directory.'))
84
81
        else:
85
82
            # Just a simple directory
86
83
            try:
87
 
                os.mkdir(newdir)
 
84
                os.mkdir(os.path.join(wt.base, wtpath))
88
85
            except OSError, e:
89
86
                if e.errno == 17:
90
 
                    self.dialog.error_dialog(_('Directory already exists'),
 
87
                    error_dialog(_('Directory already exists'),
91
88
                                             _('Please specify another name to continue.'))
92
89
                    return
93
90