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

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

G_BEGIN_DECLS GType gnt_menuitem_get_gtype | ( | void |  | ) |

Returns
  GType for GntMenuItem.

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

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

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

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

Create a new menuitem.

Parameters

  text | Label for the menuitem.

Returns
  The newly created menuitem.

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.

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

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.

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