Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2013-04-01 14:55:06 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2013-04-01 14:55:06 (GMT)
commit771606ff2913b378dd8ce00efb709d176a150589 (patch)
tree47b04ec7a0004ee259fdc3135b90873df88a042a
parent59ed83751016307789b684ce1b7207c326fcdbbc (diff)
some cleans - add new style of toolbar
-rw-r--r--activity.py98
1 files changed, 44 insertions, 54 deletions
diff --git a/activity.py b/activity.py
index e73dcdb..b88c5b4 100644
--- a/activity.py
+++ b/activity.py
@@ -1,4 +1,6 @@
-# -*- coding: UTF-8 -*-
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
# Copyright 2007-2008 One Laptop Per Child
# Copyright 2007 Gerard J. Cerchio <www.circlesoft.com>
# Copyright 2008 Andrés Ambrois <andresambrois@gmail.com>
@@ -18,48 +20,56 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-import logging
-import sugar.logger
import gtk
-import pygtk
-from gettext import gettext as _
-from sugar.activity.activity import Activity, ActivityToolbox
import pango
import os
import commands
-import sys
+from sugar.activity import activity
+from sugar.graphics.toolbarbox import ToolbarBox
+from sugar.activity.widgets import ActivityToolbarButton
+from sugar.activity.widgets import StopButton
-logger = logging.getLogger('JRE')
+from gettext import gettext as _
-class JreActivity(Activity):
+class JreActivity(activity.Activity):
- # Folder where the JRE has been unpacked
- jre_folder = "jre"
+ def __init__(self, handle):
+ activity.Activity.__init__(self, handle)
+ self.max_participants = 1
+ self.folder_path = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
+ self.jre_folder = os.path.join(self.folder_path, "jre")
+ self.ceibaljam_icon_path = os.path.join(self.folder_path, "images/ceibaljam.png")
+
+ self.build_toolbar()
+ self.build_canvas()
+ self.show_all()
+
+ def build_toolbar(self):
+
+ toolbox = ToolbarBox()
+
+ activity_button = ActivityToolbarButton(self)
+ toolbox.toolbar.insert(activity_button, -1)
+ activity_button.show()
+
+ separator = gtk.SeparatorToolItem()
+ separator.props.draw = False
+ separator.set_expand(True)
+ toolbox.toolbar.insert(separator, -1)
+
+ stop_button = StopButton(self)
+ stop_button.props.accelerator = _('<Ctrl>Q')
+ toolbox.toolbar.insert(stop_button, -1)
+ stop_button.show()
- def __init__(self, handle):
- # Initialize the parent
- Activity.__init__(self, handle)
- logger.debug('Initiating JRE')
-
-
-
- # Set the activity toolbox
- toolbox = ActivityToolbox(self)
self.set_toolbox(toolbox)
- self.ceibaljam_icon_path = os.getenv("SUGAR_BUNDLE_PATH") + "/images/ceibaljam.png"
+ def build_canvas(self):
- #
- # There's a good explanation of the use of boxes in PyGTK here:
- # http://www.pygtk.org/pygtk2tutorial/sec-DetailsOfBoxes.html
- #
-
box_canvas = gtk.VBox(False, 0)
- self.set_canvas(box_canvas)
-
# Title
@@ -81,27 +91,22 @@ class JreActivity(Activity):
box_title.add(label_copyright2)
box_title.add(gtk.Label(""))
- # Version
+ # Version
box_version = gtk.VBox(False, 0)
- #label_version_title = gtk.Label(_("Version information"))
- #label_version_title.modify_font(pango.FontDescription("Arial 12"))
- #label_version_title.set_justify(gtk.JUSTIFY_LEFT)
- version_information = commands.getoutput(os.path.dirname(os.path.abspath(__file__)) + "/" + self.jre_folder + "/bin/java -version")
+ version_information = commands.getoutput(self.jre_folder + "/bin/java -version")
label_version_info = gtk.Label(version_information)
label_version_info.set_justify(gtk.JUSTIFY_CENTER)
- #box_version.add(gtk.Label(""))
- #box_version.add(box_version_title)
box_version.add(gtk.Label(""))
box_version.add(label_version_info)
box_version.add(gtk.Label(""))
- # Usage explanation
+ # Usage explanation
box_usage = gtk.VBox(False, 0)
label_usage1 = gtk.Label(_("To use this JRE in your activity, add the following line to your script:"))
- label_usage2 = gtk.Label('<b>PATH=/home/olpc/Activities/Java.activity/' + self.jre_folder + '/bin:$PATH</b>')
+ label_usage2 = gtk.Label('<b>PATH=' + self.jre_folder + '/bin:$PATH</b>')
label_usage2.set_use_markup(True)
label_usage1.set_justify(gtk.JUSTIFY_CENTER)
label_usage2.set_justify(gtk.JUSTIFY_CENTER)
@@ -137,8 +142,7 @@ class JreActivity(Activity):
image_ceibaljam.set_from_file(self.ceibaljam_icon_path)
box_ceibaljam_image.pack_end(image_ceibaljam, False, False, 0)
-
- # Get all the boxes together
+ # Get all the boxes together
box_canvas.pack_start(box_title, False, False, 0)
box_canvas.pack_start(box_version, False, False, 0)
@@ -147,19 +151,5 @@ class JreActivity(Activity):
box_canvas.pack_end(box_ceibaljam_image, False, False, 0)
box_canvas.pack_end(box_credits, False, False, 0)
-
-
-
- # Test to show some environment variables
- """
- box_footer = gtk.VBox(False, 0)
- box_footer.add(gtk.Label(""))
- box_footer.add(gtk.Label("TUXMATH_SCRIPT = '" + os.getenv("TUXMATH_SCRIPT") + "'"))
- box_footer.add(gtk.Label(""))
- box_canvas.pack_end(box_footer, False, False, 0)
- """
-
- self.show_all()
-
-
+ self.set_canvas(box_canvas)