104
106
bzrlib.ui.ui_factory = GtkUIFactory()
108
return os.path.dirname(__file__)
111
def icon_path(*args):
112
basedirs = [os.path.join(data_path()),
110
return [os.path.dirname(__file__),
113
111
"/usr/share/bzr-gtk",
114
112
"/usr/local/share/bzr-gtk"]
115
for basedir in basedirs:
116
path = os.path.join(basedir, 'icons', *args)
115
def data_path(*args):
116
for basedir in data_basedirs():
117
path = os.path.join(basedir, *args)
117
118
if os.path.exists(path):
123
def icon_path(*args):
124
return data_path(os.path.join('icons', *args))
122
127
def open_display():
123
128
pygtk = import_pygtk()
169
174
def run(self, location="."):
170
175
(br, path) = branch.Branch.open_containing(location)
172
from push import PushDialog
177
from bzrlib.plugins.gtk.push import PushDialog
173
178
dialog = PushDialog(br.repository, br.last_revision(), br)
182
class cmd_gloom(GTKCommand):
186
takes_args = [ "location?" ]
188
def run(self, location="."):
190
(tree, path) = workingtree.WorkingTree.open_containing(location)
192
except NoWorkingTree, e:
193
(br, path) = branch.Branch.open_containing(location)
196
from bzrlib.plugins.gtk.loom import LoomDialog
197
dialog = LoomDialog(br, tree)
178
201
class cmd_gdiff(GTKCommand):
179
202
"""Show differences in working tree in a GTK+ Window.
475
class cmd_ginfo(Command):
480
from bzrlib import workingtree
481
from bzrlib.plugins.gtk.olive.info import InfoDialog
482
wt = workingtree.WorkingTree.open_containing('.')[0]
483
info = InfoDialog(wt.branch)
488
class cmd_gmerge(Command):
489
""" GTK+ merge dialog
492
takes_args = ["merge_from_path?"]
493
def run(self, merge_from_path=None):
494
from bzrlib import workingtree
495
from bzrlib.plugins.gtk.dialog import error_dialog
496
from bzrlib.plugins.gtk.merge import MergeDialog
498
(wt, path) = workingtree.WorkingTree.open_containing('.')
499
old_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
500
delta = wt.changes_from(old_tree)
501
if len(delta.added) or len(delta.removed) or len(delta.renamed) or len(delta.modified):
502
error_dialog(_i18n('There are local changes in the branch'),
503
_i18n('Please commit or revert the changes before merging.'))
505
parent_branch_path = wt.branch.get_parent()
506
merge = MergeDialog(wt, path, parent_branch_path)
507
response = merge.run()
452
511
class cmd_gmissing(Command):
453
512
""" GTK+ missing revisions dialog.
586
from bzrlib.plugins import loom
588
pass # Loom plugin doesn't appear to be present
590
commands.append(cmd_gloom)
524
592
for cmd in commands:
525
593
register_command(cmd)
528
class cmd_commit_notify(GTKCommand):
529
"""Run the bzr commit notifier.
531
This is a background program which will pop up a notification on the users
532
screen when a commit occurs.
536
from notify import NotifyPopupMenu
538
menu = NotifyPopupMenu()
539
icon = gtk.status_icon_new_from_file(icon_path("bzr-icon-64.png"))
540
icon.connect('popup-menu', menu.display)
546
from bzrlib.bzrdir import BzrDir
547
from bzrlib import errors
548
from bzrlib.osutils import format_date
549
from bzrlib.transport import get_transport
550
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
552
BROADCAST_INTERFACE = "org.bazaarvcs.plugins.dbus.Broadcast"
553
bus = dbus.SessionBus()
555
def catch_branch(revision_id, urls):
556
# TODO: show all the urls, or perhaps choose the 'best'.
559
if isinstance(revision_id, unicode):
560
revision_id = revision_id.encode('utf8')
561
transport = get_transport(url)
562
a_dir = BzrDir.open_from_transport(transport)
563
branch = a_dir.open_branch()
564
revno = branch.revision_id_to_revno(revision_id)
565
revision = branch.repository.get_revision(revision_id)
566
summary = 'New revision %d in %s' % (revno, url)
567
body = 'Committer: %s\n' % revision.committer
568
body += 'Date: %s\n' % format_date(revision.timestamp,
571
body += revision.message
572
body = cgi.escape(body)
573
nw = pynotify.Notification(summary, body)
574
def start_viz(notification=None, action=None, data=None):
575
"""Start the viz program."""
576
pp = start_viz_window(branch, revision_id)
578
def start_branch(notification=None, action=None, data=None):
579
"""Start a Branch dialog"""
580
from bzrlib.plugins.gtk.branch import BranchDialog
581
bd = BranchDialog(remote_path=url)
583
nw.add_action("inspect", "Inspect", start_viz, None)
584
nw.add_action("branch", "Branch", start_branch, None)
590
bus.add_signal_receiver(catch_branch,
591
dbus_interface=BROADCAST_INTERFACE,
592
signal_name="Revision")
593
pynotify.init("bzr commit-notify")
596
register_command(cmd_commit_notify)
599
596
class cmd_gselftest(GTKCommand):
600
597
"""Version of selftest that displays a notification at the end"""
630
627
register_command(cmd_gselftest)
633
class cmd_test_gtk(GTKCommand):
634
"""Version of selftest that just runs the gtk test suite."""
636
takes_options = ['verbose',
637
Option('one', short_name='1',
638
help='Stop when one test fails.'),
639
Option('benchmark', help='Run the benchmarks.'),
640
Option('lsprof-timed',
641
help='Generate lsprof output for benchmarked'
642
' sections of code.'),
644
help='List the tests instead of running them.'),
645
Option('randomize', type=str, argname="SEED",
646
help='Randomize the order of tests using the given'
647
' seed or "now" for the current time.'),
649
takes_args = ['testspecs*']
651
def run(self, verbose=None, one=False, benchmark=None,
652
lsprof_timed=None, list_only=False, randomize=None,
653
testspecs_list=None):
654
from bzrlib import __path__ as bzrlib_path
655
from bzrlib.tests import selftest
657
print '%10s: %s' % ('bzrlib', bzrlib_path[0])
659
print 'No benchmarks yet'
662
test_suite_factory = bench_suite
665
# TODO: should possibly lock the history file...
666
benchfile = open(".perf_history", "at", buffering=1)
668
test_suite_factory = test_suite
673
if testspecs_list is not None:
674
pattern = '|'.join(testspecs_list)
679
result = selftest(verbose=verbose,
682
test_suite_factory=test_suite_factory,
683
lsprof_timed=lsprof_timed,
684
bench_history=benchfile,
686
random_seed=randomize,
689
if benchfile is not None:
692
register_command(cmd_test_gtk)
697
631
gettext.install('olive-gtk')