Exemplo n.º 1
0
    def __init__(self):

        Configurator.__init__(self)

        self.__vbox = VBox()
        self.__vbox.set_spacing(12)
        self.add(self.__vbox)

        lbl = Label("Voice:", theme.font_mb_plain,
                    theme.color_mb_listitem_text)
        self.__vbox.add(lbl)

        hbox = HBox()
        hbox.set_size(600, 80)
        self.__vbox.add(hbox)

        current_voice = config.get_voice()
        chbox = ChoiceBox("Male A", "m1", "Male B", "m2", "Male C", "m3",
                          "Male D", "m4", "Female A", "f1", "Female B", "f2",
                          "Female C", "f3", "Female D", "f4", "Whisper",
                          "whisper")
        chbox.select_by_value(current_voice)
        chbox.connect_changed(self.__on_select_voice)
        hbox.add(chbox)

        button = Button("Test Voice")
        button.connect_clicked(self.__on_test_voice)
        hbox.add(button)

        pitch = config.get_pitch()
        self.__lbl_pitch = Label("Pitch: %d" % pitch, theme.font_mb_plain,
                                 theme.color_mb_listitem_text)
        self.__vbox.add(self.__lbl_pitch)

        slider = Slider(theme.mb_slider_gauge)
        slider.set_background_color(theme.color_mb_gauge)
        slider.connect_value_changed(self.__on_set_pitch)
        slider.set_value(pitch / 99.0)
        slider.set_size(600, 40)
        self.__vbox.add(slider)

        speed = config.get_speed()
        self.__lbl_speed = Label("Words per minute: %d" % speed,
                                 theme.font_mb_plain,
                                 theme.color_mb_listitem_text)
        self.__vbox.add(self.__lbl_speed)

        slider = Slider(theme.mb_slider_gauge)
        slider.set_background_color(theme.color_mb_gauge)
        slider.connect_value_changed(self.__on_set_speed)
        slider.set_value((speed - 80) / 290.0)
        slider.set_size(600, 40)
        self.__vbox.add(slider)

        lbl = Label(
            "Talk Navigation powered by espeak - http://espeak.sourceforge.net",
            theme.font_mb_tiny, theme.color_mb_listitem_text)
        self.__vbox.add(lbl)
Exemplo n.º 2
0
    def guardar(self):
        default_config = config.global_config
        if os.path.exists(self.home_mos.get_text()):
            default_config["home"] = self.home_mos.get_text()
        if os.path.exists(self.aud_dir.get_text()):
            default_config["aud_dir"] = self.aud_dir.get_text()
        if os.path.exists(self.im_dir.get_text()):
            default_config["im_dir"] = self.im_dir.get_text()
        if os.path.exists(self.mos_dir.get_text()):
            default_config["mos_dir"] = self.mos_dir.get_text()
        if os.path.exists(self.save_dir.get_text()):
            default_config["save_dir"] = self.save_dir.get_text()

        default_config["sender_email"] = self.sender.get_text()
        if self.sender.get_text().find("@") != -1:
            default_config["usuario"] = self.sender.get_text().split("@")[0]
        default_config["password"] = base64.b64encode(self.password.get_text())
        default_config["smtpserver"] = self.smtpserver.get_text()
        default_config["encabezado"] = self.cabecera.get_text()
        default_config["tls"] = self.tls.get_active()
        default_config["remember_session"] = self.save_session.get_active()
        default_config["selfcleaner"] = self.cleaner.get_active()
        default_config["selfspace"] = self.spacer.get_active()
        default_config["eco"] = self.eco.get_active()

        model = self.lang.get_model()
        active = self.lang.get_active()
        default_config["idioma"] = model[active][0]

        # default_config["user"] = self.user.get_text()
        cfont = (self.colorfont.get_color().red, self.colorfont.get_color().green, self.colorfont.get_color().blue)
        cbackg = (self.colorback.get_color().red, self.colorback.get_color().green, self.colorback.get_color().blue)
        default_config["color_letra"] = tohex(cfont)
        default_config["color_fondo"] = tohex(cbackg)
        default_config["tipo_letra"] = self.fontbutton.get_font_name()[:-2]
        default_config["size_letra"] = int(self.fontbutton.get_font_name()[-2:])
        default_config["size_imagen"] = int(self.hscale.get_value())
        default_config["espaciado"] = self.espaciado.get_value_as_int()
        prefs = gconf_prefs.AutoPrefs("/apps/compi/", default_config)
        config.global_config = default_config
        prefs.gconf_save()

        voice = config.get_voice()
        if voice:
            config.player.set_voice(voice)
