/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:40:05 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927174005-5dfa27de4081ed19
Handle non-bzr unknown errors as well.

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