<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>gtk &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/gtk/</link>
	<description>Feed of posts on WordPress.com tagged "gtk"</description>
	<pubDate>Fri, 27 Nov 2009 09:23:23 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Modifica el borde de las ventanas con Emerald]]></title>
<link>http://mgsanchezs.wordpress.com/2009/11/24/modifica-el-borde-de-las-ventanas-con-emerald/</link>
<pubDate>Wed, 25 Nov 2009 01:21:07 +0000</pubDate>
<dc:creator>MgsanchezS</dc:creator>
<guid>http://mgsanchezs.wordpress.com/2009/11/24/modifica-el-borde-de-las-ventanas-con-emerald/</guid>
<description><![CDATA[Antes de instalar Emerald debemos de asegurarnos que tenemos activados los efectos avanzados de escr]]></description>
<content:encoded><![CDATA[Antes de instalar Emerald debemos de asegurarnos que tenemos activados los efectos avanzados de escr]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link>http://illpill.wordpress.com/2009/11/24/567/</link>
<pubDate>Tue, 24 Nov 2009 17:43:58 +0000</pubDate>
<dc:creator>zmapp</dc:creator>
<guid>http://illpill.wordpress.com/2009/11/24/567/</guid>
<description><![CDATA[]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://illpill.wordpress.com/files/2009/11/img_4229s.jpg"><img class="alignnone size-full wp-image-566" title="IMG_4229s" src="http://illpill.wordpress.com/files/2009/11/img_4229s.jpg" alt="" width="720" height="411" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link>http://illpill.wordpress.com/2009/11/24/562/</link>
<pubDate>Tue, 24 Nov 2009 17:39:59 +0000</pubDate>
<dc:creator>zmapp</dc:creator>
<guid>http://illpill.wordpress.com/2009/11/24/562/</guid>
<description><![CDATA[sweet, crone, smash]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://illpill.wordpress.com/files/2009/11/img_4225s.jpg"><img class="alignnone size-full wp-image-561" title="IMG_4225s" src="http://illpill.wordpress.com/files/2009/11/img_4225s.jpg" alt="" width="720" height="343" /></a></p>
<p>sweet, crone, smash</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Botões do Eclipse/Aptana, etc... no Ubuntu 9.10]]></title>
<link>http://kroiner.wordpress.com/2009/11/22/botoes-do-eclipseaptana-etc-no-ubuntu-9-10/</link>
<pubDate>Mon, 23 Nov 2009 02:28:22 +0000</pubDate>
<dc:creator>tonismar</dc:creator>
<guid>http://kroiner.wordpress.com/2009/11/22/botoes-do-eclipseaptana-etc-no-ubuntu-9-10/</guid>
<description><![CDATA[Olá Pessoal! Para aqueles que, como eu, estão tendo problemas com o Eclipse/Aptana no Ubuntu 9.10, s]]></description>
<content:encoded><![CDATA[Olá Pessoal! Para aqueles que, como eu, estão tendo problemas com o Eclipse/Aptana no Ubuntu 9.10, s]]></content:encoded>
</item>
<item>
<title><![CDATA[GTKPerf, medí la velocidad de cada uno de tus themes preferidos]]></title>
<link>http://elsoftwarelibre.wordpress.com/2009/11/22/gtkperf-medi-la-velocidad-de-cada-uno-de-tus-themes-preferidos/</link>
<pubDate>Sun, 22 Nov 2009 17:30:04 +0000</pubDate>
<dc:creator>Soft-Libre</dc:creator>
<guid>http://elsoftwarelibre.wordpress.com/2009/11/22/gtkperf-medi-la-velocidad-de-cada-uno-de-tus-themes-preferidos/</guid>
<description><![CDATA[GTKPerf es una aplicación que al ejecutarla nos permite testear la velocidad con que se desempeña ca]]></description>
<content:encoded><![CDATA[GTKPerf es una aplicación que al ejecutarla nos permite testear la velocidad con que se desempeña ca]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link>http://illpill.wordpress.com/2009/11/20/529/</link>
<pubDate>Fri, 20 Nov 2009 22:04:40 +0000</pubDate>
<dc:creator>zmapp</dc:creator>
<guid>http://illpill.wordpress.com/2009/11/20/529/</guid>
<description><![CDATA[chico, ace, rois]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://illpill.wordpress.com/files/2009/11/chacropanos.jpg"><img class="alignnone size-full wp-image-528" title="chacropanos" src="http://illpill.wordpress.com/files/2009/11/chacropanos.jpg" alt="" width="720" height="179" /></a></p>
<p>chico, ace, rois</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Charla "Introducción al Desarrollo de Aplicaciones con PyGTK" en IRC]]></title>
<link>http://tecnotaku.wordpress.com/2009/11/20/charla-introduccion-al-desarrollo-de-aplicaciones-con-pygtk-en-irc/</link>
<pubDate>Fri, 20 Nov 2009 16:14:58 +0000</pubDate>
<dc:creator>zero2004</dc:creator>
<guid>http://tecnotaku.wordpress.com/2009/11/20/charla-introduccion-al-desarrollo-de-aplicaciones-con-pygtk-en-irc/</guid>
<description><![CDATA[La asociación de GNOME Hispano anunció con este mensaje en su lista de correo la próxima charla ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div id="HOTWordsTxt">
<p>La asociación de <a href="http://es.gnome.org/">GNOME  Hispano</a> anunció con <a href="http://mail.gnome.org/archives/gnome-hispano-list/2009-November/msg00014.html">este  mensaje</a> en su lista de correo la próxima charla <em>&#8220;Introducción  al Desarrollo de Aplicaciones con PyGTK&#8221;</em> a llevarse a cabo el  próxmo <strong>Sábado 21 de Noviembre</strong> en el marco de sus <a href="http://es.gnome.org/Eventos/CharlasIRC">Charlas IRC</a> mensuales.  La charla se realizará el canal <code>#gnome-hispano</code> de <strong>irc.gnome.org</strong> a las 17 hrs. UTC (14:00 hrs. de Argentina, si no me equivoco) y estará  a cargo de Alejandro Valdés, un miembro de la comunidad de GNOME.</p>
<p>La temática de la charla estará dividida en dos partes:</p>
<ol>
<li>Un poco de teoría: programación por  <a href="http://www.vivalinux.com.ar/eventos/charla-desarrollo-pygtk-gnome-irc#">eventos</a>, widgets, <em>signals</em>,  <em>callbacks</em>, etc.</li>
<li>Ejercicios: Partiendo desde un ejemplo interactivo con Python,  pasado por ejemplos con/sin señales, ejemplos con/sin  libglade/gtkbuilder, ejemplos con/sin clases, terminando con algunos  ejemplos de como utilizar algunos cosas  <a href="http://www.vivalinux.com.ar/eventos/charla-desarrollo-pygtk-gnome-irc#">interesantes</a> como gconf, vte,  treeview, gettext, etc.</li>
</ol>
<ul>
<li>Artículo completo en <a href="http://diariolinux.com/2009/11/15/charla-irc-de-noviembre-gnome-hispano/">DiarioLinux</a>.</li>
</ul>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Wiithon 1.1 publicado!]]></title>
<link>http://blogricardo.wordpress.com/2009/11/20/wiithon-1-1-publicado/</link>
<pubDate>Fri, 20 Nov 2009 03:16:00 +0000</pubDate>
<dc:creator>makiolo</dc:creator>
<guid>http://blogricardo.wordpress.com/2009/11/20/wiithon-1-1-publicado/</guid>
<description><![CDATA[Actualizado: sábado, 21 de noviembre de 2009 Bueno por fin publicamos la nueva versión tras casi 5 m]]></description>
<content:encoded><![CDATA[Actualizado: sábado, 21 de noviembre de 2009 Bueno por fin publicamos la nueva versión tras casi 5 m]]></content:encoded>
</item>
<item>
<title><![CDATA[Java: Native GTK+ GUIs on Gnome using Java-Gnome]]></title>
<link>http://cyberpython.wordpress.com/2009/11/17/java-native-gtk-guis-on-gnome-using-java-gnome/</link>
<pubDate>Tue, 17 Nov 2009 19:05:18 +0000</pubDate>
<dc:creator>cyberpython</dc:creator>
<guid>http://cyberpython.wordpress.com/2009/11/17/java-native-gtk-guis-on-gnome-using-java-gnome/</guid>
<description><![CDATA[In this post we&#8217;ll see how to create a simple text editor for Linux systems using Java and GTK]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In this post we&#8217;ll see how to create a simple text editor for Linux systems using Java and GTK+.</p>
<p>First of all we will need to have a Linux system with:</p>
<ul>
<li>JRE and JDK</li>
<li>GTK (if you are using a Gnome-based distro like Ubuntu it&#8217;s already there)</li>
<li>Gnome-Java GTK+ bindings for Java<br />
If you are using Ubuntu Karmic you can install these with:<br />
sudo apt-get install libjava-gnome-java libjava-gnome-jni libjava-gnome-java-doc<br />
Otherwise you can grab the bindings from <a href="http://java-gnome.sourceforge.net/4.0/get/" target="_blank">here</a> and follow these <a href="http://java-gnome.sourceforge.net/4.0/README.html" target="_blank">instructions</a> for manual installation.</li>
<li>Glade Interface Designer (It must be available through your distribution&#8217;s package management tool)</li>
<li>Your favorite Java editor/IDE &#8211; I&#8217;ll be using Netbeans (if you don&#8217;t, make sure you have a grasp of how the classpath works).</li>
</ul>
<p><!--more--></p>
<p>Now that we have everything we need installed and configured, we start Netbeans and create a new Java Application Project named MyGtkTextEditor.</p>
<p style="text-align:center;"><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-2.png"><img class="size-thumbnail wp-image-443" title="Screenshot-2" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-2.png?w=150" alt="" width="150" height="100" /></a><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-3.png"><img class="size-thumbnail wp-image-444" title="Screenshot-3" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-3.png?w=150" alt="" width="150" height="103" /></a></p>
<p>Next, we have to tell Netbeans to include the necessary java-gnome JAR files in order to be able to compile our project. Right click on &#8220;Libraries&#8221; and choose &#8220;Add JAR/folder&#8221;.</p>
<p style="text-align:center;"><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-4.png"><img class="alignnone size-thumbnail wp-image-445" title="Screenshot-4" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-4.png?w=136" alt="" width="136" height="150" /></a></p>
<p>Now, navigate to /usr/share/java , select gtk.jar and gtk-4.0.jar and click on &#8220;OK&#8221;.</p>
<p style="text-align:center;"><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-5.png"><img class="alignnone size-thumbnail wp-image-446" title="Screenshot-5" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-5.png?w=150" alt="" width="150" height="96" /></a></p>
<p>From now on we can use GTK+ in our Java application!<br />
Next we will design the GUI using Glade Interface Designer. Start Glade and select &#8220;Libglade&#8221; as the project&#8217;s file format. The libglade format is scheduled for deprecation and will be replaced by GtkBuilder, but java-gnome only supports libglade in its current version.</p>
<p style="text-align:center;"><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot.png"><img class="alignnone size-thumbnail wp-image-447" title="Screenshot" src="http://cyberpython.wordpress.com/files/2009/11/screenshot.png?w=150" alt="" width="150" height="86" /></a></p>
<p>Now create a window and add a vertical box with 4 slots. Then add a menubar, a toolbar, a ScrolledWindow and a statusbar. We add a TextView inside the ScrolledWindow. Then populate the toolbar (using the &#8220;pencil&#8221; icon on Glade&#8217;s main toolbar which appears after selecting the toolbar) to look like the one on the following picture:</p>
<p style="text-align:center;"><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-1.png"><img class="alignnone size-thumbnail wp-image-448" title="Screenshot-1" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-1.png?w=150" alt="" width="150" height="88" /></a></p>
<p>Now save the project as &#8220;main_window.glade&#8221; in a folder named &#8220;glade&#8221; inside your Netbeans project directory and close Glade:</p>
<p style="text-align:center;"><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-6.png"><img class="alignnone size-thumbnail wp-image-449" title="Screenshot-6" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-6.png?w=150" alt="" width="150" height="88" /></a></p>
<p>You can download the glade file from <a href="http://cyberpython.net76.net/files/mygtktexteditor/glade/main_window.glade">here</a>.</p>
<p>In order to be able to build/run our project with Netbeans and create redistributable &#8220;dist&#8221; folder we must tell Ant to copy out glade file in our build/dist folder somewhere where we can locate it at runtime &#8211; e.g. to build/glade/main_window.glade  and dist/glade/main_window.glade . Open build.xml using your favorite text editor and add the following before &#60;/project&#62; :</p>
<pre style="color:#000000;background:#ffffff;"><span style="color:#7f0055;">&#60;</span><span style="color:#7f0055;">target</span> name=<span style="color:#2a00ff;">"</span><span style="color:#2a00ff;">-post-compile</span><span style="color:#2a00ff;">"</span><span style="color:#7f0055;">&#62;</span>
    <span style="color:#7f0055;">&#60;</span><span style="color:#7f0055;">copy</span> todir=<span style="color:#2a00ff;">"</span><span style="color:#2a00ff;">build/glade</span><span style="color:#2a00ff;">"</span><span style="color:#7f0055;">&#62;</span>
        <span style="color:#7f0055;">&#60;</span><span style="color:#7f0055;">fileset</span> dir=<span style="color:#2a00ff;">"</span><span style="color:#2a00ff;">glade</span><span style="color:#2a00ff;">"</span><span style="color:#7f0055;">/&#62;</span>
    <span style="color:#7f0055;">&#60;/</span><span style="color:#7f0055;">copy</span><span style="color:#7f0055;">&#62;</span>
<span style="color:#7f0055;">&#60;/</span><span style="color:#7f0055;">target</span><span style="color:#7f0055;">&#62;</span>
<span style="color:#7f0055;">&#60;</span><span style="color:#7f0055;">target</span> name=<span style="color:#2a00ff;">"</span><span style="color:#2a00ff;">-post-jar</span><span style="color:#2a00ff;">"</span><span style="color:#7f0055;">&#62;</span>
    <span style="color:#7f0055;">&#60;</span><span style="color:#7f0055;">copy</span> todir=<span style="color:#2a00ff;">"</span><span style="color:#2a00ff;">dist/glade</span><span style="color:#2a00ff;">"</span><span style="color:#7f0055;">&#62;</span>
        <span style="color:#7f0055;">&#60;</span><span style="color:#7f0055;">fileset</span> dir=<span style="color:#2a00ff;">"</span><span style="color:#2a00ff;">glade</span><span style="color:#2a00ff;">"</span><span style="color:#7f0055;">/&#62;</span>
    <span style="color:#7f0055;">&#60;/</span><span style="color:#7f0055;">copy</span><span style="color:#7f0055;">&#62;</span>
<span style="color:#7f0055;">&#60;/</span><span style="color:#7f0055;">target</span><span style="color:#7f0055;">&#62;</span></pre>
<p style="text-align:center;"><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-7.png"><img class="alignnone size-thumbnail wp-image-450" title="Screenshot-7" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-7.png?w=150" alt="" width="150" height="89" /></a><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-8.png"><img class="alignnone size-thumbnail wp-image-451" title="Screenshot-8" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-8.png?w=150" alt="" width="150" height="100" /></a></p>
<p>Now go to NetBeans and create a new Java class named &#8220;MyGtkTextEditor&#8221; inside mygtktexteditor:</p>
<p style="text-align:center;"><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-9.png"><img class="alignnone size-thumbnail wp-image-452" title="Screenshot-9" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-9.png?w=150" alt="" width="150" height="95" /></a></p>
<p>First we will create a method that returns the path of the gladefile at runtime:</p>
<pre style="color:#000000;background:#ffffff;"><span style="color:#7f0055;font-weight:bold;">private</span> String getGladefilePath() {
    <span style="color:#7f0055;font-weight:bold;">try</span> {
        URI uri = <span style="color:#7f0055;font-weight:bold;">this</span>.getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
        <span style="color:#7f0055;font-weight:bold;">File</span> f = <span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">File</span>(uri);
        <span style="color:#7f0055;font-weight:bold;">String</span> canonicalPath = f.getParentFile().getCanonicalPath();
        <span style="color:#7f0055;font-weight:bold;">File</span> f2 = <span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">File</span>(canonicalPath + <span style="color:#7f0055;font-weight:bold;">File</span>.separator + <span style="color:#2a00ff;">"glade"</span> + <span style="color:#7f0055;font-weight:bold;">File</span>.separator + <span style="color:#2a00ff;">"main_window.glade"</span>);
        <span style="color:#7f0055;font-weight:bold;">return</span> f2.getCanonicalPath();
    } <span style="color:#7f0055;font-weight:bold;">catch</span> (<span style="color:#7f0055;font-weight:bold;">Exception</span> e) {
        e.printStackTrace();
        <span style="color:#7f0055;font-weight:bold;">return</span> <span style="color:#7f0055;font-weight:bold;">null</span>;
    }
}</pre>
<p>Next a method that parses the XML glade file and gets object references:</p>
<pre style="color:#000000;background:#ffffff;"><span style="color:#7f0055;font-weight:bold;">private</span> void initComponents(String path) {
    <span style="color:#7f0055;font-weight:bold;">try</span> {
        XML gladeXML = Glade.parse(path, <span style="color:#2a00ff;">"window1"</span>);

        <span style="color:#7f0055;font-weight:bold;">this</span>.mainWindow = (<span style="color:#7f0055;font-weight:bold;">Window</span>) gladeXML.getWidget(<span style="color:#2a00ff;">"window1"</span>);
        <span style="color:#7f0055;font-weight:bold;">this</span>.openButton = (ToolButton) gladeXML.getWidget(<span style="color:#2a00ff;">"toolbutton2"</span>);
        <span style="color:#7f0055;font-weight:bold;">this</span>.textView = (TextView) gladeXML.getWidget(<span style="color:#2a00ff;">"textview1"</span>);

        <span style="color:#7f0055;font-weight:bold;">this</span>.textBuffer = <span style="color:#7f0055;font-weight:bold;">new</span> TextBuffer();
        <span style="color:#7f0055;font-weight:bold;">this</span>.textView.setBuffer(<span style="color:#7f0055;font-weight:bold;">this</span>.textBuffer);

        <span style="color:#7f0055;font-weight:bold;">this</span>.mainWindow.showAll();
    } <span style="color:#7f0055;font-weight:bold;">catch</span> (<span style="color:#7f0055;font-weight:bold;">FileNotFoundException</span> fnfe) {
        fnfe.printStackTrace();
    }

}</pre>
<p>A method that connects widgets and events:</p>
<pre style="color:#000000;background:#ffffff;"><span style="color:#7f0055;font-weight:bold;">private</span> void connectWidgetsAndEvents() {

    <span style="color:#7f0055;font-weight:bold;">this</span>.mainWindow.connect(<span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">Window</span>.DeleteEvent() {
        <span style="color:#7f0055;font-weight:bold;">public</span> <span style="color:#7f0055;font-weight:bold;">boolean</span> onDeleteEvent(Widget source, <span style="color:#7f0055;font-weight:bold;">Event</span> event) {
        Gtk.mainQuit();
        <span style="color:#7f0055;font-weight:bold;">return</span> <span style="color:#7f0055;font-weight:bold;">false</span>;
        }
    });

    <span style="color:#7f0055;font-weight:bold;">this</span>.openButton.connect(<span style="color:#7f0055;font-weight:bold;">new</span> ToolButton.Clicked() {
        <span style="color:#7f0055;font-weight:bold;">public</span> <span style="color:#7f0055;font-weight:bold;">void</span> onClicked(ToolButton arg0) {
        openFile();
        }
    });

}</pre>
<p>Another one that loads a file in our TextView:</p>
<pre style="color:#000000;background:#ffffff;"><span style="color:#7f0055;font-weight:bold;">private</span> void openFile() {
    FileChooserDialog dlg = <span style="color:#7f0055;font-weight:bold;">new</span> FileChooserDialog(<span style="color:#2a00ff;">"Open..."</span>, <span style="color:#7f0055;font-weight:bold;">this</span>.mainWindow, FileChooserAction.OPEN);
    FileFilter textFileFilter = <span style="color:#7f0055;font-weight:bold;">new</span> FileFilter(<span style="color:#2a00ff;">"Text files"</span>);
    textFileFilter.addMimeType(<span style="color:#2a00ff;">"text/plain"</span>);
    dlg.addFilter(textFileFilter);

    ResponseType response = dlg.run();
    dlg.hide();
    <span style="color:#7f0055;font-weight:bold;">if</span>(response.equals(ResponseType.OK)){
        <span style="color:#7f0055;font-weight:bold;">String</span> text = <span style="color:#2a00ff;">""</span>;
        <span style="color:#7f0055;font-weight:bold;">try</span>{
        <span style="color:#7f0055;font-weight:bold;">InputStreamReader</span> reader = <span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">InputStreamReader</span>(<span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">FileInputStream</span>(dlg.getFilename()), <span style="color:#2a00ff;">"UTF-8"</span>);
        <span style="color:#7f0055;font-weight:bold;">char</span>[] buffer = <span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">char</span>[512];
        <span style="color:#7f0055;font-weight:bold;">while</span>(reader.read(buffer)!=-1){
            text = text + <span style="color:#7f0055;font-weight:bold;">String</span>.valueOf(buffer);
        }
        reader.close();
        }<span style="color:#7f0055;font-weight:bold;">catch</span>(<span style="color:#7f0055;font-weight:bold;">IOException</span> ioe){
        ioe.printStackTrace();
        text = <span style="color:#2a00ff;">""</span>;
        }
        <span style="color:#7f0055;font-weight:bold;">this</span>.textBuffer.setText(text);
    }
}</pre>
<p>And finally the constructor that uses all the above methods:</p>
<pre style="color:#000000;background:#ffffff;"><span style="color:#7f0055;font-weight:bold;">public</span> MyGtkTextEditor(){
    Gtk.init(<span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">String</span>[0]);<span style="color:#3f7f59;">//This must be called before </span>
                        <span style="color:#3f7f59;">//anything else that is GTK related</span>

    initComponents(<span style="color:#7f0055;font-weight:bold;">this</span>.getGladefilePath());
    connectWidgetsAndEvents();

    Gtk.main();<span style="color:#3f7f59;">//invokes the GTK main loop</span>
}</pre>
<p>Our class should now look like this:</p>
<pre style="color:#000000;background:#ffffff;"><span style="color:#3f7f59;">/*</span>
<span style="color:#3f7f59;"> * To change this template, choose Tools &#124; Templates</span>
<span style="color:#3f7f59;"> * and open the template in the editor.</span>
<span style="color:#3f7f59;"> */</span>
<span style="color:#7f0055;font-weight:bold;">package</span><span style="color:#7f0055;"> mygtktexteditor</span><span style="color:#7f0055;">;</span>

<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> java</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">io</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">File</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> java</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">io</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">FileInputStream</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> java</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">io</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">FileNotFoundException</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> java</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">io</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">IOException</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> java</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">io</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">InputStreamReader</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> java</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">net</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">URI</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gdk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">Event</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">glade</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">Glade</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">glade</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">XML</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">FileChooserAction</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">FileChooserDialog</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">FileFilter</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">Gtk</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">ResponseType</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">TextBuffer</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">TextView</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">ToolButton</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">Widget</span><span style="color:#7f0055;">;</span>
<span style="color:#7f0055;font-weight:bold;">import</span><span style="color:#7f0055;"> org</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gnome</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">gtk</span><span style="color:#7f0055;">.</span><span style="color:#7f0055;">Window</span><span style="color:#7f0055;">;</span>

<span style="color:#3f5fbf;">/**</span>
<span style="color:#3f5fbf;"> </span><span style="color:#7f9fbf;font-weight:bold;">*</span>
<span style="color:#3f5fbf;"> </span><span style="color:#7f9fbf;font-weight:bold;">*</span><span style="color:#3f5fbf;"> </span><span style="color:#7f9fbf;font-weight:bold;">@author</span><span style="color:#3f5fbf;"> </span><span style="color:#7f9fbf;font-weight:bold;">Georgios "cyberpython" Migdos &#60;cyberpython@gmail.com&#62;</span>
<span style="color:#3f5fbf;"> */</span>
<span style="color:#7f0055;font-weight:bold;">public</span> <span style="color:#7f0055;font-weight:bold;">class</span> MyGtkTextEditor {

    <span style="color:#7f0055;font-weight:bold;">private</span> <span style="color:#7f0055;font-weight:bold;">Window</span> mainWindow;
    <span style="color:#7f0055;font-weight:bold;">private</span> ToolButton openButton;
    <span style="color:#7f0055;font-weight:bold;">private</span> TextView textView;
    <span style="color:#7f0055;font-weight:bold;">private</span> TextBuffer textBuffer;

    <span style="color:#7f0055;font-weight:bold;">public</span> MyGtkTextEditor(){

        Gtk.init(<span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">String</span>[0]);<span style="color:#3f7f59;">//This must be called before</span>
                                <span style="color:#3f7f59;">//anything else that is GTK related</span>

        initComponents(<span style="color:#7f0055;font-weight:bold;">this</span>.getGladefilePath());
        connectWidgetsAndEvents();

        Gtk.main();<span style="color:#3f7f59;">//invokes the GTK main loop</span>
    }

    <span style="color:#7f0055;font-weight:bold;">private</span> <span style="color:#7f0055;font-weight:bold;">void</span> initComponents(<span style="color:#7f0055;font-weight:bold;">String</span> path) {
        <span style="color:#7f0055;font-weight:bold;">try</span> {
            XML gladeXML = Glade.parse(path, <span style="color:#2a00ff;">"window1"</span>);

            <span style="color:#7f0055;font-weight:bold;">this</span>.mainWindow = (<span style="color:#7f0055;font-weight:bold;">Window</span>) gladeXML.getWidget(<span style="color:#2a00ff;">"window1"</span>);
            <span style="color:#7f0055;font-weight:bold;">this</span>.openButton = (ToolButton) gladeXML.getWidget(<span style="color:#2a00ff;">"toolbutton2"</span>);
            <span style="color:#7f0055;font-weight:bold;">this</span>.textView = (TextView) gladeXML.getWidget(<span style="color:#2a00ff;">"textview1"</span>);

            <span style="color:#7f0055;font-weight:bold;">this</span>.textBuffer = <span style="color:#7f0055;font-weight:bold;">new</span> TextBuffer();
            <span style="color:#7f0055;font-weight:bold;">this</span>.textView.setBuffer(<span style="color:#7f0055;font-weight:bold;">this</span>.textBuffer);

            <span style="color:#7f0055;font-weight:bold;">this</span>.mainWindow.showAll();
        } <span style="color:#7f0055;font-weight:bold;">catch</span> (<span style="color:#7f0055;font-weight:bold;">FileNotFoundException</span> fnfe) {
            fnfe.printStackTrace();
        }

    }

    <span style="color:#7f0055;font-weight:bold;">private</span> <span style="color:#7f0055;font-weight:bold;">void</span> connectWidgetsAndEvents() {

        <span style="color:#7f0055;font-weight:bold;">this</span>.mainWindow.connect(<span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">Window</span>.DeleteEvent() {
            <span style="color:#7f0055;font-weight:bold;">public</span> <span style="color:#7f0055;font-weight:bold;">boolean</span> onDeleteEvent(Widget source, <span style="color:#7f0055;font-weight:bold;">Event</span> event) {
                Gtk.mainQuit();
                <span style="color:#7f0055;font-weight:bold;">return</span> <span style="color:#7f0055;font-weight:bold;">false</span>;
            }
        });

        <span style="color:#7f0055;font-weight:bold;">this</span>.openButton.connect(<span style="color:#7f0055;font-weight:bold;">new</span> ToolButton.Clicked() {
            <span style="color:#7f0055;font-weight:bold;">public</span> <span style="color:#7f0055;font-weight:bold;">void</span> onClicked(ToolButton arg0) {
                openFile();
            }
        });

    }

    <span style="color:#7f0055;font-weight:bold;">private</span> <span style="color:#7f0055;font-weight:bold;">void</span> openFile() {
        FileChooserDialog dlg = <span style="color:#7f0055;font-weight:bold;">new</span> FileChooserDialog(<span style="color:#2a00ff;">"Open..."</span>, <span style="color:#7f0055;font-weight:bold;">this</span>.mainWindow, FileChooserAction.OPEN);
        FileFilter textFileFilter = <span style="color:#7f0055;font-weight:bold;">new</span> FileFilter(<span style="color:#2a00ff;">"Text files"</span>);
        textFileFilter.addMimeType(<span style="color:#2a00ff;">"text/plain"</span>);
        dlg.addFilter(textFileFilter);

        ResponseType response = dlg.run();
        dlg.hide();
        <span style="color:#7f0055;font-weight:bold;">if</span>(response.equals(ResponseType.OK)){
            <span style="color:#7f0055;font-weight:bold;">String</span> text = <span style="color:#2a00ff;">""</span>;
            <span style="color:#7f0055;font-weight:bold;">try</span>{
                <span style="color:#7f0055;font-weight:bold;">InputStreamReader</span> reader = <span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">InputStreamReader</span>(<span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">FileInputStream</span>(dlg.getFilename()), <span style="color:#2a00ff;">"UTF-8"</span>);
                <span style="color:#7f0055;font-weight:bold;">char</span>[] buffer = <span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">char</span>[512];
                <span style="color:#7f0055;font-weight:bold;">while</span>(reader.read(buffer)!=-1){
                    text = text + <span style="color:#7f0055;font-weight:bold;">String</span>.valueOf(buffer);
                }
                reader.close();
            }<span style="color:#7f0055;font-weight:bold;">catch</span>(<span style="color:#7f0055;font-weight:bold;">IOException</span> ioe){
                ioe.printStackTrace();
                text = <span style="color:#2a00ff;">""</span>;
            }
            <span style="color:#7f0055;font-weight:bold;">this</span>.textBuffer.setText(text);
        }
    }

    <span style="color:#7f0055;font-weight:bold;">private</span> <span style="color:#7f0055;font-weight:bold;">String</span> getGladefilePath() {
        <span style="color:#7f0055;font-weight:bold;">try</span> {
            URI uri = <span style="color:#7f0055;font-weight:bold;">this</span>.getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
            <span style="color:#7f0055;font-weight:bold;">File</span> f = <span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">File</span>(uri);
            <span style="color:#7f0055;font-weight:bold;">String</span> canonicalPath = f.getParentFile().getCanonicalPath();
            <span style="color:#7f0055;font-weight:bold;">File</span> f2 = <span style="color:#7f0055;font-weight:bold;">new</span> <span style="color:#7f0055;font-weight:bold;">File</span>(canonicalPath + <span style="color:#7f0055;font-weight:bold;">File</span>.separator + <span style="color:#2a00ff;">"glade"</span> + <span style="color:#7f0055;font-weight:bold;">File</span>.separator + <span style="color:#2a00ff;">"main_window.glade"</span>);
            <span style="color:#7f0055;font-weight:bold;">return</span> f2.getCanonicalPath();
        } <span style="color:#7f0055;font-weight:bold;">catch</span> (<span style="color:#7f0055;font-weight:bold;">Exception</span> e) {
            e.printStackTrace();
            <span style="color:#7f0055;font-weight:bold;">return</span> <span style="color:#7f0055;font-weight:bold;">null</span>;
        }
    }
}</pre>
<p>Now, edit Main.java and create a MyGtkTextEditor object in the main method:</p>
<pre style="color:#000000;background:#ffffff;">MyGtkTextEditor myTextEditor = <span style="color:#7f0055;font-weight:bold;">new</span> MyGtkTextEditor();</pre>
<p>Finally, click on &#8220;Run&#8221; -&#62; &#8220;Clean and Build Main Project&#8221; and then click &#8220;Run&#8221; -&#62; &#8220;Run Main Project&#8221;. You should get something like this:</p>
<p><a href="http://cyberpython.wordpress.com/files/2009/11/screenshot-11.png"><img class="aligncenter size-thumbnail wp-image-453" title="Screenshot-11" src="http://cyberpython.wordpress.com/files/2009/11/screenshot-11.png?w=150" alt="" width="150" height="70" /></a></p>
<p>You can browse the Java-Gnome API documention <a href="http://java-gnome.sourceforge.net/4.0/doc/api/overview-summary.html" target="_blank">here</a>.</p>
<p>Now that you know how to work with GTK+ and Java you can implement the missing functionality for our application (New/Save, clipboard operations etc.). Or you can replace the TextView with a GtkSourceView and turn this into a code editor with syntax-highlighting.</p>
<p>Have fun!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Glossário virtual em Python e Glade - parte II]]></title>
<link>http://icaju.wordpress.com/2009/11/16/glossario-virtual-em-python-e-glade-parte-ii/</link>
<pubDate>Mon, 16 Nov 2009 19:43:08 +0000</pubDate>
<dc:creator>Mamutti</dc:creator>
<guid>http://icaju.wordpress.com/2009/11/16/glossario-virtual-em-python-e-glade-parte-ii/</guid>
<description><![CDATA[Na primeira parte deste tutorial você viu como montar o ambiente de desenvolvimento necessário para ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:justify;">Na <a href="http://icaju.wordpress.com/2009/10/08/glossario-virtual-em-python-e-glade-parte-i/">primeira parte</a> deste tutorial você viu como montar o ambiente de desenvolvimento necessário para criar o glossário, e definimos um dialeto CSV para ser usado ao ler e gravar os arquivos com os termos do glossário. Nessa parte, você verá como fazer o programa ler e gravar esses arquivos CSV.<!--more--></p>
<p style="text-align:justify;">Antes de escrever o código, é necessário conhecer as funções <em>reader</em> e <em>writer</em> do módulo CSV. Como o próprio nome diz, <em>reader</em> serve para ler o CSV. Ela recebe um dialeto e um objeto iterável contendo strings (como uma lista ou um arquivo) e retorna outro objeto iterável, dessa vez com os campos do CSV já separados de acordo com o dialeto. Exemplo:</p>
<p><code>reader = csv.reader(arquivo, dialect="excel")</code></p>
<p style="text-align:justify;">No nosso caso, usar uma lista com os campos (termo e significado) não faz muito sentido, pois um dicionário com os termos como chaves, e os significados como seus valores, cumpriria bem melhor o papel. Assim, na hora de pesquisar um significado, basta chamar:</p>
<p><code>dicionario[termo]</code></p>
<p style="text-align:justify;">E na hora de gravar ou criar um novo termo, basta chamar:</p>
<p><code>dicionario[termo] = significado</code></p>
<p style="text-align:justify;">Mais na frente faremos algumas modificações no dicionário do Python (a tipo <em>dict</em>) para adaptá-lo melhor às necessidades de um glossário, mas por enquanto só precisamos de uma função que receba o caminho do arquivo CSV e retorne um dicionário comum. <a href="http://icaju.pastebin.com/f6d187e9a">Veja o código da função</a>.</p>
<p style="text-align:justify;">Repare que quando há uma exceção IOError ao abrir o arquivo, caso ele exista, é lançada uma exceção do tipo ArquivosError, que nada mais é do que uma classe de exceção vazia. Classe de exceção é uma classe que herda da classe base para todas as exceções no Python, a <em> Exception</em>. Pra que criar uma classe de exceção vazia? Para organizar nosso programa e dar um tratamento especial a esses erros na interface gráfica. <a href="http://icaju.pastebin.com/f6683fa98">Veja o código da classe  ArquivosError</a>.</p>
<p style="text-align:justify;">O próximo passo é criar a função que vai gravar os novos termos e as alterações que foram feitas no glossário do arquivo a partir do qual ele foi carregado. Para isso, utilizaremos a função writer que, assim como reader, recebe um arquivo e um dialeto retornando um objeto com os métodos write e writerows. Write escreve um registro por vez, e writerows recebe um iterável e escreve cada registro dentro dele no arquivo. Exemplo:</p>
<p><code>registro = ('C', 'Linguagem de programação.')</code><br />
<code>f = file('arquivo.csv', 'w')</code></p>
<p><code>writer = csv.writer(f, dialect='excel')</code><br />
<code>writer.write(registro)</code></p>
<p><code>registros = {'Flash':'Uma tecnologia para estragar sites.', 'Assembler':'Não é o nome de uma linguagem'}</code><br />
<code>writer.writerows(registros.items())</code></p>
<p style="text-align:justify;">O que precisamos no nosso módulo de arquivos, é uma função que receba um dicionário com os dados a serem gravados no arquivo, e receba um caminho de arquivo para gravar esses dados. Lembra quando eu disse que vamos criar um dicionário personalizado? Um dos recursos do nosso dicionário é que ele armazenará no atributo <em>path</em> uma string com o caminho do arquivo de onde ele foi lido, assim a nossa função de gravar só precisa receber o glossário, ou seja, o nosso dicionário especial. <a href="http://icaju.pastebin.com/f3e126363">Veja o código da função</a>.</p>
<p style="text-align:justify;">Note que nas duas funções eu usei o módulo <em>codecs</em> para abrir os arquivos, e usei a &#8220;constante&#8221; <em>CODIFICACAO</em> para informar a função <em>open()</em>, a codificação do arquivo. O módulo <em>codecs</em> é uma mão na roda na hora de mexer com arquivos de texto, porque ele evita diversos problemas de codificação. Ao ler um arquivo, ele usa a codificação informada para converter o conteúdo em Unicode (uma espécie de codificação universal), e ao gravar ele transforma as strings Unicode de volta em strings codificadas, de forma transparente. <a href="http://nerdson.com/blog/decifra-me-ou-dvorak/">Eu � Unicode</a>. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p style="text-align:justify;">Você pode atribuir a <em>CODIFICACAO</em> o charset que quiser (eu gosto de usar sempre <em>utf-8</em>). Basta que ao salvar o CSV em outros programas (como editores de planilha), você tenha o cuidado de usar sempre a mesma codificação para evitar que o texto apareça todo zoado no glossário.</p>
<p style="text-align:justify;">Com essa parte do tutorial finalizamos o nosso módulo de ler arquivos. Veja <a href="http://icaju.pastebin.com/f13c5b854">aqui</a> o código completo, comentado e documentado do módulo. Na próxima parte do tutorial, faremos o nosso &#8220;model&#8221; e  mostrarei como personalizar o dicionário do Python, incluindo o atributo <em>path</em> e otras cositas más.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Eclipse 3.5 - problem with clicking buttons]]></title>
<link>http://dailyuse.wordpress.com/2009/11/15/eclipse-3-5-problem-with-clicking-buttons/</link>
<pubDate>Sun, 15 Nov 2009 16:04:36 +0000</pubDate>
<dc:creator>danutzdobrescu</dc:creator>
<guid>http://dailyuse.wordpress.com/2009/11/15/eclipse-3-5-problem-with-clicking-buttons/</guid>
<description><![CDATA[After installing Karmic Koala, i&#8217;ve encountered a stupid problem in Eclipse which kept me from]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>After installing <strong>Karmic Koala</strong>, i&#8217;ve encountered a stupid problem in <strong>Eclipse</strong> which kept me from coding a few days, just because i couldn&#8217;t do click some buttons. After creating a new project, the <strong>Next </strong>button was not working if i was clicking on it, but navigating to it from the keyboard and then pressing space seemed to be the solution. I&#8217;ve discovered a bug, <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=287307" target="_blank">https://bugs.eclipse.org/bugs/show_bug.cgi?id=287307</a>, and it seems that this will be changed for Eclipse 3.6, but for previous versions for Eclipse, just make sure you set <strong>environment variable GDK_NATIVE_WINDOWS=1</strong></p>
<p><strong>Example:</strong></p>
<p>#!/bin/sh<br />
export GDK_NATIVE_WINDOWS=1<br />
`/media/part2/programming/eclipse/eclipse -vmargs -Xms128M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=512M &#38;&#62; /dev/null` &#38;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Solucionar el problema con los botones en Eclipse en Ubuntu]]></title>
<link>http://onoametal.wordpress.com/2009/11/15/solucionar-el-problema-con-los-botones-en-eclipse-en-ubuntu/</link>
<pubDate>Sun, 15 Nov 2009 15:48:00 +0000</pubDate>
<dc:creator>onoametal</dc:creator>
<guid>http://onoametal.wordpress.com/2009/11/15/solucionar-el-problema-con-los-botones-en-eclipse-en-ubuntu/</guid>
<description><![CDATA[Si actualizaste a Karmic y venias usando Eclipse, podrás darte cuenta que los botones no funcionan c]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="background-color:#ffffff;">Si actualizaste a Karmic y venias usando Eclipse, podrás darte cuenta que los botones no funcionan correctamente en esta aplicación. Bueno, la solución es muy sencilla, solo debemos abrir una consola y escribir lo siguiente:</span></p>
<p><strong><em>sudo gedit /ruta_donde_instalaste_eclipse/MiEclipse</em></strong></p>
<p>Ahí te debe abrir un archivo vacio, entonces copia y pega lo siguiente (modifica la ruta a eclipse tal y como lo hiciste en el paso anterior)</p>
<p><strong><em>#!/bin/sh</em></strong></p>
<p><strong><em>export GDK_NATIVE_WINDOWS=1</em></strong></p>
<p><strong><em>/RUTA_DONDE_TIENES_ECLIPSE/eclipse</em></strong></p>
<p>Guardas el archivo, y luego le das permisos de ejecución:</p>
<p><strong><em>sudo chmod +x /ruta_donde_instalaste_eclipse/MiEclipse</em></strong></p>
<p>Ahora modificas el lanzador de la aplicación, dirígete al Menú <em>Aplicaciones</em>, le das click derecho, selecciona la opción <em>Editar los Menús, </em>encontrarás esta pantalla</p>
<p><em> </em></p>
<p><em> </em></p>
<p><em></p>
<div class="wp-caption alignnone" style="width: 389px"><img class="  " src="http://lh6.ggpht.com/_BFud75Vu4Z4/SwAhLXsI5UI/AAAAAAAABoY/X1Ed58ct0L4/s800/screenshot_043.jpeg" alt="" width="379" height="308" /><p class="wp-caption-text">Menú de opciones del menú de Aplicaciones (que raro suena!!)</p></div>
<p></em></p>
<p>&#160;</p>
<p><span style="font-style:normal;">Selecciona Eclipse, y modifica el lanzador para que quede como esta imagen (obviamente la ruta de eclipse es distinta, modifícala según tu instalación)</span></p>
<p><span style="font-style:normal;"><img class="aligncenter" src="http://lh3.ggpht.com/_BFud75Vu4Z4/SwAhLpYEc-I/AAAAAAAABoc/ijSnodKNwsM/s800/screenshot_044.jpeg" alt="" width="412" height="210" /></span></p>
<p><span style="font-style:normal;">Y listo!! Cuando abras Eclipse los botones ya deben funcionar.</span></p>
<p><span style="font-style:normal;">Up The Irons!!</span></p>
<h5><span style="font-style:normal;">Fuente: <a href="http://zdes.wordpress.com/2009/11/04/solucionado-botones-en-aptana-y-eclipse-no-funcionan-en-ubuntu/#comment-378" target="_blank">Zdes</a> (Gracias!!!)</span></h5>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Widget Animation in Linux ]]></title>
<link>http://multics69.wordpress.com/2009/11/14/widget-animation-in-linux/</link>
<pubDate>Sat, 14 Nov 2009 10:00:46 +0000</pubDate>
<dc:creator>multics69</dc:creator>
<guid>http://multics69.wordpress.com/2009/11/14/widget-animation-in-linux/</guid>
<description><![CDATA[These days, widget animation in linux is quite hot. I summarized several approaches. GTK + Clutter B]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>These days, widget animation in linux is quite hot. I summarized several approaches.<strong> </strong></p>
<h3><strong>GTK + Clutter</strong></h3>
<p>Basic idea behind this approach is adding GTK widget as an Clutter Actor on Clutter Scene. Animation and transparency is done by Clutter. It is by virtue of GTK client side window, off screen rendering, supported from 2.18.x.</p>
<ul>
<li><a href="http://blogs.gnome.org/alexl/2009/06/12/the-return-of-client-side-windows/">The return of Client side windows</a></li>
<li><a href="http://dannipenguin.livejournal.com/280866.html">Animating GTK+, Clutter-Gtk, client-side-windows and demos</a></li>
<li><a href="http://blog.didrocks.fr/index.php/post/Design-experience-and-demos-in-GTK-Clutter">Design experience and demos in GTK and Clutter</a></li>
</ul>
<h3>Pixmap based animation in GTK</h3>
<p>Comparing to the GTK+Clutter approach, it animates redirected widget in main event loop using cairo.</p>
<ul>
<li>Discussion at GTK Dev Mailing list: <a href="http://old.nabble.com/Animation-in-Gtk%2B-td21475559.html#a21475559">[1]</a>, <a href="http://old.nabble.com/Pixmap-based-animation-in-Gtk%2B-td21827965.html">[2]</a></li>
<li>Bugzilla: <a href="https://bugzilla.gnome.org/show_bug.cgi?id=570479">pixmap based animation</a>, <a href="https://bugzilla.gnome.org/show_bug.cgi?id=444659">timeline</a></li>
<li>Demo video clips: <a href="http://video.google.de/videoplay?docid=7034876403392178308">[1]</a>, <a href="http://video.google.com/videoplay?docid=793477820753124601">[2]</a></li>
</ul>
<h3>PAF aka PAF Animation Framework</h3>
<p>However above two approaches are specific to GTK, PAF is aiming to create a more general framework. It provides a interface to change GObject values with given time function.</p>
<ul>
<li><a href="http://live.gnome.org/PAF">GNOME PAF Project page</a></li>
<li><a href="https://guij.emont.org/blog/2008/03/10/paf-animation-framework/">Blog post</a></li>
</ul>
<h3>QT Animation Framework</h3>
<p>QT also provides <a href="http://en.wikipedia.org/wiki/Implicit_animation">implicit animation</a> framework from QT 4.x. Here are some introductory materials.</p>
<ul>
<li><a href="http://kgronholm.blogspot.com/2009/04/qt-animation-framework.html">Blog post with video clip</a></li>
<li>Nokia: <a href="http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Utilities/qtanimationframework">[1]</a>, <a href="http://doc.trolltech.com/solutions/4/qtanimationframework/animation.html">[2]</a></li>
</ul>
<h3>Other References</h3>
<ul>
<li><a href="https://code.fluendo.com/pigment/trac/wiki/ExistingTimingFrameworks">Quick Study of Existing Animation Systems</a></li>
<li><a href="http://en.wikipedia.org/wiki/Core_Animation">Apple&#8217;s CoreAnimation</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Printing in Mono]]></title>
<link>http://monoexperiences.wordpress.com/2009/11/13/printing-in-mono/</link>
<pubDate>Fri, 13 Nov 2009 16:46:43 +0000</pubDate>
<dc:creator>rohdef</dc:creator>
<guid>http://monoexperiences.wordpress.com/2009/11/13/printing-in-mono/</guid>
<description><![CDATA[Working with GTK# can be a  pain, which is also true with printing. The only good thing I can say on]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Working with GTK# can be a  pain, which is also true with printing. The only good thing I can say on this is that for once GTK# isn&#8217;t far behind other toolkits such as WinForms and WPF. Just like all the other toolkits you have to draw everything.</p>
<p>The good news is that we don&#8217;t have to use GTK#. Mono has a project called webkit-sharp that makes rendering prints a dream compared to existing solutions. Bad news about it is that you have to compile it yourself on Ubuntu, since the the current libraries isn&#8217;t up to date (probably will be in 10.04, since Mono 2.6 should be out then).</p>
<p>I won&#8217;t cover compiling here though that&#8217;s for another post.</p>
<p>How to do the actual printing is actually so simple it&#8217;s silly. What you basically do is to create a WebView, feed it with the html and run the Print-method. Here&#8217;s an example:</p>
<pre style="background:#fff9bc;">using System;
using Gtk;
using WebKit;

class MainClass
{
     public static void Main(string[] args)
     {
         Application.Init();
         WebView v = new WebView();
         v.LoadHtmlString(@"&#60;html&#62;&#60;body&#62;&#60;h1&#62;Hello printer!&#60;/ht&#62;&#60;/body&#62;&#60;/html&#62;", null);
         v.MainFrame.Print();
         Application.Run();
     }
}
</pre>
<p>Hope this will easy your job of printing next time you need to print something</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link>http://illpill.wordpress.com/2009/11/11/516/</link>
<pubDate>Wed, 11 Nov 2009 21:47:01 +0000</pubDate>
<dc:creator>zmapp</dc:creator>
<guid>http://illpill.wordpress.com/2009/11/11/516/</guid>
<description><![CDATA[kesp]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><img class="alignnone size-full wp-image-515" title="PB090125s" src="http://illpill.wordpress.com/files/2009/11/pb090125s.jpg" alt="PB090125s" width="720" height="778" /></p>
<p>kesp</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link>http://illpill.wordpress.com/2009/11/11/510/</link>
<pubDate>Wed, 11 Nov 2009 21:43:30 +0000</pubDate>
<dc:creator>zmapp</dc:creator>
<guid>http://illpill.wordpress.com/2009/11/11/510/</guid>
<description><![CDATA[gold]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><img class="alignnone size-full wp-image-509" title="PB090109s" src="http://illpill.wordpress.com/files/2009/11/pb090109s.jpg" alt="PB090109s" width="720" height="380" /></p>
<p>gold</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link>http://illpill.wordpress.com/2009/11/11/492/</link>
<pubDate>Wed, 11 Nov 2009 21:31:16 +0000</pubDate>
<dc:creator>zmapp</dc:creator>
<guid>http://illpill.wordpress.com/2009/11/11/492/</guid>
<description><![CDATA[chico]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><img class="alignnone size-full wp-image-491" src="http://illpill.wordpress.com/files/2009/11/img_4141s1.jpg" alt="" width="720" height="805" /></p>
<p>chico</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link>http://illpill.wordpress.com/2009/11/11/484/</link>
<pubDate>Wed, 11 Nov 2009 21:25:03 +0000</pubDate>
<dc:creator>zmapp</dc:creator>
<guid>http://illpill.wordpress.com/2009/11/11/484/</guid>
<description><![CDATA[]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><img class="alignnone size-full wp-image-486" src="http://illpill.wordpress.com/files/2009/11/img_4126s1.jpg" alt="" width="720" height="399" /></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Tema para Ubuntu - Cole]]></title>
<link>http://ubuntuparatodos.wordpress.com/2009/11/10/tema-para-ubuntu-cole/</link>
<pubDate>Wed, 11 Nov 2009 03:51:04 +0000</pubDate>
<dc:creator>leonciokof</dc:creator>
<guid>http://ubuntuparatodos.wordpress.com/2009/11/10/tema-para-ubuntu-cole/</guid>
<description><![CDATA[Excelente tema de escritorio para Ubuntu, muy Dark como me gustan, esta disponible en deviantART par]]></description>
<content:encoded><![CDATA[Excelente tema de escritorio para Ubuntu, muy Dark como me gustan, esta disponible en deviantART par]]></content:encoded>
</item>
<item>
<title><![CDATA[Eclipse, Pydev and GTK with code completion]]></title>
<link>http://matgnt.wordpress.com/2009/11/08/eclipse-pydev-and-gtk-with-code-completion/</link>
<pubDate>Sun, 08 Nov 2009 15:38:13 +0000</pubDate>
<dc:creator>matgnt</dc:creator>
<guid>http://matgnt.wordpress.com/2009/11/08/eclipse-pydev-and-gtk-with-code-completion/</guid>
<description><![CDATA[Today I tried to use Eclipse with Pydev to create a HelloWorld GTK application, but it was not that ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Today I tried to use <a href="http://eclipse.org/">Eclipse</a> with <a href="http://pydev.org/">Pydev</a> to create a HelloWorld <a href="http://gtk.org/">GTK</a> application, but it was not that easy I&#8217;ve thought it would be. With the following lines I want to describe my encountered problem and how to solve it.  After installing pydev you have to add the python interpreter manually. Go to<em> Window-&#62;Preferences-&#62;Pydev-&#62;Interpreter Python</em> and add e.g. <em>/usr/bin/python2.6</em> Now the plugin will automatically detect some directories to add to the PYTHONPATH and you can run your first HelloWorld application:</p>
<pre class="brush: python;">
import gtk
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect(&#34;destroy&#34;, gtk.main_quit)
window.show()
gtk.main()
</pre>
<p>It shouldn&#8217;t be a problem to run this application with &#8220;<em>Run As-&#62;Python Run</em>&#8221; and you will see a simple GTK window.  But the problem is, that code completion for gtk doesn&#8217;t work because pydev can&#8217;t find the imported gtk package.</p>
<p style="text-align:center;"><img class="alignnone size-full wp-image-8" title="Unresolved Import: gtk" src="http://matgnt.wordpress.com/files/2009/11/screenshot-9.png" alt="Unresolved Import: gtk" width="450" height="403" /></p>
<p>To solve this problem, add <em>/var/lib/python-support/python2.6/gtk-2.0</em> and <em>/var/lib/python-support/python2.6/</em> to your PYTHONPATH and gtk, gobject, pango and atk to your &#8220;Forced Builtins&#8221;.</p>
<div class="separator" style="clear:both;text-align:center;"><img class="alignnone size-full wp-image-9" title="Settings PYTHONPATH" src="http://matgnt.wordpress.com/files/2009/11/screenshot-preferences.png" alt="Settings PYTHONPATH" width="450" height="408" /><img class="alignnone size-full wp-image-10" title="Settings Forced Builtins" src="http://matgnt.wordpress.com/files/2009/11/screenshot-preferences-1.png" alt="Settings Forced Builtins" width="450" height="408" /></div>
<p>(The picture doesn&#8217;t show &#8220;atk&#8221;, but it should also be added to the list.)  If the problem is still present, remove the python interpreter and add it again.  Now the code completion for GTK should work.</p>
<div class="separator" style="clear:both;text-align:center;"><img class="alignnone size-full wp-image-11" title="Pydev code completion" src="http://matgnt.wordpress.com/files/2009/11/screenshot1.png" alt="Pydev code completion" width="450" height="455" /></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Linux and the Quest for Eye Candy]]></title>
<link>http://sandeep.wordpress.com/2009/11/08/linux-and-the-quest-for-eye-candy/</link>
<pubDate>Sun, 08 Nov 2009 07:39:10 +0000</pubDate>
<dc:creator>sandeep</dc:creator>
<guid>http://sandeep.wordpress.com/2009/11/08/linux-and-the-quest-for-eye-candy/</guid>
<description><![CDATA[For the past couple of days, I have been struggling with my eyesight on a 12 inch monitor with Ubunt]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>For the past couple of days, I have been struggling with my eyesight on a 12 inch monitor with Ubuntu Karmic. It has not helped that, for some reason or other, I have been working frequently on a Windows 7 machine. As much as I hate to admit it &#8211; Win7 beats the pants off Karmic with its eye candy and usability.</p>
<p>These days I am building a Linux NAS box using <a href="http://groups.google.com/group/zfs-fuse/" target="_blank">ZFS-FUSE</a> on a Hardy Box and I keep running into unfixed driver <strong>regressions </strong>like this one for a <a href="https://bugs.launchpad.net/ubuntu/+bug/435244/comments/3" target="_blank">Davicom Ethernet Card</a>. I personally believe that for Lucid Lynx, all that Ubuntu should work on is getting driver support cleaned up.</p>
<p>However, one thing I would like to see is <a href="http://en.wikipedia.org/wiki/Resolution_independence" target="_blank">resolution independence</a> (Ubuntu&#8217;s <a href="https://wiki.ubuntu.com/ResolutionIndependence" target="_blank">blueprint</a>) &#8211; which is where my eyesight and the 12 inch desktop comes in. In essence what it means is that the operating system resizes it&#8217;s UI &#8211; fonts, icons, windows &#8211; at any hardware resolution to match the physical size that you are comfortable with. This does away with the problem that at higher screen resolution, fonts look smaller (because at higher resolution the pixels themselves take up lesser space). Win7 included this feature after a lot of <a href="http://blogs.msdn.com/e7/archive/2008/09/13/follow-up-on-high-dpi-resolution.aspx" target="_blank">brainstorming</a>.</p>
<p>And of course, the question of high quality icons for Linux &#8211; there have been quite a few ideas <a href="http://brainstorm.ubuntu.com/idea/1134/" target="_blank">submitted</a> to Ubuntu about this &#8211; most of which rely on Scalable Vector Graphics for this. While being theoretically sound &#8211; there is a huge performance hit by using scalable graphics, rather than bitmaps for icons. OSX &#8211; which has arguably the sweetest eye candy &#8211; does <strong>not</strong> use vector graphics for its icons.</p>
<p>The key to this is its <a href="http://en.wikipedia.org/wiki/Apple_Icon_Image" target="_blank">ICNS</a> format &#8211; which has a set of images at <a href="http://ezix.org/project/wiki/MacOSXIcons" target="_blank">varying resolutions</a> for icons. Interestingly, GTK has had <a href="https://bugzilla.gnome.org/show_bug.cgi?id=395738" target="_blank">support</a> for Apple .icns for a <a href="http://svn.gnome.org/viewvc/gtk%2B/tags/GTK_2_13_0/gdk-pixbuf/io-icns.c?view=markup" target="_blank">long time</a> now. A very interesting discussion on the impact of resolution-independence on <a href="http://blog.cocoia.com/2007/truths-on-resolution-independence/" target="_blank">icons</a> is quite lively to read.</p>
<p>I would be all in favor of using the Apple ICNS format as the standard supported format in Linux. Except for not-invented-here, what&#8217;s not to like ? The format itself may demand support of scaling and resolution independent technologies to be included in GTK &#8211; which I think is a good thing, rather than mutating the icon format to support the state of GTK as it is now.</p>
<p>One gets access to a big market of designers who create high quality icon sets for MacOS (may more out there than for Gnome) and readily available toolchains (including for <a href="http://www.giantmike.com/articles/gimp_icon_tutorial.html" target="_blank">Gimp</a>)</p>
<p>Take a look here and tell you dont want <a title="Icon candy" href="http://www.cultofmac.com/icon-porn-feast-your-eyes-on-snow-leopards-beautiful-icons/15764" target="_blank">these</a> &#8230;. and then let&#8217;s talk.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Wireshark 1.2.3]]></title>
<link>http://macin.wordpress.com/2009/11/06/wireshark-123/</link>
<pubDate>Fri, 06 Nov 2009 10:18:43 +0000</pubDate>
<dc:creator>kabbala</dc:creator>
<guid>http://macin.wordpress.com/2009/11/06/wireshark-123/</guid>
<description><![CDATA[Wireshark 1.2.3 SVN Rev 30730 (2009-10-27) Gerald Combs 무료 · download for Intel CPU]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div style="text-align:center;">
<table border="0" align="center">
<tbody>
<tr align="center">
<td width="48" valign="top"><a href="http://macin.wordpress.com/files/2009/11/wireshark-icon.png"><img src="http://macin.wordpress.com/files/2009/11/wireshark-icon.png?w=48" alt="Wireshark Icon" title="Wireshark Icon" width="48" height="48" class="alignnone size-thumbnail wp-image-10235" /></a></td>
<td><a href="http://www.wireshark.org/">Wireshark</a> 1.2.3 SVN Rev 30730 <a href="http://www.wireshark.org/news/20091027.html">(2009-10-27)</a><br />
Gerald Combs</td>
</tr>
</tbody>
</table>
</div>
<div style="text-align:center;">무료 · <a href="http://wireshark.cs.pu.edu.tw/download/osx/Wireshark%201.2.3%20Intel.dmg">download for Intel CPU</a></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Gerar senha aleatória coma Python - Gráfico]]></title>
<link>http://mrsantos76.wordpress.com/2009/11/04/gerar-senha-aleatoria-coma-python-grafico/</link>
<pubDate>Wed, 04 Nov 2009 19:43:00 +0000</pubDate>
<dc:creator>mrsantos76</dc:creator>
<guid>http://mrsantos76.wordpress.com/2009/11/04/gerar-senha-aleatoria-coma-python-grafico/</guid>
<description><![CDATA[Há uns dias atrás mostrei como escrever um programinha pra gerar senha aleatória com python, bom res]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Há uns dias atrás mostrei como escrever um programinha pra gerar senha aleatória com python, bom resolvi montar uma interface gráfica pra ele usando gtk+glade+python o script que gera a senha é basicamente o mesmo que mostrei em outro post..<br />
bom galera espero que gostem, na verdade vi vários desses na net e resolvi tbm codificar o meu <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
há ia me esquecendo a tela que desenhei no glade é super simples tem um caixa de texto que dei o nome de senha<br />
um label que ira mostrar o resultado que dei o nome de resultado <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
e tem tbm 3 botoes,<br />
um pra gerar a senha, outro com about só pra fazer uso das caixas de mensagens e tem tbm um botão pra sair do programa, qq duvida a respeito das telas me avisem, vou ver se coloca elas aqui tbm <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre>
#! /usr/bin/python
# -*- coding: iso-8859-1 -*-

# Criado em: "03/11/2009"
# Autor: MRSantos mrsantos@viaconnect.com.br
#
# A espera não é uma esperaça vazia,
# possui a certeza interior de alcançar seu objetivo...

try:
	import gtk
except:
	print "Modulo python-gtk2 nao encontrado: sudo apt-get install python-gtk2"

try:
	import gtk.glade
except:
	print "Modulo python-glade2 nao encontrado: sudo apt-get install python-glade2"

import os
from random import choice

class gera_senha(object):

	def __init__(self):

		os.system("clear")
		dir = ''
		file = 'gera_senha.glade'
		path = "%s%s" % (dir, file)
		self.interface = gtk.glade.XML(path)
		self.interface.signal_autoconnect(self)

		self.janela = self.interface.get_widget("janela")
		self.janela.set_title("Gerador de senhas by mrsantos")
		self.janela.connect("destroy", gtk.main_quit)

		self.tamanho = self.interface.get_widget("tamanho")
		self.tamanho.set_text("10")

		self.resultado = self.interface.get_widget("resultado")

	def mensagem(self, texto, janela=None):
		dialogo= gtk.MessageDialog(janela, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, texto)
		dialogo.set_markup(texto)
		dialogo.run()
		dialogo.destroy()

	def gera_senha(self):
		tamanho = None
		caracters = '0123456789abcdefghijlmnopqrstuwvxz'
		try:
			tamanho = int(self.tamanho.get_text())
		except:
			tamanho = 10

		passwd = ''
		for char in range(tamanho):
			passwd += choice(caracters)

		return passwd

	def on_sair_clicked(self, widget):
		gtk.main_quit()

	def on_about_clicked(self, widget):
		texto = "<span>%s</span>" % (15000, 'blue', "By mrsantos")
		self.mensagem(texto)

	def on_gera_clicked(self, widget):
		passwd = self.gera_senha()
		self.resultado.set_label("<span>%s</span>" % \
		(15000, 'orange', passwd))

	def main(self):
		self.janela.show_all()
		gtk.main()

if __name__ == '__main__':
	gs = gera_senha()
	gs.main()
</pre>
<p>imagem da tela feita no glade</p>
<p><img src="http://lh4.ggpht.com/_B760yE8mvz4/SwQzMiLZCpI/AAAAAAAAAF4/ZzyX-6T264o/gera_senha_glade.png" alt="tela no glade" /></p>
<p>imagem do aplicativo pronto <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img src="http://lh5.ggpht.com/_B760yE8mvz4/SwQvM0UpGaI/AAAAAAAAAF0/VeSXlvTDOhw/gera_senha.png" alt="gera senha" /></p>
<p><img src="http://lh5.ggpht.com/_B760yE8mvz4/SwRK5J44WlI/AAAAAAAAAHA/kw4cA03sgko/about.png" alt="about" /></p>
<p>É isso ai galera, espero que gostem, abraços</p>
<p>Marcio</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using gtksourceview]]></title>
<link>http://aeosynth.wordpress.com/2009/11/03/using-gtksourceview/</link>
<pubDate>Wed, 04 Nov 2009 01:14:25 +0000</pubDate>
<dc:creator>aeosynth</dc:creator>
<guid>http://aeosynth.wordpress.com/2009/11/03/using-gtksourceview/</guid>
<description><![CDATA[I&#8217;m writing a gvim clone in Vala, and wanted auto-indentation for my &#8216;open new line]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m writing a gvim clone in <a href="http://live.gnome.org/Vala">Vala</a>, and wanted auto-indentation for my &#8216;open new line&#8217; function. So I looked around, and hey, all I have to do is <code>set_auto_indent (true);</code>. But wait, that&#8217;s using SourceView, and I&#8217;ve been using TextView! For a minute I panicked, thinking I would have to rewrite everything, but no, I pretty much just have to change<br />
<code>view = new TextView ();</code><br />
to<br />
<code>view = new SourceView ();</code><br />
and I&#8217;m good to go.</p>
<p>Well, not quite &#8211; auto-indentation is triggered on keypress, so instead of inserting a newline with:<br />
<code>buffer.insert_at_cursor ("\n", 1);</code><br />
I have to emit a keypress signal:<br />
<code>Event open = new Event (EventType.KEY_PRESS);<br />
open.key.keyval = 65293;//enter<br />
Signal.emit_by_name (view, "key-press-event", open);</code></p>
<p>This is what I end up with:</p>
<pre>using Gtk;
using Gdk;

public class TextEditor : Gtk.Window {

	public SourceView view;
	public TextBuffer buffer;

	public TextEditor () {
		this.set_default_size (400, 300);
		this.view = new SourceView ();
		view.set_auto_indent (true);
		this.buffer = this.view.buffer;
		buffer.text = "\toh hai";

		var scroll = new ScrolledWindow (null, null);
		scroll.set_policy (PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
		scroll.add (this.view);
		add (scroll);

		key_snooper_install (snoop_callback, null);
	}

	public int snoop_callback () {
		var event = get_current_event ();
		var key = event.key;
		if (event.type == EventType.KEY_PRESS) {
			switch (key.keyval) {
				case 111://o
					var offset = buffer.cursor_position;
					TextIter iter;
					buffer.get_iter_at_offset (out iter, offset);
					if (!iter.ends_line ())
						iter.forward_to_line_end ();
					buffer.place_cursor (iter);
					Event open = new Event (EventType.KEY_PRESS);
					open.key.keyval = 65293;//enter
					Signal.emit_by_name (view, "key-press-event", open);
					break;
				default:
					stdout.printf("%u %s\n", key.keyval, key.str);
					break;
			}
		}
		return 1;
	}

	public static int main (string[] args) {
		Gtk.init (ref args);

		var window = new TextEditor ();
		window.destroy.connect (Gtk.main_quit);
		window.show_all ();
		window.present ();

		Gtk.main ();
		return 0;
	}
}
</pre>
<p>This gives lots of warnings that I&#8217;m not sure what to do with, but it works.</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
