/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-30 21:45:54 UTC
  • Revision ID: jelmer@samba.org-20111130214554-5kfx0b5y7t5zh033
Extend branch preferences, show location widget.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 
40
40
 
41
41
class BazaarExtension(Nautilus.MenuProvider, Nautilus.ColumnProvider,
42
 
        Nautilus.InfoProvider, Nautilus.PropertyPageProvider, GObject.GObject):
 
42
        Nautilus.InfoProvider, Nautilus.PropertyPageProvider,
 
43
        Nautilus.LocationWidgetProvider, GObject.GObject):
43
44
    """Nautilus extension providing Bazaar integration."""
44
45
 
45
46
    def __init__(self):
412
413
                tree.unlock()
413
414
        return pages
414
415
 
 
416
    def get_widget(self, uri, window):
 
417
        controldir, path = ControlDir.open_containing(uri)
 
418
        try:
 
419
            tree = controldir.open_workingtree()
 
420
        except NoWorkingTree:
 
421
            return
 
422
        ret = Gtk.HBox(False, 4)
 
423
        text = 'This is a Bazaar working tree. '
 
424
        get_shelf_manager = getattr(tree, 'get_shelf_manager', None)
 
425
        if get_shelf_manager is not None:
 
426
            manager = get_shelf_manager()
 
427
            shelves = manager.active_shelves()
 
428
            if len(shelves) == 0:
 
429
                pass
 
430
            elif len(shelves) == 1:
 
431
                text += '1 shelf exists. '
 
432
            else:
 
433
                text += '%d shelf exists. ' % len(shelves)
 
434
        label = Gtk.Label(text)
 
435
        label.show()
 
436
        ret.pack_start(label, True, True, 0)
 
437
        ret.show_all()
 
438
        return ret
 
439
 
415
440
 
416
441
class PropertyPageFile(Nautilus.PropertyPage):
417
442
 
464
489
        super(PropertyPageBranch, self).__init__(label=label,
465
490
            name="BzrNautilus::branch_page", page=table)
466
491
 
 
492
    def _create_location_entry(self, get_location, set_location):
 
493
        location = get_location()
 
494
        ret = Gtk.Entry()
 
495
        if location is not None:
 
496
            ret.set_text(location)
 
497
        return ret
 
498
 
467
499
    def _create_table(self):
468
 
        table = Gtk.Table(homogeneous=False, columns=2, rows=3)
 
500
        table = Gtk.Table(homogeneous=False, columns=2, rows=6)
 
501
 
 
502
        self._push_location_entry = self._create_location_entry(
 
503
            self.branch.get_push_location, self.branch.set_push_location)
 
504
        self._parent_location_entry = self._create_location_entry(
 
505
            self.branch.get_parent, self.branch.set_parent)
 
506
        self._bound_location_entry = self._create_location_entry(
 
507
            self.branch.get_bound_location, self.branch.set_bound_location)
 
508
        self._public_location_entry = self._create_location_entry(
 
509
            self.branch.get_public_branch, self.branch.set_public_branch)
 
510
        self._submit_location_entry = self._create_location_entry(
 
511
            self.branch.get_submit_branch, self.branch.set_submit_branch)
469
512
 
470
513
        table.attach(Gtk.Label('Push location:'), 0, 1, 0, 1)
471
 
        table.attach(Gtk.Label(self.branch.get_push_location()), 1, 2, 0, 1)
 
514
        table.attach(self._push_location_entry, 1, 2, 0, 1)
472
515
 
473
516
        table.attach(Gtk.Label('Parent location:'), 0, 1, 1, 2)
474
 
        table.attach(Gtk.Label(self.branch.get_parent()), 1, 1, 1, 2)
 
517
        table.attach(self._parent_location_entry, 1, 1, 1, 2)
 
518
 
 
519
        table.attach(Gtk.Label('Bound location:'), 0, 1, 2, 3)
 
520
        table.attach(self._bound_location_entry, 1, 1, 2, 3)
 
521
 
 
522
        table.attach(Gtk.Label('Public location:'), 0, 1, 3, 4)
 
523
        table.attach(self._public_location_entry, 1, 1, 3, 4)
 
524
 
 
525
        table.attach(Gtk.Label('Submit location:'), 0, 1, 4, 5)
 
526
        table.attach(self._submit_location_entry, 1, 1, 4, 5)
 
527
 
 
528
        self._append_revisions_only = Gtk.CheckButton('Append revisions only')
 
529
        value = self.branch.get_append_revisions_only()
 
530
        if value is None:
 
531
            value = False
 
532
        self._append_revisions_only.set_active(value)
 
533
        table.attach(self._append_revisions_only, 0, 2, 5, 6)
475
534
 
476
535
        table.show_all()
477
536
        return table