37
37
from bzrlib.plugin import load_plugins
40
from bzrlib.plugins.gtk.i18n import _i18n
41
43
class BazaarExtension(Nautilus.MenuProvider, Nautilus.ColumnProvider,
42
Nautilus.InfoProvider, Nautilus.PropertyPageProvider, GObject.GObject):
44
Nautilus.InfoProvider, Nautilus.PropertyPageProvider,
45
Nautilus.LocationWidgetProvider, GObject.GObject):
43
46
"""Nautilus extension providing Bazaar integration."""
45
48
def __init__(self):
265
275
item.connect('activate', self.remove_cb, tree, path)
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)
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)
275
286
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)
416
451
class PropertyPageFile(Nautilus.PropertyPage):
430
465
def _create_table(self):
431
466
table = Gtk.Table(homogeneous=False, columns=2, rows=3)
433
table.attach(Gtk.Label('File id:'), 0, 1, 0, 1)
468
table.attach(Gtk.Label(_i18n('File id:')), 0, 1, 0, 1)
434
469
table.attach(Gtk.Label(self.file_id), 1, 2, 0, 1)
436
table.attach(Gtk.Label('SHA1Sum:'), 0, 1, 1, 2)
471
table.attach(Gtk.Label(_i18n('SHA1Sum:')), 0, 1, 1, 2)
437
472
table.attach(Gtk.Label(self.tree.get_file_sha1(self.file_id, self.path)), 1, 1, 1, 2)
439
474
basis_tree = self.tree.revision_tree(self.tree.last_revision())
440
475
last_revision = basis_tree.get_file_revision(self.file_id)
442
table.attach(Gtk.Label('Last Change Revision:'), 0, 1, 2, 3)
477
table.attach(Gtk.Label(_i18n('Last Change Revision:')), 0, 1, 2, 3)
443
478
revno = ".".join([str(x) for x in
444
479
self.tree.branch.revision_id_to_dotted_revno(last_revision)])
445
480
table.attach(Gtk.Label(revno), 1, 1, 2, 3)
447
table.attach(Gtk.Label('Last Change Author:'), 0, 1, 3, 4)
482
table.attach(Gtk.Label(_i18n('Last Change Author:')), 0, 1, 3, 4)
448
483
rev = self.tree.branch.repository.get_revision(last_revision)
449
484
table.attach(Gtk.Label("\n".join(rev.get_apparent_authors())), 1, 1, 3, 4)
464
499
super(PropertyPageBranch, self).__init__(label=label,
465
500
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)
467
509
def _create_table(self):
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)
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)