Archive for the 'tech' Category

I’ve landed on Planet GNOME!

Now that I’ve landed on Planet GNOME, it’s time for the obligatory introduction.

Contributions

The post that got dumped onto p.g.o when my feed got activated yesterday gives some idea of why I’ve been added to p.g.o. Other than that I’ve also (hopefully) finished up the port of Vino to GNOME 3 that Ryan Lortie had started. I’ve also done other odds and ends which you can find on my Ohloh profile.

On the community side, I’m a member of the local planning team for the Desktop Summit, and organizing the GNOME 3 Berlin Release party, which I’ll have more details about in a coming post.

Personal

I’ve got 2 kids. My daughter, Vada, is 2 and my son, Rigby, is 5 months old which means I hack when I really should be sleeping. I’m an American expat living with my wife, Annika, who’s German. I adopted the German looking name from her… just to confuse people. ;)

I was also one of the lucky ones selected for a trainee position at Openismus. Thanks Murray!

Closing remarks

As for my hackergotchi… it’s outdated. But Andreas seemed keen on having one with a moustache for some reason.

I’ve followed p.g.o for many years, so it’s kinda cool to actually have my floating head join the mix. I’ll try not to bore you.

Maintenance Mode

In the last few weeks I’ve adopted a couple projects that, for whatever reason, had not been actively maintained for a while.

Cluttermm

Cluttermm wraps the Clutter Toolkit, “a software library for creating fast, compelling, portable, and dynamic graphical user interfaces”. Clutter has become an integral part of the GNOME project through its use in the GNOME Shell featured in GNOME 3. As such, I think it’d be a shame to not have high-quality C++ bindings.

Cluttermm had not really had much activity since early last year. With the rate of Clutter development, Cluttermm feel behind quickly. I’m trying to catch up now and as Murray mentioned, I’ve been able to wrap more API and fix a few bugs. So far I’ve got the 1.2 API almost fully wrapped. There are certainly bugs, some of which I’m finding now that I’m actually writing some examples. As I’m very much new to this wrapping business, I want to write a number of examples using the newly wrapped API. Once I’m comfortable that things are in good order, I’ll move onto the 1.4 and then 1.6 APIs.

GNOME System Monitor

GNOME System Monitor (g-s-m) is the default process viewer and system monitor in GNOME. I got involved by responding to the call to port g-s-m to Gtk3. Thanks goes to Openismus for allowing me to spend work time doing the porting (which I’ll blog about in the next couple days). During this process one always finds areas for improvement which spurred my interest in becoming the maintainer.

From what I can tell g-s-m hasn’t been actively developed in well over a year. You can imagine that bugzilla has a lot of suggestions for future tasks. My first order of business will be dealing with neglected patches and responding to bug reports.

So it appears as if I’ve filled all my free time for the foreseeable future. We’ll see how much I can get done between changing diapers and playing with the kids. ;)

Oh, and lastly… patches welcome. :P

First experiences with the OpenSUSE Build Service (OBS).

As part of my Openismus training, I was recently tasked with packaging a Qt application using the OpenSUSE Build Service (OBS). Here I’ll try to note my first impressions as well as offer some solutions to problems I encountered.

Note: This was my first attempt at packaging anything and the application I’m packaging (ConferenceGoer) is a personal project which is in an unusably-early state. So let’s ignore all that and focus on OBS itself.

What is OBS

The OBS allows a packager to create packages for multiple distributions and architectures using one spec file for RPM packages or one set of debian packaging files for debian packages. For example, in my OpenSUSE OBS repository I’ve built packages for multiple releases of Fedora, Ubuntu, OpenSUSE, Mandriva and Debian for the i586 and x86_64 architectures from one set of package files.

Despite the “OpenSUSE” in the name, the OBS is useful for other distros as well. For example, the MeeGo project has adopted it as its build-service of choice. I’ve used both and will refer to them as the OpenSUSE OBS and MeeGo OBS.

This is not an OBS how-to. See the OBS tutorial for getting started with OBS.

Some notes (in no particular order)

Generated moc_ files in tarball

One of the problems I ran into while packaging ConferenceGoer was that the tarball that is generated from the Makefile (which is generated from qmake), includes moc_* files. As anyone familiar with Qt knows, these are genereted files. The problem that this causes is that moc_* files generated with a newer version of Qt (4.7 in my case) will not always be compatible with older versions of Qt. As older distros do not package the newer version that you may be developing against, this will cause build problems. The easy fix for this is to remove the moc_* files from the tarball. qmake will regenerate these files for you anyway during the build process making them unnecessary.

