/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: Jelmer Vernooij
  • Date: 2007-07-15 15:22:29 UTC
  • Revision ID: jelmer@samba.org-20070715152229-clmlen0vpd8d2pzx
Add docstrings, remove unused code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#
1
3
# This program is free software; you can redistribute it and/or modify
2
4
# it under the terms of the GNU General Public License as published by
3
5
# the Free Software Foundation; either version 2 of the License, or
20
22
gbranch           GTK+ branching. 
21
23
gcheckout         GTK+ checkout. 
22
24
gcommit           GTK+ commit dialog 
23
 
gconflicts        GTK+ conflicts. 
 
25
gconflicts        GTK+ push. 
24
26
gdiff             Show differences in working tree in a GTK+ Window. 
25
27
ginit             Initialise a new branch.
26
28
gmissing          GTK+ missing revisions dialog. 
33
35
 
34
36
import bzrlib
35
37
 
36
 
__version__ = '0.91.0'
 
38
__version__ = '0.18.0'
37
39
version_info = tuple(int(n) for n in __version__.split('.'))
38
40
 
39
41
 
57
59
        from warnings import warn as warning
58
60
    if bzrlib_version < desired:
59
61
        from bzrlib.errors import BzrError
60
 
        warning('Installed Bazaar version %s is too old to be used with bzr-gtk'
 
62
        warning('Installed bzr version %s is too old to be used with bzr-gtk'
61
63
                ' %s.' % (bzrlib.__version__, __version__))
62
 
        raise BzrError('Version mismatch: %r' % (version_info,) )
 
64
        raise BzrError('Version mismatch: %r' % version_info)
63
65
    else:
64
66
        warning('bzr-gtk is not up to date with installed bzr version %s.'
65
67
                ' \nThere should be a newer version available, e.g. %i.%i.' 
76
78
lazy_import(globals(), """
77
79
from bzrlib import (
78
80
    branch,
79
 
    builtins,
80
81
    errors,
81
82
    workingtree,
82
83
    )
104
105
    bzrlib.ui.ui_factory = GtkUIFactory()
105
106
 
106
107
 
107
 
def data_path():
108
 
    return os.path.dirname(__file__)
109
 
 
110
 
 
111
108
class GTKCommand(Command):
112
109
    """Abstract class providing GTK specific run commands."""
113
110
 
158
155
        (br, path) = branch.Branch.open_containing(location)
159
156
        self.open_display()
160
157
        from push import PushDialog
161
 
        dialog = PushDialog(br.repository, br.last_revision(), br)
 
158
        dialog = PushDialog(br)
162
159
        dialog.run()
163
160
 
164
161
 
384
381
 
385
382
 
386
383
class cmd_gconflicts(GTKCommand):
387
 
    """ GTK+ conflicts.
 
384
    """ GTK+ push.
388
385
    
389
 
    Select files from the list of conflicts and run an external utility to
390
 
    resolve them.
391
386
    """
392
387
    def run(self):
393
388
        (wt, path) = workingtree.WorkingTree.open_containing('.')
496
491
        from notify import NotifyPopupMenu
497
492
        gtk = self.open_display()
498
493
        menu = NotifyPopupMenu()
499
 
        icon = gtk.status_icon_new_from_file(os.path.join(data_path(), "bzr-icon-64.png"))
 
494
        icon = gtk.status_icon_new_from_file("bzr-icon-64.png")
500
495
        icon.connect('popup-menu', menu.display)
501
496
 
502
497
        import cgi
559
554
register_command(cmd_commit_notify)
560
555
 
561
556
 
562
 
class cmd_gselftest(GTKCommand):
563
 
    """Version of selftest that displays a notification at the end"""
564
 
 
565
 
    takes_args = builtins.cmd_selftest.takes_args
566
 
    takes_options = builtins.cmd_selftest.takes_options
567
 
    _see_also = ['selftest']
568
 
 
569
 
    def run(self, *args, **kwargs):
570
 
        import cgi
571
 
        import sys
572
 
        default_encoding = sys.getdefaultencoding()
573
 
        # prevent gtk from blowing up later
574
 
        gtk = import_pygtk()
575
 
        # prevent gtk from messing with default encoding
576
 
        import pynotify
577
 
        if sys.getdefaultencoding() != default_encoding:
578
 
            reload(sys)
579
 
            sys.setdefaultencoding(default_encoding)
580
 
        result = builtins.cmd_selftest().run(*args, **kwargs)
581
 
        if result == 0:
582
 
            summary = 'Success'
583
 
            body = 'Selftest succeeded in "%s"' % os.getcwd()
584
 
        if result == 1:
585
 
            summary = 'Failure'
586
 
            body = 'Selftest failed in "%s"' % os.getcwd()
587
 
        pynotify.init("bzr gselftest")
588
 
        note = pynotify.Notification(cgi.escape(summary), cgi.escape(body))
589
 
        note.set_timeout(pynotify.EXPIRES_NEVER)
590
 
        note.show()
591
 
 
592
 
 
593
 
register_command(cmd_gselftest)
594
 
 
595
 
 
596
557
import gettext
597
558
gettext.install('olive-gtk')
598
559