/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-25 01:58:44 UTC
  • mto: (0.14.1 main)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060925015844-12e9eec2d5f41420
Huge cleanup after removing backend codebase.

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