22
22
pygtk.require("2.0")
29
import bzrlib.errors as errors
31
from olive import gladefile
31
import olive.backend.errors as errors
32
import olive.backend.fileops as fileops
34
35
""" Display the Move dialog and perform the needed actions. """
35
def __init__(self, comm):
36
def __init__(self, gladefile, comm, dialog):
36
37
""" Initialize the Move dialog. """
37
self.glade = gtk.glade.XML(gladefile, 'window_move', 'olive-gtk')
38
self.gladefile = gladefile
39
self.glade = gtk.glade.XML(self.gladefile, 'window_move')
39
41
# Communication object
42
46
self.window = self.glade.get_widget('window_move')
62
66
filename = self.comm.get_selected_right()
64
68
if filename is None:
65
error_dialog(_('No file was selected'),
66
_('Please select a file from the list to proceed.'))
69
self.dialog.error_dialog('No file was selected',
70
'Please select a file from the list to proceed.')
69
73
source = self.comm.get_path() + '/' + filename
71
75
# Move the file to a directory
73
wt1, path1 = WorkingTree.open_containing(source)
74
wt2, path2 = WorkingTree.open_containing(destination)
75
if wt1.base != wt2.base:
76
error_dialog(_('Not the same branch'),
77
_('The destination is not in the same branch.'))
80
wt1.move([source], destination)
77
fileops.move([source, destination])
81
78
except errors.NotBranchError:
82
error_dialog(_('File is not in a branch'),
83
_('The selected file is not in a branch.'))
79
self.dialog.error_dialog('File is not in a branch',
80
'The selected file is not in a branch.')
82
except errors.NotSameBranchError:
83
self.dialog.error_dialog('Not the same branch',
84
'The destination is not in the same branch.')
87
90
self.comm.refresh_right()