Interacting with the OBS

There are 2 ways to interact with the OBS. The first way is using the web interface and the other is using the command-line tool (osc). I found that a mix of these worked best. The web interface can be annoying and slow for certian tasks. Triggering a build and uploading new versions of your files takes far too long. You can use the command line tool much like you would any svn client. You make you local changes, commit them with a message, and repeat. The commit will trigger an automatic rebuild. This seems to happen much faster using osc than with the web-interface. In short, use osc when you can and use the web-interface for watching the packages build status.

OpenSUSE OBS downtime

Annoyingly, the OpenSUSE OBS site seems to be unreachable rather often. It’s also rather slow. The MeeGo OBS is fast and seems reliable though. I’m guessing this has to do with the high load on the OpenSUSE OBS. Still it’s annoying.

Moving from the OpenSUSE OBS to the MeeGo OBS

If you ‘ve managed to get everything working in the OpenSUSE OBS, moving to the MeeGo OBS should be simple. For ConferenceGoer I just needed to remove the ifdef’s for all OS’s other than the redhat-based distros. We then need to remove all Qt version info from the package names. For example, qt4 becomes qt and qmake-qt4 becomes just qmake. MeeGo only has Qt4 packages so this distinction is not needed.

Also to note is that getting access to the MeeGo OBS is a manual process. You’ve got to have a meego acount set up and request access on irc.

Font problem with Qt apps in MeeGo.

Once the package was installed on MeeGo (on the nice netbook we were given at the Dublin conference), I found that the fonts looked terrible. This turned out to be a known bug. Seems you can tweak a config file to get it looking OK but hopefully this is now fixed.

Conclusion

Overall I think the OBS is a very nice tool. It’s rather gratifying to be able to build for so many different distro/version combinations with such little effort. The command-line tool is intuitive and works well. I’d like to be able to access the OpenSUSE OBS instants on a more regular basis however.

I plan on building some new cluttermm packages soon to encourage more people to start testing and using it as well as to practice packaging libraries. So keep an eye on my repository.

Thoughts coming out of the GNOME Developer Documentation and Tools Hackfest

I’m a bit late in the game regarding blogging about the GNOME Developer Documentation and Tools Hackfest that we hosted at the Openismus Berlin office a couple weeks ago. There have been a number of good posts made summarizing what we talked about and worked on. In this post, rather than providing another summary, I’d like to share my thoughts about how we can get the most out of the demos (examples, tutorials… whatever) we started during the hackfest. Some of what I’m going to talk about was discussed at the hackfest, but much was not. Also, be warned that this will have quite a few references to Qt documentation practices.

A Tutorial for Tutorials?
So here we are, we’ve got some nice, simple code examples, some even with tutorial-style documentation. But if you look through the examples you’ll find that the documentation style varies dramatically. Before we go and write too many of these tutorials maybe we need to standardize how we write these. Some issues that arise when writing the tutorials are:

  • how do we structure the tutorial? Daniel’s Magic Mirror example incrementally builds up the program while others, including mine, explain the finished program.
  • how does one reference the code? Do we use line numbers, show full functions/classes? Do we include unexplained code in the code snippets?
  • how do you show a full listing? Do we append a full code listing at the bottom of the tutorial or provide links to files?
  • how much should we comment the code? If the code is going to be explained, do we need to repeat the same thing in the code comments?
  • and so on…

Some of these have answers. For example, we decided that we should build up the programs incrementally and that referencing line numbers is probably going to be more trouble than it’s worth.

When I was writing my photo-wall tutorial I knew that I was writing it not in isolation but as a larger collection. Thus, I wanted my tutorial to fit in with the other tutorials in the collection. As there was no guide to go by, I poked around the repository to see how others were doing it. I found one I liked and went with it.

The point is that because there is no canonical tutorial or document to go by, we are adding a possible barrier to those wishing to create such tutorials. During the hackfest it was mentioned that we can not motivate people to contribute, we can only demotivate them. Let’s not do that. ;)

