From 07341d2801bb138c53b6465a5492a80621d7073d Mon Sep 17 00:00:00 2001 From: Esteban Arias Date: Mon, 20 Sep 2010 18:16:24 +0000 Subject: first commit --- diff --git a/PrestametuVoz.activity/MANIFEST b/PrestametuVoz.activity/MANIFEST new file mode 100644 index 0000000..3a9e5b8 --- /dev/null +++ b/PrestametuVoz.activity/MANIFEST @@ -0,0 +1,26 @@ +toolbar.py +prestame_tu_voz.py +funciones.py +NEWS +sonido.py +setup.py +settings.py +manejar_datos.py +color.py +tarjeta.py +config_nuevo.py +grid.py +instance.py +activity/activity.info +activity/prestame-tu-icon.svg +icons/media-audio.svg +icons/media-record-red.png +icons/media-photo.svg +icons/game-save.svg +icons/media-video.svg +icons/game-new.svg +icons/game-load.svg +icons/media-record.png +icons/sin_foto.png +demos/fede2.zip +planillas/planillas.txt diff --git a/PrestametuVoz.activity/NEWS b/PrestametuVoz.activity/NEWS new file mode 100755 index 0000000..047ccd0 --- /dev/null +++ b/PrestametuVoz.activity/NEWS @@ -0,0 +1 @@ +No news. \ No newline at end of file diff --git a/PrestametuVoz.activity/activity/activity.info b/PrestametuVoz.activity/activity/activity.info new file mode 100755 index 0000000..cf7588d --- /dev/null +++ b/PrestametuVoz.activity/activity/activity.info @@ -0,0 +1,9 @@ +[Activity] +name = Prestame tu Voz +bundle_id = org.laptop.PrestameTuVoz +service_name = org.laptop.PrestameTuVoz +class = prestame_tu_voz.PrestameTuVozActivity +icon = prestame-tu-icon +activity_version = 6 +mime_types = +show_launcher = yes diff --git a/PrestametuVoz.activity/activity/prestame-tu-icon.svg b/PrestametuVoz.activity/activity/prestame-tu-icon.svg new file mode 100755 index 0000000..83df075 --- /dev/null +++ b/PrestametuVoz.activity/activity/prestame-tu-icon.svg @@ -0,0 +1,21 @@ + + + + + + +]> + + + + + + + + + + diff --git a/PrestametuVoz.activity/color.py b/PrestametuVoz.activity/color.py new file mode 100755 index 0000000..f544405 --- /dev/null +++ b/PrestametuVoz.activity/color.py @@ -0,0 +1,71 @@ +#Copyright (c) 2008, Media Modifications Ltd. + +#Permission is hereby granted, free of charge, to any person obtaining a copy +#of this software and associated documentation files (the "Software"), to deal +#in the Software without restriction, including without limitation the rights +#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +#copies of the Software, and to permit persons to whom the Software is +#furnished to do so, subject to the following conditions: + +#The above copyright notice and this permission notice shall be included in +#all copies or substantial portions of the Software. + +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +#THE SOFTWARE. + +import gtk + +class Color: + + def __init__(self): + pass + + + def init_rgba(self, r, g, b, a): + self._ro = r + self._go = g + self._bo = b + self._ao = a; + self._r = self._ro / 255.0 + self._g = self._go / 255.0 + self._b = self._bo / 255.0 + self._a = self._ao / 255.0 + + self._opaque = False + if (self._a == 1): + self.opaque = True + + rgb_tup = ( self._ro, self._go, self._bo ) + self.hex = self.rgb_to_hex( rgb_tup ) + self.gColor = gtk.gdk.color_parse( self.hex ) + + + def init_gdk(self, col): + self.init_hex( col.get_html() ) + + + def init_hex(self, hex): + cTup = self.hex_to_rgb( hex ) + self.init_rgba( cTup[0], cTup[1], cTup[2], 255 ) + + + def get_int(self): + return int(self._a * 255) + (int(self._b * 255) << 8) + (int(self._g * 255) << 16) + (int(self._r * 255) << 24) + + + def rgb_to_hex(self, rgb_tup): + hexcolor = '#%02x%02x%02x' % rgb_tup + return hexcolor + + + def hex_to_rgb(self, h): + c = eval('0x' + h[1:]) + r = (c >> 16) & 0xFF + g = (c >> 8) & 0xFF + b = c & 0xFF + return (int(r), int(g), int(b)) \ No newline at end of file diff --git a/PrestametuVoz.activity/color.pyc b/PrestametuVoz.activity/color.pyc new file mode 100755 index 0000000..a49aa17 --- /dev/null +++ b/PrestametuVoz.activity/color.pyc Binary files differ diff --git a/PrestametuVoz.activity/config_nuevo.py b/PrestametuVoz.activity/config_nuevo.py new file mode 100644 index 0000000..2db7413 --- /dev/null +++ b/PrestametuVoz.activity/config_nuevo.py @@ -0,0 +1,180 @@ +#!/usr/bin/python +# -*- coding: iso-8859-15 -*- +''' Config de Prestame tu voz ''' + +#Copyright (C) 2009 Federico Moreira - +# Alejandro Esperón - +#Copyright (C) 2010 Plan Ceibal +# Esteban Arias - +# +# 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 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + + +import gtk +import os + +import settings +from manejar_datos import cargar_datos, cargar_planillas + + +class VentanaConfig(gtk.Table): + + def __init__(self): + + self.lista_tarjetas = [] + + self.pos_actual = 0 + + self.posicion = gtk.Label('1/' + str(settings.TABLA_ANCHO * settings.TABLA_ALTO)) + etiqueta_titulo = gtk.Label('Titulo : ') + self.titulo = gtk.Entry(30) + self.imagen = gtk.Image() + self.boton_imagen = gtk.FileChooserButton('Agregar imagen') + etiqueta_sonido = gtk.Label('Sonido : ') + self.boton_sonido = gtk.FileChooserButton('Agregar sonido') + boton_ingresar = gtk.Button('Ingresar Sig') + + gtk.Table.__init__(self, 5, 1) + + self.attach(self.posicion,0,1,0,1) + + etiqueta_titulo.show() + self.titulo.show() + self.titulo.set_width_chars(10) + + caja_titulo = gtk.HBox() + caja_titulo.pack_start(etiqueta_titulo) + caja_titulo.pack_start(self.titulo) + + self.attach(caja_titulo,0,1,1,2) + self.imagen.show() + self.imagen.set_size_request(500, 500) + self.imagen.set_from_file(os.path.join(os.getcwd(),'icons','sin_foto.png')) + + self.boton_imagen.show() + + caja_imagen = gtk.VBox() + caja_imagen.pack_start(self.imagen) + caja_imagen.pack_start(self.boton_imagen) + self.attach(caja_imagen,0,1,2,3) + + etiqueta_sonido.show() + self.boton_sonido.show() + caja_sonido = gtk.HBox() + caja_sonido.pack_start(etiqueta_sonido) + caja_sonido.pack_start(self.boton_sonido) + self.attach(caja_sonido,0,1,3,4) + + boton_ingresar.show() + boton_ingresar.connect("clicked", self.ingresar_siguiente, "siguiente") + self.attach(boton_ingresar,0,1,4,5) + + self.cargar_demo() + + def cargar_tarjeta(self,lista_tarjetas): + print len(lista_tarjetas) + self.lista_tarjetas = lista_tarjetas + self.titulo.set_text(self.lista_tarjetas[self.pos_actual].titulo) + self.imagen.clear() + self.imagen.set_from_file(os.path.join(os.getcwd(), \ + self.lista_tarjetas[self.pos_actual].imagen)) + self.actualizar_ventana() + + + def ingresar_siguiente(self, widget, info): + self.pos_actual += 1 + if self.pos_actual > (len(self.lista_tarjetas) - 1): + self.pos_actual = 0 + self.titulo.set_text(self.lista_tarjetas[self.pos_actual].titulo) + self.posicion.set_label(str(self.pos_actual + 1) + '/'+ str(settings.TABLA_ANCHO * settings.TABLA_ALTO)) + self.actualizar_ventana() + + def actualizar_ventana(self): + self.imagen.clear() + self.imagen.set_from_file(self.lista_tarjetas[self.pos_actual].imagen) + self.boton_imagen.set_filename(self.lista_tarjetas[self.pos_actual].imagen) + self.boton_sonido.set_filename(self.lista_tarjetas[self.pos_actual].audio) + + def guardar(self, archivo): + ''' Guarda un archivo ''' + if archivo == '': + print "fideo" + selector = gtk.FileChooserDialog(title=None, + action=gtk.FILE_CHOOSER_ACTION_SAVE, + buttons=(gtk.STOCK_CANCEL, + gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN, + gtk.RESPONSE_OK)) + selector.set_current_folder(os.getcwd()) + respuesta = selector.run() + if respuesta == gtk.RESPONSE_OK: + self.crear_tarjetas(selector.get_filename()) + selector.destroy() + else: + self.crear_tarjetas(archivo) + + + def crear_tarjetas(self, nombre_archivo): + ''' Creo las tarjetas ''' + #guardar_datos(nombre_archivo, self.lista_de_tarjetas) + print nombre_archivo + + def abrir(self, widget, info): + ''' Permite abrir un archivo ''' + largo_home = len(os.environ["HOME"]) + 1 + selector = gtk.FileChooserDialog(title=None, + action=gtk.FILE_CHOOSER_ACTION_OPEN, + buttons=(gtk.STOCK_CANCEL, + gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN, + gtk.RESPONSE_OK)) + selector.set_current_folder(os.getcwd()) + selector.set_default_response(gtk.RESPONSE_OK) + respuesta = selector.run() + if respuesta == gtk.RESPONSE_OK: + self.datos = cargar_datos(selector.get_filename()) + self.archivo = selector.get_filename() + selector.destroy() + self.ventana.cargar_tarjeta(self.datos) + + def guardar(self, widget, info): + '''Permite guardar ''' + self.ventana.guardar(self.archivo) + + def cargar_demo(self): + self.lista_tarjetas = cargar_datos('fede2') + self.actualizar_ventana() + + +#config = gtk.Window(gtk.WINDOW_TOPLEVEL) +#config.set_title('Prestame tu voz') +#ventana = VentanaConfig() +##control = ControlConfig(ventana) +# +#caja_principal = gtk.VBox() +##caja_principal.pack_start(control) +#caja_principal.pack_start(ventana) +#caja_principal.show() +# +#config.add(caja_principal) +#ventana.show_all() +##control.show_all() +# +#config.set_default_size(300,300) +#config.show() +#config.connect("delete_event", gtk.main_quit) +#gtk.main() + + + diff --git a/PrestametuVoz.activity/config_nuevo.pyc b/PrestametuVoz.activity/config_nuevo.pyc new file mode 100644 index 0000000..d11d987 --- /dev/null +++ b/PrestametuVoz.activity/config_nuevo.pyc Binary files differ diff --git a/PrestametuVoz.activity/demos/fede2.zip b/PrestametuVoz.activity/demos/fede2.zip new file mode 100644 index 0000000..7597714 --- /dev/null +++ b/PrestametuVoz.activity/demos/fede2.zip Binary files differ diff --git a/PrestametuVoz.activity/funciones.py b/PrestametuVoz.activity/funciones.py new file mode 100644 index 0000000..8460938 --- /dev/null +++ b/PrestametuVoz.activity/funciones.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- +'''Prestame Tu Voz''' + +#Copyright (C) 2009 Federico Moreira - +# Alejandro Esperón - +# +# 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 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +import gtk +import os +#import Image +import settings + +def pintar_filas(button_list, num_fila): + ''' Pinta las filas de color rojo ''' + color_rojo = gtk.gdk.color_parse('#ff0000') + color_blanco = gtk.gdk.color_parse('#ffffff') + + for count in range(settings.TABLA_ALTO * settings.TABLA_ANCHO): + if (count >= num_fila and count<(num_fila+settings.TABLA_ANCHO)): + button_list[count].modify_bg(gtk.STATE_NORMAL, color_rojo) + else: + button_list[count].modify_bg(gtk.STATE_NORMAL, color_blanco) + + num_fila += settings.TABLA_ANCHO + if num_fila >= (settings.TABLA_ANCHO * settings.TABLA_ALTO): + num_fila = 0 + + + + button_list[num_fila].grab_focus() + return num_fila + +def pintar_columnas(button_list, num_fila, num_columna): + ''' Pinta las columnas de violeta ''' + colorblanco = gtk.gdk.color_parse('#ffffff') + colorrojo = gtk.gdk.color_parse('#ff0000') + + button_list[num_columna].modify_bg(gtk.STATE_NORMAL, colorblanco) + num_columna = num_columna + 1 + + #print num_fila + if num_columna > (num_fila + (settings.TABLA_ANCHO-1)): + num_columna = num_fila + + for i in range(num_fila, num_fila + (settings.TABLA_ANCHO)): + if i == num_columna: + button_list[i].modify_bg(gtk.STATE_NORMAL, colorrojo) + button_list[i].grab_focus() + else: + button_list[i].modify_bg(gtk.STATE_NORMAL, colorblanco) + + return num_columna + +#def redim_imagen(img, alto, ancho): + ''' Redimensiona las imágenes ''' +# imagen = Image.open(os.path.join(os.getcwd(), 'imagenes', img)) +# imagen.thumbnail((alto, ancho), Image.ANTIALIAS) +# imagen.save(os.path.join(os.getcwd(), img + '0.png')) + diff --git a/PrestametuVoz.activity/funciones.pyc b/PrestametuVoz.activity/funciones.pyc new file mode 100644 index 0000000..33e079c --- /dev/null +++ b/PrestametuVoz.activity/funciones.pyc Binary files differ diff --git a/PrestametuVoz.activity/grid.py b/PrestametuVoz.activity/grid.py new file mode 100644 index 0000000..46c1c70 --- /dev/null +++ b/PrestametuVoz.activity/grid.py @@ -0,0 +1,279 @@ +#!/usr/bin/python +# -*- coding: iso-8859-15 -*- +''' Ventana Principal de Prestame tu voz ''' + +#Copyright (C) 2009 Federico Moreira - +# Alejandro Esperón - +# Esteban Arias - +# +# 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 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +import gtk +import os, gobject +import subprocess + +import threading + +import settings + +from manejar_datos import cargar_datos, cargar_planillas +from sonido import reproducir +from funciones import pintar_filas, pintar_columnas + +class VentanaPrincipal(gtk.Table): + ''' Clase principal que dibuja la ventana, maneja controles + y carga los archivos de imagenes ''' + + TITLE_FONT_DESC = "sans bold 10" + def __init__(self): + + # Creamos los botones y sus labels correspondientes + self.lista_botones = [gtk.Button() for dummy in xrange(1, (settings.TABLA_ANCHO * settings.TABLA_ALTO) + 1)] + self.lista_titulos = [gtk.Label() for dummy in xrange(1, (settings.TABLA_ANCHO * settings.TABLA_ALTO) + 1)] + + + # Cargo las planillas disponibles + #self.planillas = cargar_planillas(os.path.join('planillas', + # 'planillas.txt')) + + self.num_fila = 0 + self.num_columna = 0 + + #Tiempo de barrido + self.tiempo_repeticion = 2000 + + self.seleccione_fila = -1 + self.handle_barrido_horizontal = 0 + self.handle_barrido_vertical = 0 + + self.handle_check_process = 0 + + self.process_id = None + + self.hilo = None + + # Leo las tarjetas creadas + #self.lista_tarjetas = cargar_datos(self.planillas[0].replace("\n", "")) + + #carga demo por defecto + self.lista_tarjetas = cargar_datos('fede2') + + contador = 0 + + import pango + + # Creo la tabla con un tamaño específico + gtk.Table.__init__(self, settings.TABLA_ANCHO, settings.TABLA_ALTO) + + self.flag = True + + # Por cada item cargo la fila correspondiente + for item in range(settings.TABLA_ALTO): + for pos in range(settings.TABLA_ANCHO): + + print self.lista_tarjetas[contador].audio + # Agrego la label y la muestro + #self.lista_titulos[contador].set_label(self.lista_tarjetas[contador].titulo) + self.lista_titulos[contador].set_text(self.lista_tarjetas[contador].titulo) + self.lista_titulos[contador].modify_font(pango.FontDescription(self.TITLE_FONT_DESC)) + + self.lista_titulos[contador].show() + + #Tamaño + self.lista_botones[contador].set_size_request(settings.BUTTON_SIZE, settings.BUTTON_SIZE) + + # Agrego el botón y lo muestro + self.lista_botones[contador].show() + + # Creo una caja para almacenar los titulos y la muestro + caja = gtk.VBox() + caja.show() + caja.pack_start(self.lista_titulos[contador]) + + + # Cargo las imágenes en los botones + imagen = gtk.Image() + imagen.set_from_file(self.lista_tarjetas[contador].imagen) + + self.lista_botones[contador].set_image(imagen) + # Conecto el evento de click, y asigno el método a reproducir audio + self.lista_botones[contador].connect("clicked", + self.pulso_boton, + self.lista_tarjetas[contador].audio, + self.lista_tarjetas[contador]) + + caja.pack_start(self.lista_botones[contador]) + + self.attach(caja, pos, pos + 1, item, item + 1, gtk.EXPAND, gtk.EXPAND) + + contador += 1 + + # Comienzo con el barrido horizontal + self.barrido_horizontal() + + + def barrido_horizontal(self): + '''Barrido horizontal de la ventana ''' + self.num_columna = self.num_fila + self.num_fila = pintar_filas(self.lista_botones, self.num_fila) + self.handle_barrido_horizontal = gobject.timeout_add(self.tiempo_repeticion, + self.barrido_horizontal) + def pulso_boton(self, dummy_widget, info,btn): + chat = get_chat_box() + ''' Método general que es usado al presionar algun boton ''' + if self.seleccione_fila == -1 : + gobject.source_remove(self.handle_barrido_horizontal) + self.seleccione_fila = self.num_fila - settings.TABLA_ANCHO + self.barrido_vertical() + else: + if self.flag: + if self.lista_tarjetas[self.num_columna].titulo != 'REPRODUCIR': + gobject.source_remove(self.handle_barrido_vertical) + self.hilo = threading.Thread(target=self.ejecutar_sonido, args=(self.lista_tarjetas[self.num_columna].audio,)) + + chat.add_card(self.lista_tarjetas[self.num_columna]) + self.hilo.start() + self.flag = False + self.check_process_id() + else: + self.hilo = threading.Thread(target=self.ejecutar_chatbox) + + def ejecutar_chatbox(self): + chat = get_chat_box() + chat.play_sound() + + def ejecutar_sonido(self, info): + print 'fila:' + str(self.seleccione_fila) + ' columna:' + str(self.num_columna) + reproducir(info) + #self.process_id = subprocess.Popen(['/usr/bin/aplay', info]) + #self.process_id.wait() + + def check_process_id(self): + "Verifica si el sonido termino" + if not self.hilo.isAlive() : + self.barrido_horizontal() + self.seleccione_fila = -1 + self.flag = True + gobject.source_remove(self.handle_check_process) + else: + self.handle_check_process = gobject.timeout_add(1000, + self.check_process_id) + + def barrido_vertical(self): + '''Barrido vertical de la ventana''' + self.num_columna = pintar_columnas(self.lista_botones, + self.seleccione_fila, + self.num_columna) + self.handle_barrido_vertical = gobject.timeout_add(self.tiempo_repeticion, + self.barrido_vertical) + #self.flag=False + + def modifico_tiempo_barrido(self, tiempo): + ''' Altero el tiempo de barrido ''' + self.tiempo_repeticion = tiempo + + +class ControlBarrido(gtk.Table): + ''' Clase que controla la estabilidad del barrido ''' + + def __init__(self, grilla): + gtk.Table.__init__(self, 1, 3) + + self.grilla = grilla + self.valor = 2 + + self.tiempo = gtk.Label('Espera (segundos) : '.join(str(self.valor))) + self.tiempo.show() + boton_mas = gtk.Button('+') + boton_mas.show() + boton_menos = gtk.Button('-') + boton_menos.show() + + boton_mas.connect("clicked", self.pulso_boton_mas, 1) + boton_menos.connect("clicked", self.pulso_boton_menos, 1) + + self.attach(self.tiempo, 0, 1, 0, 1) + self.attach(boton_mas, 1, 2, 0, 1) + + self.attach(boton_menos, 2, 3, 0, 1) + + def pulso_boton_mas(self, dummy_widget, dummy_info): + '''Incrementa tiempo barrido''' + self.valor += 1 + self.tiempo.set_label('Espera : ' + str(self.valor) + ' seg') + self.grilla.modifico_tiempo_barrido(self.valor * 1000) + + + def pulso_boton_menos(self, dummy_widget, dummy_info): + '''Decrementa tiempo de barrido''' + if self.valor > 1: + self.valor -= 1 + + self.tiempo.set_label('Espera : ' + str(self.valor) + ' seg') + self.grilla.modifico_tiempo_barrido(self.valor * 1000) + +_chatbox = None + +class ChatBox(gtk.HBox): + def __init__(self): + super(ChatBox, self).__init__() + self.set_size_request(settings.BUTTON_SIZE, settings.BUTTON_SIZE) + + def add_card(self, tarjeta): + tarjeta.refresh_image() + tarjeta.show() + self.pack_start(tarjeta) + + def clear_box(self): + for child in this.get_children(): + child.remove() + + def play_sound(self): + for child in this.get_children(): + child.remove() + +def get_chat_box(): + global _chatbox + if _chatbox == None: + _chatbox = ChatBox() + return _chatbox + + +#if __name__ == '__main__': +# principal = gtk.Window(gtk.WINDOW_TOPLEVEL) +# principal.set_title('Prestame tu voz') +# tablebox = VentanaPrincipal() +# control = ControlBarrido(tablebox) +# chatbox = get_chat_box() +# sw = gtk.ScrolledWindow() +# +# sw.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_NEVER) +# sw.add(chatbox) +# sw.show() +# +# caja_principal = gtk.VBox() +# caja_principal.pack_start(control) +# caja_principal.pack_start(tablebox) +# caja_principal.pack_start(sw) +# +# principal.add(caja_principal) +# tablebox.show_all() +# control.show_all() +# chatbox.show_all() +# caja_principal.show_all() +# +# +# principal.show() +# principal.connect("delete_event", gtk.main_quit) +# gtk.main() diff --git a/PrestametuVoz.activity/grid.pyc b/PrestametuVoz.activity/grid.pyc new file mode 100644 index 0000000..6186069 --- /dev/null +++ b/PrestametuVoz.activity/grid.pyc Binary files differ diff --git a/PrestametuVoz.activity/icons/game-load.svg b/PrestametuVoz.activity/icons/game-load.svg new file mode 100644 index 0000000..4222b7a --- /dev/null +++ b/PrestametuVoz.activity/icons/game-load.svg @@ -0,0 +1,166 @@ + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PrestametuVoz.activity/icons/game-new.svg b/PrestametuVoz.activity/icons/game-new.svg new file mode 100644 index 0000000..b71ccc1 --- /dev/null +++ b/PrestametuVoz.activity/icons/game-new.svg @@ -0,0 +1,129 @@ + + +image/svg+xml + + + + + + + + + + \ No newline at end of file diff --git a/PrestametuVoz.activity/icons/game-save.svg b/PrestametuVoz.activity/icons/game-save.svg new file mode 100644 index 0000000..67742a7 --- /dev/null +++ b/PrestametuVoz.activity/icons/game-save.svg @@ -0,0 +1,164 @@ + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PrestametuVoz.activity/icons/media-audio.svg b/PrestametuVoz.activity/icons/media-audio.svg new file mode 100755 index 0000000..a78405f --- /dev/null +++ b/PrestametuVoz.activity/icons/media-audio.svg @@ -0,0 +1,10 @@ + + +]> + + + + + + \ No newline at end of file diff --git a/PrestametuVoz.activity/icons/media-photo.svg b/PrestametuVoz.activity/icons/media-photo.svg new file mode 100755 index 0000000..a3a81e7 --- /dev/null +++ b/PrestametuVoz.activity/icons/media-photo.svg @@ -0,0 +1,12 @@ + + +]> + + + + + + + + \ No newline at end of file diff --git a/PrestametuVoz.activity/icons/media-record-red.png b/PrestametuVoz.activity/icons/media-record-red.png new file mode 100755 index 0000000..289b54a --- /dev/null +++ b/PrestametuVoz.activity/icons/media-record-red.png Binary files differ diff --git a/PrestametuVoz.activity/icons/media-record.png b/PrestametuVoz.activity/icons/media-record.png new file mode 100755 index 0000000..41be533 --- /dev/null +++ b/PrestametuVoz.activity/icons/media-record.png Binary files differ diff --git a/PrestametuVoz.activity/icons/media-video.svg b/PrestametuVoz.activity/icons/media-video.svg new file mode 100755 index 0000000..7f87d04 --- /dev/null +++ b/PrestametuVoz.activity/icons/media-video.svg @@ -0,0 +1,11 @@ + + +]> + + + + + + + \ No newline at end of file diff --git a/PrestametuVoz.activity/icons/sin_foto.png b/PrestametuVoz.activity/icons/sin_foto.png new file mode 100755 index 0000000..63f76b3 --- /dev/null +++ b/PrestametuVoz.activity/icons/sin_foto.png Binary files differ diff --git a/PrestametuVoz.activity/instance.py b/PrestametuVoz.activity/instance.py new file mode 100755 index 0000000..a4b1303 --- /dev/null +++ b/PrestametuVoz.activity/instance.py @@ -0,0 +1,48 @@ +import os + +from sugar import profile +from sugar import util +from sugar.activity import activity +import shutil + +from color import Color + +class Instance: + key = profile.get_pubkey() + if hasattr(util, '_sha_data'): + # sugar-0.82 and previous + keyHash = util._sha_data(key) + else: + keyHash = util.sha_data(key) + + keyHashPrintable = util.printable_hash(keyHash) + nickName = profile.get_nick_name() + + colorFill = Color() + colorFill.init_hex( profile.get_color().get_fill_color() ) + colorStroke = Color() + colorStroke.init_hex( profile.get_color().get_stroke_color() ) + + instanceId = None + instancePath = None + dataPath = None + + def __init__(self, ca): + self.__class__.instanceId = ca._activity_id + + self.__class__.instancePath = os.path.join(ca.get_activity_root(), "instance") + recreateTmp() + + self.__class__.dataPath = os.path.join(ca.get_activity_root(), "data") + recreateData() + + +def recreateTmp(): + if (not os.path.exists(Instance.instancePath)): + os.makedirs(Instance.instancePath) + + +def recreateData(): + if (not os.path.exists(Instance.dataPath)): + os.makedirs(Instance.dataPath) + diff --git a/PrestametuVoz.activity/instance.pyc b/PrestametuVoz.activity/instance.pyc new file mode 100755 index 0000000..56b6285 --- /dev/null +++ b/PrestametuVoz.activity/instance.pyc Binary files differ diff --git a/PrestametuVoz.activity/manejar_datos.py b/PrestametuVoz.activity/manejar_datos.py new file mode 100755 index 0000000..e29a9b3 --- /dev/null +++ b/PrestametuVoz.activity/manejar_datos.py @@ -0,0 +1,98 @@ +#!/usr/bin/python +# -*- coding: iso-8859-1 -*- +''' Lee y carga los archivos ''' + +#Copyright (C) 2009 Federico Moreira - +# Alejandro Esperón - +# Esteban Arias - +# +# 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 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +import os +from os import environ, makedirs, chmod +from os.path import join, basename, isdir, split, normpath +import zipfile +import tempfile +import simplejson as json + +from sugar.activity import activity +from tarjeta import Tarjeta + + +def guardar_datos(archivo, lista_completa): + ''' Leo los datos que me pasan y los guardo en la base ''' + lista =[] + for item in lista_completa: + i = {} + i['titulo'] = item.titulo + i['imagen'] = item.imagen + i['audio'] = item.audio + lista.append(i) + try: + a = open(os.path.join('data', archivo), 'w' ) + json.dump(lista, a) + except IOError, error: + print error + finally: + a.close() + +def cargar_datos(archivo): + ''' Leo los datos de la base y los devuelvo en una lista ''' + try: + #carga demo luego modificar para multiples planillas... + game_file = os.path.join(os.path.dirname(__file__), 'demos', archivo+'.zip') + + tmp_root = os.path.join(environ['SUGAR_ACTIVITY_ROOT'], 'instance') + temp_folder = tempfile.mkdtemp(dir=tmp_root) + chmod(temp_folder, 0777) + + ''' extracts files in the zip file ''' + game_name = basename(game_file)[:-4] + zipFile = zipfile.ZipFile(game_file, "r") + for each in zipFile.namelist(): + if not each.endswith('/'): + root, name = split(each) + directory = normpath(os.path.join(temp_folder, root)) + if not isdir(directory): + makedirs(directory) + file(os.path.join(directory, name), 'wb').write(zipFile.read(each)) + + print 'RUTA: ' + os.path.join(temp_folder, 'data', archivo) + a = open(os.path.join(temp_folder, 'data', archivo)) + + l = json.load(a) + lista = [] + for item in l: + card = Tarjeta() + card.titulo = item['titulo'] + card.imagen = os.path.join(temp_folder, item['imagen']) + card.audio = os.path.join(temp_folder, item['audio']) + lista.append(card) + a.close() + except IOError, error: + print error + #finally: + # a.close() + return lista + +def cargar_planillas(archivo): + ''' Carga las plantillas ''' + try: + archivo = open(archivo) + lista = archivo.readlines() + except IOError, error: + print error + finally: + archivo.close() + return lista diff --git a/PrestametuVoz.activity/manejar_datos.pyc b/PrestametuVoz.activity/manejar_datos.pyc new file mode 100755 index 0000000..195ac0a --- /dev/null +++ b/PrestametuVoz.activity/manejar_datos.pyc Binary files differ diff --git a/PrestametuVoz.activity/planillas/planillas.txt b/PrestametuVoz.activity/planillas/planillas.txt new file mode 100755 index 0000000..e9f9e1a --- /dev/null +++ b/PrestametuVoz.activity/planillas/planillas.txt @@ -0,0 +1 @@ +fede2 diff --git a/PrestametuVoz.activity/prestame_tu_voz.py b/PrestametuVoz.activity/prestame_tu_voz.py new file mode 100755 index 0000000..572d714 --- /dev/null +++ b/PrestametuVoz.activity/prestame_tu_voz.py @@ -0,0 +1,88 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +#Copyright (C) 2010 Federico Moreira - +# Alejandro Esperón - +# Esteban Arias - +# +# 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 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + + +import gtk +from gettext import gettext as _ +from sugar.activity.activity import Activity, ActivityToolbox + +from toolbar import ConfigToolbar +import grid +import config_nuevo + +_TOOLBAR_CONFIG = 1 + +class PrestameTuVozActivity(Activity): + + def __init__(self, handle): + Activity.__init__(self, handle) + + self.config_load = False + + toolbox = ActivityToolbox(self) + + toolbar_config = ConfigToolbar(toolbox, self) + toolbox.add_toolbar(_('Configuration'), toolbar_config) + toolbar_config.show() + + self.set_toolbox(toolbox) + toolbox.show() + + self.lista_tarjetas =[] + self.pos_actual = 0 + self.recording = False + self.rec_process = None + + self.mainbox = gtk.VBox() + #self.mainbox.pack_start(self.image) + + self.tablebox = grid.VentanaPrincipal() + self.control = grid.ControlBarrido(self.tablebox) + self.chatbox = grid.get_chat_box() + self.tablebox.show_all() + self.control.show_all() + self.chatbox.show_all() + self.mainbox.pack_start(self.control) + self.mainbox.pack_start(self.tablebox) + self.mainbox.pack_start(self.chatbox) + + self.set_canvas(self.mainbox) + self.mainbox.show_all() + + self.toolbox.connect('current-toolbar-changed', self.change_mode) + + def change_mode(self, notebook, index): + if index == _TOOLBAR_CONFIG: + if not self.config_load: + self.config_load = True + self.mainbox.remove(self.control) + self.mainbox.remove(self.tablebox) + self.mainbox.remove(self.chatbox) + + self.ventana_config = config_nuevo.VentanaConfig() + self.mainbox.pack_start(self.ventana_config) + self.ventana_config.show_all() + + else: + self.mainbox.remove(self.ventana_config) + + self.mainbox.pack_start(self.control) + self.mainbox.pack_start(self.tablebox) + self.mainbox.pack_start(self.chatbox) + diff --git a/PrestametuVoz.activity/prestame_tu_voz.pyc b/PrestametuVoz.activity/prestame_tu_voz.pyc new file mode 100755 index 0000000..c9c22d5 --- /dev/null +++ b/PrestametuVoz.activity/prestame_tu_voz.pyc Binary files differ diff --git a/PrestametuVoz.activity/settings.py b/PrestametuVoz.activity/settings.py new file mode 100644 index 0000000..0847fcd --- /dev/null +++ b/PrestametuVoz.activity/settings.py @@ -0,0 +1,11 @@ +from sugar.graphics import style + +def _get_button_size(): + if style._compute_zoom_factor() == 0.72: + return 100 + return 150 + +TABLA_ALTO = 3 +TABLA_ANCHO = 4 + +BUTTON_SIZE = _get_button_size() diff --git a/PrestametuVoz.activity/settings.pyc b/PrestametuVoz.activity/settings.pyc new file mode 100644 index 0000000..3792844 --- /dev/null +++ b/PrestametuVoz.activity/settings.pyc Binary files differ diff --git a/PrestametuVoz.activity/setup.py b/PrestametuVoz.activity/setup.py new file mode 100755 index 0000000..6ed89aa --- /dev/null +++ b/PrestametuVoz.activity/setup.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +from sugar.activity import bundlebuilder +bundlebuilder.start() + diff --git a/PrestametuVoz.activity/sonido.py b/PrestametuVoz.activity/sonido.py new file mode 100644 index 0000000..8d933c1 --- /dev/null +++ b/PrestametuVoz.activity/sonido.py @@ -0,0 +1,42 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- +''' Función para reproducir sonido ''' + +import pygst +#pygst.require("0.10") +import sys, gst, gobject + +gobject.threads_init() + +def reproducir(sonido): + ''' Reproduce el sonido mediante pygst ''' + + pipestr = "filesrc location= %s ! oggdemux ! vorbisdec ! audioconvert ! alsasink" % sonido + + try: + pipeline = gst.parse_launch(pipestr) + except gobject.GError, e: + print "No se pudo crear tubería,", str(e) + return -1 + + def eventos(bus, msg): + t = msg.type + if t == gst.MESSAGE_EOS: + loop.quit() + elif t == gst.MESSAGE_ERROR: + e, d = msg.parse_error() + print "ERROR:", e + loop.quit() + return True + + pipeline.get_bus().add_watch(eventos) + pipeline.set_state(gst.STATE_PLAYING) + loop = gobject.MainLoop() + try: + loop.run() + except KeyboardInterrupt: + pass + pipeline.set_state(gst.STATE_NULL) + return 0 + + diff --git a/PrestametuVoz.activity/sonido.pyc b/PrestametuVoz.activity/sonido.pyc new file mode 100644 index 0000000..081abeb --- /dev/null +++ b/PrestametuVoz.activity/sonido.pyc Binary files differ diff --git a/PrestametuVoz.activity/tarjeta.py b/PrestametuVoz.activity/tarjeta.py new file mode 100755 index 0000000..929d91c --- /dev/null +++ b/PrestametuVoz.activity/tarjeta.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +''' Clase de la Tarjeta''' + +#Copyright (C) 2009 Federico Moreira - +# Alejandro Esperón - +# +# 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 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +import gtk +import os + +class Tarjeta(gtk.Button): + ''' + Clase Tarjeta: + -------------- + + titulo --> Nombre de la tarjeta, aparece arriba de la imagen + imagen --> Imagen que se le agrega al botón al cargar el archivo + audio --> Audio que se reproduce al hacer click en la imagen + hijo --> En caso de que la accion sea la de cargar una nueva + plantilla aqui iria el nombre de la plantilla o la + posicion de la que se encuentra si tarian cargadas + en listas desde inicio. + '' = Uso normal, reproduccion de sonido + n = numero de plantilla (o nombre) + padre --> Desde donde viene, ya que seria necesario para retornar + a la plantilla anterior, dependeria si hijo tuviera algo + + ''' + + def __init__(self, titulo='', imagen='', audio='', hijo='', padre=''): + super(Tarjeta, self).__init__() + self.titulo = titulo + self.audio = audio + self.imagen = imagen + self.hijo = hijo + self.padre = padre + + def refresh_image(self): + imagen = gtk.Image() + imagen.set_from_file(os.path.join(os.getcwd(), self.imagen)) + self.set_image(imagen) diff --git a/PrestametuVoz.activity/tarjeta.pyc b/PrestametuVoz.activity/tarjeta.pyc new file mode 100755 index 0000000..0d942eb --- /dev/null +++ b/PrestametuVoz.activity/tarjeta.pyc Binary files differ diff --git a/PrestametuVoz.activity/toolbar.py b/PrestametuVoz.activity/toolbar.py new file mode 100755 index 0000000..9fa0e37 --- /dev/null +++ b/PrestametuVoz.activity/toolbar.py @@ -0,0 +1,74 @@ +# Copyright (C) 2010, Plan Ceibal +# -*- coding: utf-8 -*- +from gettext import gettext as _ +import logging +import os +import time +import gtk + +from instance import Instance +from sugar.graphics.icon import Icon +from sugar.graphics.toolbutton import ToolButton +from sugar.graphics.toggletoolbutton import ToggleToolButton +from sugar.graphics.combobox import ComboBox +from sugar.graphics.toolcombobox import ToolComboBox +from sugar.graphics.objectchooser import ObjectChooser +from sugar.graphics import iconentry +from sugar.activity.activity import ActivityToolbar +from sugar.activity.activity import EditToolbar +from sugar.graphics.menuitem import MenuItem +from sugar.datastore import datastore + +import sugar.profile + + +#ick +TOOLBAR_ACTIVITY = 0 +TOOLBAR_CONFIG = 1 + +class ConfigToolbar(gtk.Toolbar): + __gtype_name__ = 'PrestametuvozToolbar' + + def __init__(self, toolbox, parent): + gtk.Toolbar.__init__(self) + + self._toolbox = toolbox + self._parent = parent + + self._btn_game_load = ToolButton('game-load') + self._btn_game_load.get_icon_widget().set_property( 'fill-color', Instance.colorFill.hex ) + self._btn_game_load.set_tooltip(_('Load')) + self._btn_game_load_id = self._btn_game_load.connect('clicked', self._game_load) + self.insert(self._btn_game_load, -1) + self._btn_game_load.show() + + self._btn_game_new = ToolButton('game-new') + self._btn_game_new.get_icon_widget().set_property( 'fill-color', Instance.colorFill.hex ) + self._btn_game_new.set_tooltip(_('Create')) + self._btn_game_new_id = self._btn_game_new.connect('clicked', self._game_new) + self.insert(self._btn_game_new, -1) + self._btn_game_new.show() + +# self._btn_game_save = ToolButton('save-load') +# self._btn_game_save.get_icon_widget().set_property( 'fill-color', Instance.colorFill.hex ) +# self._btn_game_save.set_tooltip(_('Save')) +# self._btn_game_save_id = self._btn_game_save.connect('clicked', self._game_save) +# self.insert(self._btn_game_save, -1) +# self._btn_game_save.show() + + separator_photo = gtk.SeparatorToolItem() + separator_photo.set_draw(True) + separator_photo.show() + self.insert(separator_photo, -1) + + def _game_load(self, *args): + pass + + def _game_new(self, *args): + pass + +# def _game_save(self, *args): +# pass + + + diff --git a/PrestametuVoz.activity/toolbar.pyc b/PrestametuVoz.activity/toolbar.pyc new file mode 100755 index 0000000..8f6970a --- /dev/null +++ b/PrestametuVoz.activity/toolbar.pyc Binary files differ -- cgit v0.9.1