Google

logo top
Main Page   Widgets   Namespaces   Book  

Gtk::Main Class Reference

Main application class Every application must have one of these objects. More...

Inheritance diagram for Gtk::Main:

Inheritance graph
[legend]
List of all members.

Public Methods

 Main (int* argc, char*** argv, bool set_locale=true)
 Scans the argument vector, and strips off all parameters known to GTK+.

 Main (int& argc, char**& argv, bool set_locale=true)
virtual ~Main ()

Static Public Methods

Gtk::Main* instance ()
 Access to one global instance of Gtk::Main.

void run ()
 Start the event loop.

void run (Window& window)
 Returns from the main loop when the window is closed.

void quit ()
guint level ()
void iteration (bool blocking=true)
bool events_pending ()
RunSig& signal_run ()
 Run signal.

QuitSig& signal_quit ()
 Quit signal You can connect signal handlers to invoke actions when Gtk::Main::quit() has been called.

KeySnooperSig& signal_key_snooper ()
 KeySnooper signal Allows you to channel keypresses to a signal handler without registering with the widget.

void init_gtkmm_internals ()

Protected Methods

 Main ()
void init (int* argc, char*** argv, bool set_locale)
virtual void run_impl ()
virtual void quit_impl ()
virtual guint level_impl ()
virtual void iteration_impl (bool blocking)
virtual bool events_pending_impl ()
virtual void on_window_hide ()

Static Protected Attributes

RunSig signal_run_
QuitSig signal_quit_
KeySnooperSig signal_key_snooper_

Detailed Description

Main application class Every application must have one of these objects.

It may not be global and must be the first Gtk object created. It is a singleton so declaring more than one will simply access the first created.

Normal use of this class is in the main() function to give argc and argv to the gtk initialization. Widgets can use Gtk::Main::quit() to exit from the application.

The internals of the widget have been disguised as signals so that the user can easily connect using the same methods used throughout the widget interface.

Minimal gtkmm application is something like this:

 int main(int argc, char *argv[]) {
     Gtk::Main kit(argc, argv);
     ... create some widgets ...
     kit.run();
 }
 
Examples:

thread/dispatcher.cc.


Constructor & Destructor Documentation

Gtk::Main::Main ( int*    argc,
char ***    argv,
bool    set_locale = true
 

Scans the argument vector, and strips off all parameters known to GTK+.

Your application may then handle the remaining arguments.

Note: The argument strings themself won't be modified, although the pointers to them might change. This makes it possible to create your own argv of string literals, which have the type 'const char[]' in standard C++. (You might need to use const_cast<>, though.)

Gtk::Main::Main ( int&    argc,
char **&    argv,
bool    set_locale = true
 

virtual Gtk::Main::~Main (   [virtual]
 

Gtk::Main::Main (   [protected]
 


Member Function Documentation

bool Gtk::Main::events_pending (   [static]
 

virtual bool Gtk::Main::events_pending_impl (   [protected, virtual]
 

void Gtk::Main::init ( int*    argc,
char ***    argv,
bool    set_locale
[protected]
 

void Gtk::Main::init_gtkmm_internals (   [static]
 

Gtk::Main* Gtk::Main::instance (   [static]
 

Access to one global instance of Gtk::Main.

void Gtk::Main::iteration ( bool    blocking = true [static]
 

virtual void Gtk::Main::iteration_impl ( bool    blocking [protected, virtual]
 

guint Gtk::Main::level (   [static]
 

virtual guint Gtk::Main::level_impl (   [protected, virtual]
 

virtual void Gtk::Main::on_window_hide (   [protected, virtual]
 

void Gtk::Main::quit (   [static]
 

virtual void Gtk::Main::quit_impl (   [protected, virtual]
 

void Gtk::Main::run ( Window   window [static]
 

Returns from the main loop when the window is closed.

When using this override, you should not use Gtk::Main::quit() to close the application, but just call hide() on your Window class.

void Gtk::Main::run (   [static]
 

Start the event loop.

This begins the event loop which handles events. No events propagate until this has been called. It may be called recursively to popup dialogs

Examples:
thread/dispatcher.cc.

virtual void Gtk::Main::run_impl (   [protected, virtual]
 

KeySnooperSig& Gtk::Main::signal_key_snooper (   [static]
 

KeySnooper signal Allows you to channel keypresses to a signal handler without registering with the widget.

Parameters:
GtkWidget* widget.
GdkEventAny& event
Returns:
int
It is the responsibility of the snooper to pass the keypress to the widget, however, care must be taken that the keypress is not passed twice.

QuitSig& Gtk::Main::signal_quit (   [static]
 

Quit signal You can connect signal handlers to invoke actions when Gtk::Main::quit() has been called.

Note that main loops can be nested by calling Gtk::Main::run() recursively, therefore receiving this signal doesn't necessarily mean the application is about to be terminated. If you want to receive a signal only when the last main loop quits, call connect() with main_level = 1.

 bool thisclass::mymethod() { return false; }
 Gtk::Main::signal_quit().connect(SigC::slot(this, &thisclass::mymethod));
 
Returns:
bool - false means callback is removed, true means it'll be called again the next the main loop quits.

RunSig& Gtk::Main::signal_run (   [static]
 

Run signal.

Returns:
void


Member Data Documentation

KeySnooperSig Gtk::Main::signal_key_snooper_ [static, protected]
 

QuitSig Gtk::Main::signal_quit_ [static, protected]
 

RunSig Gtk::Main::signal_run_ [static, protected]
 


The documentation for this class was generated from the following file:
Generated for gtkmm by Doxygen 1.3-rc1 © 1997-2001