112
115
self.toolbar_diff = self.ui.get_widget('/toolbar_diff')
115
commit_menu = self.ui.get_widget('/context_right/commit')
116
commit_image = self.comm.menuitem_branch_commit.get_image()
117
commit_pixbuf = commit_image.get_pixbuf()
118
commit_icon = gtk.Image()
119
commit_icon.set_from_pixbuf(commit_pixbuf)
120
commit_menu.set_image(commit_icon)
121
diff_menu = self.ui.get_widget('/context_right/diff')
122
diff_image = self.comm.menuitem_stats_diff.get_image()
123
diff_pixbuf = diff_image.get_pixbuf()
124
diff_icon = gtk.Image()
125
diff_icon.set_from_pixbuf(diff_pixbuf)
126
diff_menu.set_image(diff_icon)
118
# TODO: do it without using deprecated comm
119
#commit_menu = self.ui.get_widget('/context_right/commit')
120
#commit_image = self.comm.menuitem_branch_commit.get_image()
121
#commit_pixbuf = commit_image.get_pixbuf()
122
#commit_icon = gtk.Image()
123
#commit_icon.set_from_pixbuf(commit_pixbuf)
124
#commit_menu.set_image(commit_icon)
125
#diff_menu = self.ui.get_widget('/context_right/diff')
126
#diff_image = self.comm.menuitem_stats_diff.get_image()
127
#diff_pixbuf = diff_image.get_pixbuf()
128
#diff_icon = gtk.Image()
129
#diff_icon.set_from_pixbuf(diff_pixbuf)
130
#diff_menu.set_image(diff_icon)
128
132
def right_context_menu(self):
129
133
return self.cmenu_right
134
138
def add_file(self, action):
135
139
""" Right context menu -> Add """
136
142
# Add only the selected file
137
directory = self.comm.get_path()
138
filename = self.comm.get_selected_right()
143
directory = self.path
144
filename = self.selected
140
146
if filename is None:
141
self.dialog.error_dialog(_('No file was selected'),
142
_('Please select a file from the list,\nor choose the other option.'))
147
error_dialog(_('No file was selected'),
148
_('Please select a file from the list,\nor choose the other option.'))
146
152
bzrlib.add.smart_add([directory + os.sep + filename])
147
153
except errors.NotBranchError:
148
self.dialog.error_dialog(_('Directory is not a branch'),
149
_('You can perform this action only in a branch.'))
154
error_dialog(_('Directory is not a branch'),
155
_('You can perform this action only in a branch.'))
152
self.comm.refresh_right()
154
158
def remove_file(self, action):
155
159
""" Right context menu -> Remove """
156
160
# Remove only the selected file
157
directory = self.comm.get_path()
158
filename = self.comm.get_selected_right()
161
directory = self.path
162
filename = self.selected
160
164
if filename is None:
161
self.dialog.error_dialog(_('No file was selected'),
162
_('Please select a file from the list,\nor choose the other option.'))
165
error_dialog(_('No file was selected'),
166
_('Please select a file from the list,\nor choose the other option.'))
169
173
except errors.NotBranchError:
170
self.dialog.error_dialog(_('Directory is not a branch'),
171
_('You can perform this action only in a branch.'))
174
error_dialog(_('Directory is not a branch'),
175
_('You can perform this action only in a branch.'))
173
177
except errors.NotVersionedError:
174
self.dialog.error_dialog(_('File not versioned'),
175
_('The selected file is not versioned.'))
178
error_dialog(_('File not versioned'),
179
_('The selected file is not versioned.'))
180
self.comm.refresh_right()
182
182
def open_file(self, action):
183
183
""" Right context menu -> Open """
184
184
# Open only the selected file
185
filename = self.comm.get_selected_right()
185
filename = self.selected
187
187
if filename is None:
188
self.dialog.error_dialog(_('No file was selected'),
189
_('Please select a file from the list,\nor choose the other option.'))
188
error_dialog(_('No file was selected'),
189
_('Please select a file from the list,\nor choose the other option.'))
192
192
if filename == '..':
193
self.comm.set_path(os.path.split(self.comm.get_path())[0])
193
# TODO: how to enter a directory?
195
fullpath = self.comm.get_path() + os.sep + filename
196
fullpath = self.path + os.sep + filename
196
197
if os.path.isdir(fullpath):
197
198
# selected item is an existant directory
198
self.comm.set_path(fullpath)
199
# TODO: how to enter a directory?
202
self.comm.refresh_right()
204
204
def commit(self, action):
205
205
""" Right context menu -> Commit """
206
206
from commit import OliveCommit
207
commit = OliveCommit(self.gladefile, self.comm, self.dialog)
207
wt, path = WorkingTree.open_containing(self.path)
208
commit = OliveCommit(wt, path)
210
211
def diff(self, action):
211
212
""" Right context menu -> Diff """
212
from diff import OliveDiff
213
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
213
from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
216
wt = WorkingTree.open_containing(self.path)[0]
217
except errors.NotBranchError:
218
error_dialog(_('File is not in a branch'),
219
_('The selected file is not in a branch.'))
222
window = DiffWindow()
223
parent_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
224
window.set_diff(wt.branch.nick, wt, parent_tree)
216
227
def bookmark(self, action):
217
228
""" Right context menu -> Bookmark """
218
if self.comm.pref.add_bookmark(self.comm.get_path()):
219
self.dialog.info_dialog(_('Bookmark successfully added'),
220
_('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
229
if self.pref.add_bookmark(self.path):
230
info_dialog(_('Bookmark successfully added'),
231
_('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
222
self.dialog.warning_dialog(_('Location already bookmarked'),
223
_('The current directory is already bookmarked.\nSee the left panel for reference.'))
225
self.comm.refresh_left()
234
warning_dialog(_('Location already bookmarked'),
235
_('The current directory is already bookmarked.\nSee the left panel for reference.'))
227
237
def edit_bookmark(self, action):
228
238
""" Left context menu -> Edit """
229
239
from bookmark import OliveBookmark
231
if self.comm.get_selected_left() != None:
232
bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
241
if self.selected != None:
242
bookmark = OliveBookmark(self.selected)
233
243
bookmark.display()
235
245
def remove_bookmark(self, action):
236
246
""" Left context menu -> Remove """
238
if self.comm.get_selected_left() != None:
239
self.comm.pref.remove_bookmark(self.comm.get_selected_left())
248
if self.selected != None:
249
self.pref.remove_bookmark(self.comm.get_selected_left())
240
250
self.comm.refresh_left()
242
252
def open_folder(self, action):
243
253
""" Left context menu -> Open Folder """
244
path = self.comm.get_selected_left()