MBMenu - A simple popup menu widget

a simple independent popup menu widget, used mainly for application launchers etc. More...

## Typedefs

typedef struct _menu | MBMenuMenu
typedef struct _menuitem | MBMenuItem
typedef struct _mbmemu | MBMenu
typedef void(* | MBMenuActivateCB) (MBMenuItem *item)

## Enumerations

enum | MBMenuColorElement
enum | MBMenuItemAddFlags

## Functions

MBMenu * | mb_menu_new (Display *dpy, int screen)
| Creates a new toplevel mbmenu instance. More...
Bool | mb_menu_set_font (MBMenu *mbmenu, char *font_desc)
| Sets the font used by the referenced menu. More...
Bool | mb_menu_set_default_icons (MBMenu *mbmenu, char *folder, char *app)
| Sets the default icons to be uses when not supplied by an individual item. More...
void | mb_menu_set_icon_size (MBMenu *mbmenu, int size)
| Sets the icon dimention in pixels used by the referenced menu instance. More...
void | mb_menu_set_col (MBMenu *mbmenu, MBMenuColorElement element, char *col_spec)
| Sets the font used by the referenced menu instance. More...
void | mb_menu_set_trans (MBMenu *mbmenu, int trans)
| Sets the menu's transparency level. More...
MBMenuMenu * | mb_menu_get_root_menu (MBMenu *mbmenu)
| Gets the top level MBMenu menu. More...
Bool | mb_menu_get_root_menu_size (MBMenu *mbmenu, int *width, int *height)
| Gets the top level MBMenu menu size. More...
void | mb_menu_add_seperator_to_menu (MBMenu *mbmenu, MBMenuMenu *menu, int flags)
| Adds a seperator to a menu. More...
MBMenuMenu * | mb_menu_add_path (MBMenu *mbmenu, char *path, char *icon_path, int flags)
| Adds single or multiple new menus to an mbmenu instance. More...
void | mb_menu_remove_menu (MBMenu *mbmenu, MBMenuMenu *menu)
| Removes a menu and all of its sub menus. More...
void | mb_menu_free (MBMenu *mbmenu)
| Free's a mbmenu toplevel instance. More...
Bool | mb_menu_is_active (MBMenu *mbmenu)
| Checks to see if specified menu intance is active ( ie popped up ) More...
void | mb_menu_activate (MBMenu *mbmenu, int x, int y)
| Checks to see if specified menu intance is active ( ie popped up ) More...
void | mb_menu_deactivate (MBMenu *mbmenu)
| Deactivates ( hides ) a mbmenu instance. More...
void | mb_menu_handle_xevent (MBMenu *mbmenu, XEvent *xevent)
| Processes an X Event. More...
MBMenuItem * | mb_menu_new_item (MBMenu *mbmenu, MBMenuMenu *menu, char *title, MBMenuActivateCB activate_callback, void *user_data, MBMenuItemAddFlags flags)
| Adds a new menu item to a menu. More...
void | mb_menu_item_icon_set (MBMenu *mbmenu, MBMenuItem *item, MBPixbufImage *img)
| Adds a new menu item to a menu. More...
void * | mb_menu_item_get_user_data (MBMenuItem *item)
| Gets any user data attatched to a menu item. More...
void | mb_menu_item_remove (MBMenu *mbmenu, MBMenuMenu *menu, MBMenuItem *item)
| Removes a menu item. More...
void | mb_menu_dump (MBMenu *mbmenu, MBMenuMenu *menu)
| Dumps an mbmenu menu structure to stdout. More...

## Detailed Description

a simple independent popup menu widget, used mainly for application launchers etc.

NOTE: Its planned that one day in the future this will be superceded by matchbox-tk.

## Typedef Documentation

## MBMenu

MBMenu

Opaque type for a 'top level' menu

## MBMenuActivateCB

MBMenuActivateCB

Callback for an activated menu item.

Definition at line 270 of file mbmenu.h.

## MBMenuItem

MBMenuItem

Opaque type for a menu item

## MBMenuMenu

MBMenuMenu

Opaque type for a menu

## Enumeration Type Documentation

## MBMenuColorElement

enum MBMenuColorElement

Used to set various menu elements colours

Definition at line 74 of file mbmenu.h.

## MBMenuItemAddFlags

enum MBMenuItemAddFlags

Used to specify how an item is added to a menu

Definition at line 86 of file mbmenu.h.

## Function Documentation

## mb_menu_activate()

void mb_menu_activate | ( | MBMenu * | mbmenu,
|  | int | x,
|  | int | y
| ) |  |

Checks to see if specified menu intance is active ( ie popped up )

Parameters

  mbmenu | mb menu instance
  x | x co-ord ( relative to root window origin ) to activate menu
  y | y co-ord ( relative to root window origin ) to activate menu

## mb_menu_add_path()

MBMenuMenu* mb_menu_add_path | ( | MBMenu * | mbmenu,
|  | char * | path,
|  | char * | icon_path,
|  | int | flags
| ) |  |

Adds single or multiple new menus to an mbmenu instance.

Parameters

  mbmenu | MBMenu instance
  path |
  icon_path |
  flags | can be 0 or MBMENU_PREPEND to prepend the seperator rather than append the seperator to the menu.

Returns
  new created menu

## mb_menu_add_seperator_to_menu()

void mb_menu_add_seperator_to_menu | ( | MBMenu * | mbmenu,
|  | MBMenuMenu * | menu,
|  | int | flags
| ) |  |

Adds a seperator to a menu.

Parameters

  mbmenu | MBMenu instance
  menu | The menu to add the seperator too.
  flags | can be 0 or MBMENU_PREPEND to prepend the seperator rather than append the seperator to the menu.

