def register_file_handler(handler): log("register_file_handler(%s)", handler) try: get_OSXApplication().connect("NSApplicationOpenFile", handler) except Exception as e: log.error("Error: cannot handle file associations:") log.error(" %s", e)
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): from xpra.platform.darwin import get_OSXApplication macapp = get_OSXApplication() try: rsc = macapp.get_resource_path() debug("get_resources_dir() %s.get_resource_path=%s", macapp, rsc) except Exception: 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
def do_init(): osxapp = get_OSXApplication() log("do_init() osxapp=%s", osxapp) if not osxapp: return #not much else we can do here from xpra.platform.paths import get_icon from xpra.platform.gui import get_default_icon filename = get_default_icon() icon = get_icon(filename) log("do_init() icon=%s", icon) if icon: osxapp.set_dock_icon_pixbuf(icon) from xpra.platform.darwin.osx_menu import getOSXMenuHelper mh = getOSXMenuHelper(None) log("do_init() menu helper=%s", mh) osxapp.set_dock_menu(mh.build_dock_menu()) osxapp.set_menu_bar(mh.rebuild())
def do_init(): osxapp = get_OSXApplication() log("do_init() osxapp=%s", osxapp) if not osxapp: return #not much else we can do here from xpra.platform.paths import get_icon from xpra.platform.gui import get_default_icon filename = get_default_icon() icon = get_icon(filename) log("do_init() icon=%s", icon) if icon: osxapp.set_dock_icon_pixbuf(icon) from xpra.platform.darwin.osx_menu import getOSXMenuHelper mh = getOSXMenuHelper(None) log("do_init() menu helper=%s", mh) osxapp.set_dock_menu(mh.build_dock_menu()) import warnings with warnings.catch_warnings(): warnings.filterwarnings("ignore", message=".*invalid cast from 'GtkMenuBar'") osxapp.set_menu_bar(mh.rebuild())
def do_ready(): osxapp = get_OSXApplication() if osxapp: log("%s()", osxapp.ready) osxapp.ready()
def get_native_tray_classes(): if get_OSXApplication(): from xpra.platform.darwin.osx_tray import OSXTray return [OSXTray] return []
def get_native_tray_menu_helper_class(): if get_OSXApplication(): from xpra.platform.darwin.osx_menu import getOSXMenuHelper return getOSXMenuHelper return None