📄 gtkcombo.html
字号:
items = g_list_append (items, "Second Item"); items = g_list_append (items, "Third Item"); items = g_list_append (items, "Fourth Item"); items = g_list_append (items, "Fifth Item"); combo = gtk_combo_new (); gtk_combo_set_popdown_strings (GTK_COMBO (combo), items);</pre></div></div><br class="example-break"><div class="example"><a name="id4528369"></a><p class="title"><b>Example 53. Creating a <span class="structname">GtkCombo</span> widget with a complex item.</b></p><div class="example-contents"><pre class="programlisting"> GtkWidget *combo, *item, *hbox, *arrow, *label; combo = gtk_combo_new (); item = gtk_list_item_new (); gtk_widget_show (item); /* You can put almost anything into the GtkListItem widget. Here we will use a horizontal box with an arrow and a label in it. */ hbox = gtk_hbox_new (FALSE, 3); gtk_container_add (GTK_CONTAINER (item), hbox); gtk_widget_show (hbox); arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT); gtk_widget_show (arrow); gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0); label = gtk_label_new ("First Item"); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); /* You must set the string to display in the entry field when the item is selected. */ gtk_combo_set_item_string (GTK_COMBO (combo), GTK_ITEM (item), "1st Item"); /* Now we simply add the item to the combo's list. */ gtk_container_add (GTK_CONTAINER (GTK_COMBO (combo)->list), item);</pre></div></div><br class="example-break"></div><div class="refsect1" lang="en"><a name="id4528408"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id4528417"></a><h3><a name="GtkCombo-struct"></a>GtkCombo</h3><a class="indexterm" name="id4528431"></a><pre class="programlisting">typedef struct { GtkWidget *entry; GtkWidget *list;} GtkCombo;</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">GtkCombo</code> has been deprecated since version 2.4 and should not be used in newly-written code. Use <a class="link" href="GtkComboBox.html" title="GtkComboBox"><span class="type">GtkComboBox</span></a> instead.</p></div><p>The <span class="type">GtkFixedChild</span> struct contains the following fields.(These fields should be considered read-only. They should never be set byan application.)</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> *<em class="structfield"><code>entry</code></em>;</span></p></td><td>the text entry field.</td></tr><tr><td><p><span class="term"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> *<em class="structfield"><code>list</code></em>;</span></p></td><td>the list shown in the drop-down window.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4528524"></a><h3><a name="gtk-combo-new"></a>gtk_combo_new ()</h3><a class="indexterm" name="id4528539"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_combo_new (void);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gtk_combo_new</code> has been deprecated since version 2.4 and should not be used in newly-written code. Use <a class="link" href="GtkComboBox.html" title="GtkComboBox"><span class="type">GtkComboBox</span></a> instead.</p></div><p>Creates a new <a class="link" href="GtkCombo.html" title="GtkCombo"><span class="type">GtkCombo</span></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>a new <a class="link" href="GtkCombo.html" title="GtkCombo"><span class="type">GtkCombo</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4528612"></a><h3><a name="gtk-combo-set-popdown-strings"></a>gtk_combo_set_popdown_strings ()</h3><a class="indexterm" name="id4528629"></a><pre class="programlisting">void gtk_combo_set_popdown_strings (<a class="link" href="GtkCombo.html" title="GtkCombo">GtkCombo</a> *combo, <ahref="/usr/share/gtk-doc/html/glib/glib-Doubly-Linked-Lists.html#GList">GList</a> *strings);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gtk_combo_set_popdown_strings</code> has been deprecated since version 2.4 and should not be used in newly-written code. Use <a class="link" href="GtkComboBox.html" title="GtkComboBox"><span class="type">GtkComboBox</span></a> instead.</p></div><p>Convenience function to set all of the items in the popup list.(See the <a class="link" href="GtkCombo.html#gtkcombo-simple-example" title="Example 52. Creating a GtkCombo widget with simple text items.">example</a> above.)</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>combo</code></em> :</span></p></td><td>a <a class="link" href="GtkCombo.html" title="GtkCombo"><span class="type">GtkCombo</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>strings</code></em> :</span></p></td><td>a list of strings, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to clear the popup list</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4528746"></a><h3><a name="gtk-combo-set-value-in-list"></a>gtk_combo_set_value_in_list ()</h3><a class="indexterm" name="id4528763"></a><pre class="programlisting">void gtk_combo_set_value_in_list (<a class="link" href="GtkCombo.html" title="GtkCombo">GtkCombo</a> *combo, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> val, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> ok_if_empty);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gtk_combo_set_value_in_list</code> has been deprecated since version 2.4 and should not be used in newly-written code. Use <a class="link" href="GtkComboBox.html" title="GtkComboBox"><span class="type">GtkComboBox</span></a> instead.</p></div><p>Specifies whether the value entered in the text entry field must match one ofthe values in the list. If this is set then the user will not be able toperform any other action until a valid value has been entered.</p><p>If an empty field is acceptable, the <em class="parameter"><code>ok_if_empty</code></em> parameter should be <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>combo</code></em> :</span></p></td><td>a <a class="link" href="GtkCombo.html" title="GtkCombo"><span class="type">GtkCombo</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>val</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 the value entered must match one of the values in the list.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>ok_if_empty</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 an empty value is considered valid.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id4528924"></a><h3><a name="gtk-combo-set-use-arrows"></a>gtk_combo_set_use_arrows ()</h3><a class="indexterm" name="id4528940"></a><pre class="programlisting">void gtk_combo_set_use_arrows (<a class="link" href="GtkCombo.html" title="GtkCombo">GtkCombo</a> *combo, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> val);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gtk_combo_set_use_arrows</code> has been deprecated since version 2.4 and should not be used in newly-written code. Use <a class="link" href="GtkComboBox.html" title="GtkComboBox"><span class="type">GtkComboBox</span></a> instead.</p></div><p>Specifies if the arrow (cursor) keys can be used to step through the items inthe list. This is on by default.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>combo</code></em> :</span></p></td><td>a <a class="link" href="GtkCombo.html" title="GtkCombo"><span class="type">GtkCombo</span></a>.</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -