gtkradiobutton.html
来自「最新gtk中文资料集」· HTML 代码 · 共 626 行 · 第 1/3 页
HTML
626 行
To remove a <a class="link" href="GtkRadioButton.html" title="GtkRadioButton"><span class="type">GtkRadioButton</span></a> from one group and make it part of a new one, use <a class="link" href="GtkRadioButton.html#gtk-radio-button-set-group"><code class="function">gtk_radio_button_set_group()</code></a>.</p><p>The group list does not need to be freed, as each <a class="link" href="GtkRadioButton.html" title="GtkRadioButton"><span class="type">GtkRadioButton</span></a> will removeitself and its list item when it is destroyed.</p><p></p><div class="example"><a name="id3503423"></a><p class="title"><b>Example 10. How to create a group of two radio buttons.</b></p><div class="example-contents"><pre class="programlisting">void create_radio_buttons (void) { GtkWidget *window, *radio1, *radio2, *box, *entry; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); box = gtk_vbox_new (TRUE, 2); /* Create a radio button with a GtkEntry widget */ radio1 = gtk_radio_button_new (NULL); entry = gtk_entry_new (); gtk_container_add (GTK_CONTAINER (radio1), entry); /* Create a radio button with a label */ radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "I'm the second radio button."); /* Pack them into a box, then show all the widgets */ gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 2); gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2); gtk_container_add (GTK_CONTAINER (window), box); gtk_widget_show_all (window); return;}</pre></div></div><p><br class="example-break"></p><p>When an unselected button in the group is clicked the clicked buttonreceives the "toggled" signal, as does the previously selected button.Inside the "toggled" handler, <a class="link" href="GtkToggleButton.html#gtk-toggle-button-get-active"><code class="function">gtk_toggle_button_get_active()</code></a> can be used to determine if the button has been selected or deselected.</p></div><div class="refsect1" lang="en"><a name="id3502684"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3502694"></a><h3><a name="GtkRadioButton-struct"></a>GtkRadioButton</h3><a class="indexterm" name="id3502707"></a><pre class="programlisting">typedef struct _GtkRadioButton GtkRadioButton;</pre><p>Contains only private data that should be read and manipulated using thefunctions below.</p></div><hr><div class="refsect2" lang="en"><a name="id3502724"></a><h3><a name="gtk-radio-button-new"></a>gtk_radio_button_new ()</h3><a class="indexterm" name="id3502737"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_radio_button_new (<ahref="/usr/share/gtk-doc/html/glib/glib-Singly-Linked-Lists.html#GSList">GSList</a> *group);</pre><p>Creates a new <a class="link" href="GtkRadioButton.html" title="GtkRadioButton"><span class="type">GtkRadioButton</span></a>. To be of any practical value, a widget shouldthen be packed into the radio button.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>group</code></em> :</span></p></td><td>an existing radio button group, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> if you are creating a new group.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a new radio button.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3503740"></a><h3><a name="gtk-radio-button-new-from-widget"></a>gtk_radio_button_new_from_widget ()</h3><a class="indexterm" name="id3503754"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_radio_button_new_from_widget (<a class="link" href="GtkRadioButton.html" title="GtkRadioButton">GtkRadioButton</a> *radio_group_member);</pre><p>Creates a new <a class="link" href="GtkRadioButton.html" title="GtkRadioButton"><span class="type">GtkRadioButton</span></a>, adding it to the same group as <em class="parameter"><code>group</code></em>. Aswith <a class="link" href="GtkRadioButton.html#gtk-radio-button-new"><code class="function">gtk_radio_button_new()</code></a>, a widget should be packed into the radio button.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>radio_group_member</code></em> :</span></p></td><td></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a new radio button.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3503839"></a><h3><a name="gtk-radio-button-new-with-label"></a>gtk_radio_button_new_with_label ()</h3><a class="indexterm" name="id3503852"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_radio_button_new_with_label (<ahref="/usr/share/gtk-doc/html/glib/glib-Singly-Linked-Lists.html#GSList">GSList</a> *group, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *label);</pre><p>Creates a new <a class="link" href="GtkRadioButton.html" title="GtkRadioButton"><span class="type">GtkRadioButton</span></a> with a text label.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>group</code></em> :</span></p></td><td>an existing radio button group, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> if you are creating a newgroup.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td>the text label to display next to the radio button.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a new radio button.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3503952"></a><h3><a name="gtk-radio-button-new-with-label-from-widget"></a>gtk_radio_button_new_with_label_from_widget ()</h3><a class="indexterm" name="id3503967"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_radio_button_new_with_label_from_widget (<a class="link" href="GtkRadioButton.html" title="GtkRadioButton">GtkRadioButton</a> *radio_group_member, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *label);</pre><p>Creates a new <a class="link" href="GtkRadioButton.html" title="GtkRadioButton"><span class="type">GtkRadioButton</span></a> with a text label, adding it to the same groupas <em class="parameter"><code>group</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>radio_group_member</code></em> :</span></p></td><td></td></tr><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td>a text string to display next to the radio button.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a new radio button.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3504063"></a><h3><a name="gtk-radio-button-new-with-mnemonic"></a>gtk_radio_button_new_with_mnemonic ()</h3><a class="indexterm" name="id3504077"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_radio_button_new_with_mnemonic (<ahref="/usr/share/gtk-doc/html/glib/glib-Singly-Linked-Lists.html#GSList">GSList</a> *group, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *label);</pre><p>Creates a new <a class="link" href="GtkRadioButton.html" title="GtkRadioButton"><span class="type">GtkRadioButton</span></a> containing a label, adding it to the same group as <em class="parameter"><code>group</code></em>. The label will be created using <a class="link" href="GtkLabel.html#gtk-label-new-with-mnemonic"><code class="function">gtk_label_new_with_mnemonic()</code></a>, so underscores in <em class="parameter"><code>label</code></em> indicate the mnemonic for the button.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?