Data Structures | Macros | Typedefs | Functions
gntmenuitem.h File Reference
GNT (GLib Ncurses Toolkit)

Menuitem API. More...

`#include <glib.h>`
`#include <glib-object.h>`
`#include "gntmenu.h"`

Go to the source code of this file.

## Data Structures
struct | _GntMenuItemPriv
struct | _GntMenuItem
struct | _GntMenuItemClass

## Macros
#define | GNT_TYPE_MENU_ITEM (gnt_menuitem_get_gtype())
#define | GNT_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_MENU_ITEM, GntMenuItem))
#define | GNT_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_MENU_ITEM, GntMenuItemClass))
#define | GNT_IS_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_MENU_ITEM))
#define | GNT_IS_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_MENU_ITEM))
#define | GNT_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_MENU_ITEM, GntMenuItemClass))
#define | GNT_MENU_ITEM_FLAGS(obj) (GNT_MENU_ITEM(obj)->priv.flags)
#define | GNT_MENU_ITEM_SET_FLAGS(obj, flags) (GNT_MENU_ITEM_FLAGS(obj) |= flags)
#define | GNT_MENU_ITEM_UNSET_FLAGS(obj, flags) (GNT_MENU_ITEM_FLAGS(obj) &= ~(flags))

## Typedefs
typedef struct _GntMenuItem | GntMenuItem
typedef struct _GntMenuItemPriv | GntMenuItemPriv
typedef struct _GntMenuItemClass | GntMenuItemClass
typedef void(* | GntMenuItemCallback) (GntMenuItem *item, gpointer data)

## Functions
G_BEGIN_DECLS GType | gnt_menuitem_get_gtype (void)
GntMenuItem * | gnt_menuitem_new (const char *text)
| Create a new menuitem. More...
void | gnt_menuitem_set_callback (GntMenuItem *item, GntMenuItemCallback callback, gpointer data)
| Set a callback function for a menuitem. More...
void | gnt_menuitem_set_submenu (GntMenuItem *item, GntMenu *menu)
| Set a submenu for a menuitem. More...
GntMenu * | gnt_menuitem_get_submenu (GntMenuItem *item)
| Get the submenu for a menuitem. More...
void | gnt_menuitem_set_trigger (GntMenuItem *item, char trigger)
| Set a trigger key for the item. More...
char | gnt_menuitem_get_trigger (GntMenuItem *item)
| Get the trigger key for a menuitem. More...
void | gnt_menuitem_set_id (GntMenuItem *item, const char *id)
| Set an ID for the menuitem. More...
const char * | gnt_menuitem_get_id (GntMenuItem *item)
| Get the ID of the menuitem. More...
gboolean | gnt_menuitem_activate (GntMenuItem *item)
| Activate a menuitem. More...

## Detailed Description

Menuitem API.

Definition in file gntmenuitem.h.

## Function Documentation

## ◆ gnt_menuitem_activate()

gboolean gnt_menuitem_activate | ( | GntMenuItem * | item | ) |

Activate a menuitem.

Activating the menuitem will first trigger the 'activate' signal for the menuitem. Then the callback for the menuitem is triggered, if there is one.

Parameters

  item | The menuitem.

Returns
  Whether the callback for the menuitem was called.

Since
  2.3.0

## ◆ gnt_menuitem_get_gtype()

G_BEGIN_DECLS GType gnt_menuitem_get_gtype | ( | void |  | ) |

Returns
  GType for GntMenuItem.

## ◆ gnt_menuitem_get_id()

const char* gnt_menuitem_get_id | ( | GntMenuItem * | item | ) |

Get the ID of the menuitem.

Parameters

  item | The menuitem.

Returns
  The ID for the menuitem.

Since
  2.3.0

## ◆ gnt_menuitem_get_submenu()

GntMenu* gnt_menuitem_get_submenu | ( | GntMenuItem * | item | ) |

Get the submenu for a menuitem.

Parameters

  item | The menuitem.

Returns
  The submenu, or `NULL`.

Since
  2.3.0

## ◆ gnt_menuitem_get_trigger()

char gnt_menuitem_get_trigger | ( | GntMenuItem * | item | ) |

Get the trigger key for a menuitem.

Parameters

  item | The menuitem

Returns
  The trigger key for the menuitem.

See also
  gnt_menuitem_set_trigger

## ◆ gnt_menuitem_new()

GntMenuItem* gnt_menuitem_new | ( | const char * | text | ) |

Create a new menuitem.

Parameters

  text | Label for the menuitem.

Returns
  The newly created menuitem.

## ◆ gnt_menuitem_set_callback()

void gnt_menuitem_set_callback | ( | GntMenuItem * | item,
|  | GntMenuItemCallback | callback,
|  | gpointer | data
| ) |  |

Set a callback function for a menuitem.

Parameters

  item | The menuitem.
  callback | The callback function.
  data | Data to send to the callback function.

## ◆ gnt_menuitem_set_id()

void gnt_menuitem_set_id | ( | GntMenuItem * | item,
|  | const char * | id
| ) |  |

Set an ID for the menuitem.

Parameters

  item | The menuitem.
  id | The ID for the menuitem.

Since
  2.3.0

## ◆ gnt_menuitem_set_submenu()

void gnt_menuitem_set_submenu | ( | GntMenuItem * | item,
|  | GntMenu * | menu
| ) |  |

Set a submenu for a menuitem.

A menuitem with a submenu cannot have a callback.

Parameters

  item | The menuitem.
  menu | The submenu.

## ◆ gnt_menuitem_set_trigger()

void gnt_menuitem_set_trigger | ( | GntMenuItem * | item,
|  | char | trigger
| ) |  |

Set a trigger key for the item.

Parameters

  item | The menuitem
  trigger | The key that will trigger the item when the parent manu is visible