Skip to content
Snippets Groups Projects
Commit 4899b78c authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Add custom module load for GUI

parent 9d4c947b
No related branches found
No related tags found
No related merge requests found
......@@ -24,8 +24,10 @@
from ctypes.util import find_library
from packaging.version import Version as V
import gajim.gui
from gajim.common import i18n
_MIN_NBXMPP_VER = '1.99.0'
_MIN_GTK_VER = '3.22.27'
_MIN_CAIRO_VER = '1.16.0'
......@@ -102,13 +104,16 @@ def _disable_csd():
def _init_gtk():
from gajim.gtk import exception
gajim.gui.init('gtk')
from gajim.gui import exception
exception.init()
i18n.initialize_direction_mark()
from gajim.application import GajimApplication
def _run_app():
from gajim.application import GajimApplication
application = GajimApplication()
_install_sginal_handlers(application)
application.run(sys.argv)
......@@ -152,3 +157,4 @@ def main():
_set_proc_title()
_disable_csd()
_init_gui('GTK')
_run_app()
import sys
import importlib
from pathlib import Path
class GUIFinder(importlib.abc.MetaPathFinder):
def __init__(self, name, fallback=None):
self._path = Path(__file__).parent.parent / name
self._fallback_path = None
if fallback is not None:
self._fallback_path = Path(__file__).parent.parent / fallback
self._suffix = 'pyc' if sys.platform == 'win32' else 'py'
def find_spec(self, fullname, _path, _target=None):
if not fullname.startswith('gajim.gui'):
return None
_namespace, module_name = fullname.rsplit('.', 1)
module_path = self._path / f'{module_name}.{self._suffix}'
if not module_path.exists():
if self._fallback_path is None:
return None
module_path = self._fallback_path / f'{module_name}.{self._suffix}'
if not module_path.exists():
return None
spec = importlib.util.spec_from_file_location(fullname, module_path)
return spec
def init(name, fallback=None):
sys.meta_path.append(GUIFinder(name, fallback=fallback))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment