menuitem: libdbusmenu-gtk Reference Manual

## menuitem menuitem — Helpers for DbusmenuMenuitem properties that require a GTK dependency |

## Stability Level

Unstable, unless otherwise indicated

## Functions

gboolean | dbusmenu_menuitem_property_set_image ()
GdkPixbuf * | dbusmenu_menuitem_property_get_image ()
gboolean | dbusmenu_menuitem_property_set_shortcut ()
gboolean | dbusmenu_menuitem_property_set_shortcut_string ()
gboolean | dbusmenu_menuitem_property_set_shortcut_menuitem ()
void | dbusmenu_menuitem_property_get_shortcut ()

## Includes

    #include <libdbusmenu-gtk/menuitem.h>

## Description

Some property helpers can't be done without picking up a GTK+ dependency. So those sit in libdbusmenu-gtk but have very similar prototypes to the code in libdbusmenu-glib so your code will look consistent, just with the extra depedency.

## Functions

### dbusmenu_menuitem_property_set_image ()

    gboolean
    dbusmenu_menuitem_property_set_image (DbusmenuMenuitem *menuitem,
                                          const gchar *property,
                                          const GdkPixbuf *data);

This function takes the pixbuf that is stored in `data` and turns it into a base64 encoded PNG so that it can be placed onto a standard DbusmenuMenuitem property.

#### Parameters

menuitem | The DbusmenuMenuitem to set the property on. |
property | Name of the property to set. |
data | The image to place on the property. |

#### Returns

Whether the function was able to set the property or not.

### dbusmenu_menuitem_property_get_image ()

    GdkPixbuf *
    dbusmenu_menuitem_property_get_image (DbusmenuMenuitem *menuitem,
                                          const gchar *property);

This function looks on the menu item for a property by the name of `property` . If one exists it tries to turn it into a GdkPixbuf. It assumes that the property is a base64 encoded PNG file like the one created by dbusmenu_menuite_property_set_image.

#### Parameters

menuitem | The DbusmenuMenuitem to look for the property on |
property | The name of the property to look for. |

#### Returns

A pixbuf or NULL to signal error.

[transfer full]

### dbusmenu_menuitem_property_set_shortcut ()

    gboolean
    dbusmenu_menuitem_property_set_shortcut
                                   (DbusmenuMenuitem *menuitem,
                                    guint key,
                                    GdkModifierType modifier);

Takes the modifer described by `key` and `modifier` and places that into the format sending across Dbus for shortcuts.

#### Parameters

menuitem | The DbusmenuMenuitem to set the shortcut on |
key | The keycode of the key to send |
modifier | A bitmask of modifiers used to activate the item |

#### Returns

Whether it was successful at setting the property.

### dbusmenu_menuitem_property_set_shortcut_string ()

    gboolean
    dbusmenu_menuitem_property_set_shortcut_string
                                   (DbusmenuMenuitem *menuitem,
                                    const gchar *shortcut);

This function takes a GTK shortcut string as defined in gtk_accelerator_parse and turns that into the information required to send it over DBusmenu.

#### Parameters

menuitem | The DbusmenuMenuitem to set the shortcut on |
shortcut | String describing the shortcut |

#### Returns

Whether it was successful at setting the property.

### dbusmenu_menuitem_property_set_shortcut_menuitem ()

    gboolean
    dbusmenu_menuitem_property_set_shortcut_menuitem
                                   (DbusmenuMenuitem *menuitem,
                                    const GtkMenuItem *gmi);

Takes the shortcut that is installed on a menu item and calls dbusmenu_menuitem_property_set_shortcut with it. It also sets up listeners to watch it change.

#### Parameters

menuitem | The DbusmenuMenuitem to set the shortcut on |
gmi | A menu item to steal the shortcut off of |

#### Returns

Whether it was successful at setting the property.

### dbusmenu_menuitem_property_get_shortcut ()

    void
    dbusmenu_menuitem_property_get_shortcut
                                   (DbusmenuMenuitem *menuitem,
                                    guint *key,
                                    GdkModifierType *modifier);

This function gets a GTK shortcut as a key and a mask for use to set the accelerators.

#### Parameters

menuitem | The DbusmenuMenuitem to get the shortcut off |
key | Location to put the key value. | [out]
modifier | Location to put the modifier mask. | [out]

## Types and Values