/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 commands.py

  • Committer: Jelmer Vernooij
  • Date: 2011-01-31 10:19:52 UTC
  • Revision ID: jelmer@samba.org-20110131101952-dkllorckboek3iqo
Move display opening, etc to commands.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from bzrlib import (
18
18
    branch,
19
 
    builtins,
 
19
    errors,
20
20
    workingtree,
21
21
    )
22
22
from bzrlib.commands import (
33
33
 
34
34
from bzrlib.plugins.gtk import (
35
35
    _i18n,
36
 
    open_display,
37
36
    import_pygtk,
38
37
    set_ui_factory,
39
38
    )
40
39
 
 
40
 
 
41
class NoDisplayError(errors.BzrCommandError):
 
42
    """gtk could not find a proper display"""
 
43
 
 
44
    def __str__(self):
 
45
        return "No DISPLAY. Unable to run GTK+ application."
 
46
 
 
47
 
 
48
def open_display():
 
49
    pygtk = import_pygtk()
 
50
    try:
 
51
        import gtk
 
52
    except RuntimeError, e:
 
53
        if str(e) == "could not open display":
 
54
            raise NoDisplayError
 
55
    set_ui_factory()
 
56
    return gtk
 
57
 
 
58
 
 
59
 
41
60
class GTKCommand(Command):
42
61
    """Abstract class providing GTK specific run commands."""
43
62