2 # -*- coding: utf-8 -*-
6 This module imports the required and optional dependencies and checks
10 # Copyright (C) 2007,2009 Felix Rabe <public@felixrabe.net>
12 # This library is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU Lesser General Public
14 # License as published by the Free Software Foundation; either
15 # version 2.1 of the License, or (at your option) any later version.
17 # This library is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # Lesser General Public License for more details.
22 # You should have received a copy of the GNU Lesser General Public License
23 # along with this library; if not, write to the Free Software Foundation,
24 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 from PyGTKShell
.Config
import pygtkshell_config
27 _config
= pygtkshell_config
28 pygtkshell_version
= _config
["version"] # DEPRECATED!
39 cairo
= None # Cairo not provided
40 if _config
["api-provide-cairo"]:
45 dbus
= None # DBus not provided
46 if _config
["api-provide-dbus"]:
51 gconf
= None # GConf not provided
52 if _config
["api-provide-gconf"]:
57 gtksourceview
= None # GtkSourceView not provided
58 if _config
["api-provide-gtksourceview"]:
60 import gtksourceview2
as gtksourceview
66 twisted
= None # Twisted not provided
67 if _config
["api-provide-twisted"]:
70 if _config
["main-loop-integrate-twisted"]:
71 from twisted
.internet
import gtk2reactor
72 _twisted_reactor
= gtk2reactor
.portableInstall()
77 # "a_" is used instead of plain "_" because Core gets * imported by API
78 # and API gets * imported by users. But "_" can't be imported anyway...
79 a_
= gettext
.translation("pygtkshell", fallback
= True).gettext
81 ## Integrated main loop support
84 PyGTK Shell main loop support. (TODO: move these docs into a docstring.)
86 You do not have to use these mechanisms if you are going to only use the
87 PyGTK main loop, i.e. by calling gtk.main() and gtk.main_quit().
90 - PyGTK (gtk.main) always used
91 - Twisted (PortableGtkReactor) used on demand
96 from PyGTKShell.Config import _config
97 _config["main-loop-integrate-dbus"] = True # not yet implemented
98 _config["main-loop-integrate-twisted"] = True
99 from PyGTKShell.API import *
101 # Set up your application here:
108 def main_loop_run(*a
, **kw
):
109 integrate_dbus
= _config
["main-loop-integrate-dbus"]
110 integrate_twisted
= _config
["main-loop-integrate-twisted"]
111 if integrate_twisted
:
112 _twisted_reactor
.run(*a
, **kw
)
116 def main_loop_quit(*a
, **kw
):
117 integrate_dbus
= _config
["main-loop-integrate-dbus"]
118 integrate_twisted
= _config
["main-loop-integrate-twisted"]
119 if integrate_twisted
:
120 if not _twisted_reactor
._stopped
: # Twisted is picky about this
121 _twisted_reactor
.stop(*a
, **kw
)
123 gtk
.main_quit(*a
, **kw
)