<?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>Pontus Östlund &#187; Vala</title>
	<atom:link href="http://www.poppa.se/blog/tag/vala/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.poppa.se/blog</link>
	<description>My blog about web development and such</description>
	<lastBuildDate>Mon, 16 Jan 2012 00:38:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Roxen Application Launcher 1.2.1</title>
		<link>http://www.poppa.se/blog/roxen-application-launcher-1-2-1/</link>
		<comments>http://www.poppa.se/blog/roxen-application-launcher-1-2-1/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 20:46:56 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Roxen]]></category>
		<category><![CDATA[gsettings]]></category>
		<category><![CDATA[GTK3]]></category>
		<category><![CDATA[RAL]]></category>
		<category><![CDATA[SOUP]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=548</guid>
		<description><![CDATA[
There&#8217;s a new release of Roxen Application Launcher (come again?) for Linux. 
Although the previous release, using GTK3, came quite recently this release has some new things.
GSettings
I dumped the &#8220;keyfile&#8221; solution for the application settings in favour to GSettings. So the settings is no longer stored in a file in the application directory but rather [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/data/images/ral-121.png"><img src="/blog/data/images/ral-121.png/680" alt="Roxen Application Launcher 1.2.1" /></a></p>
<p>There&#8217;s a new release of <a href="http://www.roxen.com">Roxen</a> Application Launcher (<a href="/blog/stuff/#roxen-applauncher">come again?</a>) for <a href="http://www.linux.com/">Linux</a>. </p>
<p>Although the previous release, using <code>GTK3</code>, came quite recently this release has some new things.</p>
<h2>GSettings</h2>
<p>I dumped the &#8220;keyfile&#8221; solution for the application settings in favour to <a href="http://developer.gnome.org/gio/2.30/GSettings.html">GSettings</a>. So the settings is no longer stored in a file in the application directory but rather in the system&#8217;s application settings backend. GSettings is part of GIO &#8211; the GNOME networking library &#8211; and since RAL depends on GIO no new dependency is needed. The upside is that I could put a file of source code in the bin! Plus, it&#8217;s fun learning new stuff!</p>
<h2>Editors and content types</h2>
<p>Previously I have kept an editor &#8211; name and command line &#8211; for every content type. Anders at <a href="http://roxen.com">Roxen</a> thought it&#8217;d be better if editors and content types were separated. I&#8217;ve thought about that before but never bothered to do anything about it.</p>
<p>But now, along with GTK3, there&#8217;s a new (I think) <code>AppInfo</code> class and the new <code>AppChooserButton</code> and <code>AppChooserDialog</code> widgets so I thought it&#8217;d be cool to use those. So selecting an editor for a new content type is way more simple now, and it also looks nicer. Plus we get the icon for the editor in the content type list under the &#8220;Applications&#8221; tab <img src='http://www.poppa.se/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>Simple logging</h2>
<p>I also implemented some simple logging which can be viewed under the new &#8220;Logging&#8221; tab. This will be worked upon and at the moment not very useful information is written to the log, but at least it&#8217;s a start.</p>
<h2>Default icons</h2>
<p>The icons in the notification popup &#8211; which only are three to the number &#8211; is now fetched from the user&#8217;s default icon theme. They we&#8217;re bundled before.</p>
<h2>SOUP all the way</h2>
<p>Previously I have used a little hack for saving downloaded files to disk. The problem was that the Vapi bindings for <code>libsoup</code> casted the data to a string which totally scrambled binary content like images and such. My solution was to write a simple C-function which took a <code>SoupMessageBody</code> struct as argument and then wrote that to diskt always keeping the <code>uint8[]</code> type of the content.</p>
<p>I bug reported this way back and it&#8217;s now fixed in Vala so I dumped my solution and am now using Vala all the way. Gone is one C and one Vapi file.</p>
<p>While at it I changed from using <em>blocking</em> functions in <code>libsoup</code> to the <em>async</em> ones. You never really noticed blocking calls was used before, but right is right. Right?</p>
<p><strong>And that&#8217;s that for this time I think!</strong></p>
<p><a class="download" title="Download from Github" href="https://github.com/downloads/poppa/Roxen-Application-Launcher/roxenlauncher-1.2.1.tar.bz2"><span>Roxen Application Launcher 1.2.1</span></a></p>
<p>Sources is available at the Roxen Application Launcher <a href="https://github.com/poppa/Roxen-Application-Launcher">Github repository</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/roxen-application-launcher-1-2-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GTK TreeViewColumn with icon and text</title>
		<link>http://www.poppa.se/blog/gtk-treeviewcolumn-with-both-icon-and-text-in-the-same-column/</link>
		<comments>http://www.poppa.se/blog/gtk-treeviewcolumn-with-both-icon-and-text-in-the-same-column/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 20:18:51 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CellRenderer]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[GTK]]></category>
		<category><![CDATA[GTK3]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[TreeViewColumn]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=534</guid>
		<description><![CDATA[
The other day I wanted to put both an icon and text in the same GTK+ TreeViewColumn, and I had absolutely no idea how to do that. So I Google&#8217;d and Google&#8217;d but had trouble finding any examples. I even downloaded the source code of the Gnome System Monitor &#8211; where exactly what I wanted [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/data/images/gtk-tvcol.png"><img src="/blog/data/images/gtk-tvcol.png/680" alt="TreeViewColumn with icon and text" /></a></p>
<p>The other day I wanted to put both an icon and text in the same <a href="http://www.gtk.org/">GTK+</a> <code>TreeViewColumn</code>, and I had absolutely no idea how to do that. So I Google&#8217;d and Google&#8217;d but had trouble finding any examples. I even downloaded the <a href="https://code.launchpad.net/gnome-system-monitor">source code</a> of the <a href="http://library.gnome.org/users/gnome-system-monitor/stable/">Gnome System Monitor</a> &#8211; where exactly what I wanted exist &#8211; but that was mostly written in C++ which I know very little of. </p>
<p>But I&#8217;m stubborn, and after a while I found and example in <a href="http://python.org/">Python</a> which I managed to interpret. Even though I know very little Python it&#8217;s not that hard to follow, and the example was short.</p>
<p>In short what&#8217;s needed is packing two <code>CellRenderer</code>s in the same <code>TreeViewColumn</code>. Quite logical when you know about it. The example below is in <a href="http://live.gnome.org/Vala">Vala</a>:</p>
<pre><code lang="vala">
var tree_view = new TreeView ();

var col = new TreeViewColumn ();
col.title = title;
col.resizable = true;

var crp = new CellRendererPixbuf ();
col.pack_start (crp, false);
col.add_attribute (crp, "pixbuf", 0);

var crt = new CellRendererText ();
col.pack_start (crt, false);
col.add_attribute (crt, "text", 1);

tree_view.insert_column (col, -1);
</code></pre>
<p>I hacked up a simple application that shows all installed programs &#8211; that has a <code>.desktop</code> entry I guess &#8211; in a list (the screenshot above). The sources is available at my <a href="https://github.com/poppa/PlayStation/tree/master/Vala/Gtk3/treeview-with-pixbuf">Github repository</a>.</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/gtk-treeviewcolumn-with-both-icon-and-text-in-the-same-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Roxen Application Launcher 1.1</title>
		<link>http://www.poppa.se/blog/roxen-application-launcher-1-1/</link>
		<comments>http://www.poppa.se/blog/roxen-application-launcher-1-1/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 22:28:34 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Roxen]]></category>
		<category><![CDATA[GTK]]></category>
		<category><![CDATA[GTK3]]></category>
		<category><![CDATA[RAL]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=519</guid>
		<description><![CDATA[
There&#8217;s a new release of Roxen Application Launcher (come again?) for Linux. 
I have updated the application launcher to use GTK3 so that it builds on Ubuntu 11.10 and any other Linux distribution using GTK3. This also made it possible to drop the dependency for libunique since Gtk.Application can handle single instance applications.
I also fixed [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/data/images/ral-1.1.png" class="no-file"><img src="/blog/data/images/ral-1.1.png/680" alt="Screenshot of Roxen Application Launcher" /></a></p>
<p>There&#8217;s a new release of <a href="http://www.roxen.com">Roxen</a> Application Launcher (<a href="/blog/stuff/#roxen-applauncher">come again?</a>) for <a href="http://www.linux.com/">Linux</a>. </p>
<p>I have updated the application launcher to use <code>GTK3</code> so that it builds on Ubuntu 11.10 and any other Linux distribution using <code>GTK3</code>. This also made it possible to drop the dependency for <code>libunique</code> since <code>Gtk.Application</code> can handle single instance applications.</p>
<p>I also fixed a bug which made it impossible to use the appliction launcher on sites not running on port <code>80</code> or <code>443</code>.</p>
<p>So there&#8217;s no new features in this release.</p>
<p><a class="download" title="Download from Github" href="https://github.com/downloads/poppa/Roxen-Application-Launcher/roxenlauncher-1.1.tar.bz2"><span>Roxen Application Launcher 1.1</span></a></p>
<p>Sources is available at the Roxen Application Launcher <a href="https://github.com/poppa/Roxen-Application-Launcher">Github repository</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/roxen-application-launcher-1-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Roxen Application Launcher 1.0.10</title>
		<link>http://www.poppa.se/blog/roxen-application-launcher-1-0-10/</link>
		<comments>http://www.poppa.se/blog/roxen-application-launcher-1-0-10/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 19:24:59 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Roxen]]></category>
		<category><![CDATA[GTK]]></category>
		<category><![CDATA[RAL]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=505</guid>
		<description><![CDATA[There&#8217;s a new release of Roxen Application Launcher (come again?) for Linux. 
No big news, but the GTK+ tree view of files is now sortable. The &#8220;minimize to tray&#8221; function is now actually invoked when the window is minimized rather than closed. A right click in the file list now also let you go the [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a new release of <a href="http://www.roxen.com">Roxen</a> Application Launcher (<a href="/blog/stuff/#roxen-applauncher">come again?</a>) for <a href="http://www.linux.com/">Linux</a>. </p>
<p>No big news, but the GTK+ tree view of files is now sortable. The &#8220;minimize to tray&#8221; function is now actually invoked when the window is minimized rather than closed. A right click in the file list now also let you go the the file&#8217;s directory in the Sitebuilder.</p>
<p>Also fixed a bug where the locales didn&#8217;t get installed correctly and also fixed a bug which scrambled the configuration file a bit.</p>
<p><a class="download" title="Download from Github" href="https://github.com/downloads/poppa/Roxen-Application-Launcher/roxenlauncher-1.0.10.tar.bz2"><span>Roxen Application Launcher 1.0.10</span></a></p>
<p>Sources is available at the Roxen Application Launcher <a href="https://github.com/poppa/Roxen-Application-Launcher">Github repository</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/roxen-application-launcher-1-0-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Variable length argument segfaults valac</title>
		<link>http://www.poppa.se/blog/variable-length-argument-segfaults-valac/</link>
		<comments>http://www.poppa.se/blog/variable-length-argument-segfaults-valac/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 20:53:41 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=482</guid>
		<description><![CDATA[Hm, found a bug in valac (the Vala compiler) today. If an abstract or virtual method contains a variable length argument (va_list) valac will segmentation fault.

// valac -o test sample.vala

int main(string[] args)
{
  return 0;
}

public abstract class Base : Object
{
  public abstract int query(string query, ... );
}

public class Child : Base
{
  public override [...]]]></description>
			<content:encoded><![CDATA[<p>Hm, found a bug in <code>valac</code> (the <a href="http://live.gnome.org/Vala/">Vala</a> compiler) today. If an abstract or virtual method contains a variable length argument (<code>va_list</code>) valac will segmentation fault.</p>
<pre><code lang="vala">
// valac -o test sample.vala

int main(string[] args)
{
  return 0;
}

public abstract class Base : Object
{
  public abstract int query(string query, ... );
}

public class Child : Base
{
  public override int query(string query, ... )
  {
    return 1;
  }
}
</code></pre>
<p>I&#8217;ve filed a <a href="https://bugzilla.gnome.org/show_bug.cgi?id=633218">bug</a> about it so we&#8217;ll see what the problem is and if it can be fixed rapidly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/variable-length-argument-segfaults-valac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Roxen Application Launcher 1.0.3</title>
		<link>http://www.poppa.se/blog/roxen-application-launcher-1-0-3/</link>
		<comments>http://www.poppa.se/blog/roxen-application-launcher-1-0-3/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 23:35:49 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Roxen]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Pike]]></category>
		<category><![CDATA[RAL]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=473</guid>
		<description><![CDATA[
In this release of Roxen Application Launcher (come again?) for Linux I&#8217;ve gotten rid of a few dependencies, namely: gconf, libgee and libgnome. The reason I dumped gconf and libgnome was to make it easier to install in KDE. I&#8217;ve verified it installs in KDE, although I noticed the translation doesn&#8217;t work and the Roxen [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/data/images/ral-103.png" class="no-file"><img src="/blog/data/images/ral-103.png/680" alt="Screenshot of Roxen Application Launcher" /></a></p>
<p>In this release of <a href="http://www.roxen.com">Roxen</a> Application Launcher (<a href="/blog/stuff/#roxen-applauncher">come again?</a>) for <a href="http://www.linux.com/">Linux</a> I&#8217;ve gotten rid of a few dependencies, namely: gconf, libgee and libgnome. The reason I dumped gconf and libgnome was to make it easier to install in KDE. I&#8217;ve verified it installs in KDE, although I noticed the translation doesn&#8217;t work and the Roxen SVG logo doesn&#8217;t show up in the window top border. </p>
<p><a href="/blog/data/images/ral-kde.png" class="no-file"><img src="/blog/data/images/ral-kde.png/680" alt="Screenshot of Roxen Application Launcher" /></a><br />
<em>Roxen Application Launcher in KDE</em></p>
<p>Libgee is a collections API written in Vala and since I used a newer version than what is available in most package managers, and I&#8217;m not sure all Linux distros provide libgee, I decided to dump it and implement the same functionality with the generic collection classes in Vala. And since the collections used in RAL is quite simple that worked out just fine. </p>
<p>I have also tried to implement bundled download, which is only used in Roxen Editorial Portal. Since I don&#8217;t have access to such an installation I haven&#8217;t been able to verify it works as expected. I re-implemented the same behavior as in the launcher written in Pike by the Roxen guys.</p>
<p>Oh, and if you already have an installation of my RAL your previously downloaded files and settings will not be available to the new install. Since I dumped gconf I now store the settings in a plain text file and I have put the RAL application directory in <code>~/.conf/roxenlauncher</code> since <code>~/.conf</code> is where you should put application specific data according to <a href="http://freedesktop.org">freedesktop.org</a>. In previous versions of RAL I stored application data in <code>~/.roxenlauncher</code> so if you want your previously downloaded files copy <code>~/.roxenlauncher/files</code> to <code>~/.conf/roxenlauncher/files</code>.</p>
<p>The sources is available at <a href="http://github.com/poppa/Roxen-Application-Launcher">Github</a>.</p>
<p><a href="/blog/data/roxenlauncher-1.0.3.tar.gz">Roxen Appliction Launcher 1.0.3</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/roxen-application-launcher-1-0-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Roxen Application Launcher 1.0</title>
		<link>http://www.poppa.se/blog/roxen-application-launcher-1-0/</link>
		<comments>http://www.poppa.se/blog/roxen-application-launcher-1-0/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 09:16:30 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Roxen]]></category>
		<category><![CDATA[Github]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[GTK]]></category>
		<category><![CDATA[RAL]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=467</guid>
		<description><![CDATA[
So I had a go at the Roxen Application Launcher (come again?) for Linux. I added a context menu &#8211; when you right click &#8211; to the file list. When you right click a file in the list you get the option to view that file in the Sitebuilder, edit it or remove it.
Other than [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/data/images/ral-1.0.png" class="no-file"><img src="/blog/data/images/ral-1.0.png/680" alt="Screenshot of Roxen Application Launcher with context menu" /></a></p>
<p>So I had a go at the <a href="http://www.roxen.com">Roxen</a> Application Launcher (<a href="/blog/stuff/#roxen-applauncher">come again?</a>) for <a href="http://www.linux.com/">Linux</a>. I added a context menu &#8211; when you right click &#8211; to the file list. When you right click a file in the list you get the option to view that file in the Sitebuilder, edit it or remove it.</p>
<p>Other than that there&#8217;s nothing new. And since the application seems to be very stable I decided to bump the version number to 1.0.</p>
<p>The sources is available at <a href="http://github.com/poppa/Roxen-Application-Launcher">Github</a>.</p>
<p><a href="/blog/data/roxenlauncher-1.0.tar.gz">Roxen Appliction Launcher 1.0</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/roxen-application-launcher-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Roxen Application Launcher 0.4.5</title>
		<link>http://www.poppa.se/blog/roxen-application-launcher-0-4-5/</link>
		<comments>http://www.poppa.se/blog/roxen-application-launcher-0-4-5/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 21:52:52 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Roxen]]></category>
		<category><![CDATA[Github]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[RAL]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=421</guid>
		<description><![CDATA[
Okey, here comes an update of my Roxen Application Launcher (come again?) for Linux. 
There&#8217;s no major changes to this release. The connection to the Roxen server is now stored in a shared object so that it can use a &#8220;keep-alive&#8221; connection. Not that I think it matters a great deal.
There&#8217;s now an option to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/data/images/ral-045.jpg" class="no-file"><img src="/blog/data/images/ral-045.jpg/680" alt="Screenshot of Roxen Application Launcher" /></a></p>
<p>Okey, here comes an update of my <a href="http://roxen.se">Roxen</a> Application Launcher (<a href="/blog/stuff/#roxen-applauncher">come again?</a>) for <a href="http://www.linux.com/">Linux</a>. </p>
<p>There&#8217;s no major changes to this release. The connection to the Roxen server is now stored in a shared object so that it can use a &#8220;keep-alive&#8221; connection. Not that I think it matters a great deal.</p>
<p>There&#8217;s now an option to change the behavior of the applications window close button so that it hides the application to the tray &#8211; or notification area as it&#8217;s called in <a href="http://gnome.org">Gnome</a> &#8211; rather than closes the application. </p>
<p>More <a href="http://live.gnome.org/Vala">Vala</a> programming to the people &#8211; <a href="http://github.com/poppa/Roxen-Application-Launcher">Sources at Github</a>.</p>
<p><a href="/blog/data/roxenlauncher-0.4.5.tar.gz">Roxen Appliction Launcher 0.4.5</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/roxen-application-launcher-0-4-5/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Roxen Application Launcher 0.4.4</title>
		<link>http://www.poppa.se/blog/roxen-application-launcher-0-4-4/</link>
		<comments>http://www.poppa.se/blog/roxen-application-launcher-0-4-4/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 22:58:28 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Roxen]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[GTK]]></category>
		<category><![CDATA[RAL]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=368</guid>
		<description><![CDATA[So, here&#8217;s a new release of the Roxen Application Launcher for Linux (RAL). The previous versions used my home made (sloppy so) HTTP client which didn&#8217;t handle redirects or secure connections &#8211; thank you tec for the feed back &#8211; since I had some major problems getting libsoup working with binary files like images and [...]]]></description>
			<content:encoded><![CDATA[<p>So, here&#8217;s a new release of the Roxen Application Launcher for Linux (RAL). The previous versions used my home made (sloppy so) HTTP client which didn&#8217;t handle redirects or secure connections &#8211; thank you <a href="/blog/new-roxen-application-launcher-for-linux-written-in-vala/#comments">tec</a> for the feed back &#8211; since I had some major problems getting <code>libsoup</code> working with binary files like images and such. Binary files was heavily scrambled when read from or written to disk so I made my own simple HTTP client that kept the data as a byte array to prevent some underlying libraries (GLib) from fiddling with it.</p>
<p>But I solved the <code>libsoup</code> issue so now the RAL handles redirects and secure connections. This is how I solved it:</p>
<h2>The <code>libsoup</code> issue</h2>
<p>When uploading a file back to the <a href="http://roxen.com">Roxen</a> server I use <code>IOChannel (g_io_channel in plain C)</code> instead of <code>Gio</code>. So the upload works like this:</p>
<pre><code lang="vala">
var sess = new Soup.SessionSync();
var mess = new Soup.Message("PUT", get_uri());
mess.request_headers.append("Cookie", get_cookie());
mess.request_headers.append("Translate", "f");

IOChannel ch = new IOChannel.file(local_file, "r");
ch.set_encoding(null); // Enables reading of binary data
string data;
size_t len;
ch.read_to_end(out data, out len);

mess.request_body.append(Soup.MemoryUse.COPY, data, len);
sess.send_message(mess);
</code></pre>
<p>And that seems to work like a charm!</p>
<p>When downloading data it&#8217;s a bit more tricky! Of course I tried using <code>IOChannel</code> in this case also but that made no difference. Downloaded images ended up 4 bytes long! But then I thought: You can make your own C bindings in Vala (remember the Vala compiler generates C code) through what is called Vapi files. So what I did was writing a C function that takes a <code>SoupMessageBody</code> object/struct passed from Vala and writes the data part to a file given as argument.</p>
<pre><code lang="cpp">
gboolean save_soup_data(SoupMessageBody *data, const char *file)
{
  FILE *fh;

  if ((fh = fopen(file, "w")) == NULL) {
    fprintf(stderr, "Unable to open file \"%s\" for writing!\n", file);
    return FALSE;
  }

  int wrote = fwrite(data->data, 1, data->length, fh);

  if (wrote != (int)data->length) {
    fprintf(stderr, "wrote (%d) != data->length (%d). Data may have been "
                    "truncated", wrote, (int)data->length);
  }

  fclose(fh);
  return TRUE;
}
</code></pre>
<p>And this was then made available to Vala by the following Vapi file:</p>
<pre><code lang="vala">
[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "")]
namespace Soppa // Soppa is Swedish for Soup <img src='http://www.poppa.se/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />
{
  [CCode (cname = "save_soup_data")]
  public bool save_soup_data(Soup.MessageBody data, string file);
}
</code></pre>
<p>And this is how the actual Vala code downloading the files looks like:</p>
<pre><code lang="vala">
var sess = new Soup.SessionSync();
var mess = new Soup.Message("GET", get_uri());
mess.request_headers.append("Cookie", get_cookie());
mess.request_headers.append("Translate", "f");
sess.send_message(mess);

if (mess.status_code == Soup.KnownStatusCode.OK) {
  // Here I call the C function made available through the Vapi file
  if (Soppa.save_soup_data(mess.response_body, local_file)) {
    message("The file was downloaded and written to disk OK");
  }
  else {
    message("Failed writing data to disk!");
  }
}
</code></pre>
<p>So that&#8217;s that on that! <img src='http://www.poppa.se/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>The notification</h2>
<p><img src="/blog/data/images/libnotify.png" class="alignright"/> I also &#8211; just for fun &#8211; implemented a notification mechanism through <code>libnotify</code>. Since I believe that can be rather annoying it&#8217;s not activated by default but can easily be activated by a checkbox in the user interface.</p>
<h2>The packages</h2>
<p>The Roxen Application Launcher for Linux can be downloaded at the <a href="http://github.com/poppa/Roxen-Application-Launcher/downloads"><strong>download page</strong></a> at <a href="http://github.com">Github</a> where also the <a href="http://github.com/poppa/Roxen-Application-Launcher"><strong>work in progress sources</strong></a> is available or downloaded below!</p>
<p><a href="/blog/data/roxenlauncher-0.4.4.tar.gz">Roxen Application Launcher 0.4.4</a></p>
<p>Stay black!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/roxen-application-launcher-0-4-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Bitlyfier &#8211; A Bit.ly client for GNOME</title>
		<link>http://www.poppa.se/blog/bitlyfier-a-bit-ly-client-for-gnome/</link>
		<comments>http://www.poppa.se/blog/bitlyfier-a-bit-ly-client-for-gnome/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 23:46:14 +0000</pubDate>
		<dc:creator>Pontus</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[Vala]]></category>

		<guid isPermaLink="false">http://www.poppa.se/blog/?p=333</guid>
		<description><![CDATA[ For those of us tweeting &#8211; or sharing web addresses in general &#8211; these long addresses with extensive query strings you wan&#8217;t to share isn&#8217;t too user friendly. So we have Bit.ly, among others, that lets you shorten a URL &#8211; or give it an alias if you like &#8211; and also gives you [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/blog/data/images/bitlyfier/bitlyfier-about.png" alt="Bitlyfier" class="alignright nobg"/> For those of us tweeting &#8211; or sharing web addresses in general &#8211; these long addresses with extensive query strings you wan&#8217;t to share isn&#8217;t too user friendly. So we have <a href="http://bit.ly">Bit.ly</a>, among others, that lets you shorten a URL &#8211; or give it an alias if you like &#8211; and also gives you statistics on how many clicks it has and if it&#8217;s shared on Twitter and what not. </p>
<p>Since I&#8217;m on the quest of learning the programming language <a href="http://live.gnome.org/Vala/">Vala</a> I though why not making a Bit.ly desktop client for <a href="http://gnome.org/">GNOME</a>. So I did!</p>
<h2>The desktop client</h2>
<p>There&#8217;s really nothing extraordinary about it, in fact it&#8217;s quite simple. Put a long URL in the input field and hit &#8220;OK&#8221;. You&#8217;ll get the shortened URL back in the same input field.</p>
<p><em>NOTE! The screenshots is showing the Swedish translation but the interface is orginally in English.</em></p>
<p><em><small>Shortening a long URL</small></em><br />
<img src="/blog/data/images/bitlyfier/bitlyfier-2.png" alt="Shortening an URL with Bitlyfier" /></p>
<p><em><small>The shortened URL</small></em><br />
<img src="/blog/data/images/bitlyfier/bitlyfier-3.png" alt="The Bit.ly shortened URL" /></p>
<p>To use the application you will of course need a Bit.ly account. The first time Bitlyfier is launched it will ask for your Bit.ly account settings. Just fill in your username and API key (it&#8217;s found on your account page at <a href="http://bit.ly/account">http://bit.ly/account</a>).</p>
<p><em><small>Bitlyfier account settings</small></em><br />
<img src="/blog/data/images/bitlyfier/bitlyfier-settings.png" alt="The bitlyfier settings dialog" /></p>
<h2>The command line interface</h2>
<p>For the hacker you, Bitlyfier can also be used as a command line tool. These are the options:</p>
<pre><code lang="none">
Usage:
  bitlyfier [OPTION...] - Bitlyfier, URL shortener/expander

Help Options:
  -h, --help        Show help options

Application Options:
  -e, --expand      Expands the given URL
  -s, --shorten     Shortens the given URL
  -n, --no-gui      Sets the application in command line mode
  -g, --gconf       Invokes setting username and apikey
</code></pre>
<p>NOTE! You should quote the value of the &#8216;-s&#8217; flag. If the URL to be shortened<br />
contains a querystring with ampersands the URL will be truncated if it&#8217;s not<br />
quoted. </p>
<p>So to shorten a long URL do like:</p>
<pre>  user@machine:~$ bitlyfier -n -s "http://domain.com/long/url/to/shorten"</pre>
<h2>The Vala Bitly API classes</h2>
<p>The Bitly API class I&#8217;ve written can of course be used standalone (it&#8217;s located in <code><a href="http://bit.ly/4DsuVg">src/bitly.vala</a></code> in the sources package downloadable below). Here&#8217;s an example of usage:</p>
<pre><code lang="vala">
// main.vala
// Compile: valac --pkg gee-1.0 --pkg json-glib-1.0 --pkg libsoup-2.4 -o main

int main(string[] argv)
{
  Bitly.Api api = new Bitly.Api("username", "R_the_api_key");
  Bitly.Response response = api.shorten("http://domain.com/the/long/url");
  stdout.printf("Short URL: %s\n", response.get_string("shortUrl"));

  response = api.stats("A2ma2z");
  stdout.printf("Clicks: %d\n", response.get_integer("clicks"));

  return 0;
}
</code></pre>
<p>More about the Bit.ly API and what the API methods do can be read about at <a href="http://bit.ly/6HIqjS">http://bit.ly/6HIqjS</a>.</p>
<h2>The sources</h2>
<p>The development sources of this application is available at <a href="http://bit.ly/7QFHvC"><strong>Bitlyfier at Github</strong></a>. The current stable release can be found at the <a href="http://github.com/poppa/Bitlyfier/downloads"><strong>Download page</strong></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.poppa.se/blog/bitlyfier-a-bit-ly-client-for-gnome/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

