Exemplo n.º 1
0
 def __searchOperationsPlugins__(self):
     """
     @summary: Search operations, and create a menu item for each.
     """
     __log__.debug("Project modules are loaded")
     
     operationsPlugins = Loader.getPluginsType(pycamimg.core.plugins.ICamimgPlugin.PLUGIN_TYPE.OPERATION)
     actionGroupOperationPlugins = gtk.ActionGroup("ActionGroupOperationPlugins")
     self.__uiManager__.insert_action_group(actionGroupOperationPlugins, pos=-1)
     
     for operation in operationsPlugins:
         __log__.debug("Processing plugin %s" % operation[Loader.INDEX_PLUGIN])    
                     
         operationInstance = operation[Loader.INDEX_PLUGIN_INSTANCE]()
         __log__.debug("Creating operation %s" % operationInstance.getOperationName())
         
         lActions = operationInstance.getActions()
         if (lActions != None):
             for aAction in lActions:
                 aAction.connect("activate", self.__activateOperation__, operationInstance.callbackAction)
                 __log__.debug("Add activate signal to  %s" % operationInstance.getOperationName())
                 actionGroupOperationPlugins.add_action(aAction)
         else:
             __log__.debug("There is not action for %s" % operationInstance.getOperationName())
             
         if (operationInstance.getXmlLocation() != ""):
             self.__uiManager__.add_ui_from_file(os.path.join(__XMLUI_FOLDER__, operationInstance.getXmlLocation()))
             
             dIcons = operationInstance.getIconsActions()
             for actionPath, iconPath in dIcons.iteritems():
                 mi = self.__uiManager__.get_widget(actionPath)
                 if (mi != None): 
                     iconPath = os.path.join(__ICONS_FOLDER__, iconPath)            
                     __log__.debug("Get project icon from %s" % iconPath)
                     if (isinstance(mi, gtk.ImageMenuItem)):
                         UIUtils.setImageToMenuItem(mi, iconPath, doGObject=False)
                     elif (isinstance(mi, gtk.ToolButton)):
                         UIUtils.setImageToToolItem(mi, iconPath, size=self.__toolBar__.get_icon_size(), doGObject=False)
                     else:
                         __log__.warning("Unknown type control.")
                 else:
                     __log__.warning("It could not update icon of %s. Action name %s was not found." % (operationInstance.getOperationName(), actionPath))
         else:
             __log__.debug("%s is not in menu." % operationInstance.getOperationName())
             
         __log__.debug("Added new operation %s" % operationInstance.getOperationName())
Exemplo n.º 2
0
 def __searchProjectPlugins__(self):
     """
     @summary: Search new kind of projects, and create a menu item for each.
     """
     __log__.debug("Project modules are loaded")
     
     projectTypes = Loader.getPluginsType(pycamimg.core.plugins.ICamimgPlugin.PLUGIN_TYPE.PROJECT)
     actionGroupProjectPlugins = gtk.ActionGroup("ActionGroupProjectPlugins")
     self.__uiManager__.insert_action_group(actionGroupProjectPlugins, pos=-1)
     
     for project in projectTypes:
         __log__.debug("Processing plugin %s" % project[Loader.INDEX_PLUGIN].getName())    
                     
         projectInstance = project[Loader.INDEX_PLUGIN_INSTANCE]()
         __log__.debug("Creating new menu item for project type %s" % projectInstance.getTypeName())
         
         aAction = projectInstance.getGtkAction()
         if (aAction != None):
             aAction.connect("activate", self.__newProjectEvent__, project[Loader.INDEX_PLUGIN_INSTANCE])
             __log__.debug("Add activate signal to  %s" % projectInstance.getTypeName())
             actionGroupProjectPlugins.add_action(aAction)
         else:
             __log__.debug("There is not action for %s" % projectInstance.getTypeName())
             
         if (projectInstance.getXmlLocation() != ""):
             self.__uiManager__.add_ui_from_file(os.path.join(__XMLUI_FOLDER__, projectInstance.getXmlLocation()))
         
             mi = self.__uiManager__.get_widget("/MenuPyCaming/FileMenu/NewProject/NewProjectAdditions/%s" % projectInstance.getTypeName())
             if (mi != None):
                 iconPath = os.path.join(__ICONS_FOLDER__, projectInstance.getIconName())
                 __log__.debug("Get project icon from %s" % iconPath)
                 UIUtils.setImageToMenuItem(mi, iconPath, doGObject=False)
             else:
                 __log__.warning("It could not update icon of %s. Action name %s was not found." % (projectInstance.getTypeName(), projectInstance.getTypeName()))
         else:
             __log__.debug("%s is not in menu." % projectInstance.getTypeName())
             
         __log__.debug("Added new project type %s" % projectInstance.getTypeName())