22
22
gcommit GTK+ commit dialog.
23
23
gconflicts GTK+ conflicts.
24
24
gdiff Show differences in working tree in a GTK+ Window.
25
ghandle-patch Display and optionally merge a merge directive or patch.
26
25
ginit Initialise a new branch.
27
26
gmissing GTK+ missing revisions dialog.
28
27
gpreferences GTK+ preferences dialog.
40
version_info = (0, 94, 0, 'dev', 0)
39
version_info = (0, 95, 0, 'dev', 1)
42
41
if version_info[3] == 'final':
43
42
version_string = '%d.%d.%d' % version_info[:3]
109
108
return os.path.dirname(__file__)
111
def icon_path(*args):
112
basedirs = [os.path.join(data_path()),
113
"/usr/share/bzr-gtk",
114
"/usr/local/share/bzr-gtk"]
115
for basedir in basedirs:
116
path = os.path.join(basedir, 'icons', *args)
117
if os.path.exists(path):
123
pygtk = import_pygtk()
126
except RuntimeError, e:
127
if str(e) == "could not open display":
112
133
class GTKCommand(Command):
113
134
"""Abstract class providing GTK specific run commands."""
115
def open_display(self):
116
pygtk = import_pygtk()
119
except RuntimeError, e:
120
if str(e) == "could not open display":
127
138
dialog = self.get_gtk_dialog(os.path.abspath('.'))
158
169
def run(self, location="."):
159
170
(br, path) = branch.Branch.open_containing(location)
161
172
from push import PushDialog
162
173
dialog = PushDialog(br.repository, br.last_revision(), br)
182
193
if revision is not None:
183
194
if len(revision) == 1:
185
revision_id = revision[0].in_history(branch).rev_id
196
revision_id = revision[0].as_revision_id(tree1.branch)
186
197
tree2 = branch.repository.revision_tree(revision_id)
187
198
elif len(revision) == 2:
188
revision_id_0 = revision[0].in_history(branch).rev_id
199
revision_id_0 = revision[0].as_revision_id(branch)
189
200
tree2 = branch.repository.revision_tree(revision_id_0)
190
revision_id_1 = revision[1].in_history(branch).rev_id
201
revision_id_1 = revision[1].as_revision_id(branch)
191
202
tree1 = branch.repository.revision_tree(revision_id_1)
250
261
if revision is None:
251
262
revids.append(br.last_revision())
253
(revno, revid) = revision[0].in_history(br)
264
revids.append(revision[0].as_revision_id(br))
256
266
pp = start_viz_window(br, revids, limit)
257
267
pp.connect("destroy", lambda w: gtk.main_quit())
276
286
aliases = ["gblame", "gpraise"]
278
288
def run(self, filename, all=False, plain=False, line='1', revision=None):
279
gtk = self.open_display()
301
311
if revision is not None:
302
312
if len(revision) != 1:
303
313
raise BzrCommandError("Only 1 revion may be specified.")
304
revision_id = revision[0].in_history(br).rev_id
314
revision_id = revision[0].as_revision_id(br)
305
315
tree = br.repository.revision_tree(revision_id)
307
317
revision_id = getattr(tree, 'get_revision_id', lambda: None)()
309
window = GAnnotateWindow(all, plain)
319
window = GAnnotateWindow(all, plain, branch=br)
310
320
window.connect("destroy", lambda w: gtk.main_quit())
311
321
config = GAnnotateConfig(window)
349
359
except NoWorkingTree, e:
350
360
from dialog import error_dialog
351
error_dialog(_('Directory does not have a working tree'),
352
_('Operation aborted.'))
361
error_dialog(_i18n('Directory does not have a working tree'),
362
_i18n('Operation aborted.'))
353
363
return 1 # should this be retval=3?
355
365
# It is a good habit to keep things locked for the duration, but it
373
383
aliases = [ "gst" ]
374
384
takes_args = ['PATH?']
385
takes_options = ['revision']
377
def run(self, path='.'):
387
def run(self, path='.', revision=None):
379
gtk = self.open_display()
380
390
from status import StatusDialog
381
391
(wt, wt_path) = workingtree.WorkingTree.open_containing(path)
382
status = StatusDialog(wt, wt_path)
393
if revision is not None:
395
revision_id = revision[0].as_revision_id(wt.branch)
397
from bzrlib.errors import BzrError
398
raise BzrError('Revision %r doesn\'t exist' % revision[0].user_spec )
402
status = StatusDialog(wt, wt_path, revision_id)
383
403
status.connect("destroy", gtk.main_quit)
392
412
(br, path) = branch.Branch.open_containing(".")
393
gtk = self.open_display()
394
414
from bzrlib.plugins.gtk.mergedirective import SendMergeDirectiveDialog
395
415
from StringIO import StringIO
396
416
dialog = SendMergeDirectiveDialog(br)
516
536
from notify import NotifyPopupMenu
517
gtk = self.open_display()
518
538
menu = NotifyPopupMenu()
519
icon = gtk.status_icon_new_from_file(os.path.join(data_path(), "bzr-icon-64.png"))
539
icon = gtk.status_icon_new_from_file(icon_path("bzr-icon-64.png"))
520
540
icon.connect('popup-menu', menu.display)
529
549
from bzrlib.transport import get_transport
530
550
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
532
from bzrlib.plugins.dbus import activity
552
BROADCAST_INTERFACE = "org.bazaarvcs.plugins.dbus.Broadcast"
533
553
bus = dbus.SessionBus()
534
# get the object so we can subscribe to callbacks from it.
535
broadcast_service = bus.get_object(
536
activity.Broadcast.DBUS_NAME,
537
activity.Broadcast.DBUS_PATH)
539
555
def catch_branch(revision_id, urls):
540
556
# TODO: show all the urls, or perhaps choose the 'best'.
571
587
except Exception, e:
574
broadcast_service.connect_to_signal("Revision", catch_branch,
575
dbus_interface=activity.Broadcast.DBUS_INTERFACE)
590
bus.add_signal_receiver(catch_branch,
591
dbus_interface=BROADCAST_INTERFACE,
592
signal_name="Revision")
576
593
pynotify.init("bzr commit-notify")
675
692
register_command(cmd_test_gtk)
678
class cmd_ghandle_patch(GTKCommand):
679
"""Display a patch or merge directive, possibly merging.
681
This is a helper, meant to be launched from other programs like browsers
682
or email clients. Since these programs often do not allow parameters to
683
be provided, a "handle-patch" script is included.
686
takes_args = ['path']
690
from bzrlib.plugins.gtk.diff import (DiffWindow,
691
MergeDirectiveWindow)
692
lines = open(path, 'rb').readlines()
693
lines = [l.replace('\r\n', '\n') for l in lines]
695
directive = merge_directive.MergeDirective.from_lines(lines)
696
except errors.NotAMergeDirective:
697
window = DiffWindow()
698
window.set_diff_text(path, lines)
700
window = MergeDirectiveWindow(directive, path)
701
window.set_diff_text(path, directive.patch.splitlines(True))
703
gtk = self.open_display()
704
window.connect("destroy", gtk.main_quit)
706
from dialog import error_dialog
707
error_dialog('Error', str(e))
712
register_command(cmd_ghandle_patch)
716
697
gettext.install('olive-gtk')
699
# Let's create a specialized alias to protect '_' from being erased by other
700
# uses of '_' as an anonymous variable (think pdb for one).
701
_i18n = gettext.gettext
719
703
class NoDisplayError(BzrCommandError):
720
704
"""gtk could not find a proper display"""