<html> <head><title>Gtk-- Reference: Gtk::Main</title></head> <body bgcolor="#F0F0F0" text="#000000" link="#0000FF" vlink="#000077" alink="#FF0000"> <table align=center border=0 cellspacing=10> <tr> <td><a href="class_index.html">Class Index</a></td> <td><a href="cross_index.html">Cross Index</a></td> <td><a href="name_index.html">Namespace Index</a></td> </table> <h1 align=center>Class Gtk::Main</h1><p> <b> Main application class</b><br> Contained in: <a href="Gtk.html">Gtk</a><br> Derived from: SigC::Object <br> Derived by: <i>none</i> <p> #include <gtk--/main.h> <p> <hr noshade> <table border=0> <tr><td colspan=3><h3>public function member index:</h3></td> <tr valign=top><td align=right><tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1849"><tt><font color=blue><b>Main</b></font></tt></a></td><td><tt>(<tt><font color=purple>int</font></tt>* <tt><font color=blue>argc</font></tt>, <tt><font color=purple>char</font></tt>* **<tt><font color=blue>argv</font></tt>, <tt><font color=purple>bool</font></tt> <tt><font color=blue>have_locale</font></tt>=false)</tt>;</td> <tr valign=top><td align=right><tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1850"><tt><font color=blue><b>Main</b></font></tt></a></td><td><tt>(<tt><font color=purple>int</font></tt>& <tt><font color=blue>argc</font></tt>, <tt><font color=purple>char</font></tt>* *&<tt><font color=blue>argv</font></tt>, <tt><font color=purple>bool</font></tt> <tt><font color=blue>have_locale</font></tt>=false)</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>gint</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1854"><tt><font color=blue><b>events_pending</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1855"><tt><font color=blue><b>grab_add</b></font></tt></a></td><td><tt>(<a href="Gtk%3A%3AWidget.html"><tt><font color=navy><b>Widget</b></font></tt></a>& <tt><font color=blue>widget</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <a href="Gtk%3A%3AWidget.html"><tt><font color=navy><b>Widget</b></font></tt></a>*</tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1857"><tt><font color=blue><b>grab_get_current</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1856"><tt><font color=blue><b>grab_remove</b></font></tt></a></td><td><tt>(<a href="Gtk%3A%3AWidget.html"><tt><font color=navy><b>Widget</b></font></tt></a>& <tt><font color=blue>widget</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1859"><tt><font color=blue><b>gtk_false</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1858"><tt><font color=blue><b>gtk_true</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <a href="Gtk%3A%3AMain.html#1865"><tt><font color=blue><b>Main</b></font></tt></a>*</tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1848"><tt><font color=blue><b>instance</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1853"><tt><font color=blue><b>iteration</b></font></tt></a></td><td><tt>(<tt><font color=purple>bool</font></tt> <tt><font color=blue>blocking</font></tt>=TRUE)</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1852"><tt><font color=blue><b>run</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1851"><tt><font color=blue><b>~Main</b></font></tt></a></td><td><tt>()</tt>;</td> <tr><td> </td><tr><td colspan=3><h3>protected function member index:</h3></td> <tr valign=top><td align=right><tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1865"><tt><font color=blue><b>Main</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>gint</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1871"><tt><font color=blue><b>events_pending_impl</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1866"><tt><font color=blue><b>init</b></font></tt></a></td><td><tt>(<tt><font color=purple>int</font></tt>* <tt><font color=blue>argc</font></tt>, <tt><font color=purple>char</font></tt>* **<tt><font color=blue>argv</font></tt>, <tt><font color=purple>bool</font></tt> <tt><font color=blue>have_locale</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1867"><tt><font color=blue><b>init_gtkmm_internals</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1870"><tt><font color=blue><b>iteration_impl</b></font></tt></a></td><td><tt>(<tt><font color=purple>bool</font></tt> <tt><font color=blue>blocking</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1869"><tt><font color=blue><b>quit_impl</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AMain.html#1868"><tt><font color=blue><b>run_impl</b></font></tt></a></td><td><tt>()</tt>;</td> <tr><td> </td></table> <hr noshade> <h2>Description:</h2> Every application must have one of these objects. It may not be global and must be the first Gtk object created. <tt><a href="Gtk.html"><tt><font color=navy><b>Gtk</b></font></tt></a>::<a href="Gtk.html#1872">Kit</a></tt> is an alias for <tt><a href="Gtk.html"><tt><font color=navy><b>Gtk</b></font></tt></a>::<a href="Gtk%3A%3AMain.html"><tt><font color=navy><b>Main</b></font></tt></a></tt>. It is a singleton so declaring more than one will simply access the first created. <P> Normal use of this class is in <tt><font color=blue><b></b></font></tt> function to give <tt><tt><font color=blue>argc</font></tt></tt> and <tt><tt><font color=blue>argv</font></tt></tt> to the gtk initialization. Widgets can use <a href="Gtk%3A%3AMain.html#1864"><tt><font color=blue>quit</font></tt></a> for example to exit from the application. <P> 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. <P> Minimal gtk-- application is something like this: <pre> void main(int argc, char *argv[]) { Gtk::Kit kit(argc, argv); ... create some widgets ... kit.run(); } </pre><br> <p> <hr noshade> <h2>Function Member Descriptions:</h2> <a name="1855"><font size=+1><b>Gtk::Main::grab_add</b></font></a> - Grabs events to a widget modal<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AMain.html#1855"><tt><font color=blue><b>grab_add</b></font></tt></a><tt>(<a href="Gtk%3A%3AWidget.html"><tt><font color=navy><b>Widget</b></font></tt></a>& <tt><font color=blue>widget</font></tt>)</tt>;<br><blockquote> Prevents events to everything else than given widget and its childs. This way you can create modal dialogs(not recommended).</blockquote> <br><br> <a name="1857"><font size=+1><b>Gtk::Main::grab_get_current</b></font></a> - Returns the widget which is grabbing events<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <a href="Gtk%3A%3AWidget.html"><tt><font color=navy><b>Widget</b></font></tt></a>*</tt> <a href="Gtk%3A%3AMain.html#1857"><tt><font color=blue><b>grab_get_current</b></font></tt></a><tt>()</tt>;<br><br> <a name="1856"><font size=+1><b>Gtk::Main::grab_remove</b></font></a> - Removes event grab<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AMain.html#1856"><tt><font color=blue><b>grab_remove</b></font></tt></a><tt>(<a href="Gtk%3A%3AWidget.html"><tt><font color=navy><b>Widget</b></font></tt></a>& <tt><font color=blue>widget</font></tt>)</tt>;<br><br> <a name="1848"><font size=+1><b>Gtk::Main::instance</b></font></a> - Access to one global instance of Gtk::Main.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <a href="Gtk%3A%3AMain.html#1865"><tt><font color=blue><b>Main</b></font></tt></a>*</tt> <a href="Gtk%3A%3AMain.html#1848"><tt><font color=blue><b>instance</b></font></tt></a><tt>()</tt>;<br><br> <a name="1852"><font size=+1><b>Gtk::Main::run</b></font></a> - Start the widget loop.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AMain.html#1852"><tt><font color=blue><b>run</b></font></tt></a><tt>()</tt>;<br><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AMain.html#1868"><tt><font color=blue><b>run_impl</b></font></tt></a><tt>()</tt>;<br><blockquote> This begins the event loop which handles events. No events propagate until this has been called. It may be called recursively to popup dialogs.</blockquote> <br><br> <hr noshade> <h2>Variable Member Descriptions:</h2> <a name="1860"><font size=+1><b>Gtk::Main::idle</b></font></a> - Idle signal<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <a href="Gtk%3A%3AIdleSig.html"><tt><font color=navy><b>IdleSig</b></font></tt></a> </tt> <tt><a href="Gtk%3A%3AMain.html#1860"><tt><font color=blue>idle</font></tt></a>;</tt><br><blockquote> 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. <P> 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. <P> Example: <pre> gint thisclass::mymethod() { return 1; } Main::idle.connect(slot(this,&thisclass::mymethod)); </pre> <P> You can supply an integer priority to the <a href="Gtk%3A%3AMain.html#1860"><tt><font color=blue>idle</font></tt></a> call; by default, it's <tt><font color=green>GTK_PRIORITY_DEFAULT</font></tt>, lower numbers are higher priority.</blockquote> <br> <a name="1863"><font size=+1><b>Gtk::Main::input</b></font></a> - Input signal<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <a href="Gtk%3A%3AInputSig.html"><tt><font color=navy><b>InputSig</b></font></tt></a> </tt> <tt><a href="Gtk%3A%3AMain.html#1863"><tt><font color=blue>input</font></tt></a>;</tt><br><blockquote> input provides a way to monitor a file descriptor for activity for a number of conditions. Conditions can be any combination of <tt><font color=green>GDK_INPUT_READ, GDK_INPUT_WRITE, GDK_INPUT_EXCEPTION</font></tt>. <P> The first argument of the callback is the file descriptor with activity, the second denotes the kind of activity. <P> See also open(2), fileno(3) and socket(2) for ways of obtaining a file descriptor. <P> This is largely a wrapper for gdk_input_add_full, which in turn uses select(2). <P> Example: <pre> 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)); </pre></blockquote> <br> <a name="1862"><font size=+1><b>Gtk::Main::key_snooper</b></font></a> - KeySnooper signal<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <a href="Gtk%3A%3AKeySnooperSig.html"><tt><font color=navy><b>KeySnooperSig</b></font></tt></a> </tt> <tt><a href="Gtk%3A%3AMain.html#1862"><tt><font color=blue>key_snooper</font></tt></a>;</tt><br><blockquote> key_snooper provides a way to channel keypresses to a callback without registering with the widget. <P> 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.</blockquote> <br> <a name="1864"><font size=+1><b>Gtk::Main::quit</b></font></a> - Quit signal<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <a href="Gtk%3A%3AQuitSig.html"><tt><font color=navy><b>QuitSig</b></font></tt></a> </tt> <tt><a href="Gtk%3A%3AMain.html#1864"><tt><font color=blue>quit</font></tt></a>;</tt><br><blockquote> 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. <P> Example: <pre> Connecting to: gint thisclass::mymethod() { return 1; } Main::quit.connect(slot(this,&thisclass::mymethod); <P> Invoking when: Gtk_Button button; <P> button.clicked.connect(Main::quit.slot()); <P> Calling directly: Main::quit(); </pre></blockquote> <br> <a name="1861"><font size=+1><b>Gtk::Main::timeout</b></font></a> - Timeout signal<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <a href="Gtk%3A%3ATimeoutSig.html"><tt><font color=navy><b>TimeoutSig</b></font></tt></a> </tt> <tt><a href="Gtk%3A%3AMain.html#1861"><tt><font color=blue>timeout</font></tt></a>;</tt><br><blockquote> timeout provides a way to setup a callback that will be called when certain time has elapsed. <P> 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. <P> Example: <pre> gint thisclass::mymethod() { return 1; } Main::timeout.connect(slot(this,&thisclass::mymethod),100); </pre></blockquote> <br> <hr noshade> </html>