Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Main Namespace Reference

Initialization, main event loop and events. More...

## Compounds

- class IdleSignal
    Idle signal class. More...
- class InputSignal
    Input signal class. More...
- class KeySnooperSignal
    KeySnooper signal class. More...
- class QuitSignal
    Quit signal class. More...
- class TimeoutSignal
    Timeout signal class. More...

## Initializers

- void init (int *argc, char ***argv)
    Initialize the Inti library.
- bool init_check (int *argc, char ***argv)
    Initialize the Inti library.
- void init_add (const Slot0< int > *callback)
    Register a slot to be called when the mainloop is started.

## Accessors

- PangoLanguage * default_language ()
    Get the default language currently in effect.
- bool events_pending ()
    Checks if any events are pending.
- Pointer< Gtk::Widget > event_widget (Gdk::Event &event)
    Get the widget that originally received the event.

## Main Event Loop

- void run ()
    Runs the main loop until quit() is called.
- int level ()
    Asks for the current nesting level of the main loop.
- void quit ()
    Makes the innermost invocation of the main loop return when it regains control.
- bool iterate (bool blocking=true)
    Runs a single iteration of the mainloop.
- void grab_add (Gtk::Widget &widget)
    Makes widget the current grabbed widget.
- Pointer< Gtk::Widget > grab_get_current ()
    Queries the current grab.
- void grab_remove (Gtk::Widget &widget)
    Removes the grab from the given widget.

## Signals

- QuitSignal quit_signal
    A namespace instance of the QuitSignal for connecting slots to be invoked at the termination of the current mainloop.
- TimeoutSignal timeout_signal
    A namespace instance of the TimeoutSignal for connecting slots to be invoked periodically.
- IdleSignal idle_signal
    A namespace instance of the IdleSignal for connecting slots to be invoked when the event loop is idle.
- KeySnooperSignal key_snooper_signal
    A namespace instance of the KeySnooperSignal for connecting slots that will receive keypress events.
- InputSignal input_signal
    A namespace instance of the InputSignal for connecting slots to be called when a condition becomes true on a file descriptor.

## Detailed Description

Initialization, main event loop and events.

Provides a set of methods and signals for handling program initialization and custom event loop processing.

## Function Documentation

PangoLanguage* default_language | ( |  | ) |

Get the default language currently in effect.

Returns:
  The ISO language code for the default language currently in effect.

Note that this can change over the life of an application. The default language is derived from the current locale. It determines, for example, whether Inti uses the right-to-left or left-to-right text direction.

Pointer<Gtk::Widget> event_widget | ( | Gdk::Event & | event | ) |

Get the widget that originally received the event.

Parameters:

  event | A reference to a Gdk::Event.

Returns:
  The widget that originally received event, or null.

If event is null or the event was not associated with any widget, returns null, otherwise returns the widget that received the event originally. The widget is returned as a smart pointer because there is the possiblity that the widget was wrapped for the first time and needs to be unreferenced.

bool events_pending | ( |  | ) |

Checks if any events are pending.

Returns:
  true if any events are pending, false otherwise.

This can be used to update the GUI and invoke timeouts etc. while doing some time intensive computation.

Example: Updating the GUI during a long computation.

                 // computation going on
                 ...
                 while (events_pending())
                    iterate();
                 ...
                 // computation continued

void grab_add | ( | Gtk::Widget & | widget | ) |

Makes widget the current grabbed widget.

Parameters:

  widget | The widget that grabs keyboard and pointer events.

This means that interaction with other widgets in the same application is blocked and mouse as well as keyboard events are delivered to this widget.

Pointer<Gtk::Widget> grab_get_current | ( |  | ) |

Queries the current grab.

Returns:
  The widget which currently has the grab or null if no grab is active.

void grab_remove | ( | Gtk::Widget & | widget | ) |

Removes the grab from the given widget.

Parameters:

  widget | The widget which gives up the grab. You have to pair calls to grab_add() and grab_remove().

void init | ( | int * | argc,
|  | char *** | argv
| ) |

Initialize the Inti library.

Parameters:

  argc | Address of the argc parameter of your main function. Changed if any arguments were handled.
  argv | Address of the argv parameter of main(). Any parameters understood by init() are stripped before returning.

Call this method before using any other Inti methods in your GUI applications. It will initialize everything needed to operate the toolkit and parses some standard command line options. argc and argv are adjusted accordingly so your own code will never see those standard arguments.

void init_add | ( | const Slot0< int > * | callback | ) |

Register a slot to be called when the mainloop is started.

Parameters:

  callback | A slot to invoke when main() is called next.

The callback slot must be explicitly unreferenced before the program ends.

bool init_check | ( | int * | argc,
|  | char *** | argv
| ) |

Initialize the Inti library.

Parameters:

  argc | A reference to the argc of the main() function.
  argv | A reference to the argv of the main() function.

Returns:
  true if the GUI has been successfully initialized, false otherwise.

This method does the same work as init() with only a single change: It does not terminate the program if the GUI can't be initialized. Instead it returns false on failure. This way the application can fall back to some other means of communication with the user - for example a ommand line interface.

bool iterate | ( | bool | blocking = true | ) |

Runs a single iteration of the mainloop.

Parameters:

  blocking | Set true if you want to block if no events are pending.

Returns:
  true if quit() has been called for the innermost mainloop.

If blocking is true and no events are waiting to be processed Inti will block until the next event is noticed. If blocking is false and no events are available return.

int level | ( |  | ) |

Asks for the current nesting level of the main loop.

Returns:
  The nesting level of the current invocation of the main loop.

This can be useful when connecting a slot to the quit_signal.

void run | ( |  | ) |

| Runs the main loop until quit() is called. You can nest calls to run(). In that case quit() will make the innermost invocation of the main loop return.

Main Page - Footer