def initPlugins(self):
        if get_settings().get_plugins_enabled():
            from yapsy.PluginManager import PluginManagerSingleton
            from lunchinator.plugin import NotificationPluginManager
            
            PluginManagerSingleton.setBehaviour([
                NotificationPluginManager,
            ])
            self.plugin_manager = PluginManagerSingleton.get()
            self.plugin_manager.app = self
            self.plugin_manager.setConfigParser(get_settings().get_config_file(), get_settings().write_config_to_hd)
            self.plugin_manager.setPluginPlaces(get_settings().get_plugin_dirs())

            try:
                self.plugin_manager.collectPlugins()
            except:
                getCoreLogger().exception("problem when loading plugins")
            
            get_peer_actions().initialize()
        else:
            getCoreLogger().info("lunchinator initialised without plugins")
Пример #2
0
def _fillPeerActionsMenu(popupMenu, peerID, filterFunc, parentWidget):
    peerInfo = get_peers().getPeerInfo(pID=peerID)
    actionsDict = get_peer_actions().getPeerActions(peerID, peerInfo, filterFunc)
    if actionsDict:
        actionsList = [] # tuples (sort key, displayed name, [actions])
        
        first = True
        for actionKey in actionsDict:
            actions = actionsDict[actionKey]
            if actionKey == PeerActions.STANDARD_PEER_ACTIONS_KEY:
                displayedName = "General"
                sortKey = u""
            else:
                displayedName = actions[0].getPluginObject().get_displayed_name()
                if not displayedName:
                    displayedName = actionKey
                sortKey = displayedName
                    
            actionsList.append((sortKey, displayedName, actions))
        
        actionsList = sorted(actionsList, key=lambda tup:tup[0].lower())
        for _, displayedName, actions in actionsList:
            if not first:
                popupMenu.addSeparator()
            else:
                first = False
            header = popupMenu.addAction(displayedName)
            header.setEnabled(False)
            
            for action in actions:
                icon = action.getIcon()
                if icon is not None:
                    popupMenu.addAction(icon, action.getDisplayedName(peerID), partial(action.performAction, peerID, peerInfo, parentWidget))
                else:
                    popupMenu.addAction(action.getDisplayedName(peerID), partial(action.performAction, peerID, peerInfo, parentWidget))
    return popupMenu