Initial import to Tizen
[profile/ivi/python-twisted.git] / twisted / internet / glib2reactor.py
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 This module provides support for Twisted to interact with the glib mainloop.
6 This is like gtk2, but slightly faster and does not require a working
7 $DISPLAY. However, you cannot run GUIs under this reactor: for that you must
8 use the gtk2reactor instead.
9
10 In order to use this support, simply do the following::
11
12     from twisted.internet import glib2reactor
13     glib2reactor.install()
14
15 Then use twisted.internet APIs as usual.  The other methods here are not
16 intended to be called directly.
17 """
18
19 from twisted.internet import gtk2reactor
20
21
22 class Glib2Reactor(gtk2reactor.Gtk2Reactor):
23     """
24     The reactor using the glib mainloop.
25     """
26
27     def __init__(self):
28         """
29         Override init to set the C{useGtk} flag.
30         """
31         gtk2reactor.Gtk2Reactor.__init__(self, useGtk=False)
32
33
34
35 def install():
36     """
37     Configure the twisted mainloop to be run inside the glib mainloop.
38     """
39     reactor = Glib2Reactor()
40     from twisted.internet.main import installReactor
41     installReactor(reactor)
42
43
44 __all__ = ['install']