hook-gi.repository.Gtk.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-2021, PyInstaller Development Team.
  3. #
  4. # Distributed under the terms of the GNU General Public License (version 2
  5. # or later) with exception for distributing the bootloader.
  6. #
  7. # The full license is in the file COPYING.txt, distributed with this software.
  8. #
  9. # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
  10. #-----------------------------------------------------------------------------
  11. """
  12. Import hook for PyGObject https://wiki.gnome.org/PyGObject
  13. """
  14. import os
  15. import os.path
  16. from PyInstaller.compat import is_win
  17. from PyInstaller.utils.hooks import get_hook_config
  18. from PyInstaller.utils.hooks.gi import \
  19. collect_glib_etc_files, collect_glib_share_files, collect_glib_translations, get_gi_typelibs
  20. binaries, datas, hiddenimports = get_gi_typelibs('Gtk', '3.0')
  21. datas += collect_glib_share_files('fontconfig')
  22. def hook(hook_api):
  23. hook_datas = []
  24. icon_list = get_hook_config(hook_api, "gi", "icons")
  25. theme_list = get_hook_config(hook_api, "gi", "themes")
  26. lang_list = get_hook_config(hook_api, "gi", "languages")
  27. if icon_list is not None:
  28. for icon in icon_list:
  29. hook_datas += collect_glib_share_files(os.path.join("icons", icon))
  30. else:
  31. hook_datas += collect_glib_share_files('icons')
  32. if theme_list is not None:
  33. for theme in theme_list:
  34. hook_datas += collect_glib_share_files(os.path.join('themes', theme))
  35. else:
  36. hook_datas += collect_glib_share_files('themes')
  37. hook_datas += collect_glib_translations('gtk30', lang_list)
  38. hook_api.add_datas(hook_datas)
  39. # these only seem to be required on Windows
  40. if is_win:
  41. datas += collect_glib_etc_files('fonts')
  42. datas += collect_glib_etc_files('pango')
  43. datas += collect_glib_share_files('fonts')