index
gtk-- homepage



Description:
Gtk_Main

#include <gtk--/main.h>
Base classes: public

Main application class
Every application must have one of these objects. (actually can have more than one, but all Gtk_Main objects handle the same instance - at least for now)

Normal use of this class is in main() function to give argc and argv to the gtk initialization. Widgets can use Gtk_Main::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_Main m(argc, argv);
     ... create some widgets ...
     m.run();
   }
 


Properties:


Public member index:


static Gtk_Main *instance();
Gtk_Main(int *argc,char ***argv,bool have_locale=false);
Gtk_Main(int &argc,char **&argv,bool have_locale=false);
~Gtk_Main();
static void run();
static void iteration(bool blocking=TRUE);
static gint events_pending();
static void grab_add(Gtk_Widget &widget);
Grabs events to a widget modal

static void grab_remove(Gtk_Widget &widget);
Removes event grab

static Gtk_Widget *grab_get_current();
Returns the widget which is grabbing events

static void gtk_true();
static void gtk_false();
Idle signal

Timeout signal

KeySnooper signal

Input signal

Quit signal

Protected member index:


Gtk_Main();
void init(int *argc,char ***argv,bool have_locale);
void init_gtkmm_internals();
virtual void run_impl();
virtual void quit_impl();
virtual void iteration_impl(bool blocking);
virtual gint events_pending_impl();

Public member details:


grab_add
static void Gtk_Main::grab_add(Gtk_Widget &widget);

Grabs events to a widget modal
Prevents events to everything else than given widget and its childs. This way you can create modal dialogs(not recommended).


idle

Idle signal
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; }
 Gtk_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.


timeout

Timeout signal
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; }
 Gtk_Main::timeout.connect(slot(this,&thisclass::mymethod),100);
 


key_snooper

KeySnooper signal
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 responsiblity of the snooper to pass the keypress to the widget, however, care must be given that the keypress is not passed twice.


input

Input signal
input provies 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 For more information please read the select(2) man page.

(This is largely a front for a gdk_input_add_full)

Example:

 gint thisclass::mymethod() { return 1; }
 int file=open("bob",O_RDONLY);
 Gtk_Main::input.connect(slot(this,&thisclass::mymethod),
 file,
 GDK_INPUT_READ|GDK_INPUT_EXCEPTION);
 


quit

Quit signal
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; }
 Gtk_Main::quit.connect(slot(this,&thisclass::mymethod);

Invoking when: Gtk_Button button;

button.clicked.connect(Gtk_Main::quit.slot());

Calling directly: Gtk_Main::quit();


Protected member details:




Examples:





(pages generated by PERCEPS -script.)