Nisha P Kurur wrote: > We are trying to create a gtk application which should run without much of > manual intervention. Few buttons are placed in a row and each button has > an image at the top which changes to red on selection. This image changes > to green when the button goes out of selection. So the whole process has > to be done in a scan mode without any manual intervention. > > The problem with our code (attached with this mail) is that the events are > generated and the callback functions are called. But the window is not > refreshed properly. The window gets updated only when there is any > mouse/keyboard movement.
1. using the sleep() function in a GUI application is very bad programming style by all means, even if taking place in a custom thread. It's a relict of shell programming. You should rather use gtk_timeout_add() or g_timeout_add(). Probably you can even do without multiple threads then, which may avoid some hard to find bugs in the future and makes debugging much easier. See: http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-timeout-add http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-timeout-add 2. you have to make sure that GTK+ can pass through its main loop for changes to be drawn. In a single-threaded application this would have to happen after your g_signal_emit_by_name() calls. See: http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-main-iteration-do 3. you probably know that the switch-case tree of your example is bloated, i.e. contains much redundancy which could (and probably should) be avoided. Of 7 statements, 3 are completely identical and the other ones could be unified by simply using your "index" variable instead of distinct constants to pass to the respective functions. Add a little list of const strings for the xpm_label_box() call and you can do completely without a switch-case, that is, with only 1 instead of 9 blocks of that code. Golden rule of programming: _never_ use the copy & paste feature of your text editor for more than three or four lines of code, especially not multiple times! Write sub functions (or in this case: just restructure a code block) instead. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list