Re: g_main_context_depth()



On Mon, Jan 05, 2004 at 04:40:01PM -0500, Owen Taylor wrote:
> 
>  There is a temptation to use g_main_context_depth() to solve
>  problems with reentrancy. For instance, while waiting for data
>  to be received from the network in response to a menu item,
>  the menu item might be selected again. There is the temptation
>  to write:
> 
>    if (g_main_context_depth(NULL) > 1)
>      return; 
> 
>  This should be avoided since the user then sees selecting the
>  menu item do nothing. Furthermore, you'll find yourself adding
>  these checks all over your code, since there are doubtless many,
>  many things that the user could do. Instead, you can use the
>  following techniques:
> 
>   1) Use gtk_widget_set_sensitive() or modal dialogs to prevent
>      the user from interacting with elements while the main
>      loop is recursing. 

This is easier now that GtkAction is in place.  Previously you
needed to handle accelerators manually.  However, this approach is
not without cost.  Desensitizing a large toolbar is slow, there is a
noticable lag to users if your toolbars are large.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]