31
import olive.backend.fileops as fileops
32
import olive.backend.errors as errors
31
import bzrlib.errors as errors
32
from dialog import error_dialog
34
34
from launch import launch
37
37
""" This class is responsible for building the context menus. """
38
def __init__(self, gladefile, comm, dialog):
38
def __init__(self, gladefile, comm):
40
40
if sys.platform == 'win32':
41
41
self.uifile = os.path.dirname(sys.executable) + "/share/olive/cmenu.ui"
139
138
filename = self.comm.get_selected_right()
141
140
if filename is None:
142
self.dialog.error_dialog(_('No file was selected'),
141
error_dialog(_('No file was selected'),
143
142
_('Please select a file from the list,\nor choose the other option.'))
147
fileops.add([directory + '/' + filename])
146
bzrlib.add.smart_add([directory + '/' + filename])
148
147
except errors.NotBranchError:
149
self.dialog.error_dialog(_('Directory is not a branch'),
148
error_dialog(_('Directory is not a branch'),
150
149
_('You can perform this action only in a branch.'))
155
152
self.comm.refresh_right()
161
158
filename = self.comm.get_selected_right()
163
160
if filename is None:
164
self.dialog.error_dialog(_('No file was selected'),
161
error_dialog(_('No file was selected'),
165
162
_('Please select a file from the list,\nor choose the other option.'))
169
fileops.remove([directory + '/' + filename])
166
wt, path = WorkingTree.open_containing(directory+'/'+filename)
170
169
except errors.NotBranchError:
171
self.dialog.error_dialog(_('Directory is not a branch'),
170
error_dialog(_('Directory is not a branch'),
172
171
_('You can perform this action only in a branch.'))
174
173
except errors.NotVersionedError:
175
self.dialog.error_dialog(_('File not versioned'),
174
error_dialog(_('File not versioned'),
176
175
_('The selected file is not versioned.'))
186
185
filename = self.comm.get_selected_right()
188
187
if filename is None:
189
self.dialog.error_dialog(_('No file was selected'),
188
error_dialog(_('No file was selected'),
190
189
_('Please select a file from the list,\nor choose the other option.'))
205
204
def commit(self, action):
206
205
""" Right context menu -> Commit """
207
206
from commit import OliveCommit
208
commit = OliveCommit(self.gladefile, self.comm, self.dialog)
207
wt, path = WorkingTree.open_containing(self.comm.get_path())
208
commit = OliveCommit(self.gladefile, wt, path)
211
211
def diff(self, action):
212
212
""" Right context menu -> Diff """
213
213
from diff import OliveDiff
214
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
214
diff = OliveDiff(self.gladefile, self.comm)
217
217
def bookmark(self, action):
218
218
""" Right context menu -> Bookmark """
219
219
if self.comm.pref.add_bookmark(self.comm.get_path()):
220
self.dialog.info_dialog(_('Bookmark successfully added'),
220
info_dialog(_('Bookmark successfully added'),
221
221
_('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
223
self.dialog.warning_dialog(_('Location already bookmarked'),
223
warning_dialog(_('Location already bookmarked'),
224
224
_('The current directory is already bookmarked.\nSee the left panel for reference.'))
226
226
self.comm.refresh_left()
230
230
from bookmark import OliveBookmark
232
232
if self.comm.get_selected_left() != None:
233
bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
233
bookmark = OliveBookmark(self.gladefile, self.comm)
234
234
bookmark.display()
236
236
def remove_bookmark(self, action):
254
254
def diff_all(self, action):
255
255
""" Diff toolbutton -> All... """
256
256
from diff import OliveDiff
257
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
257
diff = OliveDiff(self.gladefile, self.comm)