/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: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

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. 
36
37
 
37
38
import bzrlib
38
39
 
39
 
version_info = (0, 95, 0, 'dev', 1)
 
40
version_info = (0, 94, 0, 'rc', 1)
40
41
 
41
42
if version_info[3] == 'final':
42
43
    version_string = '%d.%d.%d' % version_info[:3]
119
120
    return None
120
121
 
121
122
 
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
 
 
133
123
class GTKCommand(Command):
134
124
    """Abstract class providing GTK specific run commands."""
135
125
 
 
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
 
        open_display()
 
137
        self.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
 
        open_display()
 
171
        self.open_display()
172
172
        from push import PushDialog
173
173
        dialog = PushDialog(br.repository, br.last_revision(), br)
174
174
        dialog.run()
193
193
            if revision is not None:
194
194
                if len(revision) == 1:
195
195
                    tree1 = wt
196
 
                    revision_id = revision[0].as_revision_id(tree1.branch)
 
196
                    revision_id = revision[0].in_history(branch).rev_id
197
197
                    tree2 = branch.repository.revision_tree(revision_id)
198
198
                elif len(revision) == 2:
199
 
                    revision_id_0 = revision[0].as_revision_id(branch)
 
199
                    revision_id_0 = revision[0].in_history(branch).rev_id
200
200
                    tree2 = branch.repository.revision_tree(revision_id_0)
201
 
                    revision_id_1 = revision[1].as_revision_id(branch)
 
201
                    revision_id_1 = revision[1].in_history(branch).rev_id
202
202
                    tree1 = branch.repository.revision_tree(revision_id_1)
203
203
            else:
204
204
                tree1 = wt
261
261
            if revision is None:
262
262
                revids.append(br.last_revision())
263
263
            else:
264
 
                revids.append(revision[0].as_revision_id(br))
 
264
                (revno, revid) = revision[0].in_history(br)
 
265
                revids.append(revid)
265
266
        import gtk
266
267
        pp = start_viz_window(br, revids, limit)
267
268
        pp.connect("destroy", lambda w: gtk.main_quit())
286
287
    aliases = ["gblame", "gpraise"]
287
288
    
288
289
    def run(self, filename, all=False, plain=False, line='1', revision=None):
289
 
        gtk = open_display()
 
290
        gtk = self.open_display()
290
291
 
291
292
        try:
292
293
            line = int(line)
311
312
        if revision is not None:
312
313
            if len(revision) != 1:
313
314
                raise BzrCommandError("Only 1 revion may be specified.")
314
 
            revision_id = revision[0].as_revision_id(br)
 
315
            revision_id = revision[0].in_history(br).rev_id
315
316
            tree = br.repository.revision_tree(revision_id)
316
317
        else:
317
318
            revision_id = getattr(tree, 'get_revision_id', lambda: None)()
318
319
 
319
 
        window = GAnnotateWindow(all, plain, branch=br)
 
320
        window = GAnnotateWindow(all, plain)
320
321
        window.connect("destroy", lambda w: gtk.main_quit())
321
322
        config = GAnnotateConfig(window)
322
323
        window.show()
345
346
 
346
347
    def run(self, filename=None):
347
348
        import os
348
 
        open_display()
 
349
        self.open_display()
349
350
        from commit import CommitDialog
350
351
        from bzrlib.errors import (BzrCommandError,
351
352
                                   NotBranchError,
386
387
 
387
388
    def run(self, path='.', revision=None):
388
389
        import os
389
 
        gtk = open_display()
 
390
        gtk = self.open_display()
390
391
        from status import StatusDialog
391
392
        (wt, wt_path) = workingtree.WorkingTree.open_containing(path)
392
393
        
393
394
        if revision is not None:
394
395
            try:
395
 
                revision_id = revision[0].as_revision_id(wt.branch)
 
396
                revision_id = revision[0].in_history(wt.branch).rev_id
396
397
            except:
397
398
                from bzrlib.errors import BzrError
398
399
                raise BzrError('Revision %r doesn\'t exist' % revision[0].user_spec )
410
411
    """
411
412
    def run(self):
412
413
        (br, path) = branch.Branch.open_containing(".")
413
 
        gtk = open_display()
 
414
        gtk = self.open_display()
414
415
        from bzrlib.plugins.gtk.mergedirective import SendMergeDirectiveDialog
415
416
        from StringIO import StringIO
416
417
        dialog = SendMergeDirectiveDialog(br)
432
433
    """
433
434
    def run(self):
434
435
        (wt, path) = workingtree.WorkingTree.open_containing('.')
435
 
        open_display()
 
436
        self.open_display()
436
437
        from bzrlib.plugins.gtk.conflicts import ConflictsDialog
437
438
        dialog = ConflictsDialog(wt)
438
439
        dialog.run()
443
444
 
444
445
    """
445
446
    def run(self):
446
 
        open_display()
 
447
        self.open_display()
447
448
        from bzrlib.plugins.gtk.preferences import PreferencesWindow
448
449
        dialog = PreferencesWindow()
449
450
        dialog.run()
487
488
 
488
489
class cmd_ginit(GTKCommand):
489
490
    def run(self):
490
 
        open_display()
 
491
        self.open_display()
491
492
        from initialize import InitDialog
492
493
        dialog = InitDialog(os.path.abspath(os.path.curdir))
493
494
        dialog.run()
497
498
    def run(self):
498
499
        br = branch.Branch.open_containing('.')[0]
499
500
        
500
 
        gtk = open_display()
 
501
        gtk = self.open_display()
501
502
        from tags import TagsWindow
502
503
        window = TagsWindow(br)
503
504
        window.show()
534
535
 
535
536
    def run(self):
536
537
        from notify import NotifyPopupMenu
537
 
        gtk = open_display()
 
538
        gtk = self.open_display()
538
539
        menu = NotifyPopupMenu()
539
540
        icon = gtk.status_icon_new_from_file(icon_path("bzr-icon-64.png"))
540
541
        icon.connect('popup-menu', menu.display)
692
693
register_command(cmd_test_gtk)
693
694
 
694
695
 
 
696
class cmd_ghandle_patch(GTKCommand):
 
697
    """Display a patch or merge directive, possibly merging.
 
698
 
 
699
    This is a helper, meant to be launched from other programs like browsers
 
700
    or email clients.  Since these programs often do not allow parameters to
 
701
    be provided, a "handle-patch" script is included.
 
702
    """
 
703
 
 
704
    takes_args = ['path']
 
705
 
 
706
    def run(self, path):
 
707
        try:
 
708
            from bzrlib.plugins.gtk.diff import (DiffWindow,
 
709
                                                 MergeDirectiveWindow)
 
710
            lines = open(path, 'rb').readlines()
 
711
            lines = [l.replace('\r\n', '\n') for l in lines]
 
712
            try:
 
713
                directive = merge_directive.MergeDirective.from_lines(lines)
 
714
            except errors.NotAMergeDirective:
 
715
                window = DiffWindow()
 
716
                window.set_diff_text(path, lines)
 
717
            else:
 
718
                window = MergeDirectiveWindow(directive, path)
 
719
                window.set_diff_text(path, directive.patch.splitlines(True))
 
720
            window.show()
 
721
            gtk = self.open_display()
 
722
            window.connect("destroy", gtk.main_quit)
 
723
        except Exception, e:
 
724
            from dialog import error_dialog
 
725
            error_dialog('Error', str(e))
 
726
            raise
 
727
        gtk.main()
 
728
 
 
729
 
 
730
register_command(cmd_ghandle_patch)
 
731
 
695
732
 
696
733
import gettext
697
734
gettext.install('olive-gtk')