/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 __init__.py

Merged Aaron Bentley's patch handler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
25
26
ginit             Initialise a new branch.
26
27
gmissing          GTK+ missing revisions dialog. 
27
28
gpreferences      GTK+ preferences dialog. 
77
78
    branch,
78
79
    builtins,
79
80
    errors,
 
81
    merge_directive,
80
82
    workingtree,
81
83
    )
82
84
""")
672
674
register_command(cmd_test_gtk)
673
675
 
674
676
 
 
677
class cmd_ghandle_patch(GTKCommand):
 
678
    """Display a patch or merge directive, possibly merging.
 
679
 
 
680
    This is a helper, meant to be launched from other programs like browsers
 
681
    or email clients.  Since these programs often do not allow parameters to
 
682
    be provided, a "handle-patch" script is included.
 
683
    """
 
684
 
 
685
    takes_args = ['path']
 
686
 
 
687
    def run(self, path):
 
688
        from bzrlib.plugins.gtk.diff import DiffWindow, MergeDirectiveWindow
 
689
        lines = open(path, 'rb').readlines()
 
690
        try:
 
691
            directive = merge_directive.MergeDirective.from_lines(lines)
 
692
        except errors.NotAMergeDirective:
 
693
            window = DiffWindow()
 
694
            window.set_diff_text(path, lines)
 
695
        else:
 
696
            window = MergeDirectiveWindow(directive)
 
697
            window.set_diff_text(path, directive.patch.splitlines(True))
 
698
        window.show()
 
699
        gtk = self.open_display()
 
700
        window.connect("destroy", gtk.main_quit)
 
701
        gtk.main()
 
702
 
 
703
 
 
704
register_command(cmd_ghandle_patch)
 
705
 
 
706
 
675
707
import gettext
676
708
gettext.install('olive-gtk')
677
709