105
105
self.button_location_up = self.window.button_location_up
106
106
self.button_location_jump = self.window.button_location_jump
107
107
self.entry_location = self.window.entry_location
108
self.image_location_error = self.window.image_location_error
110
109
# Get the History widgets
111
110
self.check_history = self.window.checkbutton_history
156
155
self._just_started = False
158
157
def set_path(self, path, force_remote=False):
158
self.window.location_status.destroy()
159
159
self.notbranch = False
162
162
# Forcing remote mode (reading data from inventory)
163
self._show_stock_image(gtk.STOCK_DISCONNECT)
163
self.window.set_location_status(gtk.STOCK_DISCONNECT)
165
165
br = Branch.open_containing(path)[0]
166
166
except bzrerrors.NotBranchError:
167
self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
167
self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
168
168
self.check_history.set_active(False)
169
169
self.check_history.set_sensitive(False)
171
171
except bzrerrors.UnsupportedProtocol:
172
self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
172
self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
173
173
self.check_history.set_active(False)
174
174
self.check_history.set_sensitive(False)
177
self._show_stock_image(gtk.STOCK_CONNECT)
177
self.window.set_location_status(gtk.STOCK_CONNECT)
179
179
self.remote = True
211
210
self.wt, self.wtpath = WorkingTree.open_containing(os.path.realpath(path))
212
211
except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
213
212
self.notbranch = True
213
except bzrerrors.PermissionDenied:
214
self.window.set_location_status(gtk.STOCK_DIALOG_WARNING, allowPopup=True)
215
self.window.location_status.connect_object('clicked', warning_dialog,
216
*(_i18n('Branch information unreadable'),
217
_i18n('The current folder is a branch but the .bzr folder is not readable')))
218
self.notbranch = True
215
220
# If we're in the root, we cannot go up anymore
216
221
if sys.platform == 'win32':
227
232
elif not os.path.isfile(path):
228
233
# Doesn't seem to be a file nor a directory, trying to open a
229
234
# remote location
230
self._show_stock_image(gtk.STOCK_DISCONNECT)
235
self.window.set_location_status(gtk.STOCK_DISCONNECT)
232
237
br = Branch.open_containing(path)[0]
233
238
except bzrerrors.NotBranchError:
234
self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
239
self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
235
240
self.check_history.set_active(False)
236
241
self.check_history.set_sensitive(False)
238
243
except bzrerrors.UnsupportedProtocol:
239
self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
244
self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
240
245
self.check_history.set_active(False)
241
246
self.check_history.set_sensitive(False)
244
self._show_stock_image(gtk.STOCK_CONNECT)
249
self.window.set_location_status(gtk.STOCK_CONNECT)
246
251
self.remote = True
938
943
# Add the ListStore to the TreeView
939
944
self.window.treeview_left.set_model(liststore)
941
def refresh_right(self, path=None):
946
def refresh_right(self):
942
947
""" Refresh the file list. """
943
948
if not self.remote:
945
950
from bzrlib.workingtree import WorkingTree
948
path = self.get_path()
950
# A workaround for double-clicking Bookmarks
951
if not os.path.exists(path):
952
path = self.get_path()
954
954
# Get ListStore and clear it
955
955
liststore = self.window.filelist
956
956
liststore.clear()
971
971
files.append(item)
973
# Try to open the working tree
976
tree1 = WorkingTree.open_containing(os.path.realpath(path))[0]
977
except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
981
branch = tree1.branch
982
tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
984
delta = tree1.changes_from(tree2, want_unchanged=True)
987
self.window.col_status.set_visible(True)
989
# Don't show Status column
990
self.window.col_status.set_visible(False)
973
self.window.col_status.set_visible(False)
974
if not self.notbranch:
976
tree1 = WorkingTree.open_containing(os.path.realpath(path))[0]
977
branch = tree1.branch
978
tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
980
delta = tree1.changes_from(tree2, want_unchanged=True)
983
self.window.col_status.set_visible(True)
984
except bzrerrors.LockContention:
985
self.window.set_location_status(gtk.STOCK_DIALOG_ERROR, allowPopup=True)
986
self.window.location_status.connect_object('clicked', error_dialog,
987
*(_i18n('Branch is locked'),
988
_i18n('The branch in the current folder is locked by another Bazaar program')))
989
self.notbranch = True
990
self.window.set_view_to_localbranch(False)
992
992
# Add'em to the ListStore
993
993
for item in dirs:
997
if not self.notbranch:
998
998
filename = tree1.relpath(os.path.join(os.path.realpath(path), item))
1000
1000
st, status = self.statusmapper(filename, delta)
1062
self._show_stock_image(gtk.STOCK_REFRESH)
1062
self.window.set_location_status(gtk.STOCK_REFRESH)
1064
1064
for (name, type) in self.remote_entries:
1065
1065
if type.kind == 'directory':
1124
1124
while gtk.events_pending():
1125
1125
gtk.main_iteration()
1127
self.image_location_error.destroy()
1127
self.window.location_status.destroy()
1129
1129
# Columns should auto-size
1130
1130
self.window.treeview_right.columns_autosize()
1292
1292
# Either it's not a directory or not in the inventory
1295
def _show_stock_image(self, stock_id):
1296
""" Show a stock image next to the location entry. """
1297
self.image_location_error.destroy()
1298
self.image_location_error = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
1299
self.hbox_location.pack_start(self.image_location_error, False, False, 0)
1300
if sys.platform == 'win32':
1301
self.hbox_location.reorder_child(self.image_location_error, 2)
1303
self.hbox_location.reorder_child(self.image_location_error, 1)
1304
self.image_location_error.show()
1305
while gtk.events_pending():
1306
gtk.main_iteration()
1308
1295
import ConfigParser