/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: 2012-03-23 13:45:02 UTC
  • Revision ID: jelmer@samba.org-20120323134502-fsxyhpb0ilbabozp
Ignore bzr-handle-patch in software center.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
visualise         Graphically visualise this branch.
34
34
"""
35
35
 
 
36
from __future__ import absolute_import
 
37
 
36
38
import os
37
39
import sys
38
40
 
52
54
import bzrlib
53
55
import bzrlib.api
54
56
from bzrlib import (
55
 
    branch,
56
57
    config,
57
 
    errors,
58
58
    )
59
59
from bzrlib.commands import plugin_cmds
60
60
 
61
 
from info import (
 
61
from bzrlib.plugins.gtk.info import (
62
62
    bzr_plugin_version as version_info,
63
63
    bzr_compatible_versions,
64
64
    )
75
75
    from bzrlib.trace import warning
76
76
    warning("Not running as bzrlib.plugins.gtk, things may break.")
77
77
 
78
 
def import_pygtk():
79
 
    try:
80
 
        import pygtk
81
 
    except ImportError:
82
 
        raise errors.BzrCommandError("PyGTK not installed.")
83
 
    pygtk.require('2.0')
84
 
    return pygtk
85
 
 
86
78
 
87
79
def set_ui_factory():
88
 
    import_pygtk()
89
 
    from ui import GtkUIFactory
 
80
    from bzrlib.plugins.gtk.ui import GtkUIFactory
90
81
    import bzrlib.ui
91
82
    bzrlib.ui.ui_factory = GtkUIFactory()
92
83
 
139
130
                              "bzrlib.plugins.gtk.commands")
140
131
 
141
132
def save_commit_messages(*args):
142
 
    from bzrlib.plugins.gtk import commit
143
 
    commit.save_commit_messages(*args)
144
 
 
145
 
branch.Branch.hooks.install_named_hook('post_uncommit',
146
 
                                       save_commit_messages,
147
 
                                       "Saving commit messages for gcommit")
148
 
 
149
 
credential_store_registry = getattr(config, "credential_store_registry", None)
150
 
if credential_store_registry is not None:
151
 
    try:
152
 
        credential_store_registry.register_lazy(
153
 
            "gnome-keyring", "bzrlib.plugins.gtk.keyring", "GnomeKeyringCredentialStore",
154
 
            help="The GNOME Keyring.", fallback=True)
155
 
    except TypeError:
156
 
    # Fallback credentials stores were introduced in Bazaar 1.15
157
 
        credential_store_registry.register_lazy(
158
 
            "gnome-keyring", "bzrlib.plugins.gtk.keyring", "GnomeKeyringCredentialStore",
159
 
            help="The GNOME Keyring.")
160
 
 
 
133
    from bzrlib.plugins.gtk import commitmsgs
 
134
    commitmsgs.save_commit_messages(*args)
 
135
 
 
136
try:
 
137
    from bzrlib.hooks import install_lazy_named_hook
 
138
except ImportError:
 
139
    from bzrlib.branch import Branch
 
140
    Branch.hooks.install_named_hook('post_uncommit',
 
141
                                    save_commit_messages,
 
142
                                    "Saving commit messages for gcommit")
 
143
else:
 
144
    install_lazy_named_hook("bzrlib.branch", "Branch.hooks",
 
145
        'post_uncommit', save_commit_messages, "Saving commit messages for gcommit")
 
146
 
 
147
 
 
148
option_registry = getattr(config, "option_registry", None)
 
149
if option_registry is not None:
 
150
    config.option_registry.register_lazy('nautilus_integration',
 
151
            'bzrlib.plugins.gtk.config', 'opt_nautilus_integration')
161
152
 
162
153
def load_tests(basic_tests, module, loader):
163
154
    testmod_names = [
168
159
    try:
169
160
        result = basic_tests
170
161
        try:
171
 
            import_pygtk()
172
 
        except errors.BzrCommandError:
 
162
            import gi.repository.Gtk
 
163
        except ImportError:
173
164
            return basic_tests
174
165
        basic_tests.addTest(loader.loadTestsFromModuleNames(
175
166
                ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))