37
37
from bzrlib.plugin import load_plugins
40
from bzrlib.plugins.gtk.i18n import _i18n
43
41
class BazaarExtension(Nautilus.MenuProvider, Nautilus.ColumnProvider,
44
Nautilus.InfoProvider, Nautilus.PropertyPageProvider,
45
Nautilus.LocationWidgetProvider, GObject.GObject):
42
Nautilus.InfoProvider, Nautilus.PropertyPageProvider, GObject.GObject):
46
43
"""Nautilus extension providing Bazaar integration."""
48
45
def __init__(self):
275
265
item.connect('activate', self.remove_cb, tree, path)
279
item = Nautilus.MenuItem(name='BzrNautilus::annotate',
280
label='Annotate ...',
281
tip='Annotate File Data',
283
item.connect('activate', self.annotate_cb, tree, path, file_id)
268
item = Nautilus.MenuItem(name='BzrNautilus::annotate',
269
label='Annotate ...',
270
tip='Annotate File Data',
272
item.connect('activate', self.annotate_cb, tree, path, file_id)
286
275
def get_file_items(self, window, files):
426
def get_widget(self, uri, window):
427
controldir, path = ControlDir.open_containing(uri)
429
tree = controldir.open_workingtree()
430
except NoWorkingTree:
432
ret = Gtk.HBox(False, 4)
433
text = 'This is a Bazaar working tree. '
434
get_shelf_manager = getattr(tree, 'get_shelf_manager', None)
435
if get_shelf_manager is not None:
436
manager = get_shelf_manager()
437
shelves = manager.active_shelves()
438
if len(shelves) == 0:
440
elif len(shelves) == 1:
441
text += '1 shelf exists. '
443
text += '%d shelf exists. ' % len(shelves)
444
label = Gtk.Label(text)
446
ret.pack_start(label, True, True, 0)
451
416
class PropertyPageFile(Nautilus.PropertyPage):
465
430
def _create_table(self):
466
431
table = Gtk.Table(homogeneous=False, columns=2, rows=3)
468
table.attach(Gtk.Label(_i18n('File id:')), 0, 1, 0, 1)
433
table.attach(Gtk.Label('File id:'), 0, 1, 0, 1)
469
434
table.attach(Gtk.Label(self.file_id), 1, 2, 0, 1)
471
table.attach(Gtk.Label(_i18n('SHA1Sum:')), 0, 1, 1, 2)
436
table.attach(Gtk.Label('SHA1Sum:'), 0, 1, 1, 2)
472
437
table.attach(Gtk.Label(self.tree.get_file_sha1(self.file_id, self.path)), 1, 1, 1, 2)
474
439
basis_tree = self.tree.revision_tree(self.tree.last_revision())
475
440
last_revision = basis_tree.get_file_revision(self.file_id)
477
table.attach(Gtk.Label(_i18n('Last Change Revision:')), 0, 1, 2, 3)
442
table.attach(Gtk.Label('Last Change Revision:'), 0, 1, 2, 3)
478
443
revno = ".".join([str(x) for x in
479
444
self.tree.branch.revision_id_to_dotted_revno(last_revision)])
480
445
table.attach(Gtk.Label(revno), 1, 1, 2, 3)
482
table.attach(Gtk.Label(_i18n('Last Change Author:')), 0, 1, 3, 4)
447
table.attach(Gtk.Label('Last Change Author:'), 0, 1, 3, 4)
483
448
rev = self.tree.branch.repository.get_revision(last_revision)
484
449
table.attach(Gtk.Label("\n".join(rev.get_apparent_authors())), 1, 1, 3, 4)
499
464
super(PropertyPageBranch, self).__init__(label=label,
500
465
name="BzrNautilus::branch_page", page=table)
502
def _create_location_entry(self, get_location, set_location):
503
location = get_location()
505
if location is not None:
506
ret.set_text(location)
509
467
def _create_table(self):
510
table = Gtk.Table(homogeneous=False, columns=2, rows=6)
512
self._push_location_entry = self._create_location_entry(
513
self.branch.get_push_location, self.branch.set_push_location)
514
self._parent_location_entry = self._create_location_entry(
515
self.branch.get_parent, self.branch.set_parent)
516
self._bound_location_entry = self._create_location_entry(
517
self.branch.get_bound_location, self.branch.set_bound_location)
518
self._public_location_entry = self._create_location_entry(
519
self.branch.get_public_branch, self.branch.set_public_branch)
520
self._submit_location_entry = self._create_location_entry(
521
self.branch.get_submit_branch, self.branch.set_submit_branch)
523
table.attach(Gtk.Label(_i18n('Push location:')), 0, 1, 0, 1)
524
table.attach(self._push_location_entry, 1, 2, 0, 1)
526
table.attach(Gtk.Label(_i18n('Parent location:')), 0, 1, 1, 2)
527
table.attach(self._parent_location_entry, 1, 1, 1, 2)
529
table.attach(Gtk.Label(_i18n('Bound location:')), 0, 1, 2, 3)
530
table.attach(self._bound_location_entry, 1, 1, 2, 3)
532
table.attach(Gtk.Label(_i18n('Public location:')), 0, 1, 3, 4)
533
table.attach(self._public_location_entry, 1, 1, 3, 4)
535
table.attach(Gtk.Label(_i18n('Submit location:')), 0, 1, 4, 5)
536
table.attach(self._submit_location_entry, 1, 1, 4, 5)
538
self._append_revisions_only = Gtk.CheckButton(_i18n('Append revisions only'))
539
value = self.branch.get_append_revisions_only()
542
self._append_revisions_only.set_active(value)
543
table.attach(self._append_revisions_only, 0, 2, 5, 6)
468
table = Gtk.Table(homogeneous=False, columns=2, rows=3)
470
table.attach(Gtk.Label('Push location:'), 0, 1, 0, 1)
471
table.attach(Gtk.Label(self.branch.get_push_location()), 1, 2, 0, 1)
473
table.attach(Gtk.Label('Parent location:'), 0, 1, 1, 2)
474
table.attach(Gtk.Label(self.branch.get_parent()), 1, 1, 1, 2)