hook-gi.repository.Gtk.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. import glob
  17. from PyInstaller.compat import is_win
  18. from PyInstaller.utils.hooks import get_hook_config
  19. from PyInstaller.utils.hooks.gi import collect_glib_share_files, \
  20. collect_glib_etc_files, collect_glib_translations, get_gi_typelibs
  21. binaries, datas, hiddenimports = get_gi_typelibs('Gtk', '3.0')
  22. datas += collect_glib_share_files('fontconfig')
  23. def hook(hook_api):
  24. hook_datas = []
  25. icon_list = get_hook_config(hook_api, "gi", "icons")
  26. theme_list = get_hook_config(hook_api, "gi", "themes")
  27. lang_list = get_hook_config(hook_api, "gi", "languages")
  28. if icon_list is not None:
  29. for icon in icon_list:
  30. hook_datas += collect_glib_share_files(os.path.join("icons", icon))
  31. else:
  32. hook_datas += collect_glib_share_files('icons')
  33. if theme_list is not None:
  34. for theme in theme_list:
  35. hook_datas += collect_glib_share_files(
  36. os.path.join('themes', theme))
  37. else:
  38. hook_datas += collect_glib_share_files('themes')
  39. hook_datas += collect_glib_translations('gtk30', lang_list)
  40. hook_api.add_datas(hook_datas)
  41. # these only seem to be required on Windows
  42. if is_win:
  43. datas += collect_glib_etc_files('fonts')
  44. datas += collect_glib_etc_files('pango')
  45. datas += collect_glib_share_files('fonts')