<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
<!ENTITY pi "&#960;">
<!ENTITY solidus "&#8260;">
]>
<refentry id="GtkSizeGroup">
<refmeta>
<refentrytitle role="top_of_page" id="GtkSizeGroup.top_of_page">GtkSizeGroup</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK4 Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>GtkSizeGroup</refname>
<refpurpose>Grouping widgets so they request the same size</refpurpose>
</refnamediv>

<refsect1 id="GtkSizeGroup.functions" role="functions_proto">
<title role="functions_proto.title">Functions</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="functions_proto_type" colwidth="150px"/>
<colspec colname="functions_proto_name"/>
<tbody>
<row><entry role="function_type"><link linkend="GtkSizeGroup"><returnvalue>GtkSizeGroup</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-size-group-new">gtk_size_group_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-size-group-set-mode">gtk_size_group_set_mode</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GtkSizeGroupMode"><returnvalue>GtkSizeGroupMode</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-size-group-get-mode">gtk_size_group_get_mode</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-size-group-add-widget">gtk_size_group_add_widget</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-size-group-remove-widget">gtk_size_group_remove_widget</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GSList"><returnvalue>GSList</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-size-group-get-widgets">gtk_size_group_get_widgets</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkSizeGroup.properties" role="properties">
<title role="properties.title">Properties</title>
<informaltable frame="none">
<tgroup cols="3">
<colspec colname="properties_type" colwidth="150px"/>
<colspec colname="properties_name" colwidth="300px"/>
<colspec colname="properties_flags" colwidth="200px"/>
<tbody>
<row><entry role="property_type"><link linkend="GtkSizeGroupMode"><type>GtkSizeGroupMode</type></link></entry><entry role="property_name"><link linkend="GtkSizeGroup--mode">mode</link></entry><entry role="property_flags">Read / Write</entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkSizeGroup.other" role="other_proto">
<title role="other_proto.title">Types and Values</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="other_proto_type" colwidth="150px"/>
<colspec colname="other_proto_name"/>
<tbody>
<row><entry role="datatype_keyword">struct</entry><entry role="function_name"><link linkend="GtkSizeGroup-struct">GtkSizeGroup</link></entry></row>
<row><entry role="datatype_keyword">enum</entry><entry role="function_name"><link linkend="GtkSizeGroupMode">GtkSizeGroupMode</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkSizeGroup.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<screen>    <link linkend="GObject">GObject</link>
    <phrase role="lineart">&#9584;&#9472;&#9472;</phrase> GtkSizeGroup
</screen>
</refsect1>
<refsect1 id="GtkSizeGroup.implemented-interfaces" role="impl_interfaces">
<title role="impl_interfaces.title">Implemented Interfaces</title>
<para>
GtkSizeGroup implements
 <link linkend="GtkBuildable">GtkBuildable</link>.</para>

</refsect1>

<refsect1 id="GtkSizeGroup.includes"><title>Includes</title><synopsis>#include &lt;gtk/gtk.h&gt;
</synopsis></refsect1>

