/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: 2008-06-29 16:11:12 UTC
  • mfrom: (475.2.2 gtk)
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629161112-3j4zp0r0e7cv6cds
Merge Chad's progress bar in viz patch.

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