Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-04-27 20:39:34 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-04-27 20:39:34 (GMT)
commit10a1ef58277ea2ed257ff753d22eec4bb9ebb20c (patch)
tree7c4413fdd22751bf70219e40de237a0f62f53e19
Initial version
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--activity.py237
-rw-r--r--activity/activity.info7
-rw-r--r--activity/welcome-activity.svg31
-rw-r--r--images/240px-Sugarlabs_mainpage_01.pngbin0 -> 16358 bytes
-rw-r--r--images/3080618798_5a10ff2054_z.jpgbin0 -> 123924 bytes
-rw-r--r--images/4844300439_5820e3ba5e_z.jpgbin0 -> 184314 bytes
-rw-r--r--images/4844935044_e969f6177b_z.jpgbin0 -> 295073 bytes
-rw-r--r--images/4878794127_7e373961f4_z.jpgbin0 -> 160096 bytes
-rw-r--r--images/6684016469_ed33dd4d44_z.jpgbin0 -> 331848 bytes
-rwxr-xr-xsetup.py21
10 files changed, 296 insertions, 0 deletions
diff --git a/activity.py b/activity.py
new file mode 100644
index 0000000..bda2311
--- /dev/null
+++ b/activity.py
@@ -0,0 +1,237 @@
+# Copyright 2012 One Laptop per Child
+#
+# 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
+
+import os
+import logging
+from gettext import gettext as _
+
+import gtk
+import gobject
+
+from sugar.activity import activity
+from sugar.graphics.toolbarbox import ToolbarBox
+from sugar.activity.widgets import ActivityButton
+from sugar.activity.widgets import TitleEntry
+from sugar.activity.widgets import StopButton
+from sugar.activity.widgets import ShareButton
+from sugar.graphics import style
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.icon import Icon
+
+
+class WelcomeActivity(activity.Activity):
+ """WelcomeActivity class as specified in activity.info"""
+
+ def __init__(self, handle):
+ activity.Activity.__init__(self, handle)
+
+ # we do not have collaboration features
+ # make the share option insensitive
+ self.max_participants = 1
+
+ # toolbar with the new toolbar redesign
+ toolbar_box = ToolbarBox()
+
+ activity_button = ActivityButton(self)
+ toolbar_box.toolbar.insert(activity_button, 0)
+ activity_button.show()
+
+ title_entry = TitleEntry(self)
+ toolbar_box.toolbar.insert(title_entry, -1)
+ title_entry.show()
+
+ share_button = ShareButton(self)
+ toolbar_box.toolbar.insert(share_button, -1)
+ share_button.show()
+
+ separator = gtk.SeparatorToolItem()
+ separator.props.draw = False
+ separator.set_expand(True)
+ toolbar_box.toolbar.insert(separator, -1)
+ separator.show()
+
+ stop_button = StopButton(self)
+ toolbar_box.toolbar.insert(stop_button, -1)
+ stop_button.show()
+
+ self.set_toolbar_box(toolbar_box)
+ toolbar_box.show()
+
+ label = gtk.Label("")
+ label.show()
+ self.set_canvas(label)
+ gobject.idle_add(self.show_dialog)
+
+ def show_dialog(self):
+ welcome_dialog = WelcomeDialog()
+ welcome_dialog.set_transient_for(self.get_toplevel())
+
+
+class _DialogWindow(gtk.Window):
+
+ # A base class for a modal dialog window.
+
+ def __init__(self, icon_name, title):
+ super(_DialogWindow, self).__init__()
+
+ self.set_border_width(style.LINE_WIDTH)
+ offset = style.GRID_CELL_SIZE
+ width = gtk.gdk.screen_width() - style.GRID_CELL_SIZE * 2
+ height = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 2
+ self.set_size_request(width, height)
+ self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+ self.set_decorated(False)
+ self.set_border_width(style.LINE_WIDTH)
+ self.set_resizable(False)
+ self.set_modal(True)
+ self.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color())
+
+ vbox = gtk.VBox()
+ self.add(vbox)
+
+ toolbar = _DialogToolbar(icon_name, title)
+ toolbar.connect('stop-clicked', self._stop_clicked_cb)
+ vbox.pack_start(toolbar, False)
+
+ self.content_vbox = gtk.VBox()
+ self.content_vbox.set_border_width(1)
+ vbox.add(self.content_vbox)
+
+ self.connect('realize', self._realize_cb)
+
+ def _stop_clicked_cb(self, source):
+ self.destroy()
+
+ def _realize_cb(self, source):
+ self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
+ self.window.set_accept_focus(True)
+
+
+class _DialogToolbar(gtk.Toolbar):
+
+ # Displays a dialog window's toolbar, with title, icon, and close box.
+
+ __gsignals__ = {
+ 'stop-clicked': (gobject.SIGNAL_RUN_LAST, None, ()),
+ }
+
+ def __init__(self, icon_name, title):
+ super(_DialogToolbar, self).__init__()
+
+ if icon_name is not None:
+ icon = Icon()
+ icon.set_from_icon_name(icon_name, gtk.ICON_SIZE_LARGE_TOOLBAR)
+ self._add_widget(icon)
+
+ self._add_separator()
+
+ label = gtk.Label(title)
+ self._add_widget(label)
+
+ self._add_separator(expand=True)
+
+ stop = ToolButton(icon_name='dialog-cancel')
+ stop.set_tooltip(_('Done'))
+ stop.connect('clicked', self._stop_clicked_cb)
+ self.add(stop)
+
+ def _add_separator(self, expand=False):
+ separator = gtk.SeparatorToolItem()
+ separator.set_expand(expand)
+ separator.set_draw(False)
+ self.add(separator)
+
+ def _add_widget(self, widget):
+ tool_item = gtk.ToolItem()
+ tool_item.add(widget)
+ self.add(tool_item)
+
+ def _stop_clicked_cb(self, button):
+ self.emit('stop-clicked')
+
+
+class WelcomeDialog(_DialogWindow):
+
+ __gtype_name__ = 'WelcomeDialog'
+
+ def __init__(self):
+
+ # TODO: May be remove the title
+ super(WelcomeDialog, self).__init__(None, _('Welcome'))
+
+ self.image = gtk.Image()
+ self.content_vbox.pack_start(self.image, True, True, padding=0)
+
+ bottom_toolbar = gtk.Toolbar()
+ self.content_vbox.pack_start(bottom_toolbar, False, padding=0)
+
+ images_path = os.path.expanduser('~/Activities/Welcome.activity/images/')
+
+ self.image_order = 0
+ self.image_files_list = []
+ for fname in os.listdir(images_path):
+ self.image_files_list.append(images_path + fname)
+ logging.error('Image file: %s', fname)
+
+ if self.image_files_list:
+ self.image.set_from_file(self.image_files_list[self.image_order])
+
+ separator = gtk.SeparatorToolItem()
+ separator.props.draw = False
+ separator.set_expand(True)
+ bottom_toolbar.insert(separator, -1)
+
+ prev_bt = ToolButton(icon_name='go-previous')
+ bottom_toolbar.insert(prev_bt, -1)
+ prev_bt.connect('clicked', self.__prev_clicked_cb)
+
+ next_bt = ToolButton(icon_name='go-next')
+ bottom_toolbar.insert(next_bt, -1)
+ next_bt.connect('clicked', self.__next_clicked_cb)
+ self.show_all()
+
+ width, height = self.image.size_request()
+
+ height_av = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 4
+ width_av = gtk.gdk.screen_width() - style.GRID_CELL_SIZE * 2
+ size_label = gtk.Label(' Size available for image: %d x %d' %
+ (width_av, height_av))
+ item = gtk.ToolItem()
+ item.add(size_label)
+ bottom_toolbar.insert(item, 0)
+ item.show_all()
+
+ def __next_clicked_cb(self, button):
+ self.image_order += 1
+ if self.image_order == len(self.image_files_list):
+ self.image_order = 0
+ self.image.set_from_file(self.image_files_list[self.image_order])
+
+ def __prev_clicked_cb(self, button):
+ self.image_order -= 1
+ if self.image_order < 0:
+ self.image_order = len(self.image_files_list) - 1
+ self.image.set_from_file(self.image_files_list[self.image_order])
+
+
+def main():
+ welcome_dialog = WelcomeDialog()
+ #welcome_dialog.set_transient_for(self.get_toplevel())
+ welcome_dialog.connect("destroy", gtk.main_quit)
+ gtk.main()
+
+if __name__ == "__main__":
+ main()
diff --git a/activity/activity.info b/activity/activity.info
new file mode 100644
index 0000000..4cb993c
--- /dev/null
+++ b/activity/activity.info
@@ -0,0 +1,7 @@
+[Activity]
+name = Welcome
+activity_version = 1
+bundle_id = org.laptop.WelcomeActivity
+exec = sugar-activity activity.WelcomeActivity
+icon = welcome-activity
+license = GPLv2+
diff --git a/activity/welcome-activity.svg b/activity/welcome-activity.svg
new file mode 100644
index 0000000..48ade91
--- /dev/null
+++ b/activity/welcome-activity.svg
@@ -0,0 +1,31 @@
+<?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 "#010101">
+ <!ENTITY fill_color "#FFFFFF">
+]>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ version="1.0"
+ width="55"
+ height="55"
+ id="svg2173">
+ <defs
+ id="defs3047" />
+ <path
+ d="M 27.538898,41.586986 C 12.116478,44.371168 -1.6872725,31.346126 9.5065333,15.415658 31.450797,-9.7623568 71.928846,21.429706 35.517841,38.172308 36.13187,41.629459 35.382976,39.653597 40.550888,48.676127 31.143132,46.354402 30.14151,45.351303 27.538898,41.586986 z"
+ id="path3829"
+ style="fill:&stroke_color;;stroke:&stroke_color;stroke-width:4.25035143;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <text
+ x="10.535607"
+ y="32.979588"
+ transform="scale(1.1223822,0.89096209)"
+ id="text3057"
+ xml:space="preserve"
+ style="font-size:18.1829319px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:&fill_color;;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"><tspan
+ x="10.535607"
+ y="32.979588"
+ id="tspan3059">Hi!</tspan></text>
+</svg>
diff --git a/images/240px-Sugarlabs_mainpage_01.png b/images/240px-Sugarlabs_mainpage_01.png
new file mode 100644
index 0000000..fae049e
--- /dev/null
+++ b/images/240px-Sugarlabs_mainpage_01.png
Binary files differ
diff --git a/images/3080618798_5a10ff2054_z.jpg b/images/3080618798_5a10ff2054_z.jpg
new file mode 100644
index 0000000..df50f05
--- /dev/null
+++ b/images/3080618798_5a10ff2054_z.jpg
Binary files differ
diff --git a/images/4844300439_5820e3ba5e_z.jpg b/images/4844300439_5820e3ba5e_z.jpg
new file mode 100644
index 0000000..c771f3e
--- /dev/null
+++ b/images/4844300439_5820e3ba5e_z.jpg
Binary files differ
diff --git a/images/4844935044_e969f6177b_z.jpg b/images/4844935044_e969f6177b_z.jpg
new file mode 100644
index 0000000..b8612da
--- /dev/null
+++ b/images/4844935044_e969f6177b_z.jpg
Binary files differ
diff --git a/images/4878794127_7e373961f4_z.jpg b/images/4878794127_7e373961f4_z.jpg
new file mode 100644
index 0000000..69ee158
--- /dev/null
+++ b/images/4878794127_7e373961f4_z.jpg
Binary files differ
diff --git a/images/6684016469_ed33dd4d44_z.jpg b/images/6684016469_ed33dd4d44_z.jpg
new file mode 100644
index 0000000..44f9a42
--- /dev/null
+++ b/images/6684016469_ed33dd4d44_z.jpg
Binary files differ
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..c24196e
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2009, Simon Schampijer
+#
+# 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()