/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to nautilus-bzr.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-29 10:06:50 UTC
  • Revision ID: jelmer@samba.org-20111129100650-9oit3f44pxre4uq8
Credit Curtis.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from bzrlib.plugin import load_plugins
38
38
load_plugins()
39
39
 
40
 
from bzrlib.plugins.gtk.i18n import _i18n
41
 
 
42
40
 
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."""
47
44
 
48
45
    def __init__(self):
124
121
        dialog.display()
125
122
        Gtk.main()
126
123
 
127
 
    def push_cb(self, menu, controldir, path=None):
128
 
        from bzrlib.plugins.gtk.push import PushDialog
129
 
        dialog = PushDialog(branch=controldir.open_workingtree().branch)
130
 
        dialog.display()
131
 
        Gtk.main()
132
 
 
133
124
    def merge_cb(self, menu, tree, path=None):
134
125
        from bzrlib.plugins.gtk.merge import MergeDialog
135
126
        dialog = MergeDialog(tree, path)
245
236
            item.connect('activate', self.unignore_cb, tree, path)
246
237
            yield item
247
238
        else:
248
 
            kind = tree.kind(file_id)
249
239
            item = Nautilus.MenuItem(name='BzrNautilus::log',
250
240
                             label='History ...',
251
241
                             tip='List changes',
275
265
            item.connect('activate', self.remove_cb, tree, path)
276
266
            yield item
277
267
 
278
 
            if kind == 'file':
279
 
                item = Nautilus.MenuItem(name='BzrNautilus::annotate',
280
 
                             label='Annotate ...',
281
 
                             tip='Annotate File Data',
282
 
                             icon='')
283
 
                item.connect('activate', self.annotate_cb, tree, path, file_id)
284
 
                yield item
 
268
            item = Nautilus.MenuItem(name='BzrNautilus::annotate',
 
269
                         label='Annotate ...',
 
270
                         tip='Annotate File Data',
 
271
                         icon='')
 
272
            item.connect('activate', self.annotate_cb, tree, path, file_id)
 
273
            yield item
285
274
 
286
275
    def get_file_items(self, window, files):
287
276
        items = []
423
412
                tree.unlock()
424
413
        return pages
425
414
 
426
 
    def get_widget(self, uri, window):
427
 
        controldir, path = ControlDir.open_containing(uri)
428
 
        try:
429
 
            tree = controldir.open_workingtree()
430
 
        except NoWorkingTree:
431
 
            return
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:
439
 
                pass
440
 
            elif len(shelves) == 1:
441
 
                text += '1 shelf exists. '
442
 
            else:
443
 
                text += '%d shelf exists. ' % len(shelves)
444
 
        label = Gtk.Label(text)
445
 
        label.show()
446
 
        ret.pack_start(label, True, True, 0)
447
 
        ret.show_all()
448
 
        return ret
449
 
 
450
415
 
451
416
class PropertyPageFile(Nautilus.PropertyPage):
452
417
 
465
430
    def _create_table(self):
466
431
        table = Gtk.Table(homogeneous=False, columns=2, rows=3)
467
432
 
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)
470
435
 
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)
473
438
 
474
439
        basis_tree = self.tree.revision_tree(self.tree.last_revision())
475
440
        last_revision = basis_tree.get_file_revision(self.file_id)
476
441
 
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)
481
446
 
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)
485
450
 
499
464
        super(PropertyPageBranch, self).__init__(label=label,
500
465
            name="BzrNautilus::branch_page", page=table)
501
466
 
502
 
    def _create_location_entry(self, get_location, set_location):
503
 
        location = get_location()
504
 
        ret = Gtk.Entry()
505
 
        if location is not None:
506
 
            ret.set_text(location)
507
 
        return ret
508
 
 
509
467
    def _create_table(self):
510
 
        table = Gtk.Table(homogeneous=False, columns=2, rows=6)
511
 
 
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)
522
 
 
523
 
        table.attach(Gtk.Label(_i18n('Push location:')), 0, 1, 0, 1)
524
 
        table.attach(self._push_location_entry, 1, 2, 0, 1)
525
 
 
526
 
        table.attach(Gtk.Label(_i18n('Parent location:')), 0, 1, 1, 2)
527
 
        table.attach(self._parent_location_entry, 1, 1, 1, 2)
528
 
 
529
 
        table.attach(Gtk.Label(_i18n('Bound location:')), 0, 1, 2, 3)
530
 
        table.attach(self._bound_location_entry, 1, 1, 2, 3)
531
 
 
532
 
        table.attach(Gtk.Label(_i18n('Public location:')), 0, 1, 3, 4)
533
 
        table.attach(self._public_location_entry, 1, 1, 3, 4)
534
 
 
535
 
        table.attach(Gtk.Label(_i18n('Submit location:')), 0, 1, 4, 5)
536
 
        table.attach(self._submit_location_entry, 1, 1, 4, 5)
537
 
 
538
 
        self._append_revisions_only = Gtk.CheckButton(_i18n('Append revisions only'))
539
 
        value = self.branch.get_append_revisions_only()
540
 
        if value is None:
541
 
            value = False
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)
 
469
 
 
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)
 
472
 
 
473
        table.attach(Gtk.Label('Parent location:'), 0, 1, 1, 2)
 
474
        table.attach(Gtk.Label(self.branch.get_parent()), 1, 1, 1, 2)
544
475
 
545
476
        table.show_all()
546
477
        return table