117
118
self.entry_location = self.toplevel.get_widget('entry_location')
118
119
self.image_location_error = self.toplevel.get_widget('image_location_error')
121
# Get the History widgets
122
self.check_history = self.toplevel.get_widget('checkbutton_history')
123
self.entry_history = self.toplevel.get_widget('entry_history_revno')
124
self.button_history = self.toplevel.get_widget('button_history_browse')
120
126
self.vbox_main_right = self.toplevel.get_widget('vbox_main_right')
122
128
# Dictionary for signal_autoconnect
160
166
"on_treeview_left_row_activated": self.on_treeview_left_row_activated,
161
167
"on_button_location_up_clicked": self.on_button_location_up_clicked,
162
168
"on_button_location_jump_clicked": self.on_button_location_jump_clicked,
163
"on_entry_location_key_press_event": self.on_entry_location_key_press_event
169
"on_entry_location_key_press_event": self.on_entry_location_key_press_event,
170
"on_checkbutton_history_toggled": self.on_checkbutton_history_toggled,
171
"on_entry_history_revno_key_press_event": self.on_entry_history_revno_key_press_event,
172
"on_button_history_browse_clicked": self.on_button_history_browse_clicked
166
175
# Connect the signals to the handlers
202
211
self.remote = False
203
212
self.remote_branch = None
204
213
self.remote_path = None
214
self.remote_revision = None
206
216
self.set_path(os.getcwd())
207
217
self._load_right()
209
219
self._just_started = False
211
def set_path(self, path):
221
def set_path(self, path, force_remote=False):
212
222
self.notbranch = False
214
if os.path.isdir(path):
215
self.image_location_error.destroy()
220
self.wt, self.wtpath = WorkingTree.open_containing(path)
221
except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
222
self.notbranch = True
224
# If we're in the root, we cannot go up anymore
225
if sys.platform == 'win32':
226
drive, tail = os.path.splitdrive(path)
227
if tail in ('', '/', '\\'):
228
self.button_location_up.set_sensitive(False)
230
self.button_location_up.set_sensitive(True)
233
self.button_location_up.set_sensitive(False)
235
self.button_location_up.set_sensitive(True)
236
elif not os.path.isfile(path):
237
# Doesn't seem to be a file nor a directory, trying to open a
225
# Forcing remote mode (reading data from inventory)
239
226
self._show_stock_image(gtk.STOCK_DISCONNECT)
241
228
br = Branch.open_containing(path)[0]
242
229
except bzrerrors.NotBranchError:
243
230
self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
231
self.check_history.set_active(False)
232
self.check_history.set_sensitive(False)
245
234
except bzrerrors.UnsupportedProtocol:
246
235
self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
236
self.check_history.set_active(False)
237
self.check_history.set_sensitive(False)
249
240
self._show_stock_image(gtk.STOCK_CONNECT)
254
245
self.remote_branch, self.remote_path = Branch.open_containing(path)
256
self.remote_entries = self.remote_branch.repository.get_inventory(self.remote_branch.last_revision()).entries()
247
if self.remote_revision is None:
248
self.remote_entries = self.remote_branch.repository.get_inventory(self.remote_branch.last_revision()).entries()
250
self.remote_entries = self.remote_branch.repository.get_inventory(self.remote_revision).entries()
258
252
if len(self.remote_path) == 0:
259
253
self.remote_parent = self.remote_branch.repository.get_inventory(self.remote_branch.last_revision()).iter_entries_by_dir().next()[1].file_id
270
264
self.button_location_up.set_sensitive(False)
272
266
self.button_location_up.set_sensitive(True)
268
if os.path.isdir(path):
269
self.image_location_error.destroy()
274
self.wt, self.wtpath = WorkingTree.open_containing(path)
275
except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
276
self.notbranch = True
278
# If we're in the root, we cannot go up anymore
279
if sys.platform == 'win32':
280
drive, tail = os.path.splitdrive(path)
281
if tail in ('', '/', '\\'):
282
self.button_location_up.set_sensitive(False)
284
self.button_location_up.set_sensitive(True)
287
self.button_location_up.set_sensitive(False)
289
self.button_location_up.set_sensitive(True)
290
elif not os.path.isfile(path):
291
# Doesn't seem to be a file nor a directory, trying to open a
293
self._show_stock_image(gtk.STOCK_DISCONNECT)
295
br = Branch.open_containing(path)[0]
296
except bzrerrors.NotBranchError:
297
self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
298
self.check_history.set_active(False)
299
self.check_history.set_sensitive(False)
301
except bzrerrors.UnsupportedProtocol:
302
self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
303
self.check_history.set_active(False)
304
self.check_history.set_sensitive(False)
307
self._show_stock_image(gtk.STOCK_CONNECT)
312
self.remote_branch, self.remote_path = Branch.open_containing(path)
314
if self.remote_revision is None:
315
self.remote_entries = self.remote_branch.repository.get_inventory(self.remote_branch.last_revision()).entries()
317
self.remote_entries = self.remote_branch.repository.get_inventory(self.remote_revision).entries()
319
if len(self.remote_path) == 0:
320
self.remote_parent = self.remote_branch.repository.get_inventory(self.remote_branch.last_revision()).iter_entries_by_dir().next()[1].file_id
322
for (name, type) in self.remote_entries:
323
if name == self.remote_path:
324
self.remote_parent = type.file_id
327
if not path.endswith('/'):
330
if self.remote_branch.base == path:
331
self.button_location_up.set_sensitive(False)
333
self.button_location_up.set_sensitive(True)
336
self.check_history.set_active(False)
337
self.check_history.set_sensitive(False)
339
self.check_history.set_sensitive(True)
274
341
self.statusbar.push(self.context_id, path)
275
342
self.entry_location.set_text(path)
290
357
from bzrlib.plugins.gtk.dialog import about
361
def on_button_history_browse_clicked(self, widget):
362
""" Browse for revision button handler. """
364
br = self.remote_branch
368
revb = RevisionBrowser(br, self.window)
369
response = revb.run()
370
if response != gtk.RESPONSE_NONE:
373
if response == gtk.RESPONSE_OK:
374
if revb.selected_revno is not None:
375
self.entry_history.set_text(revb.selected_revno)
379
def on_button_location_jump_clicked(self, widget):
380
""" Location Jump button handler. """
381
location = self.entry_location.get_text()
383
if self.set_path(location):
293
386
def on_button_location_up_clicked(self, widget):
294
387
""" Location Up button handler. """
295
388
if not self.remote:
305
398
self.refresh_right()
307
def on_button_location_jump_clicked(self, widget):
308
""" Location Jump button handler. """
309
location = self.entry_location.get_text()
311
if self.set_path(location):
400
def on_checkbutton_history_toggled(self, widget):
401
""" History Mode toggle handler. """
402
if self.check_history.get_active():
403
# History Mode activated
404
self.entry_history.set_sensitive(True)
405
self.button_history.set_sensitive(True)
407
# History Mode deactivated
408
self.entry_history.set_sensitive(False)
409
self.button_history.set_sensitive(False)
411
def on_entry_history_revno_key_press_event(self, widget, event):
412
""" Key pressed handler for the history entry. """
413
if event.keyval == 65293:
414
# Return was hit, so we have to load that specific revision
415
# Emulate being remote, so inventory should be used
416
path = self.get_path()
419
self.remote_branch = self.wt.branch
421
revno = int(self.entry_history.get_text())
422
self.remote_revision = self.remote_branch.get_rev_id(revno)
423
if self.set_path(path, True):
314
426
def on_entry_location_key_press_event(self, widget, event):
315
427
""" Key pressed handler for the location entry. """
650
762
m_annotate.set_sensitive(False)
651
763
m_diff.set_sensitive(False)
653
menu.right_context_menu().popup(None, None, None, 0,
766
menu.right_context_menu().popup(None, None, None, 0,
769
menu.remote_context_menu().popup(None, None, None, 0,
656
772
def on_treeview_right_row_activated(self, treeview, path, view_column):
657
773
""" Occurs when somebody double-clicks or enters an item in the