CtkRadioMenuItem: CTK+ 3 Reference Manual

## CtkRadioMenuItem CtkRadioMenuItem — A choice from multiple check menu items |

## Functions

CtkWidget * | ctk_radio_menu_item_new ()
CtkWidget * | ctk_radio_menu_item_new_with_label ()
CtkWidget * | ctk_radio_menu_item_new_with_mnemonic ()
CtkWidget * | ctk_radio_menu_item_new_from_widget ()
CtkWidget * | ctk_radio_menu_item_new_with_label_from_widget ()
CtkWidget * | ctk_radio_menu_item_new_with_mnemonic_from_widget ()
void | ctk_radio_menu_item_set_group ()
GSList * | ctk_radio_menu_item_get_group ()
void | ctk_radio_menu_item_join_group ()

## Properties

CtkRadioMenuItem * | group | Write

## Signals

void | group-changed | Run First

## Types and Values

struct | CtkRadioMenuItem

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── CtkWidget
                ╰── CtkContainer
                    ╰── CtkBin
                        ╰── CtkMenuItem
                            ╰── CtkCheckMenuItem
                                ╰── CtkRadioMenuItem

## Implemented Interfaces

CtkRadioMenuItem implements AtkImplementorIface, CtkBuildable, CtkActivatable and CtkActionable.

## Includes

    #include <ctk/ctk.h>

## Description

A radio menu item is a check menu item that belongs to a group. At each instant exactly one of the radio menu items from a group is selected.

The group list does not need to be freed, as each CtkRadioMenuItem will remove itself and its list item when it is destroyed.

The correct way to create a group of radio menu items is approximatively this:

#### How to create a group of radio menu items.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    GSList *group = NULL;
    CtkWidget *item;
    gint i;

    for (i = 0; i < 5; i++)
    {
      item = ctk_radio_menu_item_new_with_label (group, "This is an example");
      group = ctk_radio_menu_item_get_group (CTK_RADIO_MENU_ITEM (item));
      if (i == 1)
        ctk_check_menu_item_set_active (CTK_CHECK_MENU_ITEM (item), TRUE);
    }

### CSS nodes

    1
    2
    3
    menuitem
    ├── radio.left
    ╰── <child>

CtkRadioMenuItem has a main CSS node with name menuitem, and a subnode with name radio, which gets the .left or .right style class.

## Functions

### ctk_radio_menu_item_new ()

    CtkWidget *
    ctk_radio_menu_item_new (GSList *group);

Creates a new CtkRadioMenuItem.

#### Parameters

group | the group to which the radio menu item is to be attached, or `NULL`. | [element-type CtkRadioMenuItem][allow-none]

#### Returns

a new CtkRadioMenuItem

### ctk_radio_menu_item_new_with_label ()

    CtkWidget *
    ctk_radio_menu_item_new_with_label (GSList *group,
                                        const gchar *label);

Creates a new CtkRadioMenuItem whose child is a simple CtkLabel.

#### Parameters

group | group the radio menu item is inside, or `NULL`. | [element-type CtkRadioMenuItem][allow-none]
label | the text for the label |

#### Returns

A new CtkRadioMenuItem.

[transfer none]

### ctk_radio_menu_item_new_with_mnemonic ()

    CtkWidget *
    ctk_radio_menu_item_new_with_mnemonic (GSList *group,
                                           const gchar *label);

Creates a new CtkRadioMenuItem containing a label. The label will be created using `ctk_label_new_with_mnemonic()`, so underscores in `label` indicate the mnemonic for the menu item.

#### Parameters

group | group the radio menu item is inside, or `NULL`. | [element-type CtkRadioMenuItem][allow-none]
label | the text of the button, with an underscore in front of the mnemonic character |

#### Returns

a new CtkRadioMenuItem

### ctk_radio_menu_item_new_from_widget ()

    CtkWidget *
    ctk_radio_menu_item_new_from_widget (CtkRadioMenuItem *group);

Creates a new CtkRadioMenuItem adding it to the same group as `group` .

