Difference between revisions of "Black&White Project/Kiwix for Sugar/Porting"

Jump to navigation Jump to search
no edit summary
Line 122: Line 122:


* '''Remove menubar'''. There is no menubar in Sugar apps.
* '''Remove menubar'''. There is no menubar in Sugar apps.
 
* '''Remove Status bar'''.
* '''Fix the resolution'''.
The OLPC XO has a very high definition (up to 200dpi). Since XR exports the system's dpi to its rendering engine, it makes all your UI look over-sized.
Fix this with the following property (adjust as you want) on ''~defaults/preferences/preferences.js''
<pre>pref("layout.css.dpi", 96);</pre>
* '''Use toolbars only'''. The standard way of displaying an App on Sugar is one toolbar at top (with possible sub-toolbars) and the content area on the rest of the screen.
* '''Toolbar at top'''.


=== Native Activity ===
=== Native Activity ===
Line 133: Line 139:
=== Toolbars ===
=== Toolbars ===


* Stock icons
Toolbars are the main way user will interact with the different features of the App.
While there is no static rule about what should be in there, you might consider the following:
 
# Quit button at the end of the bar. The button could raise the activity logger dialog to record a ''session'' and assign meta data.
# Stock icons are available in SVG format with URLs like: ''moz-icon://stock/activity-stop?size=toolbar''. Note that if you need to mix stock sugar icon with another one you made, you will have to switch to bitmaps for all.
 
=== Deep integration ===
If you need to integrate deeper with sugar (create sessions or other journal entries for example), you would have to write a component for that purpose.
Since Sugar libraries are only available on Python for now, you would need to write a python component and use pyxpcom.
 
'''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:
<pre>#!/usr/bin/env python
# encoding=utf-8
 
from xpcom import components, verbose
 
class SugarBridge:
    _com_interfaces_ = components.interfaces.ISugarBridge
    _reg_clsid_ = "{080787ae-ddff-11e0-aa79-000c2983f4e1}"
    _reg_contractid_ = "@kiwix.org/SugarBridge"
    def __init__(self):
        print("sugar bridge started")
        self.testAttr = "nop"
 
    def test(self):
        try:
            from sugar import env
            print(u"Activities: %s" % env.get_user_activities_path())
        except Exception as e:
            print(u"oops: %r" % e)</pre>
* '''register it''' in ''chrome.manifest'' like a JS component.
<pre>component {080787ae-ddff-11e0-aa79-000c2983f4e1} components/sugar_bridge.py
contract @kiwix.org/SugarBridge {080787ae-ddff-11e0-aa79-000c2983f4e1}</pre>
* '''Install pythonext''' [http://downloads.mozdev.org/pyxpcomext/pythonext-2.6.4.20100126-Linux_x86-gcc3.xpi]. Extract the extension in your ''extensions/'' directory. You can just place the XPI inside and launch XR with ''EnableExtensionManager=1'' to do so.
* '''create a ''pylib'' directory''' on your app root.
* '''copy/link any external python lib''' inside that ''pylib/'' folder.
<pre>ln -s /usr/share/pyshared/sugar pylib/</pre>
7,801

edits

Navigation menu