Hacking Sugar: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
(..)
Line 1: Line 1:

= Programming Sugar =
= Programming Sugar =


Line 20: Line 19:


= Hacking Sugar v1 =
= Hacking Sugar v1 =
''recent work by edsiper; needs to be merged with [[Sugar development]] and [[Sugar]] and other pages''
''below is recent work by edsiper; needs to be merged with [[Sugar development]] and [[Sugar]] and [[Sugar Activity Tutorial]]... and other pages.''


== Introduction ==
== Introduction ==

Revision as of 22:44, 11 October 2007

Programming Sugar

...from recent discussions with Christoph Derndofer and others

  • OLPC Austria are working on a set of guidelines for hacking sugar and specific activities.

chapters that we're thinking to include:

#0: "Preface" #1: "Introduction" #2: "Sugar Basics" #3: "Sugar User Interface" #4: "Using the X0 Input Devices" #5: "Collaboration" #6: "Content Sharing" #X: "Turning existing applications into activities"


Hacking Sugar v1

below is recent work by edsiper; needs to be merged with Sugar development and Sugar and Sugar Activity Tutorial... and other pages.

Introduction

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.

Sugar is a big opportunity for developers, you can get involved and get the chance to create and improve this wonderful graphical Shell

Motivation

In the latest 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 a 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 spent some time reading the source code.

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 exactly information about your needs and a lot of tips from experienced developers.

Is this document for me ?

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:

  • do I have a developer skill, if don't, do I would like to have one?
  • do I want to learn a lot of Python, GTK and Sugar Internals ?
  • do I want to contribute and to put a better laptop in the hands of every child ?

well, if you are reading this last line I'm happy that we got a new contributor.

OLPC, a collaborative work

OLPC is a big project, and talking about the software components we can't avoid to talk about how is development done?. OLPC has a main staff of developers, most of them provided by RedHat Inc. and lot of collaborators and volunteers from different countries, and the big part of this job is done through Internet. Let's understand how.

Softwares are in repositories

Repositories are specialized software hosted in central servers that allow to manage different project with a Control Version System, the selected one by OLPC is GIT. So all pieces of softwares of OLPC are hosted in a development server called dev.laptop.org, every piece of software has it's own repository and it's 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:


About how to get the software from the GIT respositories, do some patch and others, please read this helpful pages:


So if you have in mind to develop some SW, try to install GIT in your local Linux distribution, it's a good step to start ;)

Bug Tracker

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 tracker 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:

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)

Communication

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 the people are around the world, OLPC uses different channels of communications such as:

  • IRC (Internet Relay Chat) - irc.freenode.net #olpc #sugar #olpc-help
  • Mailing List
  • Teleconferences call
  • WiKi! http://wiki.laptop.org

You can always find someone available to help in the IRC channels, join us!

Mailing List

Some useful page about all mailing list available here:

Help is welcome!

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:

  • Sugar core development
  • Sugar Activities
  • Localization

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!

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.

OLPC is going to different countries in different languages. Most of the activities are written in English so we need help with translation. Please have a go!

Sugar

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 http://www.diveintopython.org , please read the book, to do some examples and come back here :) .

Sugar is not a Desktop as Gnome, KDE or XFCE, it's a Graphical Shell for Kids and this shell has been written from scratch following the HIG (Human Interface Guidelines). So every change, feature or new component in the core of sugar must be approved by the designer team.

This great UI (user interface), needs external components to work in a better way (similar to normal Desktops), as base, we need a Linux OS (no restricted distribution) and aditional software as:

  • D-Bus
  • HAL
  • Hippo-Canvas
  • GTK+
  • Avahi
  • Matchox Window Manager
  • Network Manager
  • Others...

How Sugar takes the control?

Talking about code, Sugar is a GTK+ program that require a Windows Manager and a X Server. A main python script called sugar-shell execute the matchbox-window-manager and this last one connect to the X server, and then the script stay in the gtk main loop. Now we have a main window as an UI and have the control. Please take a look to:

Sugar Internals

Setting up a development environment

In order to develop software for Sugar (core or activities) you need a development environment, we have different ways such as:

Emulation Images

OLPC provide every day a system image, you only need to run it inside an emulation software, the recommended one is QEMU, please take a look to this page for more information about how to emulate a XO system image:

Sugar JHBUILD

JHbuild is a tool designed to make building collections of source packages, the main idea is build a piece of software and all it's dependencies in a local directory, setup and environment to work and it avoid to cause problems in the local system. Sugar-JHBuild allow you to have a safe running Sugar environment inside your local desktop. In order to get Sugar running, you need to get sugar-jhbuild and run the 'build' process:

Get Sugar-JHBuild

git clone git://dev.laptop.org/sugar-jhbuild

Check Local Dependencies

Sugar need some packages dependencies from your local distribution, let's run a sanity check:

cd sugar-jhbuild
./sugar-jhbuild sanitycheck

now if you got the message Dependencies check succeeded., you're ready to build sugar, if don't, take a look to the dependencies needed in order to build sugar, if you have some problems or the dependencies are not available for your Linux distribution, come to #sugar channel in the irc server to get some help.

Building Sugar

This process can take some time (some hours in some cases!), sugar-jhbuild gonna try to download a lot of packages and compile them, in this case is indispensable an good internet connection. Let's build Sugar and it dependencies:

./sugar-jhbuild build

Running Sugar

Now if all packages was built without problems, you can enjoy your sugar:

./sugar-jhbuild run

More information about Sugar-JHBuild

You can find more information about sugar-jhbuild and some tips here:


Emulate or not Emulate, JHBuild or not JHBuild?

What's better?, well, all depends about what do you want to do, If you are just writing a simple Activity and you need to test it, maybe a emulation system is your solution, but always I recommend to use Sugar-JHBuild, you can get some problems in the beginning but when it's ready you will have a flexible development environment.