Re: gtk thread begginer
- From: Stefan Kost <ensonic hora-obscura de>
- To: Boris Winter <winter boris vz htnet hr>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gtk thread begginer
- Date: Fri, 18 Feb 2005 07:54:42 +0100
Hi Boris,
beause inside the thread you need to do:
gdk_threads_enter();
gtk_label_set(GTK_LABEL (kredit), a);
gdk_threads_leave();
my app is and it counts only to 3 and not to 999.
how can i do this?
thanks.:
#include<gtk/gtk.h>
#include<stdio.h>
#include<string.h>
GtkWidget *window;
GtkWidget *poruka;
GtkWidget *kredit;
void izrada_prozora(){
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "ALLs JukeBOX 3");
gtk_container_set_border_width (GTK_CONTAINER (window), 50);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK
(gtk_main_quit), NULL);
kredit = gtk_label_new ("0");
gtk_container_add (GTK_CONTAINER (window), kredit);
gtk_widget_show (kredit);
gtk_widget_show(window);
}
void *argument_thread(void *args){
unsigned long int b=0;
char a[1000];
for(b;b<1000;b++){
b++;
sprintf(a, "%d", b);
gtk_label_set(GTK_LABEL (kredit), a);
g_usleep(1000000);
}
}
int main(int argc, char *argv[]){
gtk_init(&argc, &argv);
g_thread_init(NULL);
gdk_threads_init();
izrada_prozora();
g_thread_create(argument_thread, 0, 1, 0);
gdk_threads_enter ();
gtk_main ();
gdk_threads_leave ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]