CINXE.COM
Hacking Sugar - OLPC
<!DOCTYPE html> <html class="client-nojs" lang="en" dir="ltr"> <head> <meta charset="UTF-8"/> <title>Hacking Sugar - OLPC</title> <script>document.documentElement.className="client-js";RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"5182973f91194106e5bed4f9","wgCSPNonce":false,"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Hacking_Sugar","wgTitle":"Hacking Sugar","wgCurRevisionId":254053,"wgRevisionId":254053,"wgArticleId":12722,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Sugar","Developers"],"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Hacking_Sugar","wgRelevantArticleId":12722,"wgIsProbablyEditable":false,"wgRelevantPageIsProbablyEditable":false,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgVector2022PreviewPages":[]};RLSTATE={"site.styles": "ready","user.styles":"ready","user":"ready","user.options":"loading","skins.vector.styles.legacy":"ready"};RLPAGEMODULES=["site","mediawiki.page.ready","mediawiki.toc","skins.vector.legacy.js"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.implement("user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"});});});</script> <link rel="stylesheet" href="/mediawiki/load.php?lang=en&modules=skins.vector.styles.legacy&only=styles&skin=vector"/> <script async="" src="/mediawiki/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector"></script> <meta name="ResourceLoaderDynamicStyles" content=""/> <link rel="stylesheet" href="/mediawiki/load.php?lang=en&modules=site.styles&only=styles&skin=vector"/> <meta name="generator" content="MediaWiki 1.39.7"/> <meta name="format-detection" content="telephone=no"/> <meta name="viewport" content="width=1000"/> <link rel="icon" href="/favicon.ico"/> <link rel="search" type="application/opensearchdescription+xml" href="/mediawiki/opensearch_desc.php" title="OLPC (en)"/> <link rel="EditURI" type="application/rsd+xml" href="http://wiki.laptop.org/mediawiki/api.php?action=rsd"/> <link rel="alternate" type="application/atom+xml" title="OLPC Atom feed" href="/mediawiki/index.php?title=Special:RecentChanges&feed=atom"/> </head> <body class="mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Hacking_Sugar rootpage-Hacking_Sugar skin-vector action-view skin-vector-legacy vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-language-alert-in-sidebar-disabled vector-feature-sticky-header-disabled vector-feature-sticky-header-edit-disabled vector-feature-table-of-contents-disabled vector-feature-visual-enhancement-next-disabled"><div id="mw-page-base" class="noprint"></div> <div id="mw-head-base" class="noprint"></div> <div id="content" class="mw-body" role="main"> <a id="top"></a> <div id="siteNotice"></div> <div class="mw-indicators"> </div> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Hacking Sugar</span></h1> <div id="bodyContent" class="vector-body"> <div id="siteSub" class="noprint">From OLPC</div> <div id="contentSub"></div> <div id="contentSub2"></div> <div id="jump-to-nav"></div> <a class="mw-jump-link" href="#mw-head">Jump to navigation</a> <a class="mw-jump-link" href="#searchInput">Jump to search</a> <div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-parser-output"><div style="float:right; font-size:90%"> <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Fun_tricks"><span class="tocnumber">1</span> <span class="toctext">Fun tricks</span></a> <ul> <li class="toclevel-2 tocsection-2"><a href="#Alternative_'favorites_view'_layouts"><span class="tocnumber">1.1</span> <span class="toctext">Alternative 'favorites view' layouts</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-3"><a href="#Programming_Sugar"><span class="tocnumber">2</span> <span class="toctext">Programming Sugar</span></a></li> <li class="toclevel-1 tocsection-4"><a href="#Hacking_Sugar_v1"><span class="tocnumber">3</span> <span class="toctext">Hacking Sugar v1</span></a> <ul> <li class="toclevel-2 tocsection-5"><a href="#Introduction"><span class="tocnumber">3.1</span> <span class="toctext">Introduction</span></a></li> <li class="toclevel-2 tocsection-6"><a href="#Motivation"><span class="tocnumber">3.2</span> <span class="toctext">Motivation</span></a></li> <li class="toclevel-2 tocsection-7"><a href="#Is_this_document_for_me?"><span class="tocnumber">3.3</span> <span class="toctext">Is this document for me?</span></a></li> <li class="toclevel-2 tocsection-8"><a href="#OLPC,_a_collaborative_work"><span class="tocnumber">3.4</span> <span class="toctext">OLPC, a collaborative work</span></a> <ul> <li class="toclevel-3 tocsection-9"><a href="#Softwares_are_in_repositories"><span class="tocnumber">3.4.1</span> <span class="toctext">Softwares are in repositories</span></a></li> <li class="toclevel-3 tocsection-10"><a href="#Bug_Tracker"><span class="tocnumber">3.4.2</span> <span class="toctext">Bug Tracker</span></a></li> <li class="toclevel-3 tocsection-11"><a href="#Communication"><span class="tocnumber">3.4.3</span> <span class="toctext">Communication</span></a> <ul> <li class="toclevel-4 tocsection-12"><a href="#Mailing_List"><span class="tocnumber">3.4.3.1</span> <span class="toctext">Mailing List</span></a></li> </ul> </li> </ul> </li> <li class="toclevel-2 tocsection-13"><a href="#Help_is_welcome!"><span class="tocnumber">3.5</span> <span class="toctext">Help is welcome!</span></a></li> <li class="toclevel-2 tocsection-14"><a href="#Sugar"><span class="tocnumber">3.6</span> <span class="toctext">Sugar</span></a> <ul> <li class="toclevel-3 tocsection-15"><a href="#How_Sugar_takes_the_control?"><span class="tocnumber">3.6.1</span> <span class="toctext">How Sugar takes the control?</span></a></li> <li class="toclevel-3 tocsection-16"><a href="#Sugar_Internals"><span class="tocnumber">3.6.2</span> <span class="toctext">Sugar Internals</span></a></li> </ul> </li> <li class="toclevel-2 tocsection-17"><a href="#Setting_up_a_development_environment"><span class="tocnumber">3.7</span> <span class="toctext">Setting up a development environment</span></a> <ul> <li class="toclevel-3 tocsection-18"><a href="#Emulation_Images"><span class="tocnumber">3.7.1</span> <span class="toctext">Emulation Images</span></a></li> <li class="toclevel-3 tocsection-19"><a href="#Sugar_JHBUILD"><span class="tocnumber">3.7.2</span> <span class="toctext">Sugar JHBUILD</span></a> <ul> <li class="toclevel-4 tocsection-20"><a href="#Get_Sugar-JHBuild"><span class="tocnumber">3.7.2.1</span> <span class="toctext">Get Sugar-JHBuild</span></a></li> <li class="toclevel-4 tocsection-21"><a href="#Check_Local_Dependencies"><span class="tocnumber">3.7.2.2</span> <span class="toctext">Check Local Dependencies</span></a></li> <li class="toclevel-4 tocsection-22"><a href="#Building_Sugar"><span class="tocnumber">3.7.2.3</span> <span class="toctext">Building Sugar</span></a></li> <li class="toclevel-4 tocsection-23"><a href="#Running_Sugar"><span class="tocnumber">3.7.2.4</span> <span class="toctext">Running Sugar</span></a></li> <li class="toclevel-4 tocsection-24"><a href="#More_information_about_Sugar-JHBuild"><span class="tocnumber">3.7.2.5</span> <span class="toctext">More information about Sugar-JHBuild</span></a></li> </ul> </li> <li class="toclevel-3 tocsection-25"><a href="#To_emulate_or_not_to_emulate?_JHBuild_or_not?"><span class="tocnumber">3.7.3</span> <span class="toctext">To emulate or not to emulate? JHBuild or not?</span></a></li> </ul> </li> <li class="toclevel-2 tocsection-26"><a href="#Activities"><span class="tocnumber">3.8</span> <span class="toctext">Activities</span></a> <ul> <li class="toclevel-3 tocsection-27"><a href="#Simple_activity_bundle_example"><span class="tocnumber">3.8.1</span> <span class="toctext">Simple activity bundle example</span></a></li> </ul> </li> <li class="toclevel-2 tocsection-28"><a href="#See_also"><span class="tocnumber">3.9</span> <span class="toctext">See also</span></a></li> </ul> </li> </ul> </div> </div> <p>Here are various threads about how to program sugar, handbooks for running and demonstrating specific <a href="/go/Activities" title="Activities">activities</a>, and other ways to <a href="/go/Hacking_your_XO" title="Hacking your XO">hack your XO</a>. If you have written about how to <b>hack sugar</b>, program Activities for the XO, or make new projects within popular <a href="/go/Activities" title="Activities">activities</a>, please add links to your notes here. See also <b><a href="/go/Hacking_your_XO" title="Hacking your XO">Hacking your XO</a></b> </p> <h1><span class="mw-headline" id="Fun_tricks">Fun tricks</span></h1> <h2><span id="Alternative_.27favorites_view.27_layouts"></span><span class="mw-headline" id="Alternative_'favorites_view'_layouts">Alternative 'favorites view' layouts</span></h2> <p>In <code>/usr/share/sugar/shell/view/home/favoritesview.py</code> there is a chunk of code that looks like: </p> <pre>_LAYOUT_MAP = {RING_LAYOUT: favoriteslayout.RingLayout, #BOX_LAYOUT: favoriteslayout.BoxLayout, #TRIANGLE_LAYOUT: favoriteslayout.TriangleLayout, #SUNFLOWER_LAYOUT: favoriteslayout.SunflowerLayout, RANDOM_LAYOUT: favoriteslayout.RandomLayout} </pre> <p>If you remove the '#' characters, you can try out three new fun 'home view' layouts for your icons! See <trac>7685</trac> for some screenshots. </p><p>The code for the new layouts is further down in that same file. Some other fun shapes it might be fun to try to code: <a rel="nofollow" class="external text" href="http://mathworld.wolfram.com/Hypocycloid.html">Hypocycloid</a> (a/b=5), <a rel="nofollow" class="external text" href="http://mathworld.wolfram.com/ButterflyCurve.html">Butterfly</a>, <a rel="nofollow" class="external text" href="http://mathworld.wolfram.com/HeartCurve.html">Heart</a>, <a rel="nofollow" class="external text" href="http://mathworld.wolfram.com/Quadrifolium.html">Quadrifolium</a>, <a rel="nofollow" class="external text" href="http://mathworld.wolfram.com/Rose.html">Rose</a>, and <a rel="nofollow" class="external text" href="http://mathworld.wolfram.com/Superellipse.html">Superellipse</a> (the 'starfish' example). </p><p>This hack will only work on newer software builds, because older builds do not have the alternative layouts. They were introduced in build 8.2-761 (Sugar version 0.82.8). </p> <h1><span class="mw-headline" id="Programming_Sugar">Programming Sugar</span></h1> <p><i>...from recent discussions with Christoph Derndorfer and others</i>: <a href="/go/OLPC_Austria" title="OLPC Austria">OLPC Austria</a> are working on a set of guidelines for hacking sugar and specific activities. </p><p><br /> <i>chapters that we're thinking to include:</i> </p> <pre>#0: "Preface" #1: "Introduction" #2: "Sugar Basics" #3: "Sugar User Interface" #4: "Using the XO Input Devices" #5: "Collaboration" #6: "Content Sharing" #X: "Turning existing applications into activities" </pre> <p>Note: We're always open for suggestions and comments with regards to the <i>Activity Handbook</i> that we're working on, please submit them via the sugar mailing-list (and include "handbook" in the subject so we can easily filter the messages) or directly contact me at handbook AT olpcaustria.org. Thanks! <a href="/go/User:ChristophD" title="User:ChristophD">ChristophD</a> 14:59, 12 October 2007 (EDT) </p><p><br /> <b>Update (2008-01-14):</b> <i><a rel="nofollow" class="external text" href="http://www.olpcaustria.org/mediawiki/index.php/Activity_handbook">The first version of the activity handbook</a></i> is now available. <a href="/go/User:ChristophD" title="User:ChristophD">ChristophD</a> 09:50, 14 January 2008 (EST) </p> <h1><span class="mw-headline" id="Hacking_Sugar_v1">Hacking Sugar v1</span></h1> <p><i>below is recent work by <a href="/go/User:Edsiper" title="User:Edsiper">edsiper</a>; needs to be merged with <a href="/go/Sugar_development" title="Sugar development">Sugar development</a> and <a href="/go/Sugar" title="Sugar">Sugar</a> and <a href="/go/Activity_tutorial" title="Activity tutorial">Activity tutorial</a>... and other pages.</i> </p> <h2><span class="mw-headline" id="Introduction">Introduction</span></h2> <p>Hacking Sugar is a public resource for developers that want to get involved in the Sugar Shell development. Here you can find useful information about how to hack/write new sugar components or write external activities and how to integrate them in Sugar. </p><p>Sugar is a big opportunity for developers, you can get involved and get the chance to create and improve this wonderful graphical Shell </p> <h2><span class="mw-headline" id="Motivation">Motivation</span></h2> <p>Over the last two years, OLPC has developed and improved a lot of components for the XO platform, including Hardware, Firmwares, Linux Devices Drivers and a graphical shell for kids called Sugar. To start working in an open source project, sometimes it can be a little difficult if you don't have an updated documentation about "how this piece of software works ?", and you have to spend some time reading the source code. </p><p>The OLPC project, specially Sugar is changing every day, new API, components, ideas, etc. The main idea of "Hacking Sugar" is to write a collaborative document where you can find the exact information you require and a lot of tips from experienced developers. </p> <h2><span id="Is_this_document_for_me.3F"></span><span class="mw-headline" id="Is_this_document_for_me?">Is this document for me?</span></h2> <p>Every time that we read some document, we ask our self if "is this document that we want?", so let's do some questions before to spent many hours reading this: </p> <ul><li>Do I have development skills? If not, would I like to learn?</li> <li>Do I want to learn a lot of <a href="/go/Python" title="Python">Python</a>, GTK and <a href="/go/Sugar" title="Sugar">Sugar</a> Internals?</li> <li>Do I want to contribute and to put a better laptop in the hands of every child?</li></ul> <p>If your answer is yes to each of these, I'm happy that we have a new contributor. </p> <h2><span id="OLPC.2C_a_collaborative_work"></span><span class="mw-headline" id="OLPC,_a_collaborative_work">OLPC, a collaborative work</span></h2> <p>OLPC is a big project, and talking about the software components we can't avoid to talk about <b>how is development done?</b> OLPC has a main staff of developers, most of them provided by RedHat Inc. and lot of collaborators and volunteers from different countries. The big part of this job is done through Internet. Let's understand how. </p> <h3><span class="mw-headline" id="Softwares_are_in_repositories">Softwares are in repositories</span></h3> <p>Repositories are specialized software hosted in central servers that allow to manage different project with a Version Control System, the selected one by OLPC is <a href="/go/Git" title="Git">GIT</a>. So all of the software for OLPC is hosted in a development server called dev.laptop.org. Every piece of software has its own repository and its own maintainer and developers. You can browse through the code, look for applied patches, commits, revision changes, etc. A real example about this is here: </p> <ul><li><a rel="nofollow" class="external free" href="http://dev.laptop.org/git">http://dev.laptop.org/git</a></li></ul> <p>To learn about how to get the software from the GIT respositories, do some patch and others, please read these helpful pages: </p> <ul><li><a href="/go/Git" title="Git">Git</a></li> <li><a href="/go/Git_tips" title="Git tips">Git tips</a> (advanced tips)</li></ul> <p>So if want to develop some SW, try to install GIT in your local Linux distribution, it's a good step to start ;) </p> <h3><span class="mw-headline" id="Bug_Tracker">Bug Tracker</span></h3> <p>As everybody knows, software can have a lot of problems such as special cases with bad validations or security holes that can cause many problems. It's indispensable to file this information in a bug tracking system in order to be sure that every problem has been fixed and which of it's not. Bug trackers allow to assign special problems or task TO-DO to specific developers, in OLPC the tracker system can be found here: </p> <dl><dd><a rel="nofollow" class="external free" href="http://dev.laptop.org/query">http://dev.laptop.org/query</a></dd></dl> <p>So you have to sign up to the track system and then view/create/comment tickets, report bugs or maybe assign your self some ticket not assigned (it's your opportunity to contribute) (ie: <a rel="nofollow" class="external text" href="http://dev.laptop.org/ticket/1">#1</a>) </p> <h3><span class="mw-headline" id="Communication">Communication</span></h3> <p>Sharing ideas is fundamental, and more important is the opinion from others about it. Communication is the base of every project and is more difficult in this case where people participate from all over the globe. OLPC uses various channels of communications such as: </p> <ul><li><a href="/go/IRC" title="IRC">IRC (Internet Relay Chat)</a> - irc.freenode.net #olpc #sugar #olpc-help</li> <li><a href="/go/Mailing_lists" title="Mailing lists">Mailing lists</a></li> <li>Teleconference calls</li> <li><a href="/go/The_OLPC_Wiki" title="The OLPC Wiki">The OLPC Wiki</a>!</li></ul> <p>You can always find someone available to help in the <a href="/go/IRC" title="IRC">IRC</a> channels, join us! </p> <h4><span class="mw-headline" id="Mailing_List">Mailing List</span></h4> <p>Some useful page about all mailing list available here: </p> <dl><dd><a rel="nofollow" class="external free" href="http://lists.laptop.org/listinfo">http://lists.laptop.org/listinfo</a></dd></dl> <h2><span id="Help_is_welcome.21"></span><span class="mw-headline" id="Help_is_welcome!">Help is welcome!</span></h2> <p>Being creative is important but ideas are not just restricted to creating something new. In Sugar, there are three main areas that need your contribution: </p> <ul><li>Sugar core development</li> <li>Sugar <a href="/go/Activities" title="Activities">Activities</a></li> <li><a href="/go/Localization" title="Localization">Localization</a></li></ul> <p>Sugar Core is not complicated but there are a lot of widgets to build in order to use them in activities. You could improve the internal API, come up with ideas about how to speed up modules, etc. Take a look at the code, you'll need some Python knowledge but don't feel scared, it's just Python! </p><p>Activities are external programs to the Sugar Core. They are PyGTK programs Sugarized and called activities. You can create an Activity or just "sugarize" a good PyGTK program, in this document we will explain how. </p><p>OLPC is going to work in different countries in different languages. Most of the activities are written in English so we need help with <a href="/go/Translating" title="Translating">translation</a>. Please have a go! </p> <h2><span class="mw-headline" id="Sugar">Sugar</span></h2> <p>Sugar is the core of the OLPC Human Interface. Its goal is to turn the Laptop into a fun, easy to use, social experience that promotes sharing and learning. Our first step is to learn how sugar works. In order to do that, it's necessary to have some basic Python knowledge. If you don't know about Python, you can learn about it in <a rel="nofollow" class="external free" href="http://www.diveintopython.org">http://www.diveintopython.org</a>. Please read the book, to do some examples and come back here :) . </p><p>Sugar is not a Desktop like Gnome, KDE or XFCE. It is a <b>Graphical Shell</b> for kids and this shell has been written from scratch following the <a href="/go/HIG" class="mw-redirect" title="HIG">HIG</a> (Human Interface Guidelines). So every change, feature or new component in the core of sugar must be approved by the designer team. </p><p>This great UI (user interface) needs external components to work in a better way (similar to normal Desktops). As a base, we need a Linux OS (no restricted distribution) and additional software such as: </p> <ul><li>D-Bus</li> <li>HAL</li> <li>Hippo-Canvas</li> <li>GTK+</li> <li>Avahi</li> <li>Matchbox Window Manager</li> <li>Network Manager</li> <li>Others...</li></ul> <h3><span id="How_Sugar_takes_the_control.3F"></span><span class="mw-headline" id="How_Sugar_takes_the_control?">How Sugar takes the control?</span></h3> <p>Code-wise, Sugar is a GTK+ program that requires a windows manager and an X Server. A main Python script called <b>sugar-shell</b> executes the matchbox-window-manager, which connects to the X server, and then the script stays in the gtk main loop. Now we have a main window as an UI and have the control. Please take a look at: </p> <dl><dd><a rel="nofollow" class="external free" href="http://dev.laptop.org/git?p=sugar;a=blob;f=src/main.py;hb=HEAD">http://dev.laptop.org/git?p=sugar;a=blob;f=src/main.py;hb=HEAD</a></dd> <dd><a rel="nofollow" class="external free" href="http://dev.laptop.org/git?p=sugar;a=blob;f=bin/sugar-shell.in;hb=HEAD">http://dev.laptop.org/git?p=sugar;a=blob;f=bin/sugar-shell.in;hb=HEAD</a></dd></dl> <h3><span class="mw-headline" id="Sugar_Internals">Sugar Internals</span></h3> <h2><span class="mw-headline" id="Setting_up_a_development_environment">Setting up a development environment</span></h2> <p>In order to develop software for Sugar (core or activities) you need a development environment. There are two main options: emulating the entire system, or using JHbuild to compile the system and run it natively. </p> <h3><span class="mw-headline" id="Emulation_Images">Emulation Images</span></h3> <p>OLPC provides, <b>every day</b>, a system image. You only need to run it inside an emulation environment. The recommended one is <a href="/go/QEMU" class="mw-redirect" title="QEMU">QEMU</a>, please take a look to this page for more information about how to emulate a XO system image: </p> <dl><dd><a href="/go/Emulation" class="mw-redirect" title="Emulation">Emulation</a></dd></dl> <h3><span class="mw-headline" id="Sugar_JHBUILD">Sugar JHBUILD</span></h3> <p>JHbuild is a general tool to build collections of source packages. The main idea is build a piece of software and all its dependencies in a local directory, set up an environment that is isolated from the local system. <a href="/go/Sugar_with_sugar-jhbuild" title="Sugar with sugar-jhbuild">Sugar-JHBuild</a> allows you to have a safe running Sugar environment <a href="/go/Category:Installing_Sugar" title="Category:Installing Sugar">inside your local desktop</a>. In order to get Sugar running, you need to get sugar-jhbuild and run the 'build' process: </p> <h4><span class="mw-headline" id="Get_Sugar-JHBuild">Get Sugar-JHBuild</span></h4> <pre>git clone <a rel="nofollow" class="external free" href="git://dev.laptop.org/sugar-jhbuild">git://dev.laptop.org/sugar-jhbuild</a> </pre> <h4><span class="mw-headline" id="Check_Local_Dependencies">Check Local Dependencies</span></h4> <p>Sugar will probably need some package dependencies from your local distribution. Let's run a sanity check: </p> <pre>cd sugar-jhbuild ./sugar-jhbuild sanitycheck </pre> <p>If you got the message <i>Dependencies check succeeded.</i>, you're ready to build sugar. If not, take a look at the dependencies needed in order to build sugar. If you have some problems or the dependencies are not available for your Linux distribution, use an irc client to connect to the #sugar channel on irc.freenode.net and ask for help. </p> <h4><span class="mw-headline" id="Building_Sugar">Building Sugar</span></h4> <p>This process can take some time (some hours in some cases!). sugar-jhbuild is tries to download a lot of packages and compile them. It is essential to have a decent connection to the Internet. Let's build Sugar and it dependencies: </p> <pre>./sugar-jhbuild build </pre> <h4><span class="mw-headline" id="Running_Sugar">Running Sugar</span></h4> <p>If all the packages were built without problems, you can enjoy your sugar: </p> <pre>./sugar-jhbuild run </pre> <h4><span class="mw-headline" id="More_information_about_Sugar-JHBuild">More information about Sugar-JHBuild</span></h4> <p>You can find more information about sugar-jhbuild and some tips here: </p> <dl><dd><a href="/go/Sugar_with_sugar-jhbuild" title="Sugar with sugar-jhbuild">Sugar with sugar-jhbuild</a></dd></dl> <h3><span id="To_emulate_or_not_to_emulate.3F_JHBuild_or_not.3F"></span><span class="mw-headline" id="To_emulate_or_not_to_emulate?_JHBuild_or_not?">To emulate or not to emulate? JHBuild or not?</span></h3> <p>What's better? It all depends on what you want to do. If you are just writing a simple Activity and you need to test it, an emulated system might be the answer. For standard sugar hacking I recommend Sugar-JHBuild. It takes more time to set up but once it's ready you will have a flexible development environment. </p> <h2><span class="mw-headline" id="Activities">Activities</span></h2> <p>Every end user application in Sugar is called an "Activity". In the development scene and in this document we use the term "Activity Bundle", which defines a group of related files: source code, images, and documentation. </p> <h3><span class="mw-headline" id="Simple_activity_bundle_example">Simple activity bundle example</span></h3> <p>If we are interested in developing an activity bundle for Sugar, we need to know the main structure and its requirements. You can get a very simple activity bundle sample here: </p><p><a href="/go/File:Hellokids-activity.tar.gz" title="File:Hellokids-activity.tar.gz">File:Hellokids-activity.tar.gz</a> </p><p><br /> Please download the 'Hello Kids' activity bundle example and uncompress it with the command: </p> <pre>$ tar zxvf hellowkids-activity.tar.gz </pre> <p>Every activity bundle is a main directory with a name followed with the '-activity' string, like hellokids<b>-activity</b>.tar.gz. Let's see what we have inside our activity: </p> <pre>\-> hellokids-activity/ |--> hellokids-activity/activity/ |--> hellokids-activity/activity/activity.info |--> hellokids-activity/activity/hellokids-icon.svg |--> hellokids-activity/README |--> hellokids-activity/TODO |--> hellokids-activity/setup.py |--> hellokids-activity/NEWS |--> hellokids-activity/hellokids.py </pre> <ul><li><b>hello-activity:</b> Main directory, the activity bundle!</li> <li><b>hello-activity/activity/:</b> Here's the configuration directory of our bundle composed by two files.</li> <li><b>hellokids-activity/activity/activity.info:</b> This file contains sugar the activity information:</li></ul> <pre>[Activity] name = Hello Kids activity_version = 1 service_name = org.laptop.HelloKids icon = hellokids-icon exec = sugar-activity hellokids.HelloKidsActivity </pre> <dl><dd>This file contain some variables and values assigned to them:</dd> <dd> <ul><li><i>name:</i> The activity name. This name is shown in the sugar bottom frame where the activities icons launcher are located.</li></ul></dd></dl> <dl><dd><ul><li><i>activity_version:</i> Every bundle has a version number. We use a simple version format with integers starting from 1 to infinity.</li></ul></dd></dl> <dl><dd><ul><li><i>service_name:</i> Bundles are identified by a service-name. This name is used for Sugar and D-Bus in order to launch the activity. Every activity bundle has a different service name. You can choose your own.</li></ul></dd></dl> <dl><dd><ul><li><i>icon:</i> The activity icon. Every icon must be a SVG file and in the icon field we just fill the name without the '.svg' extension.</li></ul></dd></dl> <dl><dd><ul><li><i>exec:</i> A shortened form of 'executable command line' to launch the activity. The format is 'sugar-activity yourmainfile.yourmainactivityclass'. For our first example we are telling sugar: call the HelloKidsActivity class from the hellokids file.</li></ul></dd></dl> <ul><li><b>hellokids-activity/activity/hellokids-icon.svg:</b> The activity icon. Ref: <a href="/go/Sugar_Icon_Format" class="mw-redirect" title="Sugar Icon Format">Sugar Icon Format</a></li></ul> <ul><li><b>hellokids-activity/README:</b> Write some information about your activity.</li></ul> <ul><li><b>hellokids-activity/TODO:</b> It's always good to have a 'To Do' list containing needed features, bugs to fix, optimizations, etc.</li></ul> <ul><li><b>hellokids-activity/setup.py:</b> This file allow as to build a <i>XO activity bundle</i>. Just put your activity name inside the bundlebuilder.start() call.</li></ul> <ul><li><b>hellokids-activity/NEWS:</b> News about your activity.</li></ul> <ul><li><b>hellokids-activity/hellokids.py:</b> Our main program, let's explain the content:</li></ul> <pre>class HelloKidsActivity(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) logging.debug('Starting the Hello-Kids Activity') self.set_title(_('Hello Kids Activity')) button = gtk.Button('Hello Kids!!!') button.connect('clicked', self._print_message) button.show() # CANVAS self.set_canvas(button) # TOOLBAR toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) self.show_all() # Dirty hide, we use this code to hide the 'share' and 'keep' # buttons from the toolbar, we don't need it for now... toolbar = toolbox.get_activity_toolbar() toolbar.share.hide() toolbar.keep.hide() def _print_message(self, widget): print "Hello Kids !!!" </pre> <p><br /> You can see more details in the <a href="/mediawiki/index.php?title=Activity_Bundles_specification&action=edit&redlink=1" class="new" title="Activity Bundles specification (page does not exist)">Activity Bundles specification</a>. </p> <h2><span class="mw-headline" id="See_also">See also</span></h2> <ul><li><a href="/go/PyGTK" title="PyGTK">PyGTK</a></li> <li>The Sugar <a rel="nofollow" class="external text" href="http://www.olpcaustria.org/mediawiki/index.php/Activity_handbook">Activity handbook</a></li> <li><a href="/go/Sugar_Almanac" class="mw-redirect" title="Sugar Almanac">Sugar Almanac</a> covers the various Python packages in Sugar</li> <li><a href="/go/Beyond_Hello_World" title="Beyond Hello World">Beyond Hello World</a></li> <li><a rel="nofollow" class="external text" href="http://en.flossmanuals.net/Sugar/ModifyingSugar">Flossmanuals - Modifying Sugar</a></li> <li><a rel="nofollow" class="external text" href="http://wiki.sugarlabs.org/go/Activity_Team/Modifing_an_Activity">Modifying an Activity</a></li></ul> <!-- NewPP limit report Cached time: 20241127173707 Cache expiry: 86400 Reduced expiry: false Complications: [show鈥恡oc] CPU time usage: 0.018 seconds Real time usage: 0.020 seconds Preprocessor visited node count: 130/1000000 Post鈥恊xpand include size: 35/2097152 bytes Template argument size: 2/2097152 bytes Highest expansion depth: 3/100 Expensive parser function count: 0/100 Unstrip recursion depth: 0/20 Unstrip post鈥恊xpand size: 315/5000000 bytes --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 0.408 1 Template:Ticket 100.00% 0.408 1 -total --> <!-- Saved in parser cache with key wikidb:pcache:idhash:12722-0!canonical and timestamp 20241127173707 and revision id 254053. --> </div> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="http://wiki.laptop.org/mediawiki/index.php?title=Hacking_Sugar&oldid=254053">http://wiki.laptop.org/mediawiki/index.php?title=Hacking_Sugar&oldid=254053</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/go/Special:Categories" title="Special:Categories">Categories</a>: <ul><li><a href="/go/Category:Sugar" title="Category:Sugar">Sugar</a></li><li><a href="/go/Category:Developers" title="Category:Developers">Developers</a></li></ul></div></div> </div> </div> <div id="mw-navigation"> <h2>Navigation menu</h2> <div id="mw-head"> <nav id="p-personal" class="vector-menu mw-portlet mw-portlet-personal vector-user-menu-legacy" aria-labelledby="p-personal-label" role="navigation" > <h3 id="p-personal-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Personal tools</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="pt-login" class="mw-list-item"><a href="/mediawiki/index.php?title=Special:UserLogin&returnto=Hacking+Sugar" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o"><span>Log in</span></a></li></ul> </div> </nav> <div id="left-navigation"> <nav id="p-namespaces" class="vector-menu mw-portlet mw-portlet-namespaces vector-menu-tabs vector-menu-tabs-legacy" aria-labelledby="p-namespaces-label" role="navigation" > <h3 id="p-namespaces-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Namespaces</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="ca-nstab-main" class="selected mw-list-item"><a href="/go/Hacking_Sugar" title="View the content page [c]" accesskey="c"><span>Page</span></a></li><li id="ca-talk" class="new mw-list-item"><a href="/mediawiki/index.php?title=Talk:Hacking_Sugar&action=edit&redlink=1" rel="discussion" title="Discussion about the content page (page does not exist) [t]" accesskey="t"><span>Discussion</span></a></li></ul> </div> </nav> <nav id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet vector-menu-dropdown" aria-labelledby="p-variants-label" role="navigation" > <input type="checkbox" id="p-variants-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-variants" class="vector-menu-checkbox" aria-labelledby="p-variants-label" /> <label id="p-variants-label" aria-label="Change language variant" class="vector-menu-heading " > <span class="vector-menu-heading-label">English</span> </label> <div class="vector-menu-content"> <ul class="vector-menu-content-list"></ul> </div> </nav> </div> <div id="right-navigation"> <nav id="p-views" class="vector-menu mw-portlet mw-portlet-views vector-menu-tabs vector-menu-tabs-legacy" aria-labelledby="p-views-label" role="navigation" > <h3 id="p-views-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Views</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="ca-view" class="selected mw-list-item"><a href="/go/Hacking_Sugar"><span>Read</span></a></li><li id="ca-viewsource" class="mw-list-item"><a href="/mediawiki/index.php?title=Hacking_Sugar&action=edit" title="This page is protected. You can view its source [e]" accesskey="e"><span>View source</span></a></li><li id="ca-history" class="mw-list-item"><a href="/mediawiki/index.php?title=Hacking_Sugar&action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li></ul> </div> </nav> <nav id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-menu-dropdown" aria-labelledby="p-cactions-label" role="navigation" title="More options" > <input type="checkbox" id="p-cactions-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-cactions" class="vector-menu-checkbox" aria-labelledby="p-cactions-label" /> <label id="p-cactions-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">More</span> </label> <div class="vector-menu-content"> <ul class="vector-menu-content-list"></ul> </div> </nav> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <div> <h3 > <label for="searchInput">Search</label> </h3> <form action="/mediawiki/index.php" id="searchform" class="vector-search-box-form"> <div id="simpleSearch" class="vector-search-box-inner" data-search-loc="header-navigation"> <input class="vector-search-box-input" type="search" name="search" placeholder="Search OLPC" aria-label="Search OLPC" autocapitalize="sentences" title="Search OLPC [f]" accesskey="f" id="searchInput" > <input type="hidden" name="title" value="Special:Search"> <input id="mw-searchButton" class="searchButton mw-fallbackSearchButton" type="submit" name="fulltext" title="Search the pages for this text" value="Search"> <input id="searchButton" class="searchButton" type="submit" name="go" title="Go to a page with this exact name if it exists" value="Go"> </div> </form> </div> </div> </div> </div> <div id="mw-panel"> <div id="p-logo" role="banner"> <a class="mw-wiki-logo" href="/go/The_OLPC_Wiki" title="Visit the main page"></a> </div> <nav id="p-About_OLPC" class="vector-menu mw-portlet mw-portlet-About_OLPC vector-menu-portal portal" aria-labelledby="p-About_OLPC-label" role="navigation" > <h3 id="p-About_OLPC-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">About OLPC</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="n-The-OLPC-Wiki" class="mw-list-item"><a href="/go/The_OLPC_Wiki"><span>The OLPC Wiki</span></a></li><li id="n-Contact-us" class="mw-list-item"><a href="/go/OLPC:Contact_us"><span>Contact us</span></a></li><li id="n-Blog" class="mw-list-item"><a href="http://blog.laptop.org" rel="nofollow"><span>Blog</span></a></li><li id="n-Communicate" class="mw-list-item"><a href="/go/Communication_channels"><span>Communicate</span></a></li><li id="n-Participate" class="mw-list-item"><a href="/go/Participate"><span>Participate</span></a></li><li id="n-laptop.org" class="mw-list-item"><a href="http://laptop.org" rel="nofollow"><span>laptop.org</span></a></li></ul> </div> </nav> <nav id="p-About_the_laptop" class="vector-menu mw-portlet mw-portlet-About_the_laptop vector-menu-portal portal" aria-labelledby="p-About_the_laptop-label" role="navigation" > <h3 id="p-About_the_laptop-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">About the laptop</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="n-Specifications" class="mw-list-item"><a href="/go/Hardware"><span>Specifications</span></a></li><li id="n-Buying" class="mw-list-item"><a href="/go/Buying_XOs"><span>Buying</span></a></li><li id="n-Help-using" class="mw-list-item"><a href="/go/Getting_started"><span>Help using</span></a></li><li id="n-Support-for" class="mw-list-item"><a href="/go/Support"><span>Support for</span></a></li><li id="n-Upgrading" class="mw-list-item"><a href="/go/Releases"><span>Upgrading</span></a></li><li id="n-Repairing" class="mw-list-item"><a href="/go/Repair"><span>Repairing</span></a></li><li id="n-Disassembly" class="mw-list-item"><a href="/go/Disassembly"><span>Disassembly</span></a></li></ul> </div> </nav> <nav id="p-About_the_tablet" class="vector-menu mw-portlet mw-portlet-About_the_tablet vector-menu-portal portal" aria-labelledby="p-About_the_tablet-label" role="navigation" > <h3 id="p-About_the_tablet-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">About the tablet</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="n-Specifications" class="mw-list-item"><a href="http://one.laptop.org/about/xo-tablet" rel="nofollow"><span>Specifications</span></a></li><li id="n-Buying" class="mw-list-item"><a href="http://www.walmart.com/ip/24511209" rel="nofollow"><span>Buying</span></a></li><li id="n-Help-using" class="mw-list-item"><a href="http://one.laptop.org/about/xo-tablet-faq" rel="nofollow"><span>Help using</span></a></li><li id="n-Support-for" class="mw-list-item"><a href="http://www.xotablet.com/support/" rel="nofollow"><span>Support for</span></a></li></ul> </div> </nav> <nav id="p-Projects" class="vector-menu mw-portlet mw-portlet-Projects vector-menu-portal portal" aria-labelledby="p-Projects-label" role="navigation" > <h3 id="p-Projects-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Projects</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="n-for-Educators" class="mw-list-item"><a href="/go/Educators"><span>for Educators</span></a></li><li id="n-for-Developers" class="mw-list-item"><a href="/go/Developers"><span>for Developers</span></a></li><li id="n-Software" class="mw-list-item"><a href="/go/Software_components"><span>Software</span></a></li><li id="n-Hardware" class="mw-list-item"><a href="/go/Hardware"><span>Hardware</span></a></li><li id="n-Activities" class="mw-list-item"><a href="http://activities.sugarlabs.org" rel="nofollow"><span>Activities</span></a></li><li id="n-Deployment-Guide" class="mw-list-item"><a href="/go/Deployment_Guide"><span>Deployment Guide</span></a></li><li id="n-School-Server-(XS)" class="mw-list-item"><a href="/go/School_server"><span>School Server (XS)</span></a></li><li id="n-School-Server-(XSCE)" class="mw-list-item"><a href="/go/XS_Community_Edition"><span>School Server (XSCE)</span></a></li></ul> </div> </nav> <nav id="p-OLPC_wiki" class="vector-menu mw-portlet mw-portlet-OLPC_wiki vector-menu-portal portal" aria-labelledby="p-OLPC_wiki-label" role="navigation" > <h3 id="p-OLPC_wiki-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">OLPC wiki</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="n-Recent-changes" class="mw-list-item"><a href="/go/Special:RecentChanges"><span>Recent changes</span></a></li><li id="n-Glossary" class="mw-list-item"><a href="/go/Glossary"><span>Glossary</span></a></li><li id="n-Random-page" class="mw-list-item"><a href="/go/Special:Random"><span>Random page</span></a></li><li id="n-Help-using-the-wiki" class="mw-list-item"><a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents"><span>Help using the wiki</span></a></li></ul> </div> </nav> <nav id="p-tb" class="vector-menu mw-portlet mw-portlet-tb vector-menu-portal portal" aria-labelledby="p-tb-label" role="navigation" > <h3 id="p-tb-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Tools</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"><li id="t-whatlinkshere" class="mw-list-item"><a href="/go/Special:WhatLinksHere/Hacking_Sugar" title="A list of all wiki pages that link here [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/go/Special:RecentChangesLinked/Hacking_Sugar" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/go/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-print" class="mw-list-item"><a href="javascript:print();" rel="alternate" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/mediawiki/index.php?title=Hacking_Sugar&oldid=254053" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/mediawiki/index.php?title=Hacking_Sugar&action=info" title="More information about this page"><span>Page information</span></a></li></ul> </div> </nav> </div> </div> <footer id="footer" class="mw-footer" role="contentinfo" > <ul id="footer-info"> <li id="footer-info-lastmod"> Last edited on 02:15, 10 March 2011.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="/go/OLPC:Privacy_policy">Privacy</a></li> <li id="footer-places-about"><a href="/go/OLPC:About">About OLPC</a></li> <li id="footer-places-disclaimer"><a href="/go/OLPC:General_disclaimer">Disclaimers</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/"><img src="/mediawiki/resources/assets/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" srcset="/mediawiki/resources/assets/poweredby_mediawiki_132x47.png 1.5x, /mediawiki/resources/assets/poweredby_mediawiki_176x62.png 2x" width="88" height="31" loading="lazy"/></a></li> </ul> </footer> <script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgPageParseReport":{"limitreport":{"cputime":"0.018","walltime":"0.020","ppvisitednodes":{"value":130,"limit":1000000},"postexpandincludesize":{"value":35,"limit":2097152},"templateargumentsize":{"value":2,"limit":2097152},"expansiondepth":{"value":3,"limit":100},"expensivefunctioncount":{"value":0,"limit":100},"unstrip-depth":{"value":0,"limit":20},"unstrip-size":{"value":315,"limit":5000000},"timingprofile":["100.00% 0.408 1 Template:Ticket","100.00% 0.408 1 -total"]},"cachereport":{"timestamp":"20241127173707","ttl":86400,"transientcontent":false}}});mw.config.set({"wgBackendResponseTime":92});});</script> </body> </html>