📄 gtk-general.html
字号:
<a name="id3144281"></a><p class="title"><b>Example 2. Updating the GUI during a long computation.</b></p><div class="example-contents"><pre class="programlisting"> /* computation going on */... while (gtk_events_pending ()) gtk_main_iteration ();... /* computation continued */</pre></div></div><br class="example-break"><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if any events are pending, <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3144336"></a><h3><a name="gtk-main"></a>gtk_main ()</h3><a class="indexterm" name="id3144348"></a><pre class="programlisting">void gtk_main (void);</pre><p>Runs the main loop until <a class="link" href="gtk-General.html#gtk-main-quit"><code class="function">gtk_main_quit()</code></a> is called. You can nest calls to<a class="link" href="gtk-General.html#gtk-main"><code class="function">gtk_main()</code></a>. In that case <a class="link" href="gtk-General.html#gtk-main-quit"><code class="function">gtk_main_quit()</code></a> will make the innermost invocationof the main loop return.</p></div><hr><div class="refsect2" lang="en"><a name="id3144403"></a><h3><a name="gtk-main-level"></a>gtk_main_level ()</h3><a class="indexterm" name="id3144415"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> gtk_main_level (void);</pre><p>Asks for the current nesting level of the main loop. This can be usefulwhen calling <a class="link" href="gtk-General.html#gtk-quit-add"><code class="function">gtk_quit_add()</code></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the nesting level of the current invocation of the main loop.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3144464"></a><h3><a name="gtk-main-quit"></a>gtk_main_quit ()</h3><a class="indexterm" name="id3144477"></a><pre class="programlisting">void gtk_main_quit (void);</pre><p>Makes the innermost invocation of the main loop return when it regains control.</p></div><hr><div class="refsect2" lang="en"><a name="id3144499"></a><h3><a name="gtk-main-iteration"></a>gtk_main_iteration ()</h3><a class="indexterm" name="id3144512"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> gtk_main_iteration (void);</pre><p>Runs a single iteration of the mainloop. If no events are waiting to beprocessed GTK+ will block until the next event is noticed. If you don'twant to block look at <a class="link" href="gtk-General.html#gtk-main-iteration-do"><code class="function">gtk_main_iteration_do()</code></a> or check if any events arepending with <a class="link" href="gtk-General.html#gtk-events-pending"><code class="function">gtk_events_pending()</code></a> first.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <a class="link" href="gtk-General.html#gtk-main-quit"><code class="function">gtk_main_quit()</code></a> has been called for the innermost mainloop.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3144594"></a><h3><a name="gtk-main-iteration-do"></a>gtk_main_iteration_do ()</h3><a class="indexterm" name="id3144606"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> gtk_main_iteration_do (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> blocking);</pre><p>Runs a single iteration of the mainloop. If no events are available eitherreturn or block dependent on the value of <em class="parameter"><code>blocking</code></em>. </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>blocking</code></em> :</span></p></td><td><ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if you want GTK+ to block if no events are pending.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <a class="link" href="gtk-General.html#gtk-main-quit"><code class="function">gtk_main_quit()</code></a> has been called for the innermost mainloop.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3144701"></a><h3><a name="gtk-main-do-event"></a>gtk_main_do_event ()</h3><a class="indexterm" name="id3144714"></a><pre class="programlisting">void gtk_main_do_event (<ahref="/usr/share/gtk-doc/html/gdk/gdk-Event-Structures.html#GdkEvent">GdkEvent</a> *event);</pre><p>Processes a single GDK event. This is public only to allow filtering of eventsbetween GDK and GTK+. You will not usually need to call this function directly.</p><p>While you should not call this function directly, you might want to knowhow exactly events are handled. So here is what this function does with the event:</p><div class="orderedlist"><ol type="1"><li><p> Compress enter/leave notify events. If the event passed build an enter/leave pair together with the next event (peeked from GDK) both events are thrown away. This is to avoid a backlog of (de-)highlighting widgets crossed by the pointer.</p></li><li><p> Find the widget which got the event. If the widget can't be determined the event is thrown away unless it belongs to a INCR transaction. In that case it is passed to <code class="function">gtk_selection_incr_event()</code>.</p></li><li><p> Then the event is passed on a stack so you can query the currently handled event with <a class="link" href="gtk-General.html#gtk-get-current-event"><code class="function">gtk_get_current_event()</code></a>. </p></li><li><p> The event is sent to a widget. If a grab is active all events for widgets that are not in the contained in the grab widget are sent to the latter with a few exceptions: </p><div class="itemizedlist"><ul type="disc"><li><p> Deletion and destruction events are still sent to the event widget for obvious reasons. </p></li><li><p> Events which directly relate to the visual representation of the event widget. </p></li><li><p> Leave events are delivered to the event widget if there was an enter event delivered to it before without the paired leave event. </p></li><li><p> Drag events are not redirected because it is unclear what the semantics of that would be. </p></li></ul></div><p> Another point of interest might be that all key events are first passed through the key snooper functions if there are any. Read the description of <a class="link" href="gtk-General.html#gtk-key-snooper-install"><code class="function">gtk_key_snooper_install()</code></a> if you need this feature.</p></li><li><p> After finishing the delivery the event is popped from the event stack.</p></li></ol></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>event</code></em> :</span></p></td><td>An event to process (normally) passed by GDK.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3144877"></a><h3><a name="GtkModuleInitFunc"></a>GtkModuleInitFunc ()</h3><a class="indexterm" name="id3144891"></a><pre class="programlisting">void (*GtkModuleInitFunc) (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> *argc, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> ***argv);</pre><p>Each GTK+ module must have a function <code class="function">gtk_module_init()</code> with this prototype.This function is called after loading the module with the <em class="parameter"><code>argc</code></em> and <em class="parameter"><code>argv</code></em> cleaned from any arguments that GTK+ handles itself.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>argc</code></em> :</span></p></td><td>Pointer to the number of arguments remaining after <a class="link" href="gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>argv</code></em> :</span></p></td><td>Points to the argument vector.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3144996"></a><h3><a name="GtkModuleDisplayInitFunc"></a>GtkModuleDisplayInitFunc ()</h3><a class="indexterm" name="id3145011"></a><pre class="programlisting">void (*GtkModuleDisplayInitFunc) (<ahref="/usr/share/gtk-doc/html/gdk/GdkDisplay.html">GdkDisplay</a> *display);</pre><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>display</code></em> :</span></p></td><td></td></tr></tbody></table></div><p class="since">Since 2.2</p></div><hr><div class="refsect2" lang="en"><a name="id3145064"></a><h3><a name="gtk-true"></a>gtk_true ()</h3><a class="indexterm" name="id3145076"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -