def get_OSXApplication(): global macapp if macapp is None: from xpra.gtk_common.gobject_compat import import_gtkosx_application gtkosx_application = import_gtkosx_application() macapp = gtkosx_application.Application() macapp.connect("NSApplicationWillTerminate", quit_handler) return macapp
def do_get_resources_dir(): rsc = None RESOURCES = "/Resources/" #FUGLY warning: importing gtkosx_application causes the dock to appear, #and in some cases we don't want that.. so use the env var XPRA_SKIP_UI as workaround for such cases: if not envbool("XPRA_SKIP_UI", False): try: from xpra.gtk_common.gobject_compat import import_gtkosx_application gtkosx_application = import_gtkosx_application() try: rsc = gtkosx_application.gtkosx_application_get_resource_path() debug( "get_resources_dir() gtkosx_application_get_resource_path=%s", rsc) except: #maybe we're not running from an app bundle? pass except: global _gtkosx_warning_ if _gtkosx_warning_ is False: _gtkosx_warning_ = True #delayed import to prevent cycles: get_util_logger().error( "Error: gtkosx_application module is missing - trying to continue anyway" ) else: debug("XPRA_SKIP_UI is set, not importing gtkosx_application") if rsc is None: #try using the path to this file to find the resource path: rsc = __file__ i = rsc.rfind(RESOURCES) if i <= 0: #last fallback: try the default app dir from xpra.platform.paths import default_get_app_dir rsc = default_get_app_dir() debug("get_resources_dir() default_get_app_dir()=%s", rsc) i = rsc.rfind(RESOURCES) if i > 0: rsc = rsc[:i + len(RESOURCES)] debug("get_resources_dir()=%s", rsc) return rsc