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):
35
def __init__(self, comm):
40
37
if sys.platform == 'win32':
41
38
self.uifile = os.path.dirname(sys.executable) + "/share/olive/cmenu.ui"
139
134
filename = self.comm.get_selected_right()
141
136
if filename is None:
142
self.dialog.error_dialog(_('No file was selected'),
137
error_dialog(_('No file was selected'),
143
138
_('Please select a file from the list,\nor choose the other option.'))
147
fileops.add([directory + '/' + filename])
142
bzrlib.add.smart_add([directory + '/' + filename])
148
143
except errors.NotBranchError:
149
self.dialog.error_dialog(_('Directory is not a branch'),
144
error_dialog(_('Directory is not a branch'),
150
145
_('You can perform this action only in a branch.'))
155
148
self.comm.refresh_right()
161
154
filename = self.comm.get_selected_right()
163
156
if filename is None:
164
self.dialog.error_dialog(_('No file was selected'),
157
error_dialog(_('No file was selected'),
165
158
_('Please select a file from the list,\nor choose the other option.'))
169
fileops.remove([directory + '/' + filename])
162
wt, path = WorkingTree.open_containing(directory+'/'+filename)
170
165
except errors.NotBranchError:
171
self.dialog.error_dialog(_('Directory is not a branch'),
166
error_dialog(_('Directory is not a branch'),
172
167
_('You can perform this action only in a branch.'))
174
169
except errors.NotVersionedError:
175
self.dialog.error_dialog(_('File not versioned'),
170
error_dialog(_('File not versioned'),
176
171
_('The selected file is not versioned.'))
186
181
filename = self.comm.get_selected_right()
188
183
if filename is None:
189
self.dialog.error_dialog(_('No file was selected'),
184
error_dialog(_('No file was selected'),
190
185
_('Please select a file from the list,\nor choose the other option.'))
205
200
def commit(self, action):
206
201
""" Right context menu -> Commit """
207
202
from commit import OliveCommit
208
commit = OliveCommit(self.gladefile, self.comm, self.dialog)
203
wt, path = WorkingTree.open_containing(self.comm.get_path())
204
commit = OliveCommit(wt, path)
211
207
def diff(self, action):
212
208
""" Right context menu -> Diff """
213
209
from diff import OliveDiff
214
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
210
diff = OliveDiff(self.comm)
217
213
def bookmark(self, action):
218
214
""" Right context menu -> Bookmark """
219
215
if self.comm.pref.add_bookmark(self.comm.get_path()):
220
self.dialog.info_dialog(_('Bookmark successfully added'),
216
info_dialog(_('Bookmark successfully added'),
221
217
_('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
223
self.dialog.warning_dialog(_('Location already bookmarked'),
219
warning_dialog(_('Location already bookmarked'),
224
220
_('The current directory is already bookmarked.\nSee the left panel for reference.'))
226
222
self.comm.refresh_left()
230
226
from bookmark import OliveBookmark
232
228
if self.comm.get_selected_left() != None:
233
bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
229
bookmark = OliveBookmark(self.comm)
234
230
bookmark.display()
236
232
def remove_bookmark(self, action):
254
250
def diff_all(self, action):
255
251
""" Diff toolbutton -> All... """
256
252
from diff import OliveDiff
257
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
253
diff = OliveDiff(self.comm)