RadioMenuItem


Object Hierarchy:

Gtk.RadioMenuItem Gtk.RadioMenuItem Gtk.RadioMenuItem Gtk.CheckMenuItem Gtk.CheckMenuItem Gtk.CheckMenuItem->Gtk.RadioMenuItem Gtk.MenuItem Gtk.MenuItem Gtk.MenuItem->Gtk.CheckMenuItem Gtk.Bin Gtk.Bin Gtk.Bin->Gtk.MenuItem Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Container GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.RadioMenuItem Atk.Implementor->Gtk.CheckMenuItem Atk.Implementor->Gtk.MenuItem Atk.Implementor->Gtk.Bin Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.RadioMenuItem Gtk.Buildable->Gtk.CheckMenuItem Gtk.Buildable->Gtk.MenuItem Gtk.Buildable->Gtk.Bin Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget Gtk.Actionable Gtk.Actionable Gtk.Actionable->Gtk.RadioMenuItem Gtk.Actionable->Gtk.CheckMenuItem Gtk.Actionable->Gtk.MenuItem Gtk.Activatable Gtk.Activatable Gtk.Activatable->Gtk.RadioMenuItem Gtk.Activatable->Gtk.CheckMenuItem Gtk.Activatable->Gtk.MenuItem

Description:

[ CCode ( type_id = "gtk_radio_menu_item_get_type ()" ) ]
public class RadioMenuItem : CheckMenuItem, Implementor, Actionable, Activatable, Buildable

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 RadioMenuItem 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.

GSList *group = NULL;
GtkWidget *item;
gint i;

for (i = 0; i < 5; i++)
{
item = gtk_radio_menu_item_new_with_label (group, "This is an example");
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item));
if (i == 1)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
}

CSS nodes

menuitem
├── radio.left
╰── <child>
nuItem has a main CSS node with name menuitem, and a subnode with name radio, which gets the .left or .right style class.

Example: RadioMenuItem:

public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.RadioMenuItem";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);

// MenuBar:
Gtk.MenuBar bar = new Gtk.MenuBar ();
this.add (bar);

// File:
Gtk.MenuItem item_file = new Gtk.MenuItem.with_label ("File");
bar.add (item_file);

Gtk.Menu filemenu = new Gtk.Menu ();
item_file.set_submenu (filemenu);

Gtk.RadioMenuItem item_first = new Gtk.RadioMenuItem.with_label (null, "First");
unowned SList<Gtk.RadioMenuItem> group = item_first.get_group ();
item_first.set_active (true);
filemenu.add (item_first);

Gtk.RadioMenuItem item_second = new Gtk.RadioMenuItem.with_label (group, "Second");
filemenu.add (item_second);
}

public static int main (string[] args) {
Gtk.init (ref args);

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}

valac --pkg gtk+-3.0 Gtk.RadioMenuItem.vala


Namespace: Gtk
Package: gtk+-3.0

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members:

All known members inherited from class Gtk.Bin
All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor