Problem with GtkProgressBar and multi thread application
- From: "Tomasz Jankowski" <tomcioj gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Problem with GtkProgressBar and multi thread application
- Date: Sun, 24 Dec 2006 00:26:20 +0100
Hello!
This is simple code:
#include <gtk/gtk.h>
gboolean pulse_it (gpointer data) {
gtk_progress_bar_pulse (data);
return TRUE;
}
gint thread_fun (gpointer data) {
gint source_id = g_timeout_add (100, (GSourceFunc) pulse_it, data);
g_usleep (5000000);
g_source_remove (source_id);
gdk_threads_enter ();
gtk_progress_bar_set_text (data, "lol!");
gdk_threads_leave ();
}
int main( int argc,
char *argv[])
{
GtkWidget *window;
GtkWidget *pbar;
gtk_init (&argc, &argv);
g_thread_init (NULL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
pbar = gtk_progress_bar_new ();
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (pbar));
gtk_widget_show_all (window);
g_thread_create (thread_fun, pbar, FALSE, NULL);
gdk_threads_enter ();
gtk_main ();
gdk_threads_leave ();
return 0;
}
It doesn't work form me. Progress bar is pulsing, but when event source is
removed something weird starts happening. Whole application still works, but
GUI doesn't update (new progress bar's text doesn't display). Any idea how
to solve this?! Maybe I'm too stupid...
I use Ubuntu with GTK+v.2.10.6, GLib 2.12.4 and GCC 4.1
--
Pozdrawiam!
Tom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]