7,932
edits
(One intermediate revision by the same user not shown) | |||
Line 151: | Line 151: | ||
'''Warning''': A bunch of Sugar API relies on Glib and a window which you won't have control over (I think). | '''Warning''': A bunch of Sugar API relies on Glib and a window which you won't have control over (I think). | ||
* '''Write your component'''. Just like a C++ component, write the IDL file and generate the xpt. Example python component using sugar: | * '''Write your component'''. Just like a C++ component, write the IDL[http://kiwix.svn.sourceforge.net/viewvc/kiwix/moulinkiwix/src/components/sugarBridge/ISugarBridge.idl] file and generate the xpt. Example python component [http://kiwix.svn.sourceforge.net/viewvc/kiwix/moulinkiwix/src/components/sugarBridge/sugar_bridge.py] using sugar: | ||
<pre>#!/usr/bin/env python | <pre>#!/usr/bin/env python | ||
# encoding=utf-8 | # encoding=utf-8 | ||
Line 178: | Line 178: | ||
* '''copy/link any external python lib''' inside that ''pylib/'' folder. | * '''copy/link any external python lib''' inside that ''pylib/'' folder. | ||
<pre>ln -s /usr/share/pyshared/sugar pylib/</pre> | <pre>ln -s /usr/share/pyshared/sugar pylib/</pre> | ||
* '''Use it''' like any other component | |||
<pre> if (Components.classes["@kiwix.org/SugarBridge"] == undefined) | |||
dump("Unable to register the SugarBridge XPCOM, Kiwix won't be optimized for Sugar. | |||
"); | |||
else { | |||
var sugar = Components.classes["@kiwix.org/SugarBridge"] | |||
.createInstance(Components.interfaces.ISugarBridge); | |||
sugar.test(); | |||
}</pre> |
edits