Exemplo n.º 3
0
    def __init__(self):
        """
        Constructor de la clase
        """
        # Read default config from gconf
        default_config = config.global_config
        if default_config["remember_session"]:
            self.session = config.last_session
        else:
            self.session = config.default_session
        #print default_config
        
        # Create the window
        self.window = gtk.Window()
        self.window.set_icon_from_file("/usr/share/pixmaps/mosaico.png")
        self.window.set_title(name + " " + version)
        self.window.set_default_size(800,432)
        self.window.set_border_width(1)
        #self.window.move(50,50)
        self.window.connect("delete_event", self.salir)
        

        # Create a UIManager instance
        uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        self.window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('UIManageExample')
        self.actiongroup = actiongroup

        # Create a ToggleAction, etc.
        actiongroup.add_toggle_actions([('Mute', gtk.STOCK_STOP, _('Silenciar'), None,
                        _('Silenciar sonido'), self.mute),
                        ('Pantalla',None,_('Pantalla completa'), '<Control>f', '', self.pantalla_completa)])

        # Create actions
        actiongroup.add_actions([('Quit', gtk.STOCK_QUIT, _('Salir'), None,
                    'Cerrar el programa', self.salir),
                    
                    ('File', None, _('_Archivo')),
                    
                    ('New', gtk.STOCK_NEW, _('Nuevo'), None,
                    _('Crear un nuevo mosaico'), self.nuevo_mosaico),
                    
                    ('Open', gtk.STOCK_OPEN, _('Abrir'), None, 
                    _('Abrir un mosaico'), self.abrir),
                    
                    ('Save', gtk.STOCK_SAVE, _('Guardar'), None, 
                    _('Guardar los cambios del mosaico actual'), self.guardar),
                    
                    ('Save as', gtk.STOCK_SAVE_AS, _('Guardar como'), None, 
                    _('Guardar el mosaico actual'), self.guardar_como),
                    
                    ('Print', None, _('Imprimir')),
                    
                    ('Properties', gtk.STOCK_PROPERTIES, _('Propiedades'), 
                    None, '', self.properties),
                    
                    ('Preferences', gtk.STOCK_PREFERENCES, _('Opciones'), 
                    None, '', self.preferences),
                    
                    ('Close', gtk.STOCK_CLOSE, _('Cerrar'), None,
                    _('Cerrar mosaico actual'), self.cerrar_mosaico),
                    
                    ('Format', None, _('Formato'), None, '', self.format),
                    
                    ('Add row', gtk.STOCK_ADD, _('Insertar fila'),None,
                    _('Insertar una fila'), self.insertar_fila),
                    
                    ('Add column', gtk.STOCK_ADD, _('Insertar columna'),None,
                    _('Insertar una columna'), self.insertar_columna),
                    
                    ('Delete row', gtk.STOCK_REMOVE, _('Eliminar fila'),None,
                    _('Eliminar la última fila'), self.eliminar_fila),
                    
                    ('Delete column', gtk.STOCK_REMOVE, _('Eliminar columna'),None,
                    _('Eliminar la última columna'), self.eliminar_columna),
                    
                    ('Mensaje', None, _('Mensaje'),None,
                    _('Visualizar el area de mensajes'), self.mostrar_out),
                    
                    ('Barra de herramientas', None, _('Barra de herramientas'),None,
                    _('Visualizar la barra de herramientas'), self.mostrar_toolbar),
                    
                    ('Cambiar vista', None, _('Cambiar vista'),None,
                    _(u'Intercambiar modo texto/gráfico'), self.cambiar_vista),
                    
                    ('Herramientas',None,_('Herramientas')),
                    
                    ('Vista', gtk.STOCK_REFRESH, _('Cambiar _modo'), 
                    '<Control>m', _('Cambia entre los modos texto e imagen')
                    , self.cambiar_vista),
                    
                    ('Leer todo', None, _('Leer _todo'), None, 
                    _('Leer el mensaje generado'), self.leer_todo),
                    
                    ('Leer última', None, _('Leer _ultima'), None, 
                    _('Leer ultima palabra escrita'), self.leer_ultima),
                    
                    ('Leer último', None, _('Leer _ultimo'), None, 
                    _('Leer el ultimo pulsado'), self.leer_ultimo),
                    
                    ('Borrar todo', None, _('Borrar todo'),None,
                    '', self.borrar_todo),
                    
                    ('Borrar caracter', None, _('Borrar caracter'),None,
                    '', self.borrar_caracter),
                    
                    ('Borrar palabra', None, _('Borrar palabra'),None,
                    '', self.borrar_palabra),
                    
                    ('Borrar último', None, _('Borrar _ultimo'),None,
                    '', self.borrar_ultimo),
                    
                    ('Previous', gtk.STOCK_GO_BACK, _('Mosaico anterior'),None,
                    _('Ir al mosaico anterior'), self.previous),
                    
                    ('Mail', gtk.STOCK_NETWORK, _('Enviar correo'),None,
                    _('Enviar mensaje por correo electrónico'), self.select_contact),
                    
                    ('Next', gtk.STOCK_GO_FORWARD, _('Mosaico siguiente'),None,
                    _('Ir al siguiente mosaico'), self.next),
                    
                    ('Start', gtk.STOCK_HOME, _('Ir al Inicio'),None,
                    _('Ir al inicio'), self.start),
                    
                    ('Ver', None, _('_Ver')),
                    
                    ('Ayuda', None, _('A_yuda')),
                    
                    ('Editar', None, _('_Editar')),
                    
                    ('Pagina Web', None, _('Pagina Web')),
                    
                    ('Acerca de', gtk.STOCK_ABOUT, _('Acerca de')
                    ,None, _('Información del programa'), self.about)])

        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI description
        uimanager.add_ui_from_string(config.ui)

        # Create a MenuBar
        self.menubar = uimanager.get_widget('/MenuBar')
        # Create a Toolbar
        self.toolbar = uimanager.get_widget('/Toolbar')
        #self.acciones1 = uimanager.get_widget('/AccionesTexto')
        #self.acciones2 = uimanager.get_widget('/AccionesImagenes')
        # Create navigationbar
        #self.navbar = uimanager.get_widget('/Acciones')

        # Create area for mosaics
        self.notebook = gtk.Notebook()
        self.notebook.set_tab_pos(gtk.POS_TOP)
        self.notebook.set_scrollable(True)

        # Create buttons
        do = gtk.Button(_("Leer todo"), gtk.STOCK_MEDIA_PLAY)
        do.connect("clicked", self.leer_todo)
        remove = gtk.Button(_("Borrar último"), gtk.STOCK_REMOVE)
        remove.connect("clicked", self.borrar)
        clean = gtk.Button(_("Limpiar"), gtk.STOCK_DELETE)
        clean.connect("clicked", self.borrar_todo)
        #vol = gtk.VolumeButton()
        #vol.set_value(self.session["volume"]/100.0)
        #vol.connect("popup", self.read_vol)
        #vol.connect("value-changed", self.set_volume)

        # Create area for messages (text mode)
        self.tv = gtk.TextView()
        self.tv.set_editable(True)
        self.tv.get_cursor_visible()
        font_desc = pango.FontDescription("%s %d" % (default_config["tipo_letra"], default_config["size_letra"]*2))
        self.tv.modify_font(font_desc)
        sw = gtk.ScrolledWindow()
        sw.set_size_request(300, 80)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self.tv)
        self.salida1 = gtk.Frame(_("Modo texto"))
        self.salida1.add(sw)
        self.out = {}
        self.out["texto"] = self.tv.get_buffer()
        self.out["imagenes"] = []
        config.out = self.out #readable through other classes

        # Create area for messages (graphical mode)
        self.layout = gtk.Layout()
        self.out["layout"] = self.layout
        self.layout.set_size(580, 1000)
        self.sw2 = gtk.ScrolledWindow()
        self.sw2.set_size_request(300, 80)
        self.sw2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.sw2.add(self.layout)
        self.salida2 = gtk.Frame(_(u"Modo gráfico"))
        self.salida2.add(self.sw2)

        # General Box for all the widgets
        self.contenedor = gtk.VBox(False,0)
        self.outbox = gtk.HBox(False,1)
        self.delbox = gtk.VBox(False,1)
        self.contenedor.pack_start(self.menubar,False, False,0)
        self.contenedor.pack_start(self.toolbar,False,False,0)
        self.contenedor.pack_start(self.notebook,True, True,5)
        #self.contenedor.pack_start(self.navbar,False, True,2)
        self.delbox.pack_start(remove, False, False,1)
        self.delbox.pack_start(clean, False, False,1)
        #self.delbox.pack_start(vol, False, False,1)
        self.outbox.pack_start(self.salida1,True, True,0)
        self.outbox.pack_start(self.salida2,True, True,0)
        self.outbox.pack_start(do, False, False,1)
        #self.outbox.pack_start(self.delbox, False, False,1)
        self.contenedor.pack_start(self.outbox,False, False,0)
        
        self.window.add(self.contenedor)

        self.window.show_all()
        
        # Apply the last session
        self.aplicar_sesion()
        voice = config.get_voice()
        if voice:
            config.player.set_voice(voice)
        
        # Open initial mosaic
        self.opened_mos = ["",]
        if default_config["home"] and os.path.exists(default_config["home"]): 
            self.abrir(None, default_config["home"])
        if self.session["opened"]:
            for m in eval(self.session["opened"]):
                if isinstance(m, str) and os.path.exists(m): self.abrir(None, m)
        
        config.base = self