There is a function in glib called g_idle_add which makes it so the
function will be called in the main loop, avoiding locking problems.
What I typically do is wrap functions like I've shown below so you
basically call thread_button_set_label instead of gtk_button_set_label
and everything works out. The code below basically takes the data,
sticks it into the pointer that g_idle_add needs, and sends it through
to be processed. I haven't tested the code but I think it's all correct.

- Brian


typedef struct
{
        GtkButton *button;
        gchar *label;
} ButtonData;

void thread_button_set_label_BD (ButtonData *data)
{
        gtk_button_set_label (data->button, data->label);
        g_free (data->label);
        g_free (data);
}
void thread_button_set_label (GtkButton *button, gchar *label)
{
        ButtonData *data = g_alloc (sizeof (ButtonData));
        data->button = button;
        data->label = g_strdup( label );
        g_idle_add (thread_button_set_label_BD, data);
}

_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to