<refsect1 id="GtkSizeGroup.description" role="desc">
<title role="desc.title">Description</title>
<para><link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> provides a mechanism for grouping a number of widgets
together so they all request the same amount of space.  This is
typically useful when you want a column of widgets to have the same
size, but you can’t use a <link linkend="GtkGrid"><type>GtkGrid</type></link> widget.</para>
<para>In detail, the size requested for each widget in a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> is
the maximum of the sizes that would have been requested for each
widget in the size group if they were not in the size group. The mode
of the size group (see <link linkend="gtk-size-group-set-mode"><function>gtk_size_group_set_mode()</function></link>) determines whether
this applies to the horizontal size, the vertical size, or both sizes.</para>
<para>Note that size groups only affect the amount of space requested, not
the size that the widgets finally receive. If you want the widgets in
a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> to actually be the same size, you need to pack them in
such a way that they get the size they request and not more. For
example, if you are packing your widgets into a table, you would not
include the <link linkend="GTK-FILL:CAPS"><literal>GTK_FILL</literal></link> flag.</para>
<para><link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> objects are referenced by each widget in the size group,
so once you have added all widgets to a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link>, you can drop
the initial reference to the size group with <link linkend="g-object-unref"><function>g_object_unref()</function></link>. If the
widgets in the size group are subsequently destroyed, then they will
be removed from the size group and drop their references on the size
group; when all widgets have been removed, the size group will be
freed.</para>
<para>Widgets can be part of multiple size groups; GTK+ will compute the
horizontal size of a widget from the horizontal requisition of all
widgets that can be reached from the widget by a chain of size groups
of type <link linkend="GTK-SIZE-GROUP-HORIZONTAL:CAPS"><literal>GTK_SIZE_GROUP_HORIZONTAL</literal></link> or <link linkend="GTK-SIZE-GROUP-BOTH:CAPS"><literal>GTK_SIZE_GROUP_BOTH</literal></link>, and the
vertical size from the vertical requisition of all widgets that can be
reached from the widget by a chain of size groups of type
<link linkend="GTK-SIZE-GROUP-VERTICAL:CAPS"><literal>GTK_SIZE_GROUP_VERTICAL</literal></link> or <link linkend="GTK-SIZE-GROUP-BOTH:CAPS"><literal>GTK_SIZE_GROUP_BOTH</literal></link>.</para>
<para>Note that only non-contextual sizes of every widget are ever consulted
by size groups (since size groups have no knowledge of what size a widget
will be allocated in one dimension, it cannot derive how much height
a widget will receive for a given width). When grouping widgets that
trade height for width in mode <link linkend="GTK-SIZE-GROUP-VERTICAL:CAPS"><literal>GTK_SIZE_GROUP_VERTICAL</literal></link> or <link linkend="GTK-SIZE-GROUP-BOTH:CAPS"><literal>GTK_SIZE_GROUP_BOTH</literal></link>:
the height for the minimum width will be the requested height for all
widgets in the group. The same is of course true when horizontally grouping
width for height widgets.</para>
<para>Widgets that trade height-for-width should set a reasonably large minimum width
by way of <link linkend="GtkLabel--width-chars"><type>“width-chars”</type></link> for instance. Widgets with static sizes as well
as widgets that grow (such as ellipsizing text) need no such considerations.</para>
<refsect2><title>GtkSizeGroup as GtkBuildable</title><para>Size groups can be specified in a UI definition by placing an &lt;object>
element with <literal>class="GtkSizeGroup"</literal> somewhere in the UI definition. The
widgets that belong to the size group are specified by a &lt;widgets> element
that may contain multiple &lt;widget> elements, one for each member of the
size group. The ”name” attribute gives the id of the widget.</para>
<para>An example of a UI definition fragment with GtkSizeGroup:</para>
<informalexample><programlisting role="example"><![CDATA[
<object class="GtkSizeGroup">
  <property name="mode">horizontal</property>
  <widgets>
    <widget name="radio1"/>
    <widget name="radio2"/>
  </widgets>
</object>
]]></programlisting></informalexample>
<para></para>
</refsect2>

</refsect1>
<refsect1 id="GtkSizeGroup.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="gtk-size-group-new" role="function">
<title>gtk_size_group_new&#160;()</title>
<indexterm zone="gtk-size-group-new"><primary>gtk_size_group_new</primary></indexterm>
<programlisting language="C"><link linkend="GtkSizeGroup"><returnvalue>GtkSizeGroup</returnvalue></link>&#160;*
gtk_size_group_new (<parameter><link linkend="GtkSizeGroupMode"><type>GtkSizeGroupMode</type></link> mode</parameter>);</programlisting>
<para>Create a new <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link>.</para>
<refsect3 id="gtk-size-group-new.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>mode</para></entry>
<entry role="parameter_description"><para>the mode for the new size group.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-size-group-new.returns" role="returns">
<title>Returns</title>
<para> a newly created <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link></para>
</refsect3></refsect2>
<refsect2 id="gtk-size-group-set-mode" role="function">
<title>gtk_size_group_set_mode&#160;()</title>
<indexterm zone="gtk-size-group-set-mode"><primary>gtk_size_group_set_mode</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_size_group_set_mode (<parameter><link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> *size_group</parameter>,
                         <parameter><link linkend="GtkSizeGroupMode"><type>GtkSizeGroupMode</type></link> mode</parameter>);</programlisting>
