Re: Callback and event logging



Gus Koppel wrote:
Matthias Mann wrote:


Is there any debug setting that can make a gtk application
print out what events and callbacks are happening when it
runs?

I think this is not implemented in Gtk+. But what's about
doing this by self? You just need to put a simple
printf("callback 1 done"); at end of a callback function. This is a good method to get
some text output to stdout for watching what your application
is doing.

This way only those events will be printed which the application is
prepared to handle. Trying to get informed about EVERY event for EVERY
widget would likely require some hundred custom event handlers and tons of
connects to all widgets. And still this would likely be an incomplete list
since there may be undocumented events or you might be running the next
version of GTK+, which has introduced new events which are not handled by
the program.

However, the method described above is a good way to get an overview of
the order in which a number of events is being triggered. Being informed
this way about every event on every widget on an average application would
hardly let your machine do anything else but endlessly scroll lines of
such debug output in its outoput window  ;-)

I put this at the beginning of every function in the program:

#ifdef ENABLE_DEBUG
    printf ("__FUNCTION__ = %s\n", __FUNCTION__);
#endif




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