Class Index | Cross Index | Namespace Index |
Main application class
Contained in: Gtk
Derived from:
SigC::Object
Derived by:
none
#include <gtk--/main.h>
public function member index: |
||
Main | (int* argc, char* **argv, bool have_locale=false); | |
Main | (int& argc, char* *&argv, bool have_locale=false); | |
static gint | events_pending | (); |
static void | grab_add | (Widget& widget); |
static Widget* | grab_get_current | (); |
static void | grab_remove | (Widget& widget); |
static void | gtk_false | (); |
static void | gtk_true | (); |
static Main* | instance | (); |
static void | iteration | (bool blocking=TRUE); |
static void | run | (); |
~Main | (); | |
protected function member index: |
||
Main | (); | |
virtual gint | events_pending_impl | (); |
void | init | (int* argc, char* **argv, bool have_locale); |
void | init_gtkmm_internals | (); |
virtual void | iteration_impl | (bool blocking); |
virtual void | quit_impl | (); |
virtual void | run_impl | (); |
Normal use of this class is in function to give argc and argv to the gtk initialization. Widgets can use quit for example 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 gtk-- application is something like this:
void main(int argc, char *argv[]) { Gtk::Kit kit(argc, argv); ... create some widgets ... kit.run(); }
Prevents events to everything else than given widget and its childs. This way you can create modal dialogs(not recommended).
This begins the event loop which handles events. No events propagate until this has been called. It may be called recursively to popup dialogs.
idle provides a way to setup a callback that will be called when gtk has nothing else to do, when the execution has returned from all callbacks etc.Return value of the callback will determine if the callback is removed. 0 means callback is removed, 1 means it'll be called again after gtk next time has nothing to do.
Example:
gint thisclass::mymethod() { return 1; } Main::idle.connect(slot(this,&thisclass::mymethod));You can supply an integer priority to the idle call; by default, it's GTK_PRIORITY_DEFAULT, lower numbers are higher priority.
input provides a way to monitor a file descriptor for activity for a number of conditions. Conditions can be any combination of GDK_INPUT_READ, GDK_INPUT_WRITE, GDK_INPUT_EXCEPTION.The first argument of the callback is the file descriptor with activity, the second denotes the kind of activity.
See also open(2), fileno(3) and socket(2) for ways of obtaining a file descriptor.
This is largely a wrapper for gdk_input_add_full, which in turn uses select(2).
Example:
void thisclass::mymethod(int fd, GdkInputCondition cond) { } int fd = open("bob", O_RDONLY); Main::input.connect(slot(this, &thisclass::mymethod), fd, GdkInputCondition(GDK_INPUT_READ | GDK_INPUT_EXCEPTION));
key_snooper provides a way to channel keypresses to a callback without registering with the widget.Callbacks will get the name of the widget and the keypress event. It is the responsibility of the snooper to pass the keypress to the widget, however, care must be given that the keypress is not passed twice.
quit is an emitable signal which terminates the application. You can connect callbacks to it to invoke actions when the user has requested the application should terminate.Example:
Connecting to: gint thisclass::mymethod() { return 1; } Main::quit.connect(slot(this,&thisclass::mymethod);Invoking when: Gtk_Button button;
button.clicked.connect(Main::quit.slot());
Calling directly: Main::quit();
timeout provides a way to setup a callback that will be called when certain time has elapsed.Return value of the callback will determine if the callback is removed. 0 means callback is removed, 1 means it'll call it again after the time has again elapsed.
Example:
gint thisclass::mymethod() { return 1; } Main::timeout.connect(slot(this,&thisclass::mymethod),100);