Esempio n. 1
0
 def threaded_setup(self):
     self.exec_start_commands()
     def set_reaper_callback():
         self.child_reaper.set_quit_callback(self.reaper_exit)
         self.child_reaper.check()
     self.idle_add(set_reaper_callback)
     if POSIX and not OSX and self.start_new_commands:
         try:
             self.setup_menu_watcher()
         except Exception as e:
             log("threaded_setup()", exc_info=True)
             log.error("Error setting up menu watcher:")
             log.error(" %s", e)
         from xpra.platform.xposix.xdg_helper import load_xdg_menu_data
         load_xdg_menu_data()
Esempio n. 2
0
 def get_menu_data(self, force_reload=False, remove_icons=False, wait=True):
     log("get_menu_data%s", (force_reload, remove_icons, wait))
     if not EXPORT_XDG_MENU_DATA:
         return None
     if OSX:
         return None
     menu_data = self.menu_data
     if self.load_lock.acquire(wait):
         try:
             if not self.menu_data or force_reload:
                 if POSIX:
                     from xpra.platform.xposix.xdg_helper import load_xdg_menu_data
                     menu_data = load_xdg_menu_data()
                 elif WIN32:
                     from xpra.platform.win32.menu_helper import load_menu
                     menu_data = load_menu()
                 else:
                     log.error("Error: unsupported platform!")
                     return None
                 self.menu_data = menu_data
                 add_work_item(self.got_menu_data)
         finally:
             self.load_lock.release()
     if remove_icons and self.menu_data:
         menu_data = noicondata(self.menu_data)
     return menu_data
Esempio n. 3
0
def load_command_to_type():
    global command_to_type
    if command_to_type is None:
        command_to_type = {}
        from xpra.platform.xposix.xdg_helper import load_xdg_menu_data
        xdg_menu = load_xdg_menu_data()
        categories_to_type = load_categories_to_type()
        log("load_command_to_type() xdg_menu=%s, categories_to_type=%s", xdg_menu, categories_to_type)
        if xdg_menu and categories_to_type:
            for category, category_props in xdg_menu.items():
                log("category %s: %s", category, repr_ellipsized(str(category_props)))
                entries = category_props.get("Entries", {})
                for name, props in entries.items():
                    command = props.get("TryExec") or props.get("Exec")
                    categories = props.get("Categories")
                    log("Entry '%s': command=%s, categories=%s", name, command, categories)
                    if command and categories:
                        for c in categories:
                            ctype = categories_to_type.get(c.lower())
                            if not ctype:
                                #try a more fuzzy match:
                                for category_name,ct in categories_to_type.items():
                                    if c.lower().find(category_name)>=0:
                                        ctype = ct
                                        break
                            if ctype:
                                cmd = os.path.basename(command.split(" ")[0]).encode()
                                if cmd:
                                    command_to_type[cmd] = ctype
                                    break
        log("load_command_to_type()=%s", command_to_type)
    return command_to_type
Esempio n. 4
0
 def _get_xdg_menu_data(self, force_reload=False):
     if not EXPORT_XDG_MENU_DATA:
         return None
     if not self.start_new_commands:
         return None
     if OSX:
         return None
     if POSIX:
         from xpra.platform.xposix.xdg_helper import load_xdg_menu_data
         return load_xdg_menu_data(force_reload)
     if WIN32:
         from xpra.platform.win32.menu_helper import load_menu
         return load_menu()
     log.error("Error: unsupported platform!")
     return None
Esempio n. 5
0
 def get_caps(self, source):
     caps = {}
     if self.start_new_commands and POSIX and not OSX and source.wants_features:
         from xpra.platform.xposix.xdg_helper import load_xdg_menu_data, remove_icons
         xdg_menu = load_xdg_menu_data()
         if xdg_menu:
             l = len(str(xdg_menu))
             #arbitrary: don't use more than half
             #of the maximum size of the hello packet:
             if l > 2 * 1024 * 1024:
                 xdg_menu = remove_icons(xdg_menu)
                 log.info(
                     "removed icons to reduce the size of the xdg menu data"
                 )
                 log.info("size reduced from %i to %i", l,
                          len(str(xdg_menu)))
             caps["xdg-menu"] = xdg_menu
     return caps
Esempio n. 6
0
 def _get_xdg_menu_data(self, force_reload=False):
     if not self.start_new_commands or not POSIX or OSX:
         return None
     from xpra.platform.xposix.xdg_helper import load_xdg_menu_data
     return load_xdg_menu_data(force_reload)
Esempio n. 7
0
 def get_caps(self, _source):
     caps = {}
     if self.start_new_commands and POSIX and not OSX:
         from xpra.platform.xposix.xdg_helper import load_xdg_menu_data
         caps["xdg-menu"] = load_xdg_menu_data()
     return caps
Esempio n. 8
0
def threaded_server_init():
    from xpra.platform.xposix.xdg_helper import load_xdg_menu_data
    load_xdg_menu_data()