Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2013-11-22 16:31:57 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2013-11-22 16:31:57 (GMT)
commit8845ed9f55f5a8fa673da91c2a60f1643e96310b (patch)
treeb9a46c4ac6da420e995e6b14b4487bae780665ed
parent12876a702d92c82434051d8311df0aa944f3b8b9 (diff)
Using this repo just for the library
-rw-r--r--activity/activity-hellosa.svg26
-rw-r--r--activity/activity.info7
-rw-r--r--icons/help-icon.svg14
-rwxr-xr-xsetup.py21
-rw-r--r--testactivity.py307
5 files changed, 0 insertions, 375 deletions
diff --git a/activity/activity-hellosa.svg b/activity/activity-hellosa.svg
deleted file mode 100644
index 8da7c63..0000000
--- a/activity/activity-hellosa.svg
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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 enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px">
- <g display="block" id="activity-helloworld">
- <path d="M9.263,48.396c0.682,1.152,6.027,0.059,8.246-1.463 c2.102-1.432,3.207-2.596,4.336-2.596c1.133,0,12.54,0.92,20.935-5.715c7.225-5.707,9.773-13.788,4.52-21.437 c-5.252-7.644-13.832-9.08-20.878-8.56C16.806,9.342,4.224,16.91,4.677,28.313c0.264,6.711,3.357,9.143,4.922,10.703 c1.562,1.566,4.545,1.566,2.992,5.588C11.981,46.183,8.753,47.522,9.263,48.396z" display="inline" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
- </g>
- <circle cx="27.375" cy="27.5" r="19.903"
- transform="matrix(0.6,0,0,0.6,10.95,11)"
- id="circle4" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" display="inline" />
- <g transform="matrix(0.6,0,0,0.6,10.95,11)" id="g6" style="display:inline">
- <path d="m 27.376,7.598 c 0,0 -11.205,8.394 -11.205,19.976 0,11.583 11.205,19.829 11.205,19.829"
- id="path8" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" />
- <path d="m 27.376,7.598 c 0,0 11.066,9.141 11.066,19.976 0,10.839 -11.066,19.829 -11.066,19.829"
- id="path10" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" />
- <line x1="27.375999" x2="27.375999" y1="7.598" y2="47.402"
- id="line12" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" />
- <line x1="27.375999" x2="27.375999" y1="7.598" y2="47.402"
- id="line14" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" />
- <line x1="27.375999" x2="27.375999" y1="7.598" y2="47.402"
- id="line16" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" />
- <line x1="7.4720001" x2="47.278" y1="27.5" y2="27.5"
- id="line18" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" />
- </g>
-</svg>
diff --git a/activity/activity.info b/activity/activity.info
deleted file mode 100644
index 953fb5b..0000000
--- a/activity/activity.info
+++ /dev/null
@@ -1,7 +0,0 @@
-[Activity]
-name = Hello SimpleActivity
-bundle_id = org.sugarlabs.HelloSimpleActivity
-exec = sugar-activity -s testactivity.HelloSimpleActivity
-icon = activity-hellosa
-activity_version = 1
-show_launcher = yes
diff --git a/icons/help-icon.svg b/icons/help-icon.svg
deleted file mode 100644
index f6c92bf..0000000
--- a/icons/help-icon.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="55px" height="55px">
- <path
- style="fill:none;stroke:#ffffff;stroke-width:3;stroke-linejoin:round"
- d="M 48,28 A 20,20 0 1 1 8,28 A 20,20 0 1 1 48,28 z"/>
- <path
- style="fill:none;stroke:#ffffff;stroke-width:6;stroke-linecap:round;stroke-linejoin:round"
- d="M 22,20 C 22,20 25,17 29,17 C 33,17 36,19 36,23 C 36,27 31,29 28,29 L 28,32" />
- <path
- style="fill:#ffffff"
- d="M 25,40
- a 3,3 0 1 1 6,0
- a 3,3 0 1 1 -6,0 z" />
-</svg>
diff --git a/setup.py b/setup.py
deleted file mode 100755
index c60f4d0..0000000
--- a/setup.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/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 sugar3.activity import bundlebuilder
-
-bundlebuilder.start()
diff --git a/testactivity.py b/testactivity.py
deleted file mode 100644
index e428028..0000000
--- a/testactivity.py
+++ /dev/null
@@ -1,307 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# SimpleActivity - Sharing demo
-# Copyright (C) 2013 Agustin Zubiaga <aguz@sugarlabs.org>.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 3 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-from gi.repository import Gtk
-from gi.repository import Pango
-from sharedactivity import SharedActivity
-
-from sugar3.graphics.objectchooser import ObjectChooser
-from sugar3.datastore import datastore
-from sugar3.graphics import style
-from sugar3.graphics.icon import Icon
-from sugar3.graphics.alert import Alert
-
-from gettext import gettext as _
-
-import logging
-
-TEXT1 = '<u><b>Welcome to "Hello Simple Activity"!</b></u>'
-
-TEXT2 = "\nTry to modify the value of these <b>inputs</b> and then close and \
-open again this activity."
-
-TEXT3 = "Or <b>share</b> it with other buddy in your neighborhood, and look \
-how the values change in both machines.\n"
-
-TEXT4 = "<u><b>How it works?</b></u>"
-
-TEXT5 = "<b>Sharing:</b>\nWhen you modify the values, the activity send an \
-event to the other machine, and it calls the function assigned to that event \
-with the new data. And it updates that."
-
-TEXT6 = "You just have to send events and manage the received ones :)"
-
-TEXT7 = "\n\n<b>Saving data:</b>\nWhen you change the values, it is saved into \
-the self.data variable, and when you close the Activity, SimpleActivity is \
-responsible for storing the data automatically.\
-\n\n<b>Loading saved data:</b>\nAnd when you open it again, \
-SimpleActivity will auto load the saved values into self.data. \n"
-
-TEXT8 = "You just have to modify self.data, and SimpleActivity will do \
-everything else!"
-
-
-class HelloSimpleActivity(SharedActivity):
-
- def __init__(self, handle):
- # Set some commands to use when we're sharing this activity
- events = {"eo": self._entry_1_changed,
- "et": self._entry_2_changed,
- "p": self._ping_received}
-
- SharedActivity.__init__(self, handle, events)
-
- # We can add a separator to the toolbar, just doing this
- self.add_separator()
-
- # Or add a toolbutton
- self.add_toolbutton('help-icon', self._set_help_visibility,
- _("Show/Hide help"))
-
- # Let's add a non-toolitem widget
- label = Gtk.Label(_("Click this button") + " >")
-
- # And also, put it before our last toolbutton
- self.add_to_toolbar(label, index=2)
-
- # index 0 = activity_button
- # index 1 = separator
- # index 2 = our toolbutton
-
- # Our toolbar is ready, now we have to add the stopbutton
- self.add_stopbutton()
-
- # Canvas creation below
- canvas = Gtk.VBox()
- canvas.set_border_width(10)
-
- # Add introduction label
- self._add_label(TEXT1, canvas, 2, 18)
- self._add_label(TEXT2, canvas, 2)
- self._add_label(TEXT3, canvas, 2)
-
- # Add widgets
- entries_box = Gtk.Box()
- self._entry1 = Gtk.Entry()
- self._entry1.connect('activate', self._my_entry1_changed)
- self._entry1.set_placeholder_text(_("Type here and hit enter"))
-
- entries_box.pack_start(self._entry1, True, True, 5)
-
- self._entry2 = Gtk.Entry()
- self._entry2.connect('activate', self._my_entry2_changed)
- self._entry2.set_placeholder_text(_("Type here too and hit enter."))
- entries_box.pack_start(self._entry2, True, True, 5)
-
- canvas.pack_start(entries_box, False, False, 5)
-
- bbox = Gtk.Box(homogeneous=True)
-
- button = Gtk.Button(_("Send PING!"))
- button.connect('clicked', self._ping)
- bbox.pack_start(button, True, True, 5)
-
- send_file = Gtk.Button(_('Send a file from journal'))
- send_file.connect('clicked', self._send_file)
- bbox.pack_start(send_file, True, True, 5)
-
- canvas.pack_start(bbox, False, False, 2)
-
- # Add help labels:
- h1 = self._add_label(TEXT4, canvas, 14, 18)
- h2 = self._add_label(TEXT5, canvas, 3)
- h3 = self._add_label(TEXT6, canvas, 3, 13)
- h4 = self._add_label(TEXT7, canvas, 3)
- h5 = self._add_label(TEXT8, canvas, 5, 13)
-
- self._help_labels = (h1, h2, h3, h4, h5)
- self._help_visible = True
-
- # An scroll to support small screens
- scroll = Gtk.ScrolledWindow()
- scroll.add_with_viewport(canvas)
- scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
-
- eventbox = Gtk.EventBox()
- eventbox.modify_bg(Gtk.StateType.NORMAL,
- style.COLOR_WHITE.get_gdk_color())
- eventbox.add(scroll)
-
- self.set_canvas(eventbox)
-
- self._conn_alert = None
-
- self.connect('joined', self._hide_connecting_alert)
- self.connect('data-loaded', self._data_loaded)
- self.connect('incoming-file', self._incoming_file)
- self.connect('file-completed', self._file_completed)
- self.connect('file-progress', self._file_progress)
- self.connect('file-download-error', self._file_download_error)
-
- self.show_all()
- self._set_help_visibility(None, False)
-
- if self.shared_activity:
- # We are joining
- self._conn_alert = self._show_alert(_('Connecting'),
- _('Please wait...'),
- False)
-
- def _hide_connecting_alert(self, activity):
- if self._conn_alert:
- self.remove_alert(self._conn_alert)
-
- def _show_alert(self, title,
- msg, buttons=True, cancel=False, response_cb=None):
- alert = Alert()
-
- alert.props.title = title
- alert.props.msg = msg
-
- if cancel:
- c_icon = Icon(icon_name='dialog-cancel')
- alert.add_button(Gtk.ResponseType.CANCEL, 'Cancel', c_icon)
- c_icon.show()
-
- if buttons:
- ok_icon = Icon(icon_name='dialog-ok')
- alert.add_button(Gtk.ResponseType.OK, 'Ok', ok_icon)
- ok_icon.show()
-
- if response_cb is None:
- def response_cb(alert, response):
- self.remove_alert(alert)
-
- alert.connect('response', response_cb)
- self.add_alert(alert)
- alert.show()
-
- return alert
-
- def _add_label(self, text, canvas, padding, font_size=None):
- label = Gtk.Label()
- label.set_line_wrap(Gtk.WrapMode.WORD_CHAR)
-
- if font_size:
- label.modify_font(Pango.FontDescription(str(font_size)))
-
- label.set_markup(text)
- canvas.pack_start(label, False, False, padding)
-
- return label
-
- def _set_help_visibility(self, widget, visible=None):
- if visible is None:
- visible = not self._help_visible
-
- for label in self._help_labels:
- label.set_property('visible', visible)
-
- self._help_visible = visible
-
- def _data_loaded(self, activity):
- try:
- self._entry1.set_text(self.data['entry-one'])
- self._entry2.set_text(self.data['entry-two'])
- except:
- pass
-
- # Local widgets callbacks bellow:
- def _my_entry1_changed(self, entry):
- text = entry.get_text()
- self.data['entry-one'] = text
- self.send_event('eo', text) # Sending event to every connected buddy
-
- def _my_entry2_changed(self, entry):
- text = entry.get_text()
- self.data['entry-two'] = text
- self.send_event('et', text)
-
- def _ping(self, widget):
- self.send_event('p')
-
- def _send_file(self, widget):
- chooser = ObjectChooser()
- response = chooser.run()
-
- if response == Gtk.ResponseType.ACCEPT:
- jobject = chooser.get_selected_object()
-
- data = {"title": jobject.metadata['title'],
- "mime_type": jobject.metadata['mime_type']}
-
- # Send selected file
- self.send_file(jobject.file_path, data)
-
- # Events callbacks bellow:
- def _entry_1_changed(self, data):
- self._entry1.set_text(data)
-
- def _entry_2_changed(self, data):
- self._entry2.set_text(data)
-
- def _ping_received(self, data):
- self._show_alert(_('PONG'),
- _('Somebody clicked the ping button'))
-
- # File receiving:
- def _incoming_file(self, data):
-
- def response_cb(w, response):
- self.remove_alert(w)
- if response == Gtk.ResponseType.OK:
- self._show_alert(_("Downloading file..."),
- _("File download started (progress in the Log)"))
- self.download_file(data)
-
- self._show_alert(_('Incoming file: %s') % data['title'],
- _('Would you like to receive this file?'),
- cancel=True, response_cb=response_cb)
-
- def _file_progress(self, activity, data, total, bytes_downloaded):
- logging.info("File: %s progress %s/%s" % (data['title'],
- total,
- bytes_downloaded))
-
- def _file_completed(self, activity, data, _file, suggested_filename):
- # data contains what we sent in the function _send_file,
- # and also, includes the "size" key, whose value is the lenght of
- # the file
-
- # Save received file to journal
- jobject = datastore.create()
-
- jobject.metadata['title'] = data['title']
- jobject.metadata['mime_type'] = data['mime_type']
- jobject.file_path = self.get_data_file()
-
- new_file = open(jobject.file_path, 'w')
- new_file.write(_file.read())
- new_file.close()
-
- datastore.write(jobject)
-
- self._show_alert(_('File received: %s') % data["title"],
- _('Check your journal now'))
-
- def _file_download_error(self, activity, data):
- self._show_alert(_("Error"),
- _("File: %s") % data['title'])