<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eurion · RainCT&#039;s Blog &#187; gtk</title>
	<atom:link href="http://bloc.eurion.net/archives/tag/gtk/feed/" rel="self" type="application/rss+xml" />
	<link>http://bloc.eurion.net</link>
	<description>I would love to change the world, but they won&#039;t give me the source code...</description>
	<lastBuildDate>Sun, 29 Jan 2012 13:23:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>espeak-gui 0.2</title>
		<link>http://bloc.eurion.net/archives/2010/espeak-gui-0-2/</link>
		<comments>http://bloc.eurion.net/archives/2010/espeak-gui-0-2/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 20:10:26 +0000</pubDate>
		<dc:creator>RainCT</dc:creator>
				<category><![CDATA[Planet GNOME]]></category>
		<category><![CDATA[Planet Ubuntu]]></category>
		<category><![CDATA[Planet Ubuntu.cat]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[Programari lliure]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[speech-synthesis]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://bloc.eurion.net/?p=470</guid>
		<description><![CDATA[Yesterday I did a first release of espeak-gui, so while I&#8217;m still in practice I&#8217;ve decided to get out a second one! The main changes are fixing a crash bug and&#8230; internationalization support. So, if you like this project but you&#8217;re not a coder, now you&#8217;ve got a way to contribute: translating it into your [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I did a first release of <a href="http://bloc.eurion.net/archives/2010/introducing-espeak-gui/">espeak-gui</a>, so while I&#8217;m still in practice I&#8217;ve decided to get out a second one!</p>
<p>The main changes are fixing a crash bug and&#8230; internationalization support. So, if you like this project but you&#8217;re not a coder, now you&#8217;ve got a way to contribute: <a href="https://translations.launchpad.net/espeak-gui">translating it into your language</a> (come on, it only has a few strings! :)).</p>
<p>The new version is already in <a href="https://launchpad.net/~rainct/+archive/voice/">my PPA</a>: <a href="https://launchpad.net/~rainct/+archive/voice/+files/espeak-gui_0.2-0ubuntu1~ppa1_all.deb">espeak-gui_0.2-0ubuntu1~ppa1_all.deb</a>. A tarball is also available, and the installation instructions are the following:</p>
<pre>$ wget -c <a href="http://launchpad.net/espeak-gui/trunk/0.2/+download/espeak-gui-0.2.tar.gz">http://launchpad.net/espeak-gui/trunk/0.2/+download/espeak-gui-0.2.tar.gz</a>
$ tar -xzvf espeak-gui-0.2.tar.gz; cd espeak-gui-0.2
$ python setup.py build
$ sudo python setup.py install</pre>
<p>In case you didn&#8217;t already have the previous version, you&#8217;ll also need to install the <a href="https://launchpad.net/python-espeak">python-espeak</a> module, for which there are also .deb&#8217;s (<a href="https://launchpad.net/~rainct/+archive/voice/+files/python-espeak_0.0ubuntu1~ppa1_i386.deb">i386</a>, <a href="https://launchpad.net/~rainct/+archive/voice/+files/python-espeak_0.0ubuntu1~ppa1_amd64.deb">amd64</a>) or the manual installation option like explained in my <a href="http://bloc.eurion.net/archives/2010/introducing-espeak-gui/">previous post</a>:</p>
<pre>$ bzr get lp:python-espeak
$ cd python-espeak
$ python setup.py build
$ sudo python setup.py install</pre>
<p>Here are the contents of the NEWS file:</p>
<pre>2010-01-02: Version 0.2
-----------------------

 - Fixed a crash happening when there was no voice language set in
   gconf (LP: 502253). [Reported by Rugby471]
 - Added a "Plain text" filter to the Open/Save dialogues.
 - Added internationalization support.
 - Added a manpage and a gconf schemas file.
 - A couple little user interface improvements.

Translations: Catalan.</pre>
<p>Related posts:<ol>
<li><a href='http://bloc.eurion.net/archives/2010/introducing-espeak-gui/' rel='bookmark' title='Introducing espeak-gui'>Introducing espeak-gui</a> <small>I&#8217;m joining the hype of presenting little new projects there...</small></li>
<li><a href='http://bloc.eurion.net/archives/2010/gnome-activity-journal-and-installing-it-on-ubuntu/' rel='bookmark' title='GNOME Activity Journal, and installing it on Ubuntu'>GNOME Activity Journal, and installing it on Ubuntu</a> <small>As already announced by Seif, the first development release of...</small></li>
<li><a href='http://bloc.eurion.net/archives/2009/zeitgeist-api-02/' rel='bookmark' title='Introduction to Zeitgeist 0.2&#8242;s API'>Introduction to Zeitgeist 0.2&#8242;s API</a> <small>So now that Zeitgeist 0.2.0 is out I&#8217;ve thought I&#8217;d...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://bloc.eurion.net/archives/2010/espeak-gui-0-2/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Introducing espeak-gui</title>
		<link>http://bloc.eurion.net/archives/2010/introducing-espeak-gui/</link>
		<comments>http://bloc.eurion.net/archives/2010/introducing-espeak-gui/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 21:33:36 +0000</pubDate>
		<dc:creator>RainCT</dc:creator>
				<category><![CDATA[Planet GNOME]]></category>
		<category><![CDATA[Planet Ubuntu]]></category>
		<category><![CDATA[Planet Ubuntu.cat]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[Programari lliure]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[speech-synthesis]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://bloc.eurion.net/?p=463</guid>
		<description><![CDATA[I&#8217;m joining the hype of presenting little new projects there seems to be those days, unleashing the first version of espeak-gui, a graphical interface to let the computer read out text. Why, when, who? The project started almost a year ago when, out of curiosity on what writing Python bindings for C/C++ libraries is like, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://bloc.eurion.net/wp-content/uploads/2010/01/espeak-gui-0.1.png"><img class="size-medium wp-image-464 alignright" title="Screenshot of espeak-gui (version 0.1)" src="http://bloc.eurion.net/wp-content/uploads/2010/01/espeak-gui-0.1-300x180.png" alt="" width="300" height="180" /></a>I&#8217;m joining the hype of presenting little new projects there seems to be those days, unleashing the first version of <a href="https://launchpad.net/espeak-gui">espeak-gui</a>, a graphical interface to let the computer read out text.</p>
<p><strong>Why, when, who?</strong></p>
<p>The project started almost a year ago when, out of curiosity on what writing Python bindings for C/C++ libraries is like, I started <a href="https://launchpad.net/python-espeak">python-espeak</a>, bindings for the espeak speech synthesizer (which, by the way, comes installed by default on Ubuntu and many other distributions).</p>
<p>It turned out that writing bindings isn&#8217;t as funny as I thought so they haven&#8217;t advanced much since then, but the basic functionality was there and I felt the need for some application using those bindings, so that&#8217;s how I started <a href="https://launchpad.net/python-espeak">espeak-gui</a>.</p>
<p>Some months later, in true Free Software spirit, someone else -interested in an application like this for personal usage- found my code on Launchpad and got in touch with me, providing me with quite some nice patches. Thank you, <a href="https://launchpad.net/~joe-a-burmeister">Joe Burmeister</a>! However, I didn&#8217;t do any more work on it, as I&#8217;ve been busy with other projects (eg. <a href="http://zeitgeist-project.com/">Zeitgeist</a>), and development stalled there.</p>
<p>Now, another half a year later, I&#8217;ve finally got back to this and decided it&#8217;s time I push it out into the wild. So, after cleaning it up a bit more and implementing some new feature, here you have <a href="https://launchpad.net/espeak-gui">espeak-gui</a>!</p>
<p>(The bindings aren&#8217;t really encouraged for widespread usage at this point and I&#8217;ll probably end up rewriting them using <a href="http://www.swig.org/">SWIG</a> or something else; however, if you&#8217;re interested in using them please get in touch with me).</p>
<p><strong>Where do I get it?</strong></p>
<p>If you&#8217;re using Ubuntu or Debian, you can find a <a href="https://launchpad.net/~rainct/+archive/voice/+packages">packages for python-espeak and espeak-gui</a> in <a href="https://launchpad.net/~rainct/+archive/voice">my PPA</a>.</p>
<p>For users of other distributions, you can install them manually after installing the needed dependencies (most importantly, libespeak-dev).</p>
<p>For the Python bindings for espeak:</p>
<pre>$ bzr get lp:python-espeak
$ cd python-espeak
$ python setup.py build
# python setup.py install
</pre>
<p>And for the GUI:</p>
<pre>$ wget -c <a href="http://launchpad.net/espeak-gui/trunk/0.1/+download/espeak-gui-0.1.tar.gz">http://launchpad.net/espeak-gui/trunk/0.1/+download/espeak-gui-0.1.tar.gz</a>
$ tar -xzvf espeak-gui-0.1.tar.gz
$ cd espeak-gui-0.1
# python setup.py install
</pre>
<p>[<strong>Update:</strong> A new version is out, see <a href="http://bloc.eurion.net/archives/2010/espeak-gui-0-2/">espeak-gui 0.2</a> for details.]</p>
<p>I have several ideas on how to continue improving it and I think I&#8217;ll slowly continue doing so (or maybe not so slowly if I get positive feedback on this :)). Also, patches are always welcome!</p>
<p><strong>Using it</strong></p>
<p>Once installed, you&#8217;ll find <a href="https://launchpad.net/espeak-gui">espeak-gui</a> under <em>Applications</em> -&gt; <em>Sound and Video</em> (maybe Accessibility would be a better place?), or you can run it from the command line like this:</p>
<pre>espeak [ &lt;file 1&gt; &lt;file 2&gt; ... ]</pre>
<p>Related posts:<ol>
<li><a href='http://bloc.eurion.net/archives/2010/espeak-gui-0-2/' rel='bookmark' title='espeak-gui 0.2'>espeak-gui 0.2</a> <small>Yesterday I did a first release of espeak-gui, so while...</small></li>
<li><a href='http://bloc.eurion.net/archives/2009/zeitgeist-api-02/' rel='bookmark' title='Introduction to Zeitgeist 0.2&#8242;s API'>Introduction to Zeitgeist 0.2&#8242;s API</a> <small>So now that Zeitgeist 0.2.0 is out I&#8217;ve thought I&#8217;d...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://bloc.eurion.net/archives/2010/introducing-espeak-gui/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Standalone desktop widgets with PyGTK+</title>
		<link>http://bloc.eurion.net/archives/2009/standalone-pygtk-desktop-widgets/</link>
		<comments>http://bloc.eurion.net/archives/2009/standalone-pygtk-desktop-widgets/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 22:23:55 +0000</pubDate>
		<dc:creator>RainCT</dc:creator>
				<category><![CDATA[Planet Ubuntu]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bloc.eurion.net/?p=122</guid>
		<description><![CDATA[Now that I&#8217;ve got a new computer I decided to give gdesklets a try and I have to say, I am not excited. Most of them don&#8217;t even work, and I don&#8217;t really like those which do work, so I ended up with only one single desklet enabled, &#8220;Quote of the Day&#8221;, and for a [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I&#8217;ve got a new computer I decided to give <a href="http://www.gdesklets.de/">gdesklets</a> a try and I have to say, I am not excited. Most of them don&#8217;t even work, and I don&#8217;t really like those which do work, so I ended up with only one single <em>desklet</em> enabled, &#8220;Quote of the Day&#8221;, and for a single widget I don&#8217;t want to have gdesklets running. So, considering that I&#8217;ve got some spare hours and that I haven&#8217;t coded much lately, I decided to try to create a standalone version of it.</p>
<p>So, after deciding that I&#8217;d use Python and try to get this done with GTK+, I needed a window with two properties: a) being &#8220;on the desktop&#8221;, and b) having a transparent background. I could achieve both things without too much hassle, keep reading to know how!</p>
<p><strong>Widget on the desktop</strong></p>
<p>After a quick search I found<a href="http://unpythonic.blogspot.com/2007/11/desktop-widgets-with-pygtk-launchpad.html"> this post</a>, which claims that this can be achieved by giving our window the type hint &#8220;gtk.gdk.WINDOW_TYPE_HINT_DESKTOP&#8221;. I tried it out and, yes!, there we have our widget on the desktop&#8230; But wait, I just clicked next to it and it disappeared! Weird&#8230; So it seems like clicking somewhere on the real desktop places the widget behind it (or does something else with it) and then it&#8217; s no longer visible. I looked up the hint in the documentation and there it says that it actually is to implement <em>a desktop</em>, so I stopped messing with this and looked for something else.</p>
<p>The solution I found was a quite ovious one:  just give our window all the properties we expect a widget to have. This is done with the following code (assuming that we have a gtk.Widget instance called, well, widget):</p>
<pre>widget.set_skip_taskbar_hint(True)
widget.set_skip_pager_hint(True)
widget.set_keep_below(True)
widget.set_decorated(False)
widget.stick()</pre>
<p>I am not going to stop and explain each of them as their name already explains it all; if you want to know a bit more about some of them you&#8217;ll find more details in GTK+&#8217;s docs. This code achieves the purpose, but it has a little flaw: although our window behaves pretty much like a widget, it still is a window, so clicking on &#8220;Show desktop&#8221; will hide it. Gdesklets has the same problem, though, so I guess we can live with it. <em>[Update: See below for an improved variant of this code.]</em>.</p>
<p><strong>Window with a transparent background</strong></p>
<p>A widget isn&#8217;t a true widget if it hasn&#8217;t some fancy transparency, so this is an important point, and I had absolutely no clue on how to solve it.  Fortunately, the PyGTK+ docs came to the rescue, with &#8220;A <a href="http://www.pygtk.org/docs/pygtk/class-gdkwindow.html">gtk.gdk.Window</a> Composited Windows example&#8221;. The example shows how to place a semi-transparent button upon a colored window, but simplyfing it a bit I could get it to do what I want: make the background of the window itself transparent. Here is the result:</p>
<pre>import gtk
import cairo

def transparent_expose(widget, event):
	cr = widget.window.cairo_create()
	cr.set_operator(cairo.OPERATOR_CLEAR)
	region = gtk.gdk.region_rectangle(event.area)
	cr.region(region)
	cr.fill()
	return False

# And in the GUI part, after defining a gtk.Window called "window":
		screen = window.get_screen()
		rgba = screen.get_rgba_colormap()
		window.set_colormap(rgba)
		window.set_app_paintable(True)
		window.connect("expose-event", transparent_expose)</pre>
<div id="attachment_130" class="wp-caption aligncenter" style="width: 358px"><img class="size-full wp-image-130" title="Screenshot of a transparent GTK+ window" src="http://bloc.eurion.net/wp-content/uploads/2009/01/transparent_window.png" alt="Who doesn't like transparency? :)" width="348" height="120" /><p class="wp-caption-text">Who doesn&#39;t like transparency? :)</p></div>
<p><strong>Putting it all together</strong></p>
<p>Now that we know how to implement both characteristics, we just have to put them together. To make it easier to reuse the code if I later decide to create more widgets, I wrote thi as a gtk.Window subclass:</p>
<pre>import gtk
import cairo

def transparent_expose(widget, event):
	cr = widget.window.cairo_create()
	cr.set_operator(cairo.OPERATOR_CLEAR)
	region = gtk.gdk.region_rectangle(event.area)
	cr.region(region)
	cr.fill()
	return False

class DesktopWindow(gtk.Window):

	# Based upon the composited window example from:
	# http://www.pygtk.org/docs/pygtk/class-gdkwindow.html

	def __init__(self, *args):

		gtk.Window.__init__(self, *args)

		self.set_skip_taskbar_hint(True)
		self.set_skip_pager_hint(True)
		self.set_keep_below(True)
		self.set_decorated(False)
		self.stick()

		screen = self.get_screen()
		rgba = screen.get_rgba_colormap()
		self.set_colormap(rgba)
		self.set_app_paintable(True)
		self.connect("expose-event", transparent_expose)</pre>
<p>I saved this as common.py, and now I can just import it into the file for my widget and use common.DesktopWindow() instead of Gtk.Window() to automatically get both, the transparent background and the widget behavior.</p>
<p>That&#8217;s it. Another day I&#8217;ll finish writing the actual widget (still have some other work to do now) and eventually publish it for whoever may want to use it. I may also make a module out of the above code (with some additional stuff, like possibly drag-and-drop support, position saving, right-click menu, etc). I hope this post will be useful to someone!</p>
<p>Ah, and if you know of a better way to achieve this (beside using some alternative to gdesklets, which would take out the fun of this project :P), please tell me!</p>
<p><strong>Update: Improved version</strong></p>
<p>Hans Rödtang pointed out that using the type hint &#8220;gtk.gdk.WINDOW_TYPE_HINT_DOCK&#8221; may solve the problem with our widget being hidden when the &#8220;Show desktop&#8221; button is pressed. Effectively, it does, and it also makes it unnecessary to set some of the properties we need manually, so here is an improved version of the DesktopWindow class:</p>
<pre>class DesktopWindow(gtk.Window):

	def __init__(self, *args):

		gtk.Window.__init__(self, *args)

		self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
		self.set_keep_below(True)
		self.set_decorated(False)
		self.stick()

		screen = self.get_screen()
		rgba = screen.get_rgba_colormap()
		self.set_colormap(rgba)
		self.set_app_paintable(True)
		self.connect("expose-event", transparent_expose)</pre>
<hr />
<p><small>
<a href="http://bloc.eurion.net/archives/2009/standalone-pygtk-desktop-widgets/#comments">15 comments</a><br />
© Siegfried-Angel Gevatter Pujals, 2009. |
<a href="http://bloc.eurion.net/archives/2009/standalone-pygtk-desktop-widgets/">Permalink</a> |
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">License</a> |
Post tags: <a href="http://bloc.eurion.net/archives/tag/gtk/" rel="tag">gtk</a>, <a href="http://bloc.eurion.net/archives/tag/python/" rel="tag">python</a><br/>
</small></p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://bloc.eurion.net/archives/2009/standalone-pygtk-desktop-widgets/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

