/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: 2012-07-09 15:23:26 UTC
  • mto: This revision was merged to the branch mainline in revision 794.
  • Revision ID: jelmer@samba.org-20120709152326-dzxb8zoz0btull7n
Remove bzr-notify.

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
 
40
42
 
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."""
44
47
 
45
48
    def __init__(self):
121
124
        dialog.display()
122
125
        Gtk.main()
123
126
 
 
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
 
124
133
    def merge_cb(self, menu, tree, path=None):
125
134
        from bzrlib.plugins.gtk.merge import MergeDialog
126
135
        dialog = MergeDialog(tree, path)
236
245
            item.connect('activate', self.unignore_cb, tree, path)
237
246
            yield item
238
247
        else:
 
248
            kind = tree.kind(file_id)
239
249
            item = Nautilus.MenuItem(name='BzrNautilus::log',
240
250
                             label='History ...',
241
251
                             tip='List changes',
265
275
            item.connect('activate', self.remove_cb, tree, path)
266
276
            yield item
267
277
 
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
 
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
274
285
 
275
286
    def get_file_items(self, window, files):
276
287
        items = []
412
423
                tree.unlock()
413
424
        return pages
414
425
 
 
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
 
415
450
 
416
451
class PropertyPageFile(Nautilus.PropertyPage):
417
452
 
430
465
    def _create_table(self):
431
466
        table = Gtk.Table(homogeneous=False, columns=2, rows=3)
432
467
 
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)
435
470
 
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)
438
473
 
439
474
        basis_tree = self.tree.revision_tree(self.tree.last_revision())
440
475
        last_revision = basis_tree.get_file_revision(self.file_id)
441
476
 
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)
446
481
 
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)
450
485
 
464
499
        super(PropertyPageBranch, self).__init__(label=label,
465
500
            name="BzrNautilus::branch_page", page=table)
466
501
 
 
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
 
467
509
    def _create_table(self):
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)
 
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)
475
544
 
476
545
        table.show_all()
477
546
        return table