<para>Sets the <link linkend="GtkSizeGroupMode"><type>GtkSizeGroupMode</type></link> of the size group. The mode of the size
group determines whether the widgets in the size group should
all have the same horizontal requisition (<link linkend="GTK-SIZE-GROUP-HORIZONTAL:CAPS"><literal>GTK_SIZE_GROUP_HORIZONTAL</literal></link>)
all have the same vertical requisition (<link linkend="GTK-SIZE-GROUP-VERTICAL:CAPS"><literal>GTK_SIZE_GROUP_VERTICAL</literal></link>),
or should all have the same requisition in both directions
(<link linkend="GTK-SIZE-GROUP-BOTH:CAPS"><literal>GTK_SIZE_GROUP_BOTH</literal></link>).</para>
<refsect3 id="gtk-size-group-set-mode.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>size_group</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>mode</para></entry>
<entry role="parameter_description"><para>the mode to set for the size group.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-size-group-get-mode" role="function">
<title>gtk_size_group_get_mode&#160;()</title>
<indexterm zone="gtk-size-group-get-mode"><primary>gtk_size_group_get_mode</primary></indexterm>
<programlisting language="C"><link linkend="GtkSizeGroupMode"><returnvalue>GtkSizeGroupMode</returnvalue></link>
gtk_size_group_get_mode (<parameter><link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> *size_group</parameter>);</programlisting>
<para>Gets the current mode of the size group. See <link linkend="gtk-size-group-set-mode"><function>gtk_size_group_set_mode()</function></link>.</para>
<refsect3 id="gtk-size-group-get-mode.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>size_group</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-size-group-get-mode.returns" role="returns">
<title>Returns</title>
<para> the current mode of the size group.</para>
</refsect3></refsect2>
<refsect2 id="gtk-size-group-add-widget" role="function">
<title>gtk_size_group_add_widget&#160;()</title>
<indexterm zone="gtk-size-group-add-widget"><primary>gtk_size_group_add_widget</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_size_group_add_widget (<parameter><link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> *size_group</parameter>,
                           <parameter><link linkend="GtkWidget"><type>GtkWidget</type></link> *widget</parameter>);</programlisting>
<para>Adds a widget to a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link>. In the future, the requisition
of the widget will be determined as the maximum of its requisition
and the requisition of the other widgets in the size group.
Whether this applies horizontally, vertically, or in both directions
depends on the mode of the size group. See <link linkend="gtk-size-group-set-mode"><function>gtk_size_group_set_mode()</function></link>.</para>
<para>When the widget is destroyed or no longer referenced elsewhere, it will 
be removed from the size group.</para>
<refsect3 id="gtk-size-group-add-widget.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>size_group</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>widget</para></entry>
<entry role="parameter_description"><para>the <link linkend="GtkWidget"><type>GtkWidget</type></link> to add</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-size-group-remove-widget" role="function">
<title>gtk_size_group_remove_widget&#160;()</title>
<indexterm zone="gtk-size-group-remove-widget"><primary>gtk_size_group_remove_widget</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_size_group_remove_widget (<parameter><link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> *size_group</parameter>,
                              <parameter><link linkend="GtkWidget"><type>GtkWidget</type></link> *widget</parameter>);</programlisting>
