summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authornecoro <>2007-07-07 08:50:33 +0000
committernecoro <>2007-07-07 08:50:33 +0000
commit6d9340ebbb5b942b0996053b0479827c1cf81b5a (patch)
treec7099063b564511a37b63f07a03a2fbb4217201f /doc
parent91225d6ff5bc70cd76d0cf54f35a1cf6186b538b (diff)
downloadportato-6d9340ebbb5b942b0996053b0479827c1cf81b5a.tar.gz
portato-6d9340ebbb5b942b0996053b0479827c1cf81b5a.tar.bz2
portato-6d9340ebbb5b942b0996053b0479827c1cf81b5a.zip
some more documentation
Diffstat (limited to 'doc')
-rw-r--r--doc/Hooks40
-rw-r--r--doc/Howto_Write_Plugins54
2 files changed, 94 insertions, 0 deletions
diff --git a/doc/Hooks b/doc/Hooks
new file mode 100644
index 0000000..58dabd7
--- /dev/null
+++ b/doc/Hooks
@@ -0,0 +1,40 @@
+List of hooks currently being supported by Portato
+==================================================
+
+am_i_root
+---------
+Called: When checking whether the current user is root (ie. uid == 0).
+Parameters: None
+Return if override: Boolean signaling whether we are root.
+
+
+emerge:
+-------
+Called: When emerge or every other command given by e.g. the synccmd preference is being called.
+Parameters:
+ - string[] packages: Packages to emerge (includes "world", "system").
+ - string[] command: The exact command to execute.
+ - portato.gui.wrapper.Console console: The console the output will be written to.
+
+Return if override: Nothing
+
+
+after_emerge:
+-------------
+Called: When the emerge process (or other - see emerge hook) is finished.
+Parameters:
+ - string[] packages: The list of cpv's (plus "world", "system") which have been emerged. (Or not if it failed.)
+ - int retcode: The return code of the command.
+
+Return if override: Nothing
+Comment: This uses an extra hook as emerge is started in an extra thread and thus all plugins being wanting to come "after" will be called while emerge is still running.
+
+open_ebuild:
+------------
+Called: When an ebuild window is opened.
+Parameters:
+ - portato.backend.Package package: The current package whose is going to be displayed.
+ - Window parent: The parent window. Exact type depends on the frontend.
+
+Return if override: Window-object which can be called by the frontends. Please see the explicit code to see what is expected.
+Comment: If you want to override - do this only for ONE specific frontend.
diff --git a/doc/Howto_Write_Plugins b/doc/Howto_Write_Plugins
new file mode 100644
index 0000000..660b45b
--- /dev/null
+++ b/doc/Howto_Write_Plugins
@@ -0,0 +1,54 @@
+HowTo Write A Plugin For Portato
+=================================
+
+(NOTE: The XML schema is likely to change in the future.)
+
+Writing a plugin is (quite) simple. You have to provide a XML file which tells portato how to communicate with the plugin and in most cases a Python module doing the actual work. This howto is not going to cover the writing of the plugin, but only the XML.
+
+General
+-------
+
+So - how is a plugin is working in general? Portato defines a set of hooks (see the Hooks file for a complete list) to which your plugin can connect. For each hook you have three choices: To connect before, after or instead of the function being hooked. (Of course you can connect several times to one hook ...) The latter one should be used only if you really know what you are doing as it is likely that Portato won't work any longer after this. Also have in mind, that only one plugin can override. Thus: if several plugins want to override one hook, a randomly chosen one will get the allowance.
+
+For each of the "before" and "after" mode a queue exists, holding the plugins to execute. A plugin is allowed to state another plugin which should be executed after (in "before" mode) or before (in "after" mode) your plugin. The star * exists to note that this should be applied to ALL other plugins. Portato TRIES to satisfy your request...
+
+When you now have chosen the connect(s) to chose you write an appropriate function (or better: a Python callable) which will be given in the XML-definition to be called by Portato with the hook's arguments. (Hint: All arguments will be passed as keyword parameters. So you can easily pick the ones you need and add a "**kwargs" argument, which will take the rest. As a nice side effect you do not have to reflect any API changes which will come with additional parameters :)).
+
+Finally: Add an import tag stating the module to import to execute the function(s) given - and you are done.
+
+Sample XML
+----------
+
+At the point of writing this, there is no XSD or DTD - so you cannot validate the file. But this will change at some point of time ;).
+
+<?xml version="1.0" encoding="UTF-8" ?>
+<plugin
+ author="Joe Smith"
+ name="Some small sample plugin">
+ <import>plugins.sample.small</import>
+
+ <hook
+ hook = "a_hook"
+ call = "the_calling_function">
+ <connect type="after" />
+ </hook>
+</plugin>
+
+Notes:
+
+- The author and name attributes are mandatory.
+- If you want to specify a dependency plugin the connect tag has to be like: <connect type = "after"> The other plugin we depend on </connect>.
+- It is possible of course to have more than one "hook" tag.
+
+Additional Tags
+---------------
+
+Menu:
+ It is possible, that your plugin gets an entry in the "Plugin"-menu. Therefore you have to provide (one or more) "menu" tags:
+ <menu label="The Small _Plugin" call = "the_calling_menu_function" />
+
+ Note, that the underscore in front of a character will make it be underlined in the menu and thus accessible by a shortcut.
+
+Disabled:
+ Sometimes you don't want the plugin to be enabled by default but only if the user explicitly says so. This can be archieved by just adding the "disabled" tag:
+ <disabled />