For completeness these are my opinions about the above-listed issues.

  • structuring the tutorial: Incremental build up is nice for GNOME beginners and that seems to be the target group so let’s go with that.
  • referencing the code: No line number referencing. Break the code up into small logical blocks and describe. Blocks need to be small so that one can read the description and see the code without having to scroll up and down repeatedly.
  • showing a full listing: Do like the Qt examples do; list all files at the beginning of the tutorial. This gives quick access to folks who don’t need the description.
  • commenting the code: Heavily comment the code so that is descriptive outside the context of the tutorial and probably remove the comments when placing segments in the tutorial in order to save space.

Dealing with undocumented code examples

Right now I don’t know that we have a plan for dealing with this so here are my thoughts.

In a perfect world we are going to have a tutorial written for each example in each of the core programming languages. As perfection is rather boring, lets think about the alternatives.

I think in this case we should simply look at the Qt examples. They either have a tutorial-like description or they don’t. The one’s that do have an asterisks, those without don’t.

Regardless of whether the coder is willing or able to write an accompanying tutorial, we should promote getting as many code examples in as many core languages. In fact some example may be too large to expect a tutorial. Take a look at the Qt Network torrent example for one instance of this being the case. Looking at that example you’ll see that even though there is no tutorial, a file listing and description is available. If we were to standardize on having a file listing and functional description of the example at the top of each tutorial we could just copy the description and list the files for each newly added example port. Of course, hopefully someone would eventually get around to writing a tutorial as well.

Relating reference documentation with examples

One of the nice things about the Qt reference documentation is that it often references examples in the See also section. With one click your sent to an example that’s probably more complete than the small snippets you usually find in the API reference. Looking at the QTcpSocket class you’ll find 6 referenced examples. Some have documentation while some are just commented code. Maybe Shaun has something up his sleeve for something like this using Mallard.

Closing words
Basically, I would like to see a consistent, wide-ranging, integrated and ever growing set of examples and tutorials to help developers get started with developing with GNOME technologies. I think the Hackfest was a great start to getting us there. The documentation team has done a great job laying the foundations and providing infrastructure for getting us where we want to be with GNOME 3 regarding developer docs. We just need to finish ironing out a few things before we are quite there.

Getting Openismus ready for the Development Documentation and Tools Hackfest

In 2 days the GNOME Development Documentation and Tools Hackfest starts here in the Openismus office. For the past 2 days we’ve spent a couple hours of each day getting things ready. We’ve designated two rooms as hacker rooms. Our central common area will be the main sit-down hacking area.

Common area hacker space (facing the front courtyard)

Common area hacker space (facing the front courtyard)


Common area hacker space (facing the back courtyard)


And the front room will serve as the bean-bag hacking area and provides a little warmth and color to contrast the current weather situation here in Berlin.

Bean bag hacking area in the front room.

On Wednesday we’ll have a welcome dinner for all the attendees sponsored by Openismus. Should be a good opportunity to get to know more of the GNOME hackergotchi heads in real life.

So, Openismus is ready and looking forward to a productive four days.

MeeGo Conference 2010, Dublin

Last Thursday I and the other Openismus folks returned from our visit to Dublin for the first MeeGo Conference. Here is a summary of the conference and my impressions of it.

Note: If this post is a bit long for you jump to the last section.

Day 0:
Six of us from Openismus arrived at the Conference hotel, The D4 Ballsbridge Inn, at about 4pm. It’s located about 10 minutes from Aviva Stadium, the rather unusual conference venue. After getting settled into my room, which was strangely missing a mattress at first, I chose to do some reading and get to bed early while the others chose to explore Dublin a little.

Aviva Stadium field view

Day 1:
The first conference day started out with a series of keynotes. The first of these started the conference off with a bang. AMD announced that they were getting on board and Intel announced that all (well, except for Intel and Nokia employees) conference goers were to get Lenovo S10-3t tablet netbooks. This went over well, to say the least.

The next talk was from Nokia and stressed their commitment to Qt and their optimism that it could provide a unified development platform for creating apps on the various device profiles MeeGo is targeted for. It stressed the significant role Qt Quick and QML would play in this platform. QML was emphasized throughout the conference.

The next keynote was integrator targeted. The last one was a sit down discussion which felt very staged, which made it also rather boring. I’ll spare you.

A nicely catered lunch seperated the keynotes from the afternoon talks. The first talk I attended was MeeGo Infrastructure. This dealt with the server and build infrastructure of the project. It wasn’t exactly what I had thought it’d be but was interesting nonetheless. This was also the first talk of the OBS (openSUSE build service) which would be praised often throughout the conference.

I then attended the talk about running MeeGo on a BeagleBoard. This discussed the motivations of the project, the steps needed to get it running and its current state. I’ve got a BB at home as well as in the office, so I’m hoping by the time I get around to trying it out it’s an easy install.

Afterwards I headed over to the Qt Quick talk. Here we were walked through the creation of a Qt Quick app for viewing photos. This nicely showed how the process of developing apps with QML works. I’ll have to try it out a bit in order to see if it lives up to the hype (probably not). However a small improvement would also be welcome.

Next up was a talk on MeeGo input methods. It was interesting to see how this is shaping up. The architecture seems in place and the default keyboard looks nice. They stressed that one way they are trying to improve over other on-screen keyboards is through customization. They showed various layouts the the programmer can make use of and briefly described how to change the layout and themeing of keyboards. It will be interesting to see whether these customization features will be a good thing or just clutter and confuse.

I skipped the last two sessions, deciding to get some fresh air before the evening reception. The reception was at the stadium and included finger-foods and drinks. After lots of chatting, a contingent of Openismus folks and friends got together to find somewhere for dinner. After a short walk we found a pub and capped off the evening with a nice dinner and more conversation.

Day 2:
It had been announced that the netbook were going to start being given out at 8am, so several of us got an early breakfast and proceeded to the stadium to avoid the crowd. The tickets for the Ireland vs. Norway football match were also available starting at 8, so we were killing two birds with one stone. We quickly got our tickets for the football match but the netbooks were a bit harder to get to. Eventually we found the very long route to the pickup area. It turns out we were lucky that we got there as only 1/3 of the shipment had arrived and many others had to wait till the next day, which meant more waiting in line. The early bird gets the worm I suppose.

So far I really like the new netbook (my first). Thanks to Intel for this. Not everything is working 100% right now but I look forward to seeing how MeeGo evolves on this hardware. Specifically, it’s got a multitouch display that would be nice to use as such.

Later in the day I was also given an N900 by a Nokia representative. Thanks, Nokia! Working at Openismus, one feels rather out of place without one of these. I’m happy to have a device to test an app I’m currently working on. That’s a later blog post, though.

Lenovo netbook and Nokia N900 freebies

I missed the opening session, while standing in line for the netbook. My first talk of the day was on implementing protocols with Telepathy. This was rather interesting as I haven’t looked at Telepathy deeply at all. Hopefully, I can play around with it some in the future.

I moved on to talk about MeeGo on the N900 next. Unfortunately it looks like there is a long way to go before the N900 will be running MeeGo in a usable fashion. Guess I’ll be sticking with Maemo for a while.

Side note on Maemo: In case your wondering how Nokia views Maemo now, they were promotiing using Maemo 5 as the development device for apps targeted for the MeeGo handset profile.

Next on the schedule was a talk on packaging using the OBS. The was a well presented talk. As a recent openSUSE convert, I’m very interested in getting up to speed with OBS. However, the most interesting thing about the OBS is that for the task of building packages it’s not really related to openSUSE more that any other distro. I think the openSUSE branding is unfortunate as it really seems to be a general tool, as MeeGo is very much showing. One of my next tasks at Openismus will be to learn more about the OBS.

The next talk was about getting 3rd party apps into MeeGo. This presentation was packed with tons of information (probably too much for one talk) about the tools and processes available (and planned) to application developers. There were lots of links and references within the slides, which prompted one attendee to request that the information on the slides be placed on the MeeGo wiki. The presenter agreed this would be a good idea, so keep an eye out for that soon.

Following the last talk was one regarding the community OBS and repositories. The questions following this talk made it obvious that there are many questions left unanswered regarding processes in MeeGo. The most common question was how the community and core OBSs relate and how an app migrates from the community OBS into the core OBS. Unfortunately the presenters were not able to make any definitive comments on this as the release team is in charge of the core OBS and have not yet defined this migration pattern. Additionally, the intention was to retain a similar repository structure to that in Maemo: extras, extras-testing, extras-devel. The naming scheme is subject to change, though.