<para>Removes a widget from a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link>.</para>
<refsect3 id="gtk-size-group-remove-widget.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>size_group</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>widget</para></entry>
<entry role="parameter_description"><para>the <link linkend="GtkWidget"><type>GtkWidget</type></link> to remove</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-size-group-get-widgets" role="function">
<title>gtk_size_group_get_widgets&#160;()</title>
<indexterm zone="gtk-size-group-get-widgets"><primary>gtk_size_group_get_widgets</primary></indexterm>
<programlisting language="C"><link linkend="GSList"><returnvalue>GSList</returnvalue></link>&#160;*
gtk_size_group_get_widgets (<parameter><link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link> *size_group</parameter>);</programlisting>
<para>Returns the list of widgets associated with <parameter>size_group</parameter>
.</para>
<refsect3 id="gtk-size-group-get-widgets.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>size_group</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkSizeGroup"><type>GtkSizeGroup</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-size-group-get-widgets.returns" role="returns">
<title>Returns</title>
<para>a <link linkend="GSList"><type>GSList</type></link> of
widgets. The list is owned by GTK+ and should not be modified. </para>
<para><emphasis role="annotation">[<acronym>element-type</acronym> GtkWidget][<acronym>transfer none</acronym>]</emphasis></para>
</refsect3></refsect2>

</refsect1>
<refsect1 id="GtkSizeGroup.other_details" role="details">
<title role="details.title">Types and Values</title>
<refsect2 id="GtkSizeGroup-struct" role="struct">
<title>struct GtkSizeGroup</title>
<indexterm zone="GtkSizeGroup-struct"><primary>GtkSizeGroup</primary></indexterm>
<programlisting language="C">struct GtkSizeGroup;</programlisting>
</refsect2>
<refsect2 id="GtkSizeGroupMode" role="enum">
<title>enum GtkSizeGroupMode</title>
<indexterm zone="GtkSizeGroupMode"><primary>GtkSizeGroupMode</primary></indexterm>
<para>The mode of the size group determines the directions in which the size
group affects the requested sizes of its component widgets.</para>
<refsect3 id="GtkSizeGroupMode.members" role="enum_members">
<title>Members</title>
<informaltable role="enum_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="enum_members_name" colwidth="300px"/>
<colspec colname="enum_members_description"/>
<colspec colname="enum_members_annotations" colwidth="200px"/>
<tbody>
<row role="constant"><entry role="enum_member_name"><para id="GTK-SIZE-GROUP-NONE:CAPS">GTK_SIZE_GROUP_NONE</para></entry>
<entry role="enum_member_description"><para>group has no effect</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="GTK-SIZE-GROUP-HORIZONTAL:CAPS">GTK_SIZE_GROUP_HORIZONTAL</para></entry>
<entry role="enum_member_description"><para>group affects horizontal requisition</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="GTK-SIZE-GROUP-VERTICAL:CAPS">GTK_SIZE_GROUP_VERTICAL</para></entry>
<entry role="enum_member_description"><para>group affects vertical requisition</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="GTK-SIZE-GROUP-BOTH:CAPS">GTK_SIZE_GROUP_BOTH</para></entry>
<entry role="enum_member_description"><para>group affects both horizontal and vertical requisition</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>

</refsect1>
<refsect1 id="GtkSizeGroup.property-details" role="property_details">
<title role="property_details.title">Property Details</title>
<refsect2 id="GtkSizeGroup--mode" role="property"><title>The <literal>“mode”</literal> property</title>
<indexterm zone="GtkSizeGroup--mode"><primary>GtkSizeGroup:mode</primary></indexterm>
<programlisting>  “mode”                     <link linkend="GtkSizeGroupMode"><type>GtkSizeGroupMode</type></link></programlisting>
<para>The directions in which the size group affects the requested sizes of its component widgets.</para><para>Owner: GtkSizeGroup</para>
<para>Flags: Read / Write</para>
<para>Default value: GTK_SIZE_GROUP_HORIZONTAL</para>
</refsect2>

</refsect1>

</refentry>