## mb_menu_deactivate()

void mb_menu_deactivate | ( | MBMenu * | mbmenu | ) |

Deactivates ( hides ) a mbmenu instance.

Parameters

  mbmenu | mb menu instance

## mb_menu_dump()

void mb_menu_dump | ( | MBMenu * | mbmenu,
|  | MBMenuMenu * | menu
| ) |  |

Dumps an mbmenu menu structure to stdout.

Parameters

  mbmenu | mb menu instance
  menu | menu to dump

## mb_menu_free()

void mb_menu_free | ( | MBMenu * | mbmenu | ) |

Free's a mbmenu toplevel instance.

Parameters

  mbmenu | mbmenu instance

## mb_menu_get_root_menu()

MBMenuMenu* mb_menu_get_root_menu | ( | MBMenu * | mbmenu | ) |

Gets the top level MBMenu menu.

This menu is automatically created on initialisation

Parameters

  mbmenu | mb menu instance

Returns
  root menu instance.

## mb_menu_get_root_menu_size()

Bool mb_menu_get_root_menu_size | ( | MBMenu * | mbmenu,
|  | int * | width,
|  | int * | height
| ) |  |

Gets the top level MBMenu menu size.

Parameters

  mbmenu | mb menu instance
  width | pointer to populate width int
  height | pointer to populate height int

Returns
  True on success, False on fail ( 0x0 menu ).

## mb_menu_handle_xevent()

void mb_menu_handle_xevent | ( | MBMenu * | mbmenu,
|  | XEvent * | xevent
| ) |  |

Processes an X Event.

Parameters

  mbmenu | mb menu instance
  xevent | Xevent to process

## mb_menu_is_active()

Bool mb_menu_is_active | ( | MBMenu * | mbmenu | ) |

Checks to see if specified menu intance is active ( ie popped up )

Parameters

  mbmenu | mb menu instance

Returns
  True if menu is active, False otherwise

## mb_menu_item_get_user_data()

void* mb_menu_item_get_user_data | ( | MBMenuItem * | item | ) |

Gets any user data attatched to a menu item.

Parameters

  item | menu item

Returns
  void pointer to set user data.

## mb_menu_item_icon_set()

void mb_menu_item_icon_set | ( | MBMenu * | mbmenu,
|  | MBMenuItem * | item,
|  | MBPixbufImage * | img
| ) |  |

Adds a new menu item to a menu.

Parameters

  mbmenu | mb menu instance
  item | menu item
  img | mbpixbuf image to set use as item image

## mb_menu_item_remove()

void mb_menu_item_remove | ( | MBMenu * | mbmenu,
|  | MBMenuMenu * | menu,
|  | MBMenuItem * | item
| ) |  |

Removes a menu item.

Parameters

  mbmenu | mbmenu instance
  menu | the menu to remove from
  item | the menu item

## mb_menu_new()

MBMenu* mb_menu_new | ( | Display * | dpy,
|  | int | screen
| ) |  |

Creates a new toplevel mbmenu instance.

Parameters

  dpy | X Display
  screen | X Screen

Returns
  an mbmenu instance, NULL on failure.

## mb_menu_new_item()

MBMenuItem* mb_menu_new_item | ( | MBMenu * | mbmenu,
|  | MBMenuMenu * | menu,
|  | char * | title,
|  | MBMenuActivateCB | activate_callback,
|  | void * | user_data,
|  | MBMenuItemAddFlags | flags
| ) |  |

Adds a new menu item to a menu.

Parameters

  mbmenu | mb menu instance
  menu | menu to add the item too
  title | menu item title
  activate_callback | function to call when menu is clicked.
  user_data | user data to attach to item.
  flags | specify how the item is added to the menu

Returns
  the created menu item or NULL on failiure.

## mb_menu_remove_menu()

void mb_menu_remove_menu | ( | MBMenu * | mbmenu,
|  | MBMenuMenu * | menu
| ) |  |

Removes a menu and all of its sub menus.

Parameters

  mbmenu | mb menu instance
  menu | menu to remove

## mb_menu_set_col()

void mb_menu_set_col | ( | MBMenu * | mbmenu,
|  | MBMenuColorElement | element,
|  | char * | col_spec
| ) |  |

Sets the font used by the referenced menu instance.

Parameters

  mbmenu | mb menu instance
  element | Which part of the menu to set color
  col_spec | Color specification in the form #RRGGBB

## mb_menu_set_default_icons()

Bool mb_menu_set_default_icons | ( | MBMenu * | mbmenu,
|  | char * | folder,
|  | char * | app
| ) |  |

Sets the default icons to be uses when not supplied by an individual item.

Parameters

  mbmenu | mb menu instance
  folder | icon filename for folders
  app | icon filename for items

Returns
  True if icons loaded ok, False on failiure

## mb_menu_set_font()

Bool mb_menu_set_font | ( | MBMenu * | mbmenu,
|  | char * | font_desc
| ) |  |

Sets the font used by the referenced menu.

Parameters

  mbmenu | mb menu instance
  font_desc | font to load

Returns
  True if font loaded, False on failiure

## mb_menu_set_icon_size()

void mb_menu_set_icon_size | ( | MBMenu * | mbmenu,
|  | int | size
| ) |  |

Sets the icon dimention in pixels used by the referenced menu instance.

If set to zero, icons will not be used by the menu.

Parameters

  mbmenu | mb menu instance
  size | Icon dimention in pixels

## mb_menu_set_trans()

void mb_menu_set_trans | ( | MBMenu * | mbmenu,
|  | int | trans
| ) |  |

Sets the menu's transparency level.

The Transparency is a HACK!, use at your own risk, its unsupported.

Parameters

  mbmenu | mb menu instance
  trans | Transparency level