I took a break but then attended the talk about Zypper. Being a recent openSUSE convert, I’ve been learning the openSUSE-specific tools. I’m not too fond of YaST but Zypper has been a very pleasant surprise. It’s much faster than yum and the apt* tools and seems to be more intelligent at resolving dependencies, too. It also has a very consistent command line UI. It’s easy to see the why it was chosen over the aforementioned tools once one tries it out; and this was discussed during the presentation. Many of the questions afterwards came for yum users who were asking for features that were in yum but not yet found in zypper. The answer was almost always that they were working on it or basically “patches welcome.” Also interesting is that zypper is written in C++;

Next on the agenda was the talk about designing UIs for multiple MeeGo profiles. This was very much a QML presentation and focused on why QML is the right choice over the other alternatives.

The day was getting long so I skipped the last two sessions and rested in the hotel till the buses started to leave for the party.

The evenings party was at the Guiness Storehouse and was the social highlight of the conference. I and several of the other Openismus folks were on the first bus and were greeted by some Irish lads drumming supposedly traditional Celtic drum music. Not sure how traditional it was but it was very loud. The building spread over 7 levels, the top level being known as the Gravity Bar and having walls of glass overlooking Dublin. To get to the top one went through the Guiness museum/tour. I’m not a beer drinker but it was nonetheless interesting. Once we made it to the Gravity Bar there was beer and wine in ample supply followed by appetizers and later small dishes of food, all brought around on platters. At some point everyone was summoned to the 2nd floor where a U2 cover band started playing. They were pretty good but we eventually made it back up to the Gravity Bar where we chatted while rain beat upon the glass walls.

Marco and me in the Gravity Bar at the Guiness Storehouse

After the party everyone was brought back to the hotel. There was a hacker room setup in the hotel for conference goers to hack, play games (ping pong, fussball, Wii, XBox, Chess), chill out and/or munch on the seemingly endless supply of snacks and drinks. Several of us hung out there till about 2am, playing chess (or rather being taught how to play chess by Michael) and chatting. A nice end to a very active day.

Jon and Murray relaxing on the hacker space sofa

Day 3:
The last conference day was designed to be an “unconference.” Basically, if you wanted to talk about something you could through your name and topic on a board and hoped people come. I went to a few of these but by far the most interesting (if not 100% meego related) was Micheal Meeks‘ LibreOffice talk. I pretty sure this was mostly the same talk he gave in Boston a couple weeks ago so maybe this should be considered cheating. Regardless, it was very interesting to see the night-and-day change that has happened since the announcement of LibreOffice. I asked why this had not happened at least 5 years ago. The answer was basically that the stars had not yet been aligned.

unconference schedule

The conference day ended early (16:00) because the stadium needed to be prepared for the Ireland vs. Norway football match. For those who had gotten tickets there was a pre-party in on of the VIP rooms. Again, we were more than adequately supplied with food and drinks and additionally given “Ireland” scarves and noise makers. Just before the match started we were asked to go to our seats. Ireland started out strong and scored first on a penalty kick. Norway then equalized just before the half. At half we were again treated to drinks. I started chatting and never really make it back to my seat. I did manage to catch Norway make the goal that won the match, however.

Ireland vs. Norway pre-game

General impressions

The general impression is that MeeGo has a very enthusiastic and diverse community. There is not a since of contentment, though. Many areas need to be defined regarding processes, especially regarding insuring that it truly is the open platform it describes itself as.

The most talked about technologies were QML and OBS. The OBS was universally praised and QML saw a lot of interest from people trying to see what it actually was, removed from the marketing hype. Nokia reiterated over and over it’s commitment to Qt and MeeGo as a platform.

It was interesting to see GNOME and KDE people in equal number and working on a common platform. There was one talk that I did not attend about MeeGo on the enterprise desktop (I generally run from the word enterprise). Perhaps MeeGo will be the means by which the GNOME and KDE communites come together. …or maybe not.

The conference itself was very well received. There was obviously a slew of money thrown into organizing and executing it. Everyone really appreciated the free netbooks and social events (especially the open bar!). The next conference will be in San Fransisco in May and at least one of the organizers for that has already expressed doubt that they would be able to top this first conference. Furthermore. there will be a MeeGo summit in June. Quim described the Summits as regional events while the Conferences are the General community events after releases designed to resync the community.

What the conference could not answer however was just how much traction MeeGo will receive in a very competitive market. With very well know and very good platforms that are currently available MeeGo is trying to differentiate itself by being an open and inclusive platform. I think this is something the AMD announcement underlined. However, we won’t know how much this differentiation will matter in market terms until there is a major piece of hardware featuring MeeGo. No one really expects Intel to directly introduce a netbook anytime soon so this only leaves Nokia for the immediate future. Until they releases their first phone featuring MeeGo (and targeted at a general audience) we just won’t know how much traction MeeGo can get in a very competitive market.

