21
21
pygtk.require("2.0")
30
28
import bzrlib.errors as errors
31
29
from bzrlib.workingtree import WorkingTree
31
from olive import gladefile
34
34
""" Display the Remove file(s) dialog and perform the needed actions. """
35
def __init__(self, gladefile, comm, dialog):
36
36
""" Initialize the Remove file(s) dialog. """
37
self.gladefile = gladefile
38
self.glade = gtk.glade.XML(self.gladefile, 'window_remove')
40
# Communication object
37
self.glade = gtk.glade.XML(gladefile, 'window_remove')
45
39
self.window = self.glade.get_widget('window_remove')
62
56
directory = self.comm.get_path()
64
self.comm.set_busy(self.window)
65
58
if radio_selected.get_active():
66
59
# Remove only the selected file
67
60
filename = self.comm.get_selected_right()
69
62
if filename is None:
70
self.dialog.error_dialog(_('No file was selected'),
63
error_dialog(_('No file was selected'),
71
64
_('Please select a file from the list,\nor choose the other option.'))
72
self.comm.set_busy(self.window, False)
76
68
wt, path = WorkingTree.open_containing(directory + '/' + filename)
78
70
except errors.NotBranchError:
79
self.dialog.error_dialog(_('Directory is not a branch'),
71
error_dialog(_('Directory is not a branch'),
80
72
_('You can perform this action only in a branch.'))
81
self.comm.set_busy(self.window, False)
83
74
except errors.NotVersionedError:
84
self.dialog.error_dialog(_('File not versioned'),
75
error_dialog(_('File not versioned'),
85
76
_('The selected file is not versioned.'))
86
self.comm.set_busy(self.window, False)
90
78
elif radio_new.get_active():
91
79
# Remove added files recursively
93
81
wt, path = WorkingTree.open_containing(directory)
94
82
except errors.NotBranchError:
95
self.dialog.error_dialog(_('Directory is not a branch'),
83
error_dialog(_('Directory is not a branch'),
96
84
_('You can perform this action only in a branch.'))
97
self.comm.set_busy(self.window, False)
102
87
added = wt.changes_from(wt.basis_tree()).added
103
88
file_list = sorted([f[0] for f in added], reverse=True)
104
89
if len(file_list) == 0:
105
90
dialog.warning_dialog(_('No matching files'),
106
91
_('No added files were found in the working tree.'))
107
self.comm.set_busy(self.window, False)
109
93
wt.remove(file_list)
111
# This should really never happen.
115
self.comm.refresh_right()
117
97
def close(self, widget=None):
118
98
self.window.destroy()