On Sat, 2002-11-09 at 15:29, Dirk Gerrits wrote: > Hi, > > 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 Glib::signal_idle().connect(slot_to_run,priority); 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 Glib::signal_timeout().connect(slot_to_run,N,priority); 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. > > Returns: > 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. > 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". > 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. > Thanks in advance, > Dirk Gerrits You are welcome. HTH, Tassos [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. -- Tassos Bassoukos UNIX does not prevent you from doing stupid things because that would also prevent you from doing clever things
Attachment:
signature.asc
Description: This is a digitally signed message part