<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" 
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" 
   xmlns:html="http://www.w3.org/1999/html" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
   <title>Fer's blog</title>
   <link>http://www.gnome.org/~fherrera/blog</link>
   <description>fer, ferulo, that crazy man</description>
   <language>en</language>
   <copyright>Copyright 2006 Fernando Herrera</copyright>
   <ttl>60</ttl>
   <pubDate>Sun, 29 Oct 2006 10:55 GMT</pubDate>
   <managingEditor>fherrera@onirica.com</managingEditor>
   <generator>PyBlosxom http://pyblosxom.sourceforge.net/ 1.3.2 2/13/2006</generator>
<item>
   <title>Scripting your desktop with dogtail</title>
   <guid isPermaLink="false">Scripting_with_dogtail</guid>
   <link>http://www.gnome.org/~fherrera/blog/Scripting_with_dogtail.html</link>
   <description><![CDATA[
<p>Today I was preparing some slides for my upcoming talks at <a href="http://2006.encuentrolinux.cl/">7th Encuentro Linux 2006</a> in Chile. I had planned to use some music in sync with some slides. However embbeding music in OpenOffice Impress is not easy. Also I'd prefer to use a PDF with evince in presentation mode. Solution? Using evince for display slides and totem for playing the music, both syncronized using a dogtail script. Here are the fundamentals:<br/>Guess what page evince is displaying from:<br/><center><img src="http://www.gnome.org/~fherrera/img/evince-page-number.png" border="0" /></center><br/>If the page has changed, check in an array if the new slide has music. If no music associated, press pause button on totem. If music associated, search totem playlist for the song and press play button. That's all: 30 lines of python where you can embbed your music array:<br/><pre>#!/usr/bin/python


import gtk
from dogtail.tree import root

music = {}
music['3'] = '03. Nina Simone - Pirate Jenny'
music['5'] = '04-raimon - diguem no.mp3'

current = '0'

def check_music():
        global music, page, play, totem, current

        if current == page.text:
                return True
        else:
                current = page.text


        if music.has_key(page.text):
                entry = totem.child(roleName='table cell', name=music[page.text])
                entry.doAction('activate')
                if play.name == 'gtk-media-play':
                        play.click()
        else:
                if play.name == 'gtk-media-pause':
                        play.click()

        return True


evince = root.application('evince')
toolbar = evince.child(roleName='tool bar')
page = toolbar.child(roleName='text')

totem = root.application('totem')
play = totem.child(name='gtk-media-play')

tag = gtk.timeout_add (500, check_music)

gtk.main()
</pre><br/>Next improvement would be adding a gui for creating playlists, associating PDF presentation and slides, lauching evince and launching totem with the created playlist</p>

]]></description>
   <category domain="http://www.gnome.org/~fherrera/blog">main</category>
   <pubDate>Sun, 29 Oct 2006 10:55 GMT</pubDate>
</item>
</channel>
</rss>
