<div dir="ltr"><div><div><div><div><div>Manu, <br></div>I just added the __init__.py file.<br><br></div>About the StopButton, I added the function add_stopbutton in order to be called when the activity developer finish its toolbar, because SimpleActivity can't know where it's ready, I think the only way to do this is when the user adds any item to the toolbar, move (actually, remove and insert again) the stopbutton with its separator to the end of the toolbar, but we would doing that every time an item is added and I think it doesn't make sense.<br>
</div>If there is a way to fix an item position, please let me know.<br><br></div>About new signals style:<br></div>They look nicer, when I want to define a signal without a function, I can do <br><div><div><div><div><div>
<div>
my_signal = GObject.Signal('my_signal', arg_types=(int)) as you said, then where I should put that?<br><br></div><div>self.mysignal  = GObject.Signal(.... ?<br><br></div><div>Regards,<br></div><div>aguz<br></div>
</div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/23 Manuel Quiñones <span dir="ltr"><<a href="mailto:manuq@laptop.org" target="_blank">manuq@laptop.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Nice!  I will try to use it in Browse.  We should aim to zero code<br>
duplication and make activities code easier.<br>
<br>
I gave a quick look at the code.  I think SimpleActivity should take<br>
care of adding the Stop button.  All activities will (must) have it.<br>
<br>
Please add an empty  __init__.py file so we can use it as a module.<br>
<br>
A minor implementation thing: we started to use "new style" signals.<br>
They are more pythonic.  So instead of adding a class attribute<br>
__gsignals__ you do:<br>
<br>
my_signal = GObject.Signal('my_signal', arg_types=(int,))<br>
other_gobject.connect('my_signal', my_signal_handler)<br>
my_signal.emit(42)<br>
<br>
Example: <a href="https://git.gnome.org/browse/pygobject/tree/examples/signal.py" target="_blank">https://git.gnome.org/browse/pygobject/tree/examples/signal.py</a><br>
Docstrings: <a href="https://git.gnome.org/browse/pygobject/tree/gi/_gobject/signalhelper.py" target="_blank">https://git.gnome.org/browse/pygobject/tree/gi/_gobject/signalhelper.py</a><br>
<br>
2013/11/21 Agustin Zubiaga Sanchez <<a href="mailto:aguz@sugarlabs.org">aguz@sugarlabs.org</a>>:<br>
<div><div class="h5">> = 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 one<br>
> line and also other things related to the operation for example any number,<br>
> string, dictionary or list that is saved into the self.data variable will be<br>
> auto kept in the journal, and when the instance runs again, in self.data<br>
> 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 need<br>
> to worry about register our events in a python dict, where the keys are the<br>
> names of the events and the values are the functions to call when we receive<br>
> an event, and when we want to "emit" an event with the values we need or<br>
> not, all we have to do is to call send_event(event_name, data)... And that's<br>
> all, we don't have to worry about telepathy, dbus or anything like that,<br>
> 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 whatever,<br>
> 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 FontComboBox,<br>
> 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 como<br>
> funciona en el repositorio de la actividad de ejemplo HelloSimpleActivity<br>
> [1], que implementa un montón de características, y donde pueden ver lo<br>
> fácil que es implementar la colaboración o hacer la 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 self.data,<br>
> al cerrar la actividad esta lo guardará automáticamente en el journal y al<br>
> abrir otra vez esta instancia de nuestra actividad, en self.data estará lo<br>
> 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 támbien<br>
> 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 los<br>
> eventos y los valores son las funciones a llamar cuando alguien nos envie<br>
> ese evento, y cuando deseamos emitirlos con los valores que necesitemos o no<br>
> (simpleactivity se encargara de notificar a cada maquina y enviar a todos<br>
> los datos) simplemente llamamos a una función send_event(nombre_evento,<br>
> datos)... Y listo! No debemos preocuparnos por telepathy, dbus ni nada por<br>
> 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 hay<br>
> un archivo disponible y podemos acceder a descargarlo simplemente llamando<br>
> la función download_file y SharedActivity comenzará a emitir señales con<br>
> 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 versión<br>
> compatible con GTK2, porque hoy en día las actividades nuevas se deben hacer<br>
> 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 de<br>
> 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>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Sugar-devel mailing list<br>
> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
.. manuq ..<br>
_______________________________________________<br>
Lista olpc-Sur<br>
<a href="mailto:olpc-Sur@lists.laptop.org">olpc-Sur@lists.laptop.org</a><br>
<a href="http://lists.laptop.org/listinfo/olpc-sur" target="_blank">http://lists.laptop.org/listinfo/olpc-sur</a><br>
</font></span></blockquote></div><br></div>