gladex-plugin-interface

Please check the status of this specification in Launchpad before editing it. If it is Approved, contact the Assignee or another knowledgeable person before making changes.

Summary

We should implement a plugin interface that every plugin should extend.

Release Note

This section should include a paragraph describing the end-user impact of this change. It is meant to be included in the release notes of the first release in which it is implemented. (Not all of these will actually be included in the release notes, at the release manager's discretion; but writing them is a useful exercise.)

It is mandatory.

Rationale

This will normalize the way the plugins are made and we will be able to use the full functionalities of the plugins in the main code. This will also be useful to detect if a class is a plugin thus to load it.

Use Cases

Assumptions

Design

You can have subsections that better describe specific parts of the issue.

Implementation

class Plugin:
        """
        This should be the plugin master class. To make a plugin you should inherit of this class
        """
        
        def getName(self):
                """
                Returns the name of the plugin
                @return: the name of the plugin
                @rtype: str
                """
                raise InvalidPluginException('This method is mandatory !')
        
        def getDoc(self):
                """
                This method should give a little documentation about the this plugin.
                @return: The doc string
                """
                raise InvalidPluginException("Help not implemented for this plugin")
        
        def getInfos(self):
                """
                This method returns information on the plugin in a dictionary. each entry of this dictionary should follow a convention :
                - the key isn't mean to be translated thus can be used in the code
                - the value is a couple ['Info', 'Value']
                        - Info is a string and can be translatable (it will be use as a label to show information to the user.
                        - Value is a string and can be translatable (it will be shown to the user.
                @return: a dictionary {'info1': ['Info 1','Value 1'], 'info2': ['Info 2','Value 1']} or '{}' - Empty dict - by default
                @rtype: dict
                @note: This method isn't mandatory and shall be use to show plugins information to the user
                """
                return {}
        
        def getWidget(self):
                """
                Return the plugin widget to be added to the main window when the plugin is selected
                @return: gtk.Widget
                """
                raise InvalidPluginException('This method is mandatory')
        
        def execute(self, gladeFile, destinationDir):
                """
                This method should do the task of generating the source code from the glade file.
                @param gladeFile: The glade file to generate th code from
                @param destinationDir: The destination directory to generate the file in.
                @raise Exception: An exception should be raised if anything didn't go fine.
                """
                raise InvalidPluginException('This method is mandatory')

Code Changes

  • Every current plugin will have to be changed to implement this interface.

Test/Demo Plan

It's important that we are able to test new features, and demonstrate them to users. Use this section to describe a short plan that anybody can follow that demonstrates the feature is working. This can then be used during CD testing, and to show off after release.

This need not be added or completed until the specification is nearing beta.

Outstanding Issues

This should highlight any issues that should be addressed in further specifications, and not problems with the specification itself; since any specification with problems cannot be approved.

Comments


CategorySpec

gladex-plugin-interface (last edited 2008-08-06 16:33:07 by localhost)