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