Step 1
# Copyright (C) 2006, Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from sugar.activity import bundlebuilder
bundlebuilder.start()
Next create a directory within the one that the program is in and name it Activity.
Step 3
Create a file named activity.info within the Activity directory and copy the lines below into it (replace example and ex with the name of your activity)
name = (name of your activity)
bundle_id = example
icon = exampleicon
exec = sugar-activity exActivity.exampleActivity
show_launcher = yes
activity_version = 1
license = GPLv2+
- name
The name of your Activity as it will appear to the user.- bundle_id or service_name
A unique name that Sugar will use to refer to your Activity. Any Journal entry created by your Activity will have this name stored in its metadata, so that when someone resumes the Journal entry Sugar knows to use the program that created it to read it.- icon
The name of the icon file you have created for the Activity. Since icons are always .svg files the icon file in the example is named example.svg.- exec
- This tells Sugar how to launch your Activity. What it says is to create an instance of the class exampleActivity which it will find in file exampleActivity.py.
- show_launcher
- There are two ways to launch an Activity. The first is to click on the icon in the Activity view. The second is to resume an entry in the Journal. Activities that don't create Journal entries can only be resumed from the Journal, so there is no point in putting an icon in the Activity ring for them.
- activity_version
- An integer that represents the version number of your program. The first version is 1, the next is 2, and so on.
- license
- With a computer program there is always a license that tells the person receiving the program what he or she is allowed to do with it. GPLv2+ is a popular standard license that can be used for Activities.
To make the icon, I would recommend using Inkscape.
In Inkscape, go to file, new and select icon_48x48.
This icon size drawing is ideal for sugar activities.
Step 5
Modify icon so it can
work with Sugar.
Specifically, make the icon show Sugar that Sugar can use
its own choice of stroke color and fill color.
(The SVG file format is
based on XML, which means it is a text file with some special tags in
it.)
Once Inkscapecan file is complete, load the file into any text editor and edit it as a text file.
Make the following changes:
Before:
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
After:
<!ENTITY stroke_color "#000000">
<!ENTITY fill_color "#FFFFFF">
]><svg
Now in the body of the document there are references to fill and stroke as part of an attribute called style.
Every line or shape that is drawn will have these something like this:
style="fill:#ffffff;stroke:#000000;stroke-opacity:1"
id="rect904"
width="36.142857"
height="32.142857"
x="4.1428571"
y="7.1428571" />
Change each one to look like this:
style="fill:&fill_color;;stroke:&stroke_color;;stroke-opacity:1"
id="rect904"
width="36.142857"
height="32.142857"
x="4.1428571"
y="7.1428571" />
(Note that &stroke_color; and &fill_color;
both end with semicolons (;), and semicolons are also used to separate
the properties for style. Because of this it is an extremely common
beginner's mistake to leave off the trailing semicolon because two
semicolons in a row don't look right. Be assured that the two
semicolons in a row are intentional and absolutely necessary!)
Step 6
Create a file called MANIFEST in the folder that contains the activity.
( Do not put the MANIFEST file in the activity folder in the activity)
The MANIFEST file should contain everything that is a part of the activity.
EX:
setup.py
example.py
activity/example.svg
activity/activity.info
./setup.py dev
This is because, the activity needs to be installed, which in this case means making a symbolic link between the directory that is being used for the code in the home/Activities/ directory.
A symbolic link is a way to make a file or directory appear to be located in more than one place without copying it.
By typing ./setup.py dev , this makes symbolic link by running setup.py again
Step 8
type
./setup.py dist_xo
This will create the xo file and place it in a new folder called dist in the Activity directory.
No comments:
Post a Comment