aspose file tools*
The moose likes C / C++ and the fly likes Using Glibmm Main Event Loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Using Glibmm Main Event Loop" Watch "Using Glibmm Main Event Loop" New topic
Author

Using Glibmm Main Event Loop

Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
I am trying to understand and use Glibmm Main Event Loop. I find it difficult to understand what it actually do.
A program that wants to use the Main Event Loop first defines it like this:
Glib::RefPtr<Glib::MainLoop> _mainloop;

Then the constructor creates it like this:
Application::Application () :
_mainloop (Glib::MainLoop::create())
{...}

The application must implement a run function where it calls on mainloop->run().
void
Application::run()
{
_mainloop->run();
}

Now: What exactly is it its doing?
I have read http://en.wikipedia.org/wiki/Event_loop, but I am still lost, don't know why. Maybe I need a dumbed down explanation...
I have also tried to understand the following example: http://developer.gnome.org/glibmm/unstable/thread_2dispatcher_8cc-example.html#a15
From Java I am familiar with event listeners that listens for specific events. Don't know if this is similar.

Anyway from this code I cannot see what the mainloop actually does for this Application...
Anand Hariharan
Rancher

Joined: Aug 22, 2006
Posts: 257

Glibmm is a C++ wrapper for GLib's GObjects.

To understand Glibmm's Main Event Loop, you may want to read Glib's documentation of Main Event Loop: http://developer.gnome.org/glib/2.32/glib-The-Main-Event-Loop.html

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Using Glibmm Main Event Loop