GtkCheckMenuItem

GtkCheckMenuItem — A menu item with a check box

Properties

gboolean active Read / Write
gboolean draw-as-radio Read / Write
gboolean inconsistent Read / Write

Style Properties

Signals

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkContainer
                ╰── GtkBin
                    ╰── GtkMenuItem
                        ╰── GtkCheckMenuItem
                            ╰── GtkRadioMenuItem

Implemented Interfaces

GtkCheckMenuItem implements AtkImplementorIface, GtkBuildable, GtkActivatable and GtkActionable.

Includes

#include <gtk/gtk.h>

Description

A GtkCheckMenuItem is a menu item that maintains the state of a boolean value in addition to a GtkMenuItem usual role in activating application code.

A check box indicating the state of the boolean value is displayed at the left side of the GtkMenuItem. Activating the GtkMenuItem toggles the value.

CSS nodes

menuitem
├── check.left
╰── <child>

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

Functions

gtk_check_menu_item_new ()

GtkWidget *
gtk_check_menu_item_new (void);

Creates a new GtkCheckMenuItem.

Returns

a new GtkCheckMenuItem.

gtk_check_menu_item_new_with_label ()

GtkWidget *
gtk_check_menu_item_new_with_label (const gchar *label);

Creates a new GtkCheckMenuItem with a label.

Parameters

label

the string to use for the label.

Returns

a new GtkCheckMenuItem.

gtk_check_menu_item_new_with_mnemonic ()

GtkWidget *
gtk_check_menu_item_new_with_mnemonic (const gchar *label);

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

Parameters

label

The text of the button, with an underscore in front of the character

Returns

a new GtkCheckMenuItem

gtk_check_menu_item_get_active ()

gboolean
gtk_check_menu_item_get_active (GtkCheckMenuItem *check_menu_item);

Returns whether the check menu item is active. See gtk_check_menu_item_set_active().

Parameters

check_menu_item

a GtkCheckMenuItem

Returns

TRUE if the menu item is checked.

gtk_check_menu_item_set_active ()

void
gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
                                gboolean is_active);

Sets the active state of the menu item’s check box.

Parameters

check_menu_item

a GtkCheckMenuItem.

is_active

boolean value indicating whether the check box is active.

gtk_check_menu_item_toggled ()

void
gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item);

Emits the “toggled” signal.

Parameters

check_menu_item

a GtkCheckMenuItem.

gtk_check_menu_item_get_inconsistent ()

gboolean
gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item);

Retrieves the value set by gtk_check_menu_item_set_inconsistent().

Parameters

check_menu_item

a GtkCheckMenuItem

Returns

TRUE if inconsistent

gtk_check_menu_item_set_inconsistent ()

void
gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
                                      gboolean setting);

If the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a boolean setting, and the current values in that range are inconsistent, you may want to display the check in an “in between” state. This function turns on “in between” display. Normally you would turn off the inconsistent state again if the user explicitly selects a setting. This has to be done manually, gtk_check_menu_item_set_inconsistent() only affects visual appearance, it doesn’t affect the semantics of the widget.

Parameters

check_menu_item

a GtkCheckMenuItem

setting

TRUE to display an “inconsistent” third state check

gtk_check_menu_item_set_draw_as_radio ()

void
gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item,
                                       gboolean draw_as_radio);

Sets whether check_menu_item is drawn like a GtkRadioMenuItem

Parameters

check_menu_item

a GtkCheckMenuItem

draw_as_radio

whether check_menu_item is drawn like a GtkRadioMenuItem

Since: 2.4

gtk_check_menu_item_get_draw_as_radio ()

gboolean
gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item);

Returns whether check_menu_item looks like a GtkRadioMenuItem

Parameters

check_menu_item

a GtkCheckMenuItem

Returns

Whether check_menu_item looks like a GtkRadioMenuItem

Since: 2.4

Types and Values

struct GtkCheckMenuItem

struct GtkCheckMenuItem;

struct GtkCheckMenuItemClass

struct GtkCheckMenuItemClass {
  GtkMenuItemClass parent_class;


  void (* toggled)	  (GtkCheckMenuItem *check_menu_item);
  void (* draw_indicator) (GtkCheckMenuItem *check_menu_item,
			   cairo_t          *cr);
};

Members

toggled ()

Signal emitted when the state of the check box is changed.

draw_indicator ()

Called to draw the check indicator.

Property Details

The “active” property

  “active”                   gboolean

Whether the menu item is checked.

Flags: Read / Write

Default value: FALSE

The “draw-as-radio” property

  “draw-as-radio”            gboolean

Whether the menu item looks like a radio menu item.

Flags: Read / Write

Default value: FALSE

The “inconsistent” property

  “inconsistent”             gboolean

Whether to display an "inconsistent" state.

Flags: Read / Write

Default value: FALSE

Style Property Details

The “indicator-size” style property

  “indicator-size”           gint

The size of the check or radio indicator.

GtkCheckMenuItem:indicator-size has been deprecated since version 3.20 and should not be used in newly-written code.

Use the standard CSS property min-width on the check or radio nodes; the value of this style property is ignored.

Flags: Read

Allowed values: >= 0

Default value: 16

Signal Details

The “toggled” signal

void
user_function (GtkCheckMenuItem *checkmenuitem,
               gpointer          user_data)

This signal is emitted when the state of the check box is changed.

A signal handler can use gtk_check_menu_item_get_active() to discover the new state.

Parameters

checkmenuitem

the object which received the signal.

user_data

user data set when the signal handler was connected.

Flags: Run First

© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk3/3.20/GtkCheckMenuItem.html