/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 18:12:57 UTC
  • Revision ID: jelmer@samba.org-20070715181257-g264qus2zyi3v39z
Add RevisionSelectionBox widget, use in TagDialog.

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_info = (0, 92, 0, 'dev', 0)
 
38
__version__ = '0.18.0'
 
39
version_info = tuple(int(n) for n in __version__.split('.'))
37
40
 
38
 
if version_info[3] == 'final':
39
 
    version_string = '%d.%d.%d' % version_info[:3]
40
 
else:
41
 
    version_string = '%d.%d.%d%s%d' % version_info
42
 
__version__ = version_string
43
41
 
44
42
def check_bzrlib_version(desired):
45
43
    """Check that bzrlib is compatible.
61
59
        from warnings import warn as warning
62
60
    if bzrlib_version < desired:
63
61
        from bzrlib.errors import BzrError
64
 
        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'
65
63
                ' %s.' % (bzrlib.__version__, __version__))
66
 
        raise BzrError('Version mismatch: %r, %r' % (version_info, bzrlib.version_info) )
 
64
        raise BzrError('Version mismatch: %r' % version_info)
67
65
    else:
68
66
        warning('bzr-gtk is not up to date with installed bzr version %s.'
69
67
                ' \nThere should be a newer version available, e.g. %i.%i.' 
70
68
                % (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
71
69
 
72
70
 
73
 
if version_info[2] == "final":
74
 
    check_bzrlib_version(version_info[:2])
 
71
check_bzrlib_version(version_info[:2])
75
72
 
76
73
from bzrlib.trace import warning
77
74
if __name__ != 'bzrlib.plugins.gtk':
81
78
lazy_import(globals(), """
82
79
from bzrlib import (
83
80
    branch,
84
 
    builtins,
85
81
    errors,
86
82
    workingtree,
87
83
    )
109
105
    bzrlib.ui.ui_factory = GtkUIFactory()
110
106
 
111
107
 
112
 
def data_path():
113
 
    return os.path.dirname(__file__)
114
 
 
115
 
 
116
108
class GTKCommand(Command):
117
109
    """Abstract class providing GTK specific run commands."""
118
110
 
163
155
        (br, path) = branch.Branch.open_containing(location)
164
156
        self.open_display()
165
157
        from push import PushDialog
166
 
        dialog = PushDialog(br.repository, br.last_revision(), br)
 
158
        dialog = PushDialog(br)
167
159
        dialog.run()
168
160
 
169
161
 
389
381
 
390
382
 
391
383
class cmd_gconflicts(GTKCommand):
392
 
    """ GTK+ conflicts.
 
384
    """ GTK+ push.
393
385
    
394
 
    Select files from the list of conflicts and run an external utility to
395
 
    resolve them.
396
386
    """
397
387
    def run(self):
398
388
        (wt, path) = workingtree.WorkingTree.open_containing('.')
501
491
        from notify import NotifyPopupMenu
502
492
        gtk = self.open_display()
503
493
        menu = NotifyPopupMenu()
504
 
        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")
505
495
        icon.connect('popup-menu', menu.display)
506
496
 
507
497
        import cgi
564
554
register_command(cmd_commit_notify)
565
555
 
566
556
 
567
 
class cmd_gselftest(GTKCommand):
568
 
    """Version of selftest that displays a notification at the end"""
569
 
 
570
 
    takes_args = builtins.cmd_selftest.takes_args
571
 
    takes_options = builtins.cmd_selftest.takes_options
572
 
    _see_also = ['selftest']
573
 
 
574
 
    def run(self, *args, **kwargs):
575
 
        import cgi
576
 
        import sys
577
 
        default_encoding = sys.getdefaultencoding()
578
 
        # prevent gtk from blowing up later
579
 
        gtk = import_pygtk()
580
 
        # prevent gtk from messing with default encoding
581
 
        import pynotify
582
 
        if sys.getdefaultencoding() != default_encoding:
583
 
            reload(sys)
584
 
            sys.setdefaultencoding(default_encoding)
585
 
        result = builtins.cmd_selftest().run(*args, **kwargs)
586
 
        if result == 0:
587
 
            summary = 'Success'
588
 
            body = 'Selftest succeeded in "%s"' % os.getcwd()
589
 
        if result == 1:
590
 
            summary = 'Failure'
591
 
            body = 'Selftest failed in "%s"' % os.getcwd()
592
 
        pynotify.init("bzr gselftest")
593
 
        note = pynotify.Notification(cgi.escape(summary), cgi.escape(body))
594
 
        note.set_timeout(pynotify.EXPIRES_NEVER)
595
 
        note.show()
596
 
 
597
 
 
598
 
register_command(cmd_gselftest)
599
 
 
600
 
 
601
557
import gettext
602
558
gettext.install('olive-gtk')
603
559