Commit 0ffa77d6 authored by Alexandru Băluț's avatar Alexandru Băluț

docs: Fix code formatting in the Plugins page

parent ee9dbf89
...@@ -174,32 +174,34 @@ Trac approach intruces a simple implementation for interfaces in python, ...@@ -174,32 +174,34 @@ Trac approach intruces a simple implementation for interfaces in python,
an example code of how this architecture is used for creating plugins is an example code of how this architecture is used for creating plugins is
reported in the following example (taken from Trac documentation): reported in the following example (taken from Trac documentation):
`from trac.core import *` ```
from trac.core import *
`class ITodoObserver(Interface):` class ITodoObserver(Interface):
`    def todo_added(name, description):`\     def todo_added(name, description):
`     `“““`Called`` ``when`` ``a`` ``to-do`` ``item`` ``is`` ``added.`”””     """Called when a to-do item is added."""
`class TodoList(Component):` class TodoList(Component):
`    observers = ExtensionPoint(ITodoObserver)`     observers = ExtensionPoint(ITodoObserver)
`    def __init__(self):`\     def __init__(self):
`        self.todos = {}`         self.todos = {}
`    def add(self, name, description):`\     def add(self, name, description):
`        assert not name in self.todos, 'To-do already in list'`\         assert not name in self.todos, 'To-do already in list'
`        self.todos[name] = description`\         self.todos[name] = description
`        for observer in self.observers:`\         for observer in self.observers:
`            observer.todo_added(name, description)`             observer.todo_added(name, description)
`class TodoPrinter(Component):`\ class TodoPrinter(Component):
`    implements(ITodoObserver)`     implements(ITodoObserver)
`    def todo_added(self, name, description):`\     def todo_added(self, name, description):
`        print 'TODO:', name`\         print 'TODO:', name
`        print '     ', description`         print '     ', description
```
ITodoObserver interface provides a todo\_added() callback to trigger ITodoObserver interface provides a todo\_added() callback to trigger
plugin's functionalities. plugin's functionalities.
...@@ -237,20 +239,22 @@ organize its code in the way it prefers, as long the intefrace ...@@ -237,20 +239,22 @@ organize its code in the way it prefers, as long the intefrace
requirements are fulfilled; in this way duck typing gets formalized requirements are fulfilled; in this way duck typing gets formalized
without adding a big overhead. without adding a big overhead.
`from zope.interface import Interface, implements,  providedBy` ```
from zope.interface import Interface, implements,  providedBy
`class ISing(Interface):`\ class ISing(Interface):
`   def sing():`\    def sing():
`       ``"`` Returns a melody ``"`        """Returns a melody"""
`class Sinatra(object):`\ class Sinatra(object):
`   implements(ISing)`    implements(ISing)
`   def sing(self):`\    def sing(self):
`       return ``In`` ``singing`` ``in`` ``the`` ``rain...`        return "In singing in the rain..."
`frank = Sinatra()`\ frank = Sinatra()
`ISing.providedBy(frank)    <-- True` ISing.providedBy(frank)    <-- True
```
Interfaces fully supports inheritance from other interfaces (with the Interfaces fully supports inheritance from other interfaces (with the
security check that children's methods conforms to ancestor's one if security check that children's methods conforms to ancestor's one if
...@@ -360,7 +364,7 @@ parameters (i.e /home/my\_user/.pitivi/plugin-settings). ...@@ -360,7 +364,7 @@ parameters (i.e /home/my\_user/.pitivi/plugin-settings).
The relationship that exists between extension points and plugins is The relationship that exists between extension points and plugins is
schematized in this cartoon: schematized in this cartoon:
![](images/Extension_schema.png) ![](../images/Extension_schema.png)
1. Each plugin may act as extender and as host by exposing extension 1. Each plugin may act as extender and as host by exposing extension
point itself. point itself.
...@@ -530,10 +534,13 @@ for the plugin to integrate widgets in the main user interface: ...@@ -530,10 +534,13 @@ for the plugin to integrate widgets in the main user interface:
Class IMenuProvider(Interface): Class IMenuProvider(Interface):
`   def getUI():`\ ```
`   ``"`` Return the xml code defining the user interface enhancement ``"`\ def getUI():
`   def getActions():`\ """Return the xml code defining the user interface enhancement"""
`   ``"`` Return the list of actions triggered by new menuitems ``"`
def getActions():
"""Return the list of actions triggered by new menuitems"""
```
## Additional source providers ## Additional source providers
...@@ -545,12 +552,14 @@ interface: ...@@ -545,12 +552,14 @@ interface:
Class ISourceProvider(Interface): Class ISourceProvider(Interface):
`   def getName():`\ ```
`   ``"`` Return the name to be displayed in the notebook tab title ``"`\ def getName():
`   def getWidget():`\ """Return the name to be displayed in the notebook tab title"""
`   ``"`` Return the source view widget, usually a gtk box ``"`\ def getWidget():
`   def getCallbacks():`\ """Return the source view widget, usually a gtk box"""
`   ``"`` Return a tuple of (cb_name, signal_name) in the order they must be connected ``"` def getCallbacks():
"""Return a tuple of (cb_name, signal_name) in the order they must be connected"
```
Note on signals handling: the plugin may provide callbacks to observe Note on signals handling: the plugin may provide callbacks to observe
application signals, they're retrieved from the plugin with the application signals, they're retrieved from the plugin with the
...@@ -561,30 +570,33 @@ disconnected in reverse order when the plugin is deactivated. ...@@ -561,30 +570,33 @@ disconnected in reverse order when the plugin is deactivated.
## Recording devices ## Recording devices
Recording devices such as webcams, microphones but also unconventional Recording devices such as webcams, microphones but also unconventional
items like screencast share the same requirements to be used by pitivi: items like screencast share the same requirements to be used by Pitivi:
Class IRecordingDevice(Interface): ```
class IRecordingDevice(Interface):
`   __gsignals__ =`\ __gsignals__ =
`       {`\     {
`       ``recording-started``: (gobject.SIGNAL_RUN_LAST, gobject.TYPE_VOID, ()),`\     "recording-started": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_VOID, ()),
`       ``recording-finished``: (gobject.SIGNAL_RUN_LAST, gobject.TYPE_PYOBJECT, ())`\     "recording-finished": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_PYOBJECT, ())
`       }`\     }
`       ``"`` recording-started informs observers the device started recording.`\     """recording-started informs observers the device started recording.
`           recording-finished signals the main application that a new clip is produced by the device,`\        recording-finished signals the main application that a new clip is produced by the device,
`           the clip uri is returned by the signal in order to be added among sources ``"`\        the clip uri is returned by the signal in order to be added among
`   def getName():`\   sources """
`   ``"`` Return the name of the device ``"`\
`   def hasVideo():`\ def getName():
`   ``"`` Return true if device can provide video ``"`\ """Return the name of the device"""
`   def hasAudio():`\ def hasVideo():
`   ``"`` Return true if device can provide audio ``"`\ """Return true if device can provide video"""
`   def record():`\ def hasAudio():
`   ``"`` Start recording ``"`\     """Return true if device can provide audio"""
`   def stop():`\ def record():
`   ``"`` Stop recording ``"`\   """Start recording"""
`   def isRecording():`\ def stop():
`   ``"`` Returns true if the device is currently recording ``"`     """Stop recording"""
def isRecording():
    """Returns true if the device is currently recording"""
```
## Effects/Transitions ## Effects/Transitions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment