/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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2008-06-28 07:43:10 UTC
  • mfrom: (505.1.2 fix-handle-patch)
  • Revision ID: szilveszter.farkas@gmail.com-20080628074310-31znzgsw5o99r3x0
Merge bzr-handle-patch fix from Jelmer.

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.
26
25
ginit             Initialise a new branch.
27
26
gmissing          GTK+ missing revisions dialog. 
28
27
gpreferences      GTK+ preferences dialog. 
120
119
    return None
121
120
 
122
121
 
 
122
def open_display():
 
123
    pygtk = import_pygtk()
 
124
    try:
 
125
        import gtk
 
126
    except RuntimeError, e:
 
127
        if str(e) == "could not open display":
 
128
            raise NoDisplayError
 
129
    set_ui_factory()
 
130
    return gtk
 
131
 
 
132
 
123
133
class GTKCommand(Command):
124
134
    """Abstract class providing GTK specific run commands."""
125
135
 
126
 
    def open_display(self):
127
 
        pygtk = import_pygtk()
128
 
        try:
129
 
            import gtk
130
 
        except RuntimeError, e:
131
 
            if str(e) == "could not open display":
132
 
                raise NoDisplayError
133
 
        set_ui_factory()
134
 
        return gtk
135
 
 
136
136
    def run(self):
137
 
        self.open_display()
 
137
        open_display()
138
138
        dialog = self.get_gtk_dialog(os.path.abspath('.'))
139
139
        dialog.run()
140
140
 
168
168
 
169
169
    def run(self, location="."):
170
170
        (br, path) = branch.Branch.open_containing(location)
171
 
        self.open_display()
 
171
        open_display()
172
172
        from push import PushDialog
173
173
        dialog = PushDialog(br.repository, br.last_revision(), br)
174
174
        dialog.run()
286
286
    aliases = ["gblame", "gpraise"]
287
287
    
288
288
    def run(self, filename, all=False, plain=False, line='1', revision=None):
289
 
        gtk = self.open_display()
 
289
        gtk = open_display()
290
290
 
291
291
        try:
292
292
            line = int(line)
345
345
 
346
346
    def run(self, filename=None):
347
347
        import os
348
 
        self.open_display()
 
348
        open_display()
349
349
        from commit import CommitDialog
350
350
        from bzrlib.errors import (BzrCommandError,
351
351
                                   NotBranchError,
386
386
 
387
387
    def run(self, path='.', revision=None):
388
388
        import os
389
 
        gtk = self.open_display()
 
389
        gtk = open_display()
390
390
        from status import StatusDialog
391
391
        (wt, wt_path) = workingtree.WorkingTree.open_containing(path)
392
392
        
410
410
    """
411
411
    def run(self):
412
412
        (br, path) = branch.Branch.open_containing(".")
413
 
        gtk = self.open_display()
 
413
        gtk = open_display()
414
414
        from bzrlib.plugins.gtk.mergedirective import SendMergeDirectiveDialog
415
415
        from StringIO import StringIO
416
416
        dialog = SendMergeDirectiveDialog(br)
432
432
    """
433
433
    def run(self):
434
434
        (wt, path) = workingtree.WorkingTree.open_containing('.')
435
 
        self.open_display()
 
435
        open_display()
436
436
        from bzrlib.plugins.gtk.conflicts import ConflictsDialog
437
437
        dialog = ConflictsDialog(wt)
438
438
        dialog.run()
443
443
 
444
444
    """
445
445
    def run(self):
446
 
        self.open_display()
 
446
        open_display()
447
447
        from bzrlib.plugins.gtk.preferences import PreferencesWindow
448
448
        dialog = PreferencesWindow()
449
449
        dialog.run()
487
487
 
488
488
class cmd_ginit(GTKCommand):
489
489
    def run(self):
490
 
        self.open_display()
 
490
        open_display()
491
491
        from initialize import InitDialog
492
492
        dialog = InitDialog(os.path.abspath(os.path.curdir))
493
493
        dialog.run()
497
497
    def run(self):
498
498
        br = branch.Branch.open_containing('.')[0]
499
499
        
500
 
        gtk = self.open_display()
 
500
        gtk = open_display()
501
501
        from tags import TagsWindow
502
502
        window = TagsWindow(br)
503
503
        window.show()
534
534
 
535
535
    def run(self):
536
536
        from notify import NotifyPopupMenu
537
 
        gtk = self.open_display()
 
537
        gtk = open_display()
538
538
        menu = NotifyPopupMenu()
539
539
        icon = gtk.status_icon_new_from_file(icon_path("bzr-icon-64.png"))
540
540
        icon.connect('popup-menu', menu.display)
692
692
register_command(cmd_test_gtk)
693
693
 
694
694
 
695
 
class cmd_ghandle_patch(GTKCommand):
696
 
    """Display a patch or merge directive, possibly merging.
697
 
 
698
 
    This is a helper, meant to be launched from other programs like browsers
699
 
    or email clients.  Since these programs often do not allow parameters to
700
 
    be provided, a "handle-patch" script is included.
701
 
    """
702
 
 
703
 
    takes_args = ['path']
704
 
 
705
 
    def run(self, path):
706
 
        try:
707
 
            from bzrlib.plugins.gtk.diff import (DiffController,
708
 
                                                 MergeDirectiveController)
709
 
            if path == '-':
710
 
                lines = sys.stdin.readlines()
711
 
            else:
712
 
                lines = open(path, 'rb').readlines()
713
 
            lines = [l.replace('\r\n', '\n') for l in lines]
714
 
            try:
715
 
                directive = merge_directive.MergeDirective.from_lines(lines)
716
 
            except errors.NotAMergeDirective:
717
 
                controller = DiffController(path, lines)
718
 
            else:
719
 
                controller = MergeDirectiveController(path, directive)
720
 
            window = controller.window
721
 
            window.show()
722
 
            gtk = self.open_display()
723
 
            window.connect("destroy", gtk.main_quit)
724
 
        except Exception, e:
725
 
            from dialog import error_dialog
726
 
            error_dialog('Error', str(e))
727
 
            raise
728
 
        gtk.main()
729
 
 
730
 
 
731
 
register_command(cmd_ghandle_patch)
732
 
 
733
695
 
734
696
import gettext
735
697
gettext.install('olive-gtk')