[Glade-users] Update progressbar from forked child



Steven wrote:
Hi there,

This is my first attempt to Gtk Programming in Glade. Although I know
php and a little VB, It's been a long time since I used ansi C and maybe
I'm doing stupid things.  Please feel free to point them out :-)

Hi Steven,
     First of all, you'll get a better suited audience for gtk+ programming
related questions on the gtk lists (gtk-app-devel-list at gnome.org). This
list is more related to the glade tool & the glade files that the glade tool
generates.

What I sugest you do (and there are a few ways) is this:

  - Create a thread that is responsable for the entire process of
    converting the images - from this thread you will never call gtk+
    functions that deal with widgets (or progressbars) in the main GUI thread.

  - In the thread you will loop through all the filenames and do the following
    for each file:
      o call g_spawn_sync(/* program to convert one file */);
      o call g_idle_add() /* to add a function that will be called from the
        main thread the next time the main thread is idle */

  - From the g_idle_add() callback that you registered from the worker thread
    but runs in the main thread (the gtk_main() thread that is), you will
    then proceed to call "gtk_progress_bar_whatever_you_want_cause_its_safe_here()"
    and return FALSE to ensure the idle was a one shot deal for every time it
    was explicitly registered from the thread.

There you have it :)

Cheers,
                    -Tristan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]