Re: Updating a statusbar widget
Tony Denault [EMAIL PROTECTED] writes: On Sun, 23 Jul 2000, Vlad Harchev wrote: while (gtk_events_pending()) gtk_main_iteration(); I am doing this, see my print_status function to write text status to a label: int print_status( char *fmt, ... ) { char buf[256]; va_list argptr; va_start( argptr, fmt); vsprintf( buf, fmt, argptr); va_end( argptr ); /* update single line feedback widget on main screen */ gtk_label_set_text( GTK_LABEL(Feedback_search_w), buf ); /* force update of widgets */ while ( gtk_events_pending() ) gtk_main_iteration(); // while ( gtk_main_iteration()); - this one from the FAQ don't work! As was said, this should be g_main_iteration (FALSE); if the FAQ as gtk_main_iteration, please send mail to [EMAIL PROTECTED] return ERR_NONE; } Some problems: 1. The suggested code from the FAQ doesn't work: "while (gtk_main_iteration(FALSE));" I am using GTK 1.2.7. Is the FAQ out of date with the GTK release? 2. Worse, this solution does more than just drawing updates. It also processing other events on the queue. If I call print_status(), any user input to widget and their call backs are called, expired timers call backs get called, etc This make the cure, worse that the problem. Is there a better method to handle this situation? You really need to handle events, otherwise, for example, your window won't be redrawn. So, this probably means you should probably plan on having a way of dealing with the fact that you don't want the user to interact with the application - turn off your timers - put a modal dialog (this way the user will know that something is going on and won't click furiously at the app, only to be surprised when it suddently starts handling the queued events a minute later...) If you don't want to handle events, then you can call gtk_widget_draw(some_parent_of_label_with_a_window), and it will refresh. But other parts of your app won't if they get obscured and neeed to be redrawn. I think this is the best gtk 1.2.x can do. Will 1.4.x work better? It will work pretty much the same in this regard. I don't have much of any idea how it could work better. [There is a call in GTK+-2.0: void gdk_window_process_all_updates (void); which handles all queued redraws. But even if you call this function regularly, since incoming expose events are never removed from the queue your app still won't work correctly if you don't process events. ] Regards, Owen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Updating a statusbar widget
On 31-Jul-2000 Owen Taylor wrote: As was said, this should be g_main_iteration (FALSE); if the FAQ as gtk_main_iteration, please send mail to [EMAIL PROTECTED] Mea culpae. I obviously got a bit confused somewhere along the line. Will fix. -tony --- E-Mail: [EMAIL PROTECTED] He's dead, Jim. Go Bezerk! http://www.gtk.org/~trog ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Updating a statusbar widget
On Wed, 26 Jul 2000, Tony Denault wrote: Hi, On Sun, 23 Jul 2000, Vlad Harchev wrote: while (gtk_events_pending()) gtk_main_iteration(); I am doing this, see my print_status function to write text status to a label: int print_status( char *fmt, ... ) { char buf[256]; va_list argptr; va_start( argptr, fmt); vsprintf( buf, fmt, argptr); va_end( argptr ); /* update single line feedback widget on main screen */ gtk_label_set_text( GTK_LABEL(Feedback_search_w), buf ); /* force update of widgets */ while ( gtk_events_pending() ) gtk_main_iteration(); // while ( gtk_main_iteration()); - this one from the FAQ don't work! return ERR_NONE; } Some problems: 1. The suggested code from the FAQ doesn't work: "while (gtk_main_iteration(FALSE));" I am using GTK 1.2.7. Is the FAQ out of date with the GTK release? Probably it should be while gtk_main_iteration_do(FALSE) since gtk_main_iteration() doesn't accept any arguments. If it's really bug in FAQ, please submit bug report somewhere :) 2. Worse, this solution does more than just drawing updates. It also processing other events on the queue. If I call print_status(), any user input to widget and their call backs are called, expired timers call backs get called, etc This make the cure, worse that the problem. As for timers - it looks like the right thing to call them. As for everything else: if you call print_status in some long loop (that can last rather long in average), in order to prevent user interacting with other widgets you can instead pop modal window with just one message "Please wait, %d%% done". Is there a better method to handle this situation? I think this is the best gtk 1.2.x can do. Will 1.4.x work better? Yes, it looks like the best gtk 1.2.x can do. I don't know for 1.4.x Tony /-\ | Tony Denault| Internet: [EMAIL PROTECTED] | | NASA IRTF, Institute of Astronomy | Phone: (808) 974-4206 | | 1175 Manono St., Bldg 393 | Fax: (808) 974-4207 | | Hilo, Hawaii 96720 | | \-/ Best regards, -Vlad ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Updating a statusbar widget
On Sun, 23 Jul 2000, Vlad Harchev wrote: while (gtk_events_pending()) gtk_main_iteration(); I am doing this, see my print_status function to write text status to a label: int print_status( char *fmt, ... ) { char buf[256]; va_list argptr; va_start( argptr, fmt); vsprintf( buf, fmt, argptr); va_end( argptr ); /* update single line feedback widget on main screen */ gtk_label_set_text( GTK_LABEL(Feedback_search_w), buf ); /* force update of widgets */ while ( gtk_events_pending() ) gtk_main_iteration(); // while ( gtk_main_iteration()); - this one from the FAQ don't work! return ERR_NONE; } Some problems: 1. The suggested code from the FAQ doesn't work: "while (gtk_main_iteration(FALSE));" I am using GTK 1.2.7. Is the FAQ out of date with the GTK release? 2. Worse, this solution does more than just drawing updates. It also processing other events on the queue. If I call print_status(), any user input to widget and their call backs are called, expired timers call backs get called, etc This make the cure, worse that the problem. Is there a better method to handle this situation? I think this is the best gtk 1.2.x can do. Will 1.4.x work better? Tony /-\ | Tony Denault| Internet: [EMAIL PROTECTED] | | NASA IRTF, Institute of Astronomy | Phone: (808) 974-4206 | | 1175 Manono St., Bldg 393 | Fax: (808) 974-4207 | | Hilo, Hawaii 96720 | | \-/ ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Updating a statusbar widget
hi people imagine the following lines: --- int main(arg--etc) { gtk_init (argc, argv); window --bla-bla-- /* i create a statusbar */ status_bar = gtk_statusbar_new(); gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0); gtk_widget_show (status_bar); context_id = gtk_statusbar_get_context_id( GTK_STATUSBAR(status_bar), "Statusbar example"); sub_rout1();// i call a subroutine gtk_widget_show (window); gtk_main (); return(0) } void sub_rout1 { /* here is a loop */ for (bla bla) { do smth; sub_rout2(); } } void sub_rout2 { /* in here i'm trying to update the text in 'statusbar' widget */ gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data), buff) return; } -- Well it doesn't work... exept when it exits from the loop the statusbar gets the last value. Any way how to make the updated contents of the statusbar visible while in the loop? thanks N ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Updating a statusbar widget
On Sun, 23 Jul 2000, Nicholas wrote: Hi, See FAQ - Q4.12 The A is to insert the loop of sub_rout1 the following: while (gtk_events_pending()) gtk_main_iteration(); hi people imagine the following lines: --- int main(arg--etc) { gtk_init (argc, argv); window --bla-bla-- /* i create a statusbar */ status_bar = gtk_statusbar_new(); gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0); gtk_widget_show (status_bar); context_id = gtk_statusbar_get_context_id( GTK_STATUSBAR(status_bar), "Statusbar example"); sub_rout1();// i call a subroutine gtk_widget_show (window); gtk_main (); return(0) } void sub_rout1 { /* here is a loop */ for (bla bla) { do smth; sub_rout2(); } } void sub_rout2 { /* in here i'm trying to update the text in 'statusbar' widget */ gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data), buff) return; } -- Well it doesn't work... exept when it exits from the loop the statusbar gets the last value. Any way how to make the updated contents of the statusbar visible while in the loop? thanks N ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list Best regards, -Vlad ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list