Of course, as developers we want to work on interesting and relevant projects. If Intel and Nokia were using this conference to spark interest and proclaim relevance I think they have (at least initially) succeeded. However, this coming year will be extremely important to see if this persists.

Using xmodmap to change the keyboard layout

One of the first things I do whenever I get on a new computer is to go the GNOME keyboard preference dialog and switch caps lock and the left control. While this has sufficed in the past, I now have a situation where I’d like to do a more complicated keyboard modification.

Note: The following was done on an Lenovo S10-3t running MeeGo 1.1.

Terminology
A KeyCode is the numerical code for the key. A KeySym is the symbolic code for the key. For example, my Return key has a KeyCode of 36 and a KeySym of Return.

Determining KeyCodes and KeySyms
The first thing to do is to determine the KeyCode and KeySym for the keys your want to change. This can be done by generating a list for all keys or interactively. The former approach is done by issuing the following command.

xmodmap -pke > kbd_mapping.txt

Here I’ve redirected the output to a text file so that I can view the results in a text editor. A small section of the contents look like this.

keycode 36 = Return NoSymbol Return
keycode 37 = Control_L NoSymbol Control_L
keycode 38 = a A a A ae AE
keycode 39 = s S s S ssharp section
keycode 40 = d D d D eth ETH
keycode 41 = f F f F dstroke ordfeminine
keycode 42 = g G g G eng ENG
keycode 43 = h H h H hstroke Hstroke
keycode 44 = j J j J
keycode 45 = k K k K kra ampersand
keycode 46 = l L l L lstroke Lstroke
keycode 47 = semicolon colon semicolon colon dead_acute dead_doubleacute
keycode 48 = apostrophe at apostrophe at dead_circumflex dead_caron

The different columns to the right of the equals sign corrospond to the way modifier keys change the key. Obviously the second column is the effect of the shift key being pressed. As always, the man page is the place to look for more details.

The interactive approach uses the following command.

xev | grep -A 4 KeyPress

Because xev produces a lot of output we use grep to filter only for ‘KeyPress’ events.

Here is some example output

KeyPress event, serial 29, synthetic NO, window 0x2400001,
root 0xaa, subw 0x0, time 3663762, (159,-24), root:(582,207),
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
XLookupString gives 1 bytes: (0d)

Here the KeyCode is 36 and the KeySym (also given in hex) is Return.

Once you’ve got the code and symbol combination you want, you you can place them in a file named .Xmodmap. The format for entries is the same as the output from the ‘xmodmap -pke’ command. A section of my file looks like this.
keycode 66 = Control_L NoSymbol Control_L
clear Lock
add Control = Control_L

keycode 135 = ISO_Level3_Shift Multi_key ISO_Level3_Shift Multi_key
keycode 108 = Alt_L Meta_L Alt_L Meta_L

Here I’ve turned my Caps Lock key into a control key. I’ve also moved ‘Alt Gr’ to the menu key and ‘Alt Gr’ is now an additional Alt key. The clear and add commands are necessary to redefine modifier keys. Again, see the man page for more info.

While I’ve put the commands in .Xmodmap so that it’ll persist acrooss restarts, you can also use the ‘xmodmap -e’ to test these changes out. For example, the first 3 commands would look like this.

xmodmap -e 'keycode 66 = Control_L NoSymbol Control_L'
xmodmap -e 'clear Lock'
xmodmap -e 'add Control = Control_L'

On MeeGo and openSUSE the .Xmodmap file is detected at session start. However, I’ve read that’s not always the case. So, consult your distro’s help if you have problems with loading.

Introducing Merkmal, a concentration game for GNOME.

For the last few week I’ve been working on a version of GMemory written using the gtkmm and cluttermm bindings. The project is called Merkmal.

Merkmal 0.1.0 screenshot

Currently the functionality is on par with that of GMemory. It requires at least cluttermm 1.1.2, clutter-gtkmm 0.9.6.

Here is a video of Merkmal in action. As you should see, basic game play is working but there are tons of things to be added to make the game more interesting. I listed some of those in the GMemory post.

Merkmal 0.1.0 screencast from Chris Kuehl on Vimeo.

