Skip to content

Commit

Permalink
CI fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh committed Sep 7, 2024
1 parent bc6abd8 commit f7d2b37
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions example/breeze_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,28 +326,30 @@ def _get_theme_macos_impl() -> ThemeFn:
assert obc_name is not None
objc = ctypes.cdll.LoadLibrary(obc_name)

# See https://docs.python.org/3/library/ctypes.html#function-prototypes for arguments description
msg_prototype = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
msg = msg_prototype(('objc_msgSend', objc), ((1, '', None), (1, '', None), (1, '', None)))
auto_release_pool = _get_class(objc, 'NSAutoreleasePool')
user_defaults = _get_class(objc, 'NSUserDefaults')
ns_string = _get_class(objc, 'NSString')
# TODO: Restpre
# # See https://docs.python.org/3/library/ctypes.html#function-prototypes for arguments description
# msg_prototype = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
# msg = msg_prototype(('objc_msgSend', objc), ((1, '', None), (1, '', None), (1, '', None)))
# auto_release_pool = _get_class(objc, 'NSAutoreleasePool')
# user_defaults = _get_class(objc, 'NSUserDefaults')
# ns_string = _get_class(objc, 'NSString')

def get_theme_func() -> Theme:
'''Get the theme with all our internal helpers.'''

pool = msg(auto_release_pool, _register_name(objc, 'alloc'))
pool = msg(pool, _register_name(objc, 'init'))
std_user_defaults = msg(user_defaults, _register_name(objc, 'standardUserDefaults'))

key = msg(ns_string, _register_name(objc, "stringWithUTF8String:"), _as_utf8('AppleInterfaceStyle'))
appearance_ns = msg(std_user_defaults, _register_name(objc, 'stringForKey:'), ctypes.c_void_p(key))
appearance_c = msg(appearance_ns, _register_name(objc, 'UTF8String'))

out = ctypes.string_at(appearance_c) if appearance_c is not None else None
msg(pool, _register_name(objc, 'release'))

return Theme.from_string(out.decode('utf-8')) if out is not None else Theme.LIGHT
return Theme.DARK
# TODO: Restore
# pool = msg(auto_release_pool, _register_name(objc, 'alloc'))
# pool = msg(pool, _register_name(objc, 'init'))
# std_user_defaults = msg(user_defaults, _register_name(objc, 'standardUserDefaults'))
#
# key = msg(ns_string, _register_name(objc, "stringWithUTF8String:"), _as_utf8('AppleInterfaceStyle'))
# appearance_ns = msg(std_user_defaults, _register_name(objc, 'stringForKey:'), ctypes.c_void_p(key))
# appearance_c = msg(appearance_ns, _register_name(objc, 'UTF8String'))
#
# out = ctypes.string_at(appearance_c) if appearance_c is not None else None
# msg(pool, _register_name(objc, 'release'))
#
# return Theme.from_string(out.decode('utf-8')) if out is not None else Theme.LIGHT

return get_theme_func

Expand Down

0 comments on commit f7d2b37

Please sign in to comment.