📄 gtk-general.html
字号:
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> data, <a class="link" href="gtk-Types.html#GtkDestroyNotify">GtkDestroyNotify</a> destroy);void <a class="link" href="gtk-General.html#gtk-input-remove">gtk_input_remove</a> (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> input_handler_id);#define <a class="link" href="gtk-General.html#GTK-PRIORITY-REDRAW:CAPS">GTK_PRIORITY_REDRAW</a>#define <a class="link" href="gtk-General.html#GTK-PRIORITY-RESIZE:CAPS">GTK_PRIORITY_RESIZE</a>#define <a class="link" href="gtk-General.html#GTK-PRIORITY-HIGH:CAPS">GTK_PRIORITY_HIGH</a>#define <a class="link" href="gtk-General.html#GTK-PRIORITY-INTERNAL:CAPS">GTK_PRIORITY_INTERNAL</a>#define <a class="link" href="gtk-General.html#GTK-PRIORITY-DEFAULT:CAPS">GTK_PRIORITY_DEFAULT</a>#define <a class="link" href="gtk-General.html#GTK-PRIORITY-LOW:CAPS">GTK_PRIORITY_LOW</a><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> <a class="link" href="gtk-General.html#gtk-key-snooper-install">gtk_key_snooper_install</a> (<a class="link" href="gtk-General.html#GtkKeySnoopFunc">GtkKeySnoopFunc</a> snooper, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> func_data);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> (<a class="link" href="gtk-General.html#GtkKeySnoopFunc">*GtkKeySnoopFunc</a>) (<a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> *grab_widget, <ahref="/usr/share/gtk-doc/html/gdk/gdk-Event-Structures.html#GdkEventKey">GdkEventKey</a> *event, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> func_data);void <a class="link" href="gtk-General.html#gtk-key-snooper-remove">gtk_key_snooper_remove</a> (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> snooper_handler_id);<ahref="/usr/share/gtk-doc/html/gdk/gdk-Event-Structures.html#GdkEvent">GdkEvent</a>* <a class="link" href="gtk-General.html#gtk-get-current-event">gtk_get_current_event</a> (void);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint32">guint32</a> <a class="link" href="gtk-General.html#gtk-get-current-event-time">gtk_get_current_event_time</a> (void);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gtk-General.html#gtk-get-current-event-state">gtk_get_current_event_state</a> (<ahref="/usr/share/gtk-doc/html/gdk/gdk-Windows.html#GdkModifierType">GdkModifierType</a> *state);<a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* <a class="link" href="gtk-General.html#gtk-get-event-widget">gtk_get_event_widget</a> (<ahref="/usr/share/gtk-doc/html/gdk/gdk-Event-Structures.html#GdkEvent">GdkEvent</a> *event);void <a class="link" href="gtk-General.html#gtk-propagate-event">gtk_propagate_event</a> (<a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> *widget, <ahref="/usr/share/gtk-doc/html/gdk/gdk-Event-Structures.html#GdkEvent">GdkEvent</a> *event);</pre></div><div class="refsect1" lang="en"><a name="id3142613"></a><h2>Description</h2><p>Before using GTK+, you need to initialize it; initialization connectsto the window system display, and parses some standard command linearguments. The <a class="link" href="gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a> function initializes GTK+. <a class="link" href="gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a> exitsthe application if errors occur; to avoid this, use <a class="link" href="gtk-General.html#gtk-init-check"><code class="function">gtk_init_check()</code></a>. <a class="link" href="gtk-General.html#gtk-init-check"><code class="function">gtk_init_check()</code></a> allows you to recover from a failed GTK+initialization - you might start up your application in text mode instead.</p><p>Like all GUI toolkits, GTK+ uses an event-driven programmingmodel. When the user is doing nothing, GTK+ sits in the<em class="firstterm">main loop</em> and waits for input. If the userperforms some action - say, a mouse click - then the main loop "wakesup" and delivers an event to GTK+. GTK+ forwards the event to one ormore widgets.</p><p>When widgets receive an event, they frequently emit one or more <em class="firstterm">signals</em>. Signals notify your program that"something interesting happened" by invoking functions you'veconnected to the signal with <ahref="/usr/share/gtk-doc/html/gobject/gobject-Signals.html#g-signal-connect"><code class="function">g_signal_connect()</code></a>. Functions connectedto a signal are often termed <em class="firstterm">callbacks</em>. </p><p>When your callbacks are invoked, you would typically take some action- for example, when an Open button is clicked you might display a <span class="type">GtkFileSelectionDialog</span>. After a callback finishes, GTK+ will returnto the main loop and await more user input.</p><div class="example"><a name="id3142729"></a><p class="title"><b>Example 1. Typical <code class="function">main</code> function for a GTK+ application</b></p><div class="example-contents"><pre class="programlisting">int main (int argc, char **argv){ /* Initialize i18n support */ gtk_set_locale (); /* Initialize the widget set */ gtk_init (&argc, &argv); /* Create the main window */ mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* Set up our GUI elements */ ... /* Show the application window */ gtk_widget_show_all (mainwin); /* Enter the main event loop, and wait for user interaction */ gtk_main (); /* The user lost interest */ return 0;}</pre></div></div><br class="example-break"><p>It's OK to use the GLib main loop directly instead of <a class="link" href="gtk-General.html#gtk-main"><code class="function">gtk_main()</code></a>,though it involves slightly more typing. See <ahref="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GMainLoop"><span class="type">GMainLoop</span></a> in the GLibdocumentation.</p></div><div class="refsect1" lang="en"><a name="id3142793"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3142804"></a><h3><a name="gtk-set-locale"></a>gtk_set_locale ()</h3><a class="indexterm" name="id3142816"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>* gtk_set_locale (void);</pre><p>Initializes internationalization support for GTK+. <a class="link" href="gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a>automatically does this, so there is typically no pointin calling this function.</p><p>If you are calling this function because you changed the localeafter GTK+ is was initialized, then calling this functionmay help a bit. (Note, however, that changing the localeafter GTK+ is initialized may produce inconsistent results andis not really supported.)</p><p>In detail - sets the current locale according to theprogram environment. This is the same as calling the C library function<code class="literal">setlocale (LC_ALL, "")</code> but also takes care of the locale specific setup of the windowing system used by GDK.</p><p></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> a string corresponding to the locale set, typically in theform lang_COUNTRY, where lang is an ISO-639 language code, andCOUNTRY is an ISO-3166 country code. On Unix, this form matches theresult of the <code class="function">setlocale()</code>; it is also used on other machines, such as Windows, where the C library returns a different result. The string is owned by GTK+ and should not be modified or freed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3142906"></a><h3><a name="gtk-disable-setlocale"></a>gtk_disable_setlocale ()</h3><a class="indexterm" name="id3142919"></a><pre class="programlisting">void gtk_disable_setlocale (void);</pre><p>Prevents <a class="link" href="gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a>, <a class="link" href="gtk-General.html#gtk-init-check"><code class="function">gtk_init_check()</code></a>, <a class="link" href="gtk-General.html#gtk-init-with-args"><code class="function">gtk_init_with_args()</code></a> and<a class="link" href="gtk-General.html#gtk-parse-args"><code class="function">gtk_parse_args()</code></a> from automaticallycalling <code class="literal">setlocale (LC_ALL, "")</code>. You would want to use this function if you wanted to set the locale for your program to something other than the user's locale, or if you wanted to set different values for different locale categories.</p><p>Most programs should not need to call this function.</p><p></p></div><hr><div class="refsect2" lang="en"><a name="id3143003"></a><h3><a name="gtk-get-default-language"></a>gtk_get_default_language ()</h3><a class="indexterm" name="id3143015"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/pango/pango-Text-Attributes.html#PangoLanguage">PangoLanguage</a>* gtk_get_default_language (void);</pre><p>Returns the <ahref="/usr/share/gtk-doc/html/pango/pango-Text-Attributes.html#PangoLanguage"><span class="type">PangoLanguage</span></a> for the default language currently ineffect. (Note that this can change over the life of anapplication.) The default language is derived from the currentlocale. It determines, for example, whether GTK+ uses theright-to-left or left-to-right text direction.</p><p>This function is equivalent to <ahref="/usr/share/gtk-doc/html/pango/pango-Miscellaneous-Utilities.html#pango-language-get-default"><code class="function">pango_language_get_default()</code></a>. Seethat function for details.</p><p></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 default language as a <ahref="/usr/share/gtk-doc/html/pango/pango-Text-Attributes.html#PangoLanguage"><span class="type">PangoLanguage</span></a>, must not befreed</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3143095"></a><h3><a name="gtk-parse-args"></a>gtk_parse_args ()</h3><a class="indexterm" name="id3143108"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> gtk_parse_args (int *argc, char ***argv);</pre><p>Parses command line arguments, and initializes globalattributes of GTK+, but does not actually open a connectionto a display. (See <ahref="/usr/share/gtk-doc/html/gdk/GdkDisplay.html#gdk-display-open"><code class="function">gdk_display_open()</code></a>, <ahref="/usr/share/gtk-doc/html/gdk/gdk-General.html#gdk-get-display-arg-name"><code class="function">gdk_get_display_arg_name()</code></a>)</p><p>Any arguments used by GTK+ or GDK are removed from the array and<em class="parameter"><code>argc</code></em> and <em class="parameter"><code>argv</code></em> are updated accordingly.</p><p>You shouldn't call this function explicitely if you are using<a class="link" href="gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a>, or <a class="link" href="gtk-General.html#gtk-init-check"><code class="function">gtk_init_check()</code></a>.</p><p></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> a pointer to the number of command line arguments.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>argv</code></em> :</span></p></td><td> a pointer to the array of command line arguments.</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 initialization succeeded, otherwise <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -