<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.7.6(BH)" -->
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>Planet Maemo: category &quot;feed:2f9a1cd8dccee7a19cc07970574b4d4a&quot;</title>
        <description>Blog entries from Maemo community</description>
        <link>http://maemo.org/news/planet-maemo/</link>
        <lastBuildDate>Sat, 04 Apr 2026 00:05:00 +0000</lastBuildDate>
        <generator>FeedCreator 1.7.6(BH)</generator>
        <language>en</language>
        <managingEditor>planet@maemo.org</managingEditor>
        <item>
            <title>Performance and Memory Usage of Evolution Data Server</title>
            <link>http://taschenorakel.de/mathias/2012/06/20/performance-and-memory-usage-of-evolution-data-server/</link>
            <description><![CDATA[

<p><a href="http://www.openismus.com/">Openismus</a> asked me to perform some benchmarks on <a href="https://live.gnome.org/Evolution/EDS_Architecture">Evolution Data Server</a>. We wanted to track the progress of recent performance improvements and identify possible improvements. Therefore, I tested these versions of EDS:</p>
<ul>
<li><a href="http://git.gnome.org/browse/evolution-data-server/tree/NEWS?id=EVOLUTION_DATA_SERVER_3_5_2">EDS 3.5.2</a> from June 4th 2012 - the latest development release.</li>
<li><a href="http://git.gnome.org/browse/evolution-data-server/tree/NEWS?id=EVOLUTION_DATA_SERVER_3_4_2">EDS 3.4.2</a> from May 14th 2012 - the latest stable release.</li>
<li><a href="http://git.gnome.org/browse/evolution-data-server/tree/NEWS?id=EVOLUTION_DATA_SERVER_3_2_3">EDS 3.2.3</a> from January 9th 2012 - shipped with <a href="http://www.ubuntu.com/">Ubuntu 12.04 LTS</a>.</li>
<li><a href="http://git.gnome.org/browse/evolution-data-server/tree/NEWS?id=EVOLUTION_DATA_SERVER_2_32_3">EDS 2.32.3</a> from April 21th 2011, - the last stable release of the <a href="http://www.gnome.org/">GNOME 2</a> series.</li>
<li><a href="https://maemo.gitorious.org/eds-fremantle/eds-fremantle">Maemo Fremantle's EDS fork</a> from June 23th 2010, which was carefully optimized for the <a href="http://en.wikipedia.org/wiki/Nokia_N900">Nokia N900</a>.</li>
</ul>
<p>The code is in a <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks">phonebooks-benchmarks repository on Gitorious</a> with a full auotools build, and with a script to build and test all these versions of EDS. So you can try this too, and you can help to correct or improve the benchmarks. See below for details. </p>
<p>EDS offers various APIs to access the address book. The traditional interface was <a href="http://developer.gnome.org/libebook/stable/EBook.html">EBook</a>, which has served us well in <a href="http://www.gnome.org/">GNOME 2</a> and <a href="http://de.wikipedia.org/wiki/Maemo">Maemo 5</a>. However, some APIs such as batch saving are missing in the upstream version. Also its asynchronous API doesn't follow the conventions established later by <a href="http://developer.gnome.org/gio/stable/">GIO</a>. To overcome these EBook shortcomings, and to make efficient use of <a href="http://developer.gnome.org/gio/stable/gdbus-convenience.html">GDBus</a>, the <a href="http://developer.gnome.org/libebook/stable/EBookClient.html">EBookClient</a> API was added in EDS 3.2. We can even use the backend <a href="http://developer.gnome.org/libedata-book/stable/EDataBook.html">EDataBook</a> API, and that lets us measure the overhead imposed by using D-Bus.</p>
<p>I tested the back-ends with different numbers of contacts. For each benchmark, and for each contact count, we create an entirely new private database. D-Bus communication was moved to a private D-Bus session. To avoid swapping, the maximum virtual memory size was limited to 2 GiB per ulimit command. This limit probably caused the crash of Maemo 5's EDS in the test with 12,800 contacts, but I have not checked that yet.</p>
<h2>Contact Saving</h2>
<p>These benchmarks simply store a list of parsed contacts in the address book. This simulates use cases such as the initial import of contacts upon migration or synchronization.</p>
<p>To avoid possible side effects from lazy parsing, we retrieve the attribute list for each contact before starting the benchmark.  With <a href="http://developer.gnome.org/libebook/stable/EBook.html">EBook</a> from <a href="https://maemo.gitorious.org/eds-fremantle/eds-fremantle">Maemo 5</a> and <a href="http://developer.gnome.org/libebook/stable/EBookClient.html">EBookClient</a> since EDS 3.4, contacts are saved in batches of 3,200 contacts. This partitioning was needed to deal with resource limitations in the file backend. All other EDS variants must save their contacts one by one.</p>
<p><img alt="Contact saving, without batching" src="http://taschenorakel.de/files/eds-benchmarks/contact-saving-normal.png" /></p>
<blockquote>
<p><small><a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookbenchmark.cpp#line62">EBook</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookclientbenchmark.cpp#line54">EBookClient</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/edatabookbenchmark.cpp#line88">EDataBook</a> implementation</small></p>
</blockquote>
<p>As expected, the effort for contact saving grows quickly when not using a batch API. This is because a new database transaction must be created and committed for each contact. Things look much better when using the batch saving API which was available in Maemo 5 already, and was recently added to EBookClient:</p>
<p><img alt="Contact saving in batches" src="http://taschenorakel.de/files/eds-benchmarks/batch-saving-normal.png" /></p>
<p>Batch saving performance of EDS 3.4+ is <em>just excellent</em>: Although slowly growing with the number of contacts, it remains below a threshold of 3 ms per contact even for 12,800 contacts. That growing effort can be accounted to growing attribute indices. The initial peak (until 50 contacts for Maemo 5, and until 400 contacts for EDS 3.4+) can be accounted to database setup cost.</p>
<p>In terms of performance there is no difference between using EBookClient or EDataBook (which avoids D-Bus).</p>
<h2>Contact Fetching</h2>
<p>A very basic, but essential, benchmark is fetching all contacts. To get a first impression I just fetched all contacts without any constraints.</p>
<p><img alt="Fetch all contacts" src="http://taschenorakel.de/files/eds-benchmarks/fetch-all-contacts.png" /></p>
<blockquote>
<p><small><a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookbenchmark.cpp#line144">EBook</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookclientbenchmark.cpp#line150">EBookClient</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/edatabookbenchmark.cpp#line181">EDataBook</a> implementation</small></p>
</blockquote>
<p>Contact fetching performance decreased significantly during the EDS 3 series and then got better again: Fetching all contacts with 3.4 takes about 133% of the time that EDS 2.32 needs and even 225% of Maemo 5's time. With EDS 3.5 contact loading time is improving again, making the EBook version of EDS 3.5 comparable in performance to EDS 2.32. Git archeology and quick testing identifies <a href="https://bugzilla.gnome.org/show_bug.cgi?id=673527">Christophe Dumez's bugfix</a> as the relevant change. Apparently the file backend didn't make optimal use of 
Berkeley DB transactions.</p>
<p>Still there is significant room for improvement, because:</p>
<ol>
<li>simple contact fetching with EBook 3.5 still takes 175% of the time Maemo 5 needs.</li>
<li>EBookClient 3.5 is still 20% slower than EBook 3.5, and 64% slower than EDataBook.</li>
</ol>
<p>This basic test shows already that the chosen client-server architecture of EDS causes a non-ignorable overhead.</p>
<p>It would be absolutely worth investigating how Maemo 5 reaches its far superior performance: After all it even beats EDataBook. I remember having spent significant time on avoiding vCard parsing and string copying. I also remember having replaced the rather inefficient GList with GPtrArray at several places. Some of the ideas have been ported upstream during <a href="http://wiki.meego.com/Architecture/planning/evolution-data-server/eds-improvements">Openismus' work for Intel</a>. Apparently there are more gems to recover.</p>
<h2>Fetching by UID</h2>
<p>Fetching contacts by UID simulates lazy loading of contact lists: Initially, we only fetch contact IDs. We only fetch the full contacts when the device becomes idle, or when contacts become visible on screen. This approach is needed because even the fastest implementation (Maemo 5) needs several seconds to fetch any contact list of realistical size on mobile hardware.
Another useful optimization we implemented on the Nokia N9 is fetching of partial contacts, that only contain relevant information, like for instance the person's name. EDS doesn't support this optimization.</p>
<p>As a first test we fetch contacts one-by-one, without using any kind of batch API:</p>
<p><img alt="Fetch by UID without batches" src="http://taschenorakel.de/files/eds-benchmarks/fetch-by-id-without-batches.png" /></p>
<blockquote>
<p><small><a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookbenchmark.cpp#line111">EBook</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookclientbenchmark.cpp#line116">EBookClient</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/edatabookbenchmark.cpp#line138">EDataBook</a> implementation</small></p>
</blockquote>
<p>The good news is that this chart shows quite constant performance for each client.</p>
<p>The bad news is that contact fetching is pretty slow: 3.9 ms per contact, as seen with EDS 3.5, translates roughly to 390 ms to fetch only 100 contacts on this hardware. Considering that typical mobile devices are roughly 10 times slower than my notebook, these numbers are disappointing. Especially if you consider that EDS 2.32 was about 4 times, and Maemo 5 even about 13 times faster. This are entirely different worlds. It should be investigated what causes this significant performance regression from EDS 2.32 to EDS 3.2+. One also should try to port the performance fixes of Maemo 5.</p>
<p>The performance reachable under ideal circumstances is shown by the EDataBook client. This only needs about 50 µs (0.05 ms) to fetch one contact by its id. <em>Directly accessing the address book via EDataBook is about two orders of magnitude faster than the current EBookClient</em>. That's the goal that EDS can, and should, aim for. Apparently a significant amount of time is spent on performing D-Bus communication, whereas the requested task can be performed by the backend within almost no time.</p>
<p>However, this data was acquired by fetching the contacts one by one. We can surely do better by using a batch API. That should drastically reduce the overhead caused, for instance, by D-Bus. But neither EBook or EBookClient provide an API to fetch contacts by lists of contact IDs. The thing that comes closest is filtering the contacts by a disjunction of UID field tests:</p>
<pre><code>(or (is "id" "uid1") (is "id" "id2") ...)
</code></pre>
<p>So I tried that. The results for such queries, using batches of UIDs, look like this:</p>
<p><img alt="Fetch by UID in huge batches" src="http://taschenorakel.de/files/eds-benchmarks/fetch-by-id-in-huge-batches.png" /></p>
<blockquote>
<p><small><a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookbenchmark.cpp#line136">EBook</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookclientbenchmark.cpp#line142">EBookClient</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/edatabookbenchmark.cpp#line173">EDataBook</a> implementation</small></p>
</blockquote>
<p>This chart speaks for itself. To remain responsive and appear fluid while scrolling, applications should render at 60 frames per second. To reach that framerate newly visible contacts must be fetched and rendered within less than 16 ms. EDS apparently cannot meet that performance goal even on desktop computers. Considering the huge performance differences between client-server access and direct access, as seen when fetching contacts one by one, it seems very worthwhile to add dedicated support for fetching multiple contacts by UID. The most obvious approach would be adding a batch API in the spirit of <code>e_book_client_add_contacts()</code>. Another solution would be adding more fast paths to the query processing code.</p>
<h2>Filtering</h2>
<blockquote>
<p><small><a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookbenchmark.cpp#line105">EBook</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/ebookclientbenchmark.cpp#line110">EBookClient</a>, <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/edatabookbenchmark.cpp#line132">EDataBook</a> implementation, the <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/edsbenchmark.cpp#line239">queries used</a></small></p>
</blockquote>
<p>Contact filtering is relatively efficient when using fields such as last-name, for which indices are hit. Still, the D-Bus overhead is noticeable: EDataBook needs less than 60% of EBook's or EBookClient's time.</p>
<p><img alt="" src="http://taschenorakel.de/files/eds-benchmarks/filter-by-family-name.png" /></p>
<p>The times to match long prefixes and suffixes look quite similar when hitting indices.</p>
<p>The behavior of EBook for short name prefixes is a bit strange. The EBook API is now deprecated, but it could still be worthwhile to identify the issue causing this strange behavior, so that it can be avoided in the future:</p>
<p><img alt="" src="http://taschenorakel.de/files/eds-benchmarks/filter-by-short-family-name-prefix.png" /></p>
<p>Interestingly, there seem to be no <em>functional</em> database indices for email addresses or phone numbers in more recent versions of EDS:</p>
<p><img alt="" src="http://taschenorakel.de/files/eds-benchmarks/filter-by-email-address.png" />
<img alt="" src="http://taschenorakel.de/files/eds-benchmarks/filter-by-long-phone-number-suffix.png" /></p>
<p>The behavior of Maemo 5's EDS is a bit surprising, as I know that <a href="http://www.robster.org.uk/blog/">Rob</a> spent significant amounts of time on adding Berkeley DB based indices to that EDS version.</p>
<p>It might be worth optimizing index usage in EDS, because prefix and suffix searches are commonly used in mobile applications. Prefix searches need to be fast, for quick feedback during auto completion. Suffix searches need to be fast, for instance to provide instant caller identification.</p>
<h2>Memory Usage</h2>
<p>Memory is cheap those days. Still, especially on embedded devices, you should keep a close eye on the memory consumption of your software. Obviously, memory consumption grows with the number of contacts used:</p>
<p><img alt="Resident Set Size (RSS)" src="http://taschenorakel.de/files/eds-benchmarks/memory-usage-rss.png" /></p>
<p>It's nice to see how memory consumption has reduced from release to release. It's also good to see that EBookClient seems to use slightly less memory than EBook.</p>
<p>You might miss the graphs for Maemo 5 and EDS 2.32. I had to drop them for this chart as they show <a href="http://taschenorakel.de/files/eds-benchmarks/memory-usage-rss-leaking.png">serious memory leaks</a>, preventing any useful examination. Apparently the leak really is in those versions of EDS: The EBook benchmarks for EDS 3.2+ are using exactly the same code but don't show this bad behavior.</p>
<p>Notice that I've accumulated the client's and the backend's memory consumption. This allows us to estimate the cost of EDS's client-server architecture. Apparently this architecture increases memory consumption by about 40% in these benchmarks.</p>
<p>While the RSS usage gives us information about the efficiency and correctness of the code, it's also interesting to check the virtual memory size needed by the benchmarks. Please take the following numbers with a <strong>reasonable grain of salt</strong>: I got these numbers by simply adding together the virtual memory size of the client and of the backend process, as reported by the processes' <em>status</em> file. A proper measurement would process the <em>maps</em> file to properly account for shared memory regions.</p>
<p><img alt="Virtual Memory Size (VMS)" src="http://taschenorakel.de/files/eds-benchmarks/memory-usage-vms.png" /></p>
<p>The first issue we notice is the massively increased memory usage of EBookClient 3.2. It's almost 40% more than the others. Fortunately, the issue seems to have been fixed already in EDS 3.4.</p>
<p>At first glance, the very low virtual memory usage of the EDataBook benchmark is impressive. It seems to consume only 40% of the client-server based benchmarks. Still, there is a fairly high chance that this huge delta must be attributed to my poor measurement here: Assuming perfect code segment sharing there only remains a delta of about 20 MiB, which would be nothing but the RSS delta of EDataBook and EBookClient. It would be nice to investigate this in more detail.</p>
<p><img alt="RSS usage per contact" src="http://taschenorakel.de/files/eds-benchmarks/rss-per-contact.png" /></p>
<p>This chart shows the memory per contact after the contact saving benchmark. The overall memory usage per contact has grown dramatically by almost 40% in EDS 3+. The most efficient approach is apparently to directly access EDataBook, which consumes only 55% of the RSS per contact, compared to the client-server approaches.</p>
<p><img alt="RSS usage per contact, model only" src="http://taschenorakel.de/files/eds-benchmarks/rss-per-contact-model.png" /></p>
<p>This high memory usage per contact is a bit surprising since, after subtracting effects from library and database initialization, the memory usage per contact remained constant between EDS 2.32 and EDS 3.5. The parallel usage of both Berkeley DB and SQLite in the file backend might be to blame, but this is currently pure speculation from me.</p>
<p>The temporary regression in EDS 3.2 was apparently fixed. The increased memory usage of EBookClient and EDataBook over EBook is because the EBookClient and EDataBook benchmarks, in a slightly unrealistic bias for performance, store both the EContact and the VCard string for each contact.</p>
<h2>Conclusions</h2>
<p>The developers of Evolution Data Server have paid good attention to performance and have successfully implemented significant improvements. However, EDS releases regularly suffer performance regressions, and the performance of EDS still isn't good enough for usage in mobile devices. Fortunately the performance problems are solvable. Some fixes will be straightforward, such as adding more batch API (or fast paths) for query processing. Others will need careful performance monitoring: For instance when activating more database indices, to speed up queries, we must be careful not to slow down contact saving.</p>
<p>A not so trivial improvement would be adding a direct access API for reading the local database. The speed and memory usage 
measurements show the value of such API: Direct access is significantly faster than via D-Bus in most usage cases, and it seems to significantly reduce memory usage.</p>
<p>Another significant improvement should be finishing the file backend's transition to SQLite: Using two database backends in parallel significantly increases code complexity and has measurably bad impact on memory consumption.</p>
<h2>Usage Instructions</h2>
<p>The full source code of this project is in our <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks">phonebooks-benchmarks repository on Gitorious</a>. You'll need a fairly recent C++ compiler because I also used this project to get more familiar with the new features of C++11. I've successfully tested g++ 4.6.3 and g++ 4.7.0. Clang 3.0 definitely won't work because of incomplete lambda support.</p>
<p>Other than that, you'll need <a href="http://www.boost.org/">Boost 1.48</a> to compile the benchmarks. The optional chart-drawing module uses <a href="http://www.imagemagick.org/www/Magick++/">ImageMagick++</a> and
<a href="http://mathgl.sourceforge.net/">MathGL 2.0.2</a>.</p>
<p>There is a simple script for building and installing the tested EDS versions. The configure script will give instructions.</p>
<p>To finally run the benchmarks just call <code>src/phonebook-benchmarks</code>, and to draw the charts run <code>src/phonebook-benchmarks-mkcharts</code>.</p>
<p>When doing your own tests that needs a non-trivial vCard generator take look at <a href="https://gitorious.org/openismus-playground/phonebook-benchmarks/blobs/master/src/mkvcards.cpp"><code>src/phonebook-benchmarks-mkvcards</code></a>.</p>
<h2>Outlook</h2>
<p>It would be interesting to take a more detailed look at the virtual memory usage.</p>
<p>Also it would be educational to compare these results with other address book implementations. The first candidates I have in mind are <a href="https://gitorious.org/qtcontacts-tracker">QtContacts on Tracker</a> and <a href="https://review.tizen.org/git/?p=api/contacts.git;a=tree">Tizen's native contacts API</a>.</p>
<p>We didn't cover <a href="http://developer.gnome.org/libebook/stable/EBookView.html">EBookView</a> and <a href="http://developer.gnome.org/libebook/stable/EBookClientView.html">EBookClientView</a> yet. These views take a query and notify the application when the contact set matching the query has changed. Typically, every user interface needs to use them.</p>
<p>We also didn't talk about the calendar API yet.</p>
<p>Well, and most importantly we at <a href="http://www.openismus.com/">Openismus</a> would enjoy fixing the identified performance problems.</p>
<span class="net_nemein_favourites">4 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=e61e5614ba7011e1a673130ed6e2cf99cf99&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/e61e5614ba7011e1a673130ed6e2cf99cf99/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>1 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=e61e5614ba7011e1a673130ed6e2cf99cf99&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/e61e5614ba7011e1a673130ed6e2cf99cf99/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Wed, 20 Jun 2012 00:26:40 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-e61e5614ba7011e1a673130ed6e2cf99cf99</guid>
        </item>
        <item>
            <title>Qt Contributors Summit is over</title>
            <link>http://taschenorakel.de/mathias/2011/06/18/qt-contributors-summit-over/</link>
            <description><![CDATA[

<p>Really enjoyed the <a href="http://bit.ly/qcswiki">Qt Contributors Summit</a>. Nice, open minded people. <a href="http://www.moskauberlin.net/">Caf&#233; Moskau</a> turned out as awesome location for technical orientated meetings.</p>
<p>Even held my own little session about my griefs with <a href="http://developer.qt.nokia.com/groups/qt_contributors_summit/wiki/ImprovingObjectLifeCycle">QObject life-cycle</a>. We found some few chances for improvement, but we also sadly had to conclude that proper two-phase construction and destruction isn't possible in C++, unless you forbid stack allocation and usage of the delete operator. Actually had my little pervert moment of pleasure when realising that <a href="http://labs.qt.nokia.com/author/thiago/">Thiago</a> seems a bit jealous for the freedom GObject gets from plain C.</p>
<p>Still wondering a bit if there's really no way to implement proper two-phase destruction in C++. Must we really bribe the C++ standard committee to enhance the specification?</p>
<p><a href="http://bit.ly/qcswiki"><img alt="I am attending the Qt Contributors' Summit" src="http://get.qt.nokia.com/marketing/summit_01.png" /></a></p>
<span class="net_nemein_favourites">4 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=3074548e99ca11e0bec26de363708a1b8a1b&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/3074548e99ca11e0bec26de363708a1b8a1b/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=3074548e99ca11e0bec26de363708a1b8a1b&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/3074548e99ca11e0bec26de363708a1b8a1b/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Sat, 18 Jun 2011 16:01:59 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-3074548e99ca11e0bec26de363708a1b8a1b</guid>
        </item>
        <item>
            <title>Qt Contributors&amp;#39; Summit </title>
            <link>http://taschenorakel.de/mathias/2011/05/10/qt-contributors-summit/</link>
            <description><![CDATA[

<p><a href="http://bit.ly/qcswiki"><img alt="I am attending the Qt Contributors' Summit" src="http://get.qt.nokia.com/marketing/summit_01.png" /></a>.</p>
<p>A bit odd for something with my background? Does that mean I am leaving the GNOME universe?</p>
<p>No. It just happens in Berlin, and <a href="http://gitorious.org/qtcontacts-tracker/qtcontacts-tracker">I've just spent lots of time</a> on letting <a href="http://doc.trolltech.com/qtmobility-1.2/qtcontacts.html">QtContacts</a> use some awesome GNOME technology (<a href="http://www.tracker-project.org/">tracker</a>). On the summit I'll try to convince some Qt core guys, that maybe UTF-8 would be a much better choice for the Linux port of Qt. It would improve interaction with kernel, DBus and GNOME libraries so much. Well, and maybe I can get them to consider more reasonable memory management for QObject: With Qt leaving the GUI corner it's simple parent-ownership model doesn't fit anymore. QtQuick already skips that obsolete model. Now let's also let C++ components benefit.</p>
<p>PS: If someone ever wants to modernize libebook, then looking at QtContacts API is a good exercise. It was designed to explicitly fix the issues we had with libebook during Fremantle. Actually even thought of making a GIR typelib for QtContacts - but that's a different story and maybe even doesn't make sense.</p>
<span class="net_nemein_favourites">6 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=67c240b47af211e089b1c7441a9e52ed52ed&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/67c240b47af211e089b1c7441a9e52ed52ed/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=67c240b47af211e089b1c7441a9e52ed52ed&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/67c240b47af211e089b1c7441a9e52ed52ed/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Tue, 10 May 2011 09:40:34 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-67c240b47af211e089b1c7441a9e52ed52ed</guid>
        </item>
        <item>
            <title>Operator Overloading</title>
            <link>http://taschenorakel.de/mathias/2010/09/15/operator-overloading/</link>
            <description><![CDATA[

<p>Just wondered right now why Qt doesn't provide a greater-than operator for QSize.</p>
<p>Well, indeed: How would you define this operator? Maybe like this?</p>
<pre><code>inline bool 
operator &gt;(const QSize &amp;a, const QSize &amp;b)
{
    return a.width() * a.height() &gt; b.width() * b.height();
}
</code></pre>
<p>Or is this the proper definition?</p>
<pre><code>inline bool 
operator &gt;(const QSize &amp;a, const QSize &amp;b)
{
    return (a.width() &gt; b.width() || a.height() &gt; b.height());
}
</code></pre>
<p>Mathematician might intuitively choose the first alternative, aka. covered area.
I claim for UI problems usually the second interpretation is useful.</p>
<p>Funnily the Qt author(s) of QSize implicitly agree with my claim, as they provide:</p>
<pre><code>inline bool QSize::isValid() const
{
    return wd&gt;=0 &amp;&amp; ht&gt;=0; 
}
</code></pre>
<p>Which gives "(b - a).isValid()" computing the same result as my preferred interpretion of the greater-than operator.</p>
<p>Well, my currently preferred interpretion, within the scope of my current problem. Oh, and sans integer overflows and such "minor problems" - of course. Someone really cares about such "minor details"? :-)</p>
<p>So what tells this? API design is fun. Even more if you add operator overloading to the soup.</p>
<p>*Disclaimer: There is nothing Qt specific in this post. It only provides the example. *</p>
<span class="net_nemein_favourites">9 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=7a3e958cc10a11dfa58037d460d0a8fca8fc&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/7a3e958cc10a11dfa58037d460d0a8fca8fc/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=7a3e958cc10a11dfa58037d460d0a8fca8fc&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/7a3e958cc10a11dfa58037d460d0a8fca8fc/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Wed, 15 Sep 2010 20:14:46 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-7a3e958cc10a11dfa58037d460d0a8fca8fc</guid>
        </item>
        <item>
            <title>About missing flights</title>
            <link>http://taschenorakel.de/mathias/2010/06/04/about-missing-flights/</link>
            <description><![CDATA[

<p>Frequent fliers will know this, but to everyone else: If you ever should be that stupid to miss a flight, <strong><em>call the airline</em></strong> where you booked that missed flight <strong><em>as soon as possible</em></strong>. Otherwise <a href="http://finnair.fi">they</a> will cancel your inbound flight and bet on charging you an incredible amout of money for your previously reserved seat. For me <a href="http://finnair.fi">they</a> lost their €700 bet yesterday. Just took another airline.</p>
<span class="net_nemein_favourites">2 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=52160a3c6fb511df96e089e009ab9d5e9d5e&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/52160a3c6fb511df96e089e009ab9d5e9d5e/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>10 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=52160a3c6fb511df96e089e009ab9d5e9d5e&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/52160a3c6fb511df96e089e009ab9d5e9d5e/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Fri, 04 Jun 2010 08:33:10 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-52160a3c6fb511df96e089e009ab9d5e9d5e</guid>
        </item>
        <item>
            <title>Using DBus as lock-daemon</title>
            <link>http://taschenorakel.de/mathias/2010/04/22/using-dbus-lock-daemon/</link>
            <description><![CDATA[

<p>Recently I found this comment in the source code I am working with:</p>
<blockquote>
<p>// what if both processes read in the same time and write at the same time, no increment</p>
</blockquote>
<p>Please! Don't do such things! Don't just leave such comments in hope someone else will come around and will fix later. Please take the time to apply a locking mechanism.</p>
<p>Obvious choice when dealing with files would be to create a lock file. Unfortunately creating a file based lock isn't trivial, especially when you deal with portable software. Questions arise like: Is that system call really atomic in this context? Is the feature even available? Which characters can be used in the file name? Can it start with a dot? How much time does it take? Will it reduced lifetime of my flash media?</p>
<p><strong>Uh, my head is spinning! Stop!!!</strong></p>
<p>Somewhat understandable that my colleague just left a comment.</p>
<p>Well, fortunatly there is a more trivial solution for that problem. If you have DBus available. More experienced DBus hackers already know and will feel bored now, but to everyone else:</p>
<p><strong>DBus service names can be used as locking mechanism!</strong></p>
<p>Implementation would look similar to this:</p>
<pre><code>bus.request_name('de.taschenorakel.locker.example')
bus.wait_for_name('de.taschenorakel.locker.example')

now some work...

bus.release_name('de.taschenorakel.locker.example')
</code></pre>
<p>Easy, not? Doesn't hit the file system. Fully implemented. Ready to use. Daily tested at your desktop.</p>
<p>One <a href="http://gitorious.org/qtcontacts-tracker/qtcontacts-tracker/blobs/master/src/dbus/globalmutex.cpp">implementation</a> of that concept can be found in <a href="http://gitorious.org/qtcontacts-tracker/">qtcontacts-tracker</a>.</p>
<span class="net_nemein_favourites">15 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=10f802584deb11df87b8bd10879f1cc01cc0&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/10f802584deb11df87b8bd10879f1cc01cc0/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=10f802584deb11df87b8bd10879f1cc01cc0&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/10f802584deb11df87b8bd10879f1cc01cc0/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Thu, 22 Apr 2010 07:42:36 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-10f802584deb11df87b8bd10879f1cc01cc0</guid>
        </item>
        <item>
            <title>GCC 4.5 - Awesome Release!</title>
            <link>http://taschenorakel.de/mathias/2010/04/15/gcc-45-awesome/</link>
            <description><![CDATA[

<p>GCC 4.5 just was has been released yesterday. It's a really awesome release according to its <a href="http://gcc.gnu.org/gcc-4.5/changes.html">summary of changes</a>. My favorites:
</p>
<ul>
 <li>
     The -Wc++-compat option is significantly improved.
 </li>

 <li>
     Compilation time for code that uses templates should now scale linearly with the number of instantiations rather than quadratically, as template instantiations are now looked up using hash tables.
 </li>

 <li>
     Improved experimental support for the upcoming C++0x ISO C++ standard, including support for raw strings, lambda expressions and explicit type conversion operators.
 </li>

 <li>
     And last not least: A plugin system has been added! I predict we'll see really nice static code analyzers soon!
 </li>
</ul>
<p>Awesome release! Really awesome release!
</p>
<span class="net_nemein_favourites">12 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=499aa2fa48d711dfa21d85221506ca85ca85&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/499aa2fa48d711dfa21d85221506ca85ca85/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>2 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=499aa2fa48d711dfa21d85221506ca85ca85&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/499aa2fa48d711dfa21d85221506ca85ca85/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Thu, 15 Apr 2010 20:52:03 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-499aa2fa48d711dfa21d85221506ca85ca85</guid>
        </item>
        <item>
            <title>QML Hype</title>
            <link>http://taschenorakel.de/mathias/2010/03/18/qml-hype/</link>
            <description><![CDATA[

<p>So yesterday I've skipped the chance to watch some "exciting" <a href="http://taschenorakel.de/mathias/2010/03/18/qml-hype/">QML</a> demos in <a href="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=de&amp;geocode=&amp;q=helsinki,+ruoholahti&amp;sll=37.0625,-95.677068&amp;sspn=34.122306,78.486328&amp;ie=UTF8&amp;hq=&amp;hnear=Ruoholahti,+Helsinki,+Finnland&amp;z=14">Helsinki</a>. This was quite surprising to some of my KDE rooted team mates. They didn't understand how I could not show the slightest sign of excitement.
</p>
<p>Well, but actually I wonder for months: What's actually the fancy and awesome, the brilliant new, the exciting part of QML? It doesn't seem to be rocket science. It's nothing new. Declarative UIs are done for ages. To name some very few implementations there are Windows and PM/Shell RC files, Glade, GtkBuilder. You want to mix declarations with managed code? XUL and XAML have visited that land. You want to use JavaScript for your UIs? Flash, XUL, Dynamic HTML and Web Widgets, GObject Introspection.
</p>
<p>So what am I missing except that Qt finally catches up to its competition? It's a welcome addition, but why should I be overly excited and die of excitement?
</p>
<span class="net_nemein_favourites">6 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=e8ad3682327a11dfaa87858e649da994a994&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/e8ad3682327a11dfaa87858e649da994a994/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>6 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=e8ad3682327a11dfaa87858e649da994a994&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/e8ad3682327a11dfaa87858e649da994a994/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Thu, 18 Mar 2010 10:24:35 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-e8ad3682327a11dfaa87858e649da994a994</guid>
        </item>
        <item>
            <title>Back from Maemo Summit 2009</title>
            <link>http://taschenorakel.de/mathias/2009/10/12/back-from-maesum-2009/</link>
            <description><![CDATA[


<p>So I am back from <a href="http://wiki.maemo.org/Maemo_Summit_2009">Maemo Summit 2009</a>.
   Great people. Great show. Great talks. Great venue: Enjoyed it quite much to walk arround in the Westerpark, Marc-André loved the petting zoo.
</p>
<p>Hotest topic, of course: The <a href="http://maemo.nokia.com/n900">N900</a>. Thank you Nokia for <a href="http://maemoteam.wordpress.com/2009/10/12/amsterdam-flash-marathon/">lending those devices</a>: Feels so good to finally have one for personal use! Finally got ideas for some private N900 hacking when reflecting responses to <a href="http://wiki.maemo.org/Maemo_Summit_2009/Day_2#The_Maemo_5_Address_Book">Travis' and my talk</a>.
</p>
<p>Another hot topic was DRM on Harmattan. Fortunately David Greaves came to similar conclusions like I've reached so far: <a href="http://mer-l-in.blogspot.com/2009/10/maemo-security-lockdown-or-liberation.html">Maemo Security - Lockdown or Liberation</a>. Could be I'm just a weirdo, but I seriously hope for game developers targeting Maemo: Already called Rover &quot;My next Wii&quot; in jokes for its nice screen and the acceleration sensor.
</p>
<p>Well, and then there still was this disappointment about Nokia moving to Qt as <em>their</em> prefered UI toolkit. Actually I wonder why people see this as problem: GTK+ was created without Microsoft or IBM holding our hands, so why does everyone expect Nokia to hold our hands for Maemo? If we really care about this platform, it should be absolutely possible for us to provide a proper GTK+ based toolkit for Maemo 6. Ideally Nokia would publish Layout guides and stuff early, so that we would not have to play catchup too much after device launch. Motivation and specs. More should not be needed. Really.
</p>


<span class="net_nemein_favourites">12 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=5ad6266cb77711debe08753205050e760e76&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/5ad6266cb77711debe08753205050e760e76/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=5ad6266cb77711debe08753205050e760e76&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/5ad6266cb77711debe08753205050e760e76/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Mon, 12 Oct 2009 20:48:27 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-5ad6266cb77711debe08753205050e760e76</guid>
        </item>
        <item>
            <title>Application Theming Tricks</title>
            <link>http://taschenorakel.de/mathias/2009/09/22/application-theming-tricks/</link>
            <description><![CDATA[


<p>From time to time applications need custom theming rules. Especially when <a href="http://maemo.nokia.com/n900">the project</a> has professional UI designers involved. So how to achieve this with GTK+?
</p>

<h2> Trivial Theming</h2>
<p>Most easy and very wrong:
</p>
<pre><code>if (gdk_color_parse (&quot;pink&quot;, &amp;color))
    gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &amp;color);
</code></pre><p>This will break and look childish as soon as your users use a custom color scheme.
</p>
<p>Better:
</p>
<pre><code>static void
style_set_cb (GtkWidget *widget,
              GtkStyle *old_style)
{
    GtkStyle *style = gtk_widget_get_style (widget);

    if (gtk_style_lookup_color (style, &quot;SecondaryTextColor&quot;, &amp;color))
        gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &amp;color);
}

static void
my_widget_init (MyWidget *widget)
{
    g_signal_connect (widget, &quot;style-set&quot;, G_CALLBACK (style_set_cb), NULL);
}
</code></pre><p>This will allow theme designers to override your color choice. Notice that you'll have to update those color overrides when the theme changes. Btw, the &quot;style-set&quot; signal is emitted when the widget is realized, therefore you don't have to manually invoke the callback during widget construction.
</p>
<p>Guess it's also worth to mention that Hildon provides <a href="http://maemo.org/api_refs/5.0/beta/hildon/hildon-Helper-Functions.html">convenience API for simple theming</a> requirements.
</p>

<h2> Complex Problems</h2>
<p>So for simple requirements GTK+ (and Hildon) have reasonable API support. Things become troublesome when your designers invent rules like &quot;this widget has a rounded border and drop shadow, but only within buttons&quot;. Obviously border and drop shadow radius should be themeable and therefore are implemented as <a href="http://library.gnome.org/devel/gtk/stable/GtkWidget.html#style-properties">style properties</a>, but how to impose this rule?
</p>
<p>You could scan the widget hierarchy when choosing default values for your style properties:
</p>
<pre><code>button = gtk_widget_get_ancestor (widget, GTK_TYPE_BUTTON);
gtk_widget_style_get (widget, &quot;border-radius&quot;, &amp;border_radius, NULL);

if (button)
    border_radius = (button ? 12 : 0);
</code></pre><p>You'll quickly notice the flawed hard coded default value. Also such things are hard to override in theme files. So it's probably better to apply a custom theming rule via <a href="http://library.gnome.org/devel/gtk/stable/gtk-Resource-Files.html#gtk-rc-parse-string">gtk_rc_parse_string()</a>:
</p>
<pre><code>static void
my_widget_class_init (MyWidgetClass *class)
{
    ...
    gtk_rc_parse_string
        (&quot;style 'my-widget-style-clickable' {&quot;
         &quot;    MyWidget::border-radius = 2&quot;
         &quot;}&quot;
         &quot;widget_class '*.&lt;GtkButton&gt;.MyWidget'&quot;
         &quot;style 'my-widget-style-clickable''&quot;);
    ...
}
</code></pre>
<h2> Application Theme Files</h2>
<p>Looks like a perfect solution, until you realize that this rule is applied <strong>after</strong> all rules loaded from gtkrc files!
</p>
<p>So how to inject this rule <strong>before</strong> the user's theming rules? This was a big question to me until I've found <a href="http://library.gnome.org/devel/gtk/stable/gtk-Resource-Files.html#gtk-rc-add-default-file">gtk_rc_add_default_file()</a>. Well almost: This function only adds files to the <strong>end</strong> of the search path. Therefore it suffers from the same issues as <a href="http://library.gnome.org/devel/gtk/stable/gtk-Resource-Files.html#gtk-rc-parse-string">gtk_rc_parse_string()</a>. Fortunately the API author was smart enough to also provide <a href="http://library.gnome.org/devel/gtk/stable/gtk-Resource-Files.html#gtk-rc-get-default-files">gtk_rc_get_default_files()</a> and <a href="http://library.gnome.org/devel/gtk/stable/gtk-Resource-Files.html#gtk-rc-set-default-files">gtk_rc_set_default_files()</a>. Those functions can be used to apply application specific theming rules, which can be overwritten by the user <em>- drum roll please</em>:
</p>
<pre><code>static void
inject_rc_file (const char *filename)
{
    char **system_rc_files, **p;
    GPtrArray *custom_rc_files;

    system_rc_files = gtk_rc_get_default_files ();
    custom_rc_files = g_ptr_array_new ();

    g_ptr_array_add (custom_rc_files, g_strdup (filename));

    for (p = system_rc_files; *p; ++p)
            g_ptr_array_add (custom_rc_files, g_strdup (*p));

    g_ptr_array_add (custom_rc_files, NULL);

    gtk_rc_set_default_files ((gpointer) custom_rc_files-&gt;pdata);
    g_strfreev ((gpointer) g_ptr_array_free (custom_rc_files, FALSE));
}

int
main (int argc,
      char **argv)
{
    ...
    inject_rc_file (PKGDATADIR &quot;/gtkrc.&quot; PACKAGE);
    gtk_init (&amp;argc, &amp;argv);
    ...
}
</code></pre><p> <strong>Update:</strong> Benjamin Berg just pointed out that priorities can be assigned to styles. So the following should work fine:
</p>
<pre><code>gtk_rc_parse_string
    (&quot;style 'my-widget-style-clickable' {&quot;
     &quot; MyWidget::border-radius = 2&quot;
     &quot;}&quot;
     &quot;widget_class '*.&lt;GtkButton&gt;.MyWidget'&quot;
     &quot;style : lowest 'my-widget-style-clickable''&quot;);
</code></pre><p>Awesome, little know feature.
</p>


<span class="net_nemein_favourites">17 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=e9b35056a75c11debf245d91612edde3dde3&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/e9b35056a75c11debf245d91612edde3dde3/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=e9b35056a75c11debf245d91612edde3dde3&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/e9b35056a75c11debf245d91612edde3dde3/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Tue, 22 Sep 2009 08:42:13 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-e9b35056a75c11debf245d91612edde3dde3</guid>
        </item>
        <item>
            <title>Well, and it is a phone!</title>
            <link>http://taschenorakel.de/mathias/2009/08/27/well-and-it-phone/</link>
            <description><![CDATA[


<p>So after months of denial it turns out, that <a href="http://maemo.nokia.com/">the/we Maemo folks really built a phone</a>!
</p>
<p> <img src="http://taschenorakel.de/pictures/misc/2009/08/27/n900.jpg" alt="N900 with Contacts application"/> 
</p>


<span class="net_nemein_favourites">1 <a href="http://maemo.org/news/?net_nemein_favourites_execute=fav&net_nemein_favourites_execute_for=e0dc10b2a75c11debf245d91612edde3dde3&net_nemein_favourites_url=https://maemo.org/news/favorites//json/fav/midgard_article/e0dc10b2a75c11debf245d91612edde3dde3/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-favorite.png" style="border: none;" alt="Add to favourites" title="Add to favourites" /></a>0 <a href="http://maemo.org/news/?net_nemein_favourites_execute=bury&net_nemein_favourites_execute_for=e0dc10b2a75c11debf245d91612edde3dde3&net_nemein_favourites_url=https://maemo.org/news/favorites//json/bury/midgard_article/e0dc10b2a75c11debf245d91612edde3dde3/" class="net_nemein_favourites_create"><img src="http://static.maemo.org:81/net.nemein.favourites/not-buried.png" style="border: none;" alt="Bury" title="Bury" /></a></span>]]></description>
            <author>Mathias Hasselmann &lt;mathias.hasselmann@maemo.org&gt;</author>
            <category>feed:2f9a1cd8dccee7a19cc07970574b4d4a</category>
            <pubDate>Thu, 27 Aug 2009 11:07:39 +0000</pubDate>
            <guid>http://maemo.org/midcom-permalink-e0dc10b2a75c11debf245d91612edde3dde3</guid>
        </item>
    </channel>
</rss>
