[gtkmm] Re: How to do call a function once every 'frame'? And some documentation feedback.

Bassoukos Tassos wrote:

On Sat, 2002-11-09 at 15:29, Dirk Gerrits wrote:

>I'm trying to find out how to have a function called once every 'frame'.
>In a Win32 program that would mean something like:
>while (!quit)
>     // Win32 event handling here
>     // ...
>     DoFrame();
>How would I do this in gtkmm2?

If you want to do a long-running computation whithout threads and
without blocking the user interface, use
Where slot_to_run is the slot you want to call when your program will
start to become idle and priority defines the priority at which the idle state will be cheked (see [1] if this does not make any sense). Your slot should not take too long to finish though, so that computation and event processing can be interleaved.

If instead you want to do some computation every N miliseconds, use

I need the latter. Thanks a lot.

In both cases, priority has a sane default value.

[snip -- some very relevant documentation questions]

>All of these questions remain (largely) unanswered. It seems the
>reference documentation can use a lot of improvement. There's a lot of
>missing documentation and also a lot of plain stupid documentation. Here
>is one example that shows the latter:
>SignalIdle Glib::MainContext::signal_idle()
>Idle signal, attached to this MainContext.
>     A signal proxy; you want to use SignalIdle::connect().
>This little piece of documentation tells you ABSOLUTELY NOTHING that the
>function signature doesn't tell you. I don't want to know that

It does: it returns a *signal proxy* (see the Proxy pattern), that mean that it is only an intermediary, and right afterwards: "you want to use SignalIdle::connect()", where you should go and read the docs now.

Yeah I realize that now. I think it should read "For more information see: SignalIdle::connect()" instead of "you want to use SignalIdle::connect()" though.

>signal_idle stands for the idle signal, I want to know WHAT an idle
>signal is and WHEN it is called. The documentation for
>Gtk::Main::signal_quit is much better for example.

The documentation for SignalIdle::connect states that the splot
parameter is "A slot to call when the main loop is idle". Idle as in
"the program has nothing more to do and will sleep for an event".

How about adding a section on definitions to the reference documentation? Your explanation of 'idle' seems like a great candidate for that. And there are most likely a lot more terms that could benifit from a central place where they are explained. Thread, process, signal, slot, etc, etc. Just an idea though.

>The tutorial is very good IMHO, but it does not tell you everything.
>That's what the reference documentation is supposed to do, right?

>So can anyone who knows gtkmm2 well enough that he doesn't need the
>reference tell me how I would accomplish my once every 'frame' function?

It would help if you defined better wht a frame is.

Yeah sorry about that. I explained it in detail in my answer to Leslie Polzer's reply.


[1] the priority levels are there to distinguish between the
    different sources. In this context, idle meand that only
    lower-priority sources (if at all) want to do something.

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