<div dir="ltr">Excellent work, this is something Sugar needed for a long time.<div><br></div><div>Gonzalo</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 21, 2013 at 10:19 PM, Agustin Zubiaga Sanchez <span dir="ltr"><<a href="mailto:aguz@sugarlabs.org" target="_blank">aguz@sugarlabs.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">= English (Español debajo) =<br>
<br>
Hi everyone,<br>
<br>
I am writing to show you what I was developing those last days, in order to<br>
make simpler the developing of Sugar Activities, this module, micro library<br>
or whatever you want to call it, makes much more easier the processes that<br>
every activity does, for example create ToolButtons, add them to a Toolbar<br>
or implement collaboration which is difficult for any starter developer.<br>
The main idea is include SimpleAcivity in our toolkit, but thinking about<br>
all the review processes it takes, you can add it to your activity for now<br>
or you can take a look about how it works in the Demo activity I did [1],<br>
where you can see how easy is to implement sharing or create the toolbar.<br>
<br>
* SimpleActivity classes *<br>
<br>
simpleactivity.SimpleActivity:<br>
The activities which doesn't want to implement collaboration, can derive<br>
from this class (instead of sugar3.activity.activity.Activity), this class<br>
automatically adds the toolbar to the activity with his<br>
ActivityToolbarButton and it makes easier some processes related to the<br>
design, e.g. add buttons, separators, or whatever to the toolbar in only<br>
one line and also other things related to the operation for example any<br>
number, string, dictionary or list that is saved into the self.data<br>
variable will be auto kept in the journal, and when the instance runs<br>
again, in self.data will be what you leaved when the activity was closed.<br>
Among these there are many other simple features, that after all, they do<br>
everything much easier.<br>
<br>
simpleactivity.SharedActivity (derives from SimpleActivity, you can use all<br>
its methods): :<br>
>From this class should derive every activity which needs to be shared, the<br>
process is greatly simplified cause the communication is done automatically<br>
and the "system" works with something like an event manager, so we only<br>
need to worry about register our events in a python dict, where the keys<br>
are the names of the events and the values are the functions to call when<br>
we receive an event, and when we want to "emit" an event with the values we<br>
need or not, all we have to do is to call send_event(event_name, data)...<br>
And that's all, we don't have to worry about telepathy, dbus or anything<br>
like that, SimpleActivity does everything for you :)<br>
Also it includes an option to send files in a very easy way, using the<br>
method send_file(file_path, data) that notifies every peer that a file is<br>
available, and it can be downloaded just calling the download_file method,<br>
and then SharedActivity will start emiting signals with information related<br>
to the download progress, etc.<br>
The process of downloading is done using another independent tube, then<br>
nothing gets blocked while the file is sent/downloaded, we can continue<br>
sending events while, and everything will continue working.<br>
<br>
Notes:<br>
- Both classes derives from the "natives" classes of sugar, so we can<br>
continue using every method of sugar.activity.activity.Activity or<br>
whatever, without any problem.<br>
- Whole SimpleActivity (module) is only one .py file, then we can put it<br>
into our activity directory easily as we do with HelpButton or<br>
FontComboBox, even if it isn't in sugar toolkit.<br>
- It only supports GTK3, I think it is not necessary to make it compatible<br>
with GTK2, because nowadays the new activities should be did in GTK3.<br>
- I advice everyone who is interested to take a look of the documentation<br>
that you can found in the docstrings in the file for now (I will create a<br>
cleaner documentation with sphinx), to learn about all you can do with<br>
SimpleActivity.<br>
<br>
Also I started a Feature wiki page [2], but is not ready yet. Could anyone<br>
help me with that?<br>
I need some documentation experts ;)<br>
<br>
I hope you find it useful, as I always say, I love developing for Sugar,<br>
because it causes a great feeling to know that the lines of code I wrote<br>
will be used directly or indirectly by millions of children around the<br>
world.<br>
<br>
[1] <a href="https://git.sugarlabs.org/simpleactivity/" target="_blank">https://git.sugarlabs.org/simpleactivity/</a><br>
[2] <a href="http://wiki.sugarlabs.org/go/Features/SimpleActivity" target="_blank">http://wiki.sugarlabs.org/go/Features/SimpleActivity</a><br>
<br>
Thank you very much,<br>
aguz<br>
<br>
-<br>
= Español =<br>
<br>
Hola a todos,<br>
<br>
Les escribo para presentarles lo que he estado desarrollando estos últimos<br>
días, con el fin de hacer más simple la creación de actividades para Sugar,<br>
este modulo, micro librería, o como quieran llamarle, hace mucho más fácil<br>
los procesos que todas las actividades hacen, como crear ToolButtons,<br>
agregarlos a una Toolbar o implementar colaboración para cualquier<br>
desarrollador que esté comenzando.<br>
La idea principal es incluir SimpleActivity en la toolkit de sugar, pero<br>
tomando en cuenta todos los procesos de revisados que lleva, pueden ver<br>
como funciona en el repositorio de la actividad de ejemplo<br>
HelloSimpleActivity [1], que implementa un montón de características, y<br>
donde pueden ver lo fácil que es implementar la colaboración o hacer la<br>
barra de herramientas.<br>
<br>
* Clases de simpleactivity *<br>
<br>
simpleactivity.SimpleActivity:<br>
Las actividades que NO deseen implementar colaboración, pueden simplemente<br>
heredar de esta clase (en lugar de sugar3.activity.activity.Activity), esta<br>
clase agrega automáticamente la toolbar a la actividad con su<br>
ActivityToolButton, y simplifica varios procesos relacionados con el diseño<br>
por ejemplo agregar botones, separadores (o lo que sea) a la toolbar en una<br>
sola linea y también otros de funcionamiento como por ejemplo cualquier<br>
numero, string, diccionario o lista que se guarde, en la variable<br>
self.data, al cerrar la actividad esta lo guardará automáticamente en el<br>
journal y al abrir otra vez esta instancia de nuestra actividad, en<br>
self.data estará lo que allí dejamos.<br>
Entre estas hay muchas otras características simples, que al fin y al cabo,<br>
hacen todo mucho más fácil.<br>
<br>
simpleactivity.SharedActivity (hereda de SimpleActivity, puedes usar<br>
támbien todos sus metodos):<br>
De esta clase deben heredar todas las actividades que deseen implementar<br>
colaboración, el proceso se simplifica enormemente, ya que la comunicación<br>
la hace toda automática, el "sistema" funciona con una especie de manejador<br>
de eventos, por lo que solo debemos de preocuparnos por registrar nuestros<br>
eventos en un diccionario de python, donde las claves son los nombres de<br>
los eventos y los valores son las funciones a llamar cuando alguien nos<br>
envie ese evento, y cuando deseamos emitirlos con los valores que<br>
necesitemos o no (simpleactivity se encargara de notificar a cada maquina y<br>
enviar a todos los datos) simplemente llamamos a una función<br>
send_event(nombre_evento, datos)... Y listo! No debemos preocuparnos por<br>
telepathy, dbus ni nada por el estilo, SimpleActivity hace todo por ti :)<br>
Además incluye la opción de enviar archivos de una manera muy fácil,<br>
utilizando un metodo send_file que avisa a todas las demás maquinas, que<br>
hay un archivo disponible y podemos acceder a descargarlo simplemente<br>
llamando la función download_file y SharedActivity comenzará a emitir<br>
señales con información acerca del progreso de descarga, etc.<br>
El proceso de descarga de archivos se hace por un tubo aparte por lo cual,<br>
nada se bloquea mientras el archivo se envia/descarga, podemos seguir<br>
enviando eventos sin problemas mientras lo hacemos, y todo seguirá<br>
funcionando.<br>
<br>
Notas:<br>
- Ambas clases heredan de las clases nativas de sugar, por lo cual podemos<br>
utilizar todos los métodos de  sugar3.activity.activity.Activity o lo que<br>
sea que deseemos, sin ningún problema.<br>
- SimpleActivity (módulo) es en su totalidad un solo archivo .py por lo que<br>
podemos incorporarlo en nuestra actividad muy fácilmente, así como lo<br>
hacemos con HelpButton o FontComboBox, aunque aún no esten en sugar toolkit.<br>
- Soporta solo GTK3, creo que no es necesario dedicarnos a hacer una<br>
versión compatible con GTK2, porque hoy en día las actividades nuevas se<br>
deben hacer desde el inicio con GTK3.<br>
- Recomiendo a todos los interesados revisar la documentación que está en<br>
docstrings en el archivo por ahora, (proximamente armaré una documentación<br>
más prolija con sphinx), para enterarse de todo lo que se puede hacer con<br>
simpleactivity.<br>
<br>
Además comencé con una pagina en la wiki [2], pero todavía no está lista.<br>
¿Alguien quiere ayudarme con eso?<br>
Necesito ayuda de los expertos en documentación ;)<br>
<br>
Espero que les sea útil, como siempre digo, me encanta desarrollar para<br>
Sugar, porque me provoca un sentimiento inexplicable saber que las lineas<br>
de código que escribo van a ser utilizadas directa o indirectamente por<br>
millones de chicos al rededor del mundo.<br>
<br>
[1] <a href="https://git.sugarlabs.org/simpleactivity/" target="_blank">https://git.sugarlabs.org/simpleactivity/</a><br>
[2] <a href="http://wiki.sugarlabs.org/go/Features/SimpleActivity" target="_blank">http://wiki.sugarlabs.org/go/Features/SimpleActivity</a><br>
<br>
Muchas gracias,<br>
aguz<br>
_______________________________________________<br>
Sugar-Desarrollo mailing list<br>
<a href="mailto:Sugar-Desarrollo@lists.sugarlabs.org">Sugar-Desarrollo@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-desarrollo" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-desarrollo</a><br>
</blockquote></div><br></div>