Thursday, May 24, 2007

Curious why you have ~/.config...

... and why some applications are porting their configuration to be under it? It's part of the freedesktop standards. Check it here.

pyNeighborhood patch

Recently some of my patches or bug reports have been made some progress. Some days ago a patch I sent to pyNeighborhood was committed and now I have a contribution to a project written in Python :-) Thanks to Mykola Lynnyk (pyNeighborhood's author) for accepting and committing it. I hope it helps improving this good application.

Thursday, May 17, 2007


"A heuristic is a technique that helps you look for an answer. Its results are subject to a chance because a heuristic tells you only how to look, not what to find. It doesn't tell you how to get directly from point A to point B; it might not even know where point A and point B are. In effect, a heuristic is an algorithm in a clown suit. It's less predictable, it's more fun, and it comes without a 30-day, money-back guarantee." - Steve McConnell, "Code Complete"

Wednesday, May 16, 2007

gtk: when the window stopped moving?

It's very common to use the following gtk function to start to move the window when the user pressed the left button:


The control of the window is passed to the window manager, which will move the window. However, you may want to find out when the window stopped moving in order to update something, like a background image. There is no specific signal for that and trying button-release-event is something that does not work either (* - see below).

A friend of mine suggestion a good solution for that. First, you connect to in-focus-event. This event will be emitted right after you stop moving the window. But, it is emitted whenever you click on the window, even when not dragging. Then, what you can do is the following:

gboolean on_focus_in_event (GtkWidget* pWidget, GdkEvent* event)
if (moving) {
moving = FALSE;
// move stopped
// do whatever you need
return FALSE;

gboolean on_button_press (GtkWidget* widget,
GdkEventButton* button, GdkWindowEdge edge)
if (button->type == GDK_BUTTON_PRESS &&
button->button == 1)
moving = TRUE;
GTK_WINDOW (gtk_widget_get_toplevel (pWidget)),
button->button, button->x_root, button->y_root,


gtk_widget_add_events (window, GDK_BUTTON_PRESS_MASK);

g_signal_connect (G_OBJECT (window), "button-press-event",
G_CALLBACK (on_button_press), NULL);
g_signal_connect (G_OBJECT (window), "focus-in-event",
G_CALLBACK (on_focus_in_event), NULL);

(*) The button-press-event works when you click but does not move the window. So, you can connect to the button-press-event to detect this case and undo anything you may have done when the user first clicked.

Tuesday, May 15, 2007

Exit code from gobject spawned processes

[Python] Do you spawn a process using gobject's spawn_async() and want to find out what's the exit code? First, you have to add a callback to child_watch_add() function, which will be called when the process exits. This callback has this signature:

def callback(pid, condition, user_data)

Condition is the exit status information, but soon you will find out that it does not match the exit code. The reason is that it has both the exit code and the exit signal encoded in this variable. So, to find out each one, you have to do the following:

exitCode = (condition >> 8) & 0xFF
exitSignal = condition & 0xFF

Really really hard to find this information on the web to be able to check the exit code and do the appropriate action. I hope this helps you.

Monday, May 14, 2007

Most popular Hibernate bug: now fixed!

This bug is the most popular Hibernate bug and has been open for quite a while. I hit it last year and created a patch that has been working perfectly for me since then. Although it seems that it wasn't used (mostly because hibernate has been changed the parts where I changed since 3.1 and also some better ideas came up), I am glad that it was fixed after all. I hope I can test it soon and be able to use, from now on, a stock version rather than patching it for each upgrade :-)

Other bugs, like this one are more than 2 years old and still not fixed. And I also provided a fix for it.

Saturday, May 05, 2007


"The manager's function is not to make people work, it is to make it possible for people to work." - DeMarco and Lister.

"The top performers' space is quieter, more private, better protected against interruption, and there is more of it [...] Does it really matter to you [...] whether quiet, space, and privacy help your current people to do better work or [alternatively] help you to attract and keep better people?" - DeMarco and Lister.

(quoted in "The Mythical Man-Month", Frederick Brooks)