Q:

GtkStatusBar gets stuck at a /random/ position and wants me to mousehover button

I will keep it simple
I have the function inside_thread that runs a while loop and calls the function update_progressbar that simply updates a GtkStatusBar.
I am calling inside_thread in a thread using g_thread_new("processing", GThreadFunc, NULL); from a callback function on_starter_clicked.

It tends to do the job, it works fast and it updates the status bar according to the progress of the while loop.
The problem is that sometimes (at unspecified place) the progress bar gets stuck and it gets unstuck if I mouseenter or mouseleave a button in the application. Very strange behavior I must admit
What could be wrong?

A:

No, you can't update the GtkProgressBar from another thread. There are two solutions to your problem, and both involve gdk_threads_idle_add():
1. Wait for the Idle Callback
In this case,your thread would schedule the progress bar update with gdk_threads_add_idle(), then wait for it to finish. I don't know what the best way to do this with GLib is, but there's probably something you can do (GMutex?). The idea is this:
gboolean updateProgressBar(gpointer data)
{
    gtk_progress_bar_set_fraction(progressbar, value);
    tellOtherThreadToContinue();
    return G_SOURCE_REMOVE;        // == FALSE
}

gpointer otherThread(gpointer data)
{
    while (condition) {
        doStep();
        gdk_threads_idle_add(updateProgressBar, NULL);
        waitForProgressBarToBeUpdated();
    }
    return (gpointer) 0;
}

2. Forego the Thread Entirely and Loop the Idle Callback
If the idle callback returns G_SOURCE_CONTINUE (== TRUE), GTK+ will schedule your function again for the next idle period. You can take advantage of this to rewrite your while loop as an idle callback:
gboolean loop(gpointer data)
{
    if (condition)
        return G_SOURCE_REMOVE;
    doStep();
    gtk_progress_bar_set_fraction(progressbar, value);
    return G_SOURCE_CONTINUE;
}

// in your code, start the loop going with
gdk_threads_idle_add(loop, NULL);

Regardless of what you choose, you can take advantage of the data parameter to both the idle callback and the thread to pass data those functions would need around. Just be careful not to pass a pointer to a local variable to the idle callback, as that might run after your function returns (and the variable goes out of scope/ceases to exist).
Note that regardless of what you do, you'll be waiting for the progress bar to update (and in the latter case, redraw). If things become too slow, you may want to look into updating the progress bar in chunks. This, however, depends entirely on how many steps you have.