Cluttermm

Now that I’ve ported the game to C++, adding these features should be much easier. However, there are some issues that I’ve been running into. I seem to be among the first (if not the only) consumer of cluttermm at the moment. This has of course meant that I’ve been running into bugs here and there. I’ve fixed the ones I’ve run into. I’ve also started filing bugs for missing api. For example, the new layout classes and animation framework have yet to be wrapped. I’ve filed some bugs for the ones that I’d most like to use.

GNOME Bindings

Having written the same application in both gtk+ and gtkmm, I don’t see why one would not use one of the bindings to write user apps. One of the beauties of GNOME is that there are so many high-quality bindings available. Bindings are a top priority for the project and it shows. With the introspection work that is going on, the situation will only get better.

Debugging reference counting in GNOME C++ bindings with GDB

Overview

For the last couple days I’ve been tracking down some reference counting problems in cluttermm. In the course of this I’ve been working on figuring out how GDB can help me do this. Here is what I’ve come up with. If you have improvements please let me know.

Watching the reference count variable

The first small obstacle is that pretty much all objects are wrapped in a RefPtr, glibmm‘s reference-counting shared smartpointers. This is a good thing and gdb makes accessing the underlying C++ object pretty painless. The following command demonstrates this.

p alpha.pCppObject_

For this example I’m using the alpha variable of type Glib::RefPtr<Clutter::Alpha>. In this command we used the fact that gdb gives you access to any member of a class, whether public or private. You should have gotten output similar to the following.

$1 = (Clutter::Alpha *) 0x9cfe40

Now the interesting part. We want to detect any changes in the ref_count variable. To do this we need to watch the ref_count field. The following command does this.

watch alpha.pCppObject_->gobject_->ref_count

To make this a bit more convenient, I’ve used the gdb define command to create a shortcut. Here is an example session.

(gdb) define watchRefCnt
Type commands for definition of "watchRefCnt".
End with a line saying just "end".
>watch ($arg0).pCppObject_->gobject_->ref_count
>end

Now you just need to use the shortcut like this.

watchRefCnt alpha

Which should give you a confirmation similar to the following.

Hardware watchpoint 2: (alpha).pCppObject_->gobject_->ref_count

The obvious thing to do next is to place this command in a .gdbinit file so that it can be pulled in automatically.

Breaking on last unreference

One of things I was most interested in catching was when the g_object_unref function was called with the condition that the _object pointer was equal to a certian pointer and the ref_count variable == 1. This would indicate that the object is ready to be disposed. To do this we first need to get the address of the underlying GObject like this.

(gdb) p alpha.pCppObject_->gobject_
$3 = (GObject *) 0x9c91e0

You now have a convenience variable, $3, which you can use in the conditions. You then need to set a breakpoint on g_object_unref and set the conditions like this.

b g_object_unref
cond 4 _object==$3&&((GObject*)$3)->ref_count==1

This, of course, would also be nice as a custom command. I’ll leave that as an exercise for the reader. ;)

Future explorations

I forsee future blog entries along these lines so stay tuned. There are quite a few things that interest me in gdb right now.

The Archer project is quickly improving C++ support in gdb. I’ve been using gdb 7.2 for my debugging as I wanted to have a stable debugging platform with all the new C++ enhancements. They have a git repository for those who want the bleeding edge.

Python scripting has been available in gdb since 7.0. I plan on looking into this as a way of streamlining debugging tasks and honing my Python skills which are pretty rusty.

Please let me know if you see any areas for improvement.

New Flat and the Internet Gap

We slept in the new flat for the first time last night. As usual, at least in Germany, it’s going to take a few weeks to get DSL connected. In our case, DSL gets connected on the 30th. This used to be the time when I’d fall into a deep depression due to withdrawal issues. However, this time is different.

For the time being I’m using the awesome new feature in Android 2.2 for sharing a mobile internet connection. Impressed with how easy it is to set up. It’s as easy as turning the feature on and setting the access point name and passphrase. Once that’s done up to 8 computers can connect as they would to any wireless access point.

Unfortunately, my mobile data plan only allows up to 200MB at 3G speed after which it gets throttled down to GPRS speeds. But it’s better than nothing and once DSL is finally connected we’ll be rewarded with 50Mbits down and 10Mbits up. That’s about 8-9 faster than what we had in San Diego for only a little more money.