[constructor]

#### Parameters

group | An existing CtkRadioMenuItem. | [allow-none]

#### Returns

The new CtkRadioMenuItem.

[transfer none]

Since: 2.4

### ctk_radio_menu_item_new_with_label_from_widget ()

    CtkWidget *
    ctk_radio_menu_item_new_with_label_from_widget
                                   (CtkRadioMenuItem *group,
                                    const gchar *label);

Creates a new CtkRadioMenuItem whose child is a simple CtkLabel. The new CtkRadioMenuItem is added to the same group as `group` .

[constructor]

#### Parameters

group | an existing CtkRadioMenuItem. | [allow-none]
label | the text for the label. | [allow-none]

#### Returns

The new CtkRadioMenuItem.

[transfer none]

Since: 2.4

### ctk_radio_menu_item_new_with_mnemonic_from_widget ()

    CtkWidget *
    ctk_radio_menu_item_new_with_mnemonic_from_widget
                                   (CtkRadioMenuItem *group,
                                    const gchar *label);

Creates a new CtkRadioMenuItem containing a label. The label will be created using `ctk_label_new_with_mnemonic()`, so underscores in label indicate the mnemonic for the menu item.

The new CtkRadioMenuItem is added to the same group as `group` .

[constructor]

#### Parameters

group | An existing CtkRadioMenuItem. | [allow-none]
label | the text of the button, with an underscore in front of the mnemonic character. | [allow-none]

#### Returns

The new CtkRadioMenuItem.

[transfer none]

Since: 2.4

### ctk_radio_menu_item_set_group ()

    void
    ctk_radio_menu_item_set_group (CtkRadioMenuItem *radio_menu_item,
                                   GSList *group);

Sets the group of a radio menu item, or changes it.

#### Parameters

radio_menu_item | a CtkRadioMenuItem. |
group | the new group, or `NULL`. | [element-type CtkRadioMenuItem][allow-none]

### ctk_radio_menu_item_get_group ()

    GSList *
    ctk_radio_menu_item_get_group (CtkRadioMenuItem *radio_menu_item);

Returns the group to which the radio menu item belongs, as a GList of CtkRadioMenuItem. The list belongs to CTK+ and should not be freed.

#### Parameters

radio_menu_item | a CtkRadioMenuItem |

#### Returns

the group of `radio_menu_item` .

[element-type CtkRadioMenuItem][transfer none]

### ctk_radio_menu_item_join_group ()

    void
    ctk_radio_menu_item_join_group (CtkRadioMenuItem *radio_menu_item,
                                    CtkRadioMenuItem *group_source);

Joins a CtkRadioMenuItem object to the group of another CtkRadioMenuItem object.

This function should be used by language bindings to avoid the memory manangement of the opaque GSList of `ctk_radio_menu_item_get_group()` and `ctk_radio_menu_item_set_group()`.

A common way to set up a group of CtkRadioMenuItem instances is:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    CtkRadioMenuItem *last_item = NULL;

    while ( ...more items to add... )
      {
        CtkRadioMenuItem *radio_item;

        radio_item = ctk_radio_menu_item_new (...);

        ctk_radio_menu_item_join_group (radio_item, last_item);
        last_item = radio_item;
      }

#### Parameters

radio_menu_item | a CtkRadioMenuItem |
group_source | a CtkRadioMenuItem whose group we are joining, or `NULL` to remove the `radio_menu_item` from its current group. | [allow-none]

Since: 3.18

## Types and Values

### struct CtkRadioMenuItem

    struct CtkRadioMenuItem;

## Property Details

### The `“group”` property

      “group”                    CtkRadioMenuItem *

The radio menu item whose group this widget belongs to.

Owner: CtkRadioMenuItem

Flags: Write

Since: 2.8

## Signal Details

### The `“group-changed”` signal

    void
    user_function (CtkRadioMenuItem *ctkradiomenuitem,
                   gpointer          user_data)

Flags: Run First

## See Also

CtkMenuItem, CtkCheckMenuItem