Re: Return code for g_main_run/gtk_main



> What's the use case for it, and what's the alternative approach to the
> same problem?

The usefulness is when you are blocking on something by using a recursive
main loop, like gtk_dialog_run(), and you want to return some sort of
status to the function that called the main loop. For GtkDialog, it seems
to eliminate the need for the RunInfo struct.

In my example, I am doing an async file transfer that I need to block
on. I have a signal that is called when the transfer is finished. So I run
gtk_main() after starting the transfer and call gtk_main_quit() in the
"file_done" callback. I would like to return a code via gtk_main_quit to
tell me back in the original function whether or not the transfer
succeeded.

The alternatives to this are either to make a struct like RunInfo in
GtkDialog and passing in the address of a struct or having a global
variable. Nothing too heavy, but handy nonetheless.

Joe





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