/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-13 20:19:31 UTC
  • mfrom: (0.8.79 main)
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060913201931-23adba246d4d6529
Merge main branch.

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