Re: Xlib: unexpected async reply (sequence #####)!



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gabriel Schulhof wrote:
On Sun, 2007-08-05 at 11:29 +0800, Gregory Hosler wrote:
I'm looking for code examples specifically on how to use/implement g_idle_add().
Know any projects that uses g_idle_add() and related infrastructure?


static gboolean
make_insensitive_idle_cb(gpointer data)
{
  GtkWidget *widget = GTK_WIDGET(data);

  gtk_widget_set_sensitive(widget, FALSE);

/* Return FALSE so as not to keep executing this function over and over
   again */
  return FALSE;
}

static gpointer
my_thread(gpointer data)
{
/* ... do something of long duration, during which ... */

g_idle_add(make_insensitive_idle_cb, some_widget);

/* ... do the rest of the long duration stuff ... */

return NULL;
}

Have a look at

http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#id2603517

I actually had a look at that page prior to my post. It didn't answer some of
the basic questions / concerns I had.

Your example clears up alot of stuff for me. One of my questions (that your
example pretty much clarifies for me), was "what do I g_idle_add()" ?
If I understand correctly, you basically add callback functions, and in
particular, ones that are gtk/gdk related (i.e. that deal with the displaying of
widgets).

is this more or less correct ?

so, um, when a g_idle_add does a "gtk_widget_show()" on a widget, and that
widget would get displayed as part of the main thread.

Am I correct to say that things like gtk_label_new(), and all the related calls
to build a label widget, can be done in a thread, but the "show" must be done in
the main loop (via the g_adle_add() call) ?

If there a list (or guideline) of which gtk_calls should be done in the idle,
and which need not be ?

many thanks,

- -Greg

HTH,

yes, it did!

- -G



Gabriel



- --
+---------------------------------------------------------------------+

Please also check the log file at "/dev/null" for additional information.
                (from /var/log/Xorg.setup.log)

| Greg Hosler                                   ghosler redhat com    |
+---------------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFGtb57404fl/0CV/QRAtJHAKCcPTvYTNlvKN71ttWyEGUTkuBd2ACcDmvx
eJuwrFcdbeHq0vHmnwBHets=
=S79l
-----END PGP SIGNATURE-----



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