⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtkdialog.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<td><p><span class="term"><a name="GTK-RESPONSE-CANCEL:CAPS"></a><code class="literal">GTK_RESPONSE_CANCEL</code></span></p></td><td>Returned by Cancel buttons in GTK+ dialogs.</td></tr><tr><td><p><span class="term"><a name="GTK-RESPONSE-CLOSE:CAPS"></a><code class="literal">GTK_RESPONSE_CLOSE</code></span></p></td><td>Returned by Close buttons in GTK+ dialogs.</td></tr><tr><td><p><span class="term"><a name="GTK-RESPONSE-YES:CAPS"></a><code class="literal">GTK_RESPONSE_YES</code></span></p></td><td>Returned by Yes buttons in GTK+ dialogs.</td></tr><tr><td><p><span class="term"><a name="GTK-RESPONSE-NO:CAPS"></a><code class="literal">GTK_RESPONSE_NO</code></span></p></td><td>Returned by No buttons in GTK+ dialogs.</td></tr><tr><td><p><span class="term"><a name="GTK-RESPONSE-APPLY:CAPS"></a><code class="literal">GTK_RESPONSE_APPLY</code></span></p></td><td>Returned by Apply buttons in GTK+ dialogs.</td></tr><tr><td><p><span class="term"><a name="GTK-RESPONSE-HELP:CAPS"></a><code class="literal">GTK_RESPONSE_HELP</code></span></p></td><td>Returned by Help buttons in GTK+ dialogs.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3360702"></a><h3><a name="gtk-dialog-new"></a>gtk_dialog_new ()</h3><a class="indexterm" name="id3360715"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>*          gtk_dialog_new                      (void);</pre><p>Creates a new dialog box. Widgets should not be packed into this <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a>directly, but into the <em class="parameter"><code>vbox</code></em> and <em class="parameter"><code>action_area</code></em>, as described above. </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>&#160;:</span></p></td><td>a new <a class="link" href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3360780"></a><h3><a name="gtk-dialog-new-with-buttons"></a>gtk_dialog_new_with_buttons ()</h3><a class="indexterm" name="id3360794"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>*          gtk_dialog_new_with_buttons         (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *title,                                                         <a class="link" href="GtkWindow.html" title="GtkWindow">GtkWindow</a> *parent,                                                         <a class="link" href="GtkDialog.html#GtkDialogFlags">GtkDialogFlags</a> flags,                                                         const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *first_button_text,                                                         ...);</pre><p>Creates a new <a class="link" href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a> with title <em class="parameter"><code>title</code></em> (or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> for the defaulttitle; see <a class="link" href="GtkWindow.html#gtk-window-set-title"><code class="function">gtk_window_set_title()</code></a>) and transient parent <em class="parameter"><code>parent</code></em> (or<ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> for none; see <a class="link" href="GtkWindow.html#gtk-window-set-transient-for"><code class="function">gtk_window_set_transient_for()</code></a>). The <em class="parameter"><code>flags</code></em>argument can be used to make the dialog modal (<a class="link" href="GtkDialog.html#GTK-DIALOG-MODAL:CAPS"><span class="type">GTK_DIALOG_MODAL</span></a>)and/or to have it destroyed along with its transient parent(<a class="link" href="GtkDialog.html#GTK-DIALOG-DESTROY-WITH-PARENT:CAPS"><span class="type">GTK_DIALOG_DESTROY_WITH_PARENT</span></a>). After <em class="parameter"><code>flags</code></em>, buttontext/response ID pairs should be listed, with a <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> pointer endingthe list. Button text can be either a stock ID such as<a class="link" href="gtk-Stock-Items.html#GTK-STOCK-OK:CAPS"><span class="type">GTK_STOCK_OK</span></a>, or some arbitrary text. A response ID can beany positive number, or one of the values in the <a class="link" href="GtkDialog.html#GtkResponseType"><span class="type">GtkResponseType</span></a>enumeration. If the user clicks one of these dialog buttons,<a class="link" href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a> will emit the <a class="link" href="GtkDialog.html#GtkDialog-response"><span class="type">"response"</span></a> signal with the correspondingresponse ID. If a <a class="link" href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a> receives the <a class="link" href="GtkWidget.html#GtkWidget-delete-event"><span class="type">"delete-event"</span></a> signal, it will emit ::response with a response ID of <a class="link" href="GtkDialog.html#GTK-RESPONSE-DELETE-EVENT:CAPS"><span class="type">GTK_RESPONSE_DELETE_EVENT</span></a>.However, destroying a dialog does not emit the ::response signal;so be careful relying on ::response when using the <a class="link" href="GtkDialog.html#GTK-DIALOG-DESTROY-WITH-PARENT:CAPS"><span class="type">GTK_DIALOG_DESTROY_WITH_PARENT</span></a> flag. Buttons are from left to right,so the first button in the list will be the leftmost button in the dialog.</p><p>Here's a simple example:</p><div class="informalexample"><pre class="programlisting"> GtkWidget *dialog = gtk_dialog_new_with_buttons ("My dialog",                                                  main_app_window,                                                  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,                                                  GTK_STOCK_OK,                                                  GTK_RESPONSE_ACCEPT,                                                  GTK_STOCK_CANCEL,                                                  GTK_RESPONSE_REJECT,                                                  NULL);</pre></div><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>title</code></em>&#160;:</span></p></td><td> Title of the dialog, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>parent</code></em>&#160;:</span></p></td><td> Transient parent of the dialog, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></p></td><td> from <a class="link" href="GtkDialog.html#GtkDialogFlags"><span class="type">GtkDialogFlags</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>first_button_text</code></em>&#160;:</span></p></td><td> stock ID or text to go in first button, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em>&#160;:</span></p></td><td> response ID for first button, then additional buttons, ending with <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> a new <a class="link" href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3361199"></a><h3><a name="gtk-dialog-run"></a>gtk_dialog_run ()</h3><a class="indexterm" name="id3361212"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a>                gtk_dialog_run                      (<a class="link" href="GtkDialog.html" title="GtkDialog">GtkDialog</a> *dialog);</pre><p>Blocks in a recursive main loop until the <em class="parameter"><code>dialog</code></em> either emits the<a class="link" href="GtkDialog.html#GtkDialog-response"><span class="type">"response"</span></a> signal, or is destroyed. If the dialog is destroyed during the call to <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a>, <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> returns <a class="link" href="GtkDialog.html#GTK-RESPONSE-NONE:CAPS"><span class="type">GTK_RESPONSE_NONE</span></a>. Otherwise, it returns the response ID from the ::response signal emission.</p><p>Before entering the recursive main loop, <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> calls<a class="link" href="GtkWidget.html#gtk-widget-show"><code class="function">gtk_widget_show()</code></a> on the dialog for you. Note that you stillneed to show any children of the dialog yourself.</p><p>During <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a>, the default behavior of <a class="link" href="GtkWidget.html#GtkWidget-delete-event"><span class="type">"delete-event"</span></a> is disabled; if the dialog receives ::delete_event, it will not bedestroyed as windows usually are, and <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> will return<a class="link" href="GtkDialog.html#GTK-RESPONSE-DELETE-EVENT:CAPS"><span class="type">GTK_RESPONSE_DELETE_EVENT</span></a>. Also, during <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> the dialog will be modal. You can force <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> to return at any time bycalling <a class="link" href="GtkDialog.html#gtk-dialog-response"><code class="function">gtk_dialog_response()</code></a> to emit the ::response signal. Destroying the dialog during <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> is a very bad idea, because your post-run code won't know whether the dialog was destroyed or not.</p><p>After <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> returns, you are responsible for hiding ordestroying the dialog if you wish to do so.</p><p>Typical usage of this function might be:</p><div class="informalexample"><pre class="programlisting">  gint result = gtk_dialog_run (GTK_DIALOG (dialog));  switch (result)    {      case GTK_RESPONSE_ACCEPT:         do_application_specific_something ();         break;      default:         do_nothing_since_dialog_was_cancelled ();         break;    }  gtk_widget_destroy (dialog);</pre></div><p></p><p>Note that even though the recursive main loop gives the effect of amodal dialog (it prevents the user from interacting with other windows in the same window group while the dialog is run), callbacks such as timeouts, IO channel watches, DND drops, etc, <span class="emphasis"><em>will</em></span> be triggered during a <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> call.</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>dialog</code></em>&#160;:</span></p></td><td> a <a class="link" href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> response ID</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3361503"></a><h3><a name="gtk-dialog-response"></a>gtk_dialog_response ()</h3><a class="indexterm" name="id3361516"></a><pre class="programlisting">void                gtk_dialog_response                 (<a class="link" href="GtkDialog.html" title="GtkDialog">GtkDialog</a> *dialog,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> response_id);</pre><p>Emits the <a class="link" href="GtkDialog.html#GtkDialog-response"><span class="type">"response"</span></a> signal with the given response ID. Used to indicate that the user has responded to the dialog in some way;typically either you or <a class="link" href="GtkDialog.html#gtk-dialog-run"><code class="function">gtk_dialog_run()</code></a> will be monitoring the::response signal and take appropriate action.</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>dialog</code></em>&#160;:</span></p></td><td> a <a class="link" href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>response_id</code></em>&#160;:</span></p></td><td> response ID </td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -