![]() |
![]() |
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(); }
Public Member Functions | |
Main (int& argc, char**& argv, bool set_locale=true) | |
See Main(int* argc, char*** argv, bool set_locale). | |
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, Glib::OptionContext& option_context) | |
Scans the argument vector, and strips off all parameters parsed by GTK+ or your option_context. | |
virtual | ~Main () |
Static Public Member Functions | |
static void | add_gtk_option_group (Glib::OptionContext& option_context, bool open_default_display=true) |
Add a Glib::OptionGroup, for the commandline arguments recognized by GTK+ and GDK, to a Glib::OptionContext, so that these commandline arguments will be processed in addition to the existing commandline arguments specified by the Glib::OptionContext. | |
static bool | events_pending () |
Checks if any events are pending. | |
static void | init_gtkmm_internals () |
static Gtk::Main* | instance () |
Access to the one global instance of Gtk::Main. | |
static bool | iteration (bool blocking=true) |
Runs a single iteration of the main loop. | |
static guint | level () |
static void | quit () |
Makes the innermost invocation of the main loop return when it regains control. | |
static void | run (Window& window) |
Returns from the main loop when the window is closed. | |
static void | run () |
Start the event loop. | |
static KeySnooperSig& | signal_key_snooper () |
KeySnooper signal Allows you to channel keypresses to a signal handler without registering with the widget. | |
static QuitSig& | signal_quit () |
Quit signal You can connect signal handlers to invoke actions when Gtk::Main::quit() has been called. | |
static RunSig& | signal_run () |
Run signal. | |
Protected Member Functions | |
virtual bool | events_pending_impl () |
void | init (int* argc, char*** argv, bool set_locale) |
virtual bool | iteration_impl (bool blocking) |
virtual guint | level_impl () |
Main () | |
virtual void | on_window_hide () |
virtual void | quit_impl () |
virtual void | run_impl () |
Static Protected Attributes | |
static KeySnooperSig | signal_key_snooper_ |
static QuitSig | signal_quit_ |
static RunSig | signal_run_ |
|
Scans the argument vector, and strips off all parameters parsed by GTK+ or your option_context. Add a Glib::OptionGroup to the Glib::OptionContext to parse your own command-line 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.) This function automatically generates nicely formatted <option>--help</option> output. Note that your program will be terminated after writing out the help output.
|
|
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.) |
|
See Main(int* argc, char*** argv, bool set_locale).
|
|
|
|
|
|
Add a Glib::OptionGroup, for the commandline arguments recognized by GTK+ and GDK, to a Glib::OptionContext, so that these commandline arguments will be processed in addition to the existing commandline arguments specified by the Glib::OptionContext. You do not need to use this method if you pass your Glib::OptionContext to the Main constructor, because it adds the gtk option group automatically.
|
|
Checks if any events are pending. 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( Gtk::Main::events_pending() ) Gtk::Main::iteration(); // computation continued
|
|
|
|
|
|
|
|
Access to the one global instance of Gtk::Main.
|
|
Runs a single iteration of the main loop. If no events are waiting to be processed GTK+ will block until the next event is noticed. If you don't want to block then pass false for blocking or check if any events are pending with pending() first.
|
|
|
|
|
|
|
|
|
|
Makes the innermost invocation of the main loop return when it regains control.
|
|
|
|
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.
|
|
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 |
|
|
|
KeySnooper signal Allows you to channel keypresses to a signal handler without registering with the widget.
|
|
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 bool thisclass::mymethod() { return false; } Gtk::Main::signal_quit().connect(sigc::mem_fun(this, &thisclass::mymethod));
|
|
Run signal.
|
|
|
|
|
|
|