Wednesday, January 13, 2010

Post's prior to December can all be found at

http://students.gctaa.net/~rbrooke/year2/index.html
I went to activities.sugarlabs.org

And repackaged TimeLapse on the XO with all of the changes that we have made. Then I uploaded the repackaged TimeLapse and finally published the activity, with all of the information about it filled in. This also included a screenshot of TimeLapse in action.

http://activities.sugarlabs.org/en-US/sugar/addon/4270

Is the link to where TimeLapse is available for experimental download.
Tuesday, December 8, 2009

Going to Frank's House

Today, after quickly fixing a bug in TimeLapse at the career center, I went with Peter to Frank's house. The entire thing ran very smoothly and Frank was impressed with the changes we had made, especially the improved sound!! He also had some suggestions about changes that we could make to improve TimeLapse.

1) Have items play when they are double-clicked
2) Enable items that do not have a picture to play
3) Create a confirmation window for the delete all button

Hopefully, we will be able to make this changes without a hitch!

Old TimeLapse

Old TimeLapse

Tuesday, December 15, 2009


Have item play when it is double clicked

@glade_callback
    def doubleclicked(self, data, third):
        if os.path.isfile(os.path.abspath(self.soundfile)):
            self.player.set_property("uri", "file://" +
                                     os.path.abspath(self.soundfile))
        self.player.set_state(gst.STATE_PLAYING)
        else:
           pass


Fix bug where data can not be selected if it does not have a picture  

def itemSelected(self,data):
        self.timestamp = data.get_cells()[0].get_property("text")
        def datum_by_tag(tag):
            return xmlhelper.get_datum_by_timestamp(self.timestamp, tag)
        self.filepath = datum_by_tag("filepath")
        try:
            image = datum_by_tag("image")
        except:
            image = "noImage.jpg"
        myPixbuf = gtk.gdk.pixbuf_new_from_file_at_size(image, 400, 400)
        self.MainImage.set_from_pixbuf(myPixbuf)
        self.soundfile = datum_by_tag("sound")
        if self.soundfile is not None:
            self.interface.get_widget("play_button").set_sensitive(True)
        else:
            self.interface.get_widget("play_button").set_sensitive(False)

Confirmation Window for Delete All button
    
    @glade_callback
    def deleteAllClicked(self, data):
        self.interface.get_widget("delete_confirmation").show()

    @glade_callback
    def deleteAllConfirmed(self, data):
        print "all deleted"
        self.update_pixbuf()
        shutil.rmtree("data/")
        os.mkdir("data")
        xmlhelper.remove_all_data()
        self.update_pixbuf()
        self.interface.get_widget("delete_confirmation").hide()
    
    @glade_callback
    def deleteAllCanceled(self, data):
        self.interface.get_widget("delete_confirmation").hide()



Today I worked on the canvas.glade to fix some of the minor glade problems that were plaguing it.

The first thing that I fixed was the spacing and placement of each collection.

The next thing that I did was add a horizontal and vertical scroll bar to the window where the collections were being displayed.

Creating An .xo file

Creating An .xo file

Step 1

Create setup.py in the same directory that the Activity program is in and copy the lines below into it.

#!/usr/bin/env python

# 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()

Step 2

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)




[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.




Step 4

Create an icon that contains the same name as the one used in activity.info with .svg added on to it.
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:


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg


After:

<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
<!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:


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


<rect
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


Step 7

In home/Activities/example, type:

./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

In home/Activities/example
type

./setup.py dist_xo

This will create the xo file and place it in a new folder called dist in the Activity directory.


Tuesday, January 12, 2010

Under the cameramic section in the computer post, you will notice that some sections are highlighted because these are the sections that I added coding to so that the quality tab would work with TimeLapse.

you will notice that width, height, and rate are all = %d, and right after each of them I have % qualitytab.tab.width or qualitytab.tab.height, qualitytab.tab.rate

This means that the value for what width, height, and rate are is based upon the values dictated in my qualitytab.py which is in-turn based upon where the slider is placed by the user.

You will also notice that at the end of each def, wrote print qualitytab.tab.width or qualitytab.tab.height, qualitytab.tab.rate, that way the developers can look at the terminal to see what values are actually being used in TimeLapse, helping anyone who wants to make changes to the existing qualitytab.py