DbusmenuClient: libdbusmenu-glib Reference Manual

## DbusmenuClient DbusmenuClient — The catcher of all the server traffic |

## Stability Level

Unstable, unless otherwise indicated

## Functions

gboolean | (*DbusmenuClientTypeHandler) ()
DbusmenuClient * | dbusmenu_client_new ()
GStrv | dbusmenu_client_get_icon_paths ()
DbusmenuMenuitem * | dbusmenu_client_get_root ()
DbusmenuStatus | dbusmenu_client_get_status ()
DbusmenuTextDirection | dbusmenu_client_get_text_direction ()
gboolean | dbusmenu_client_add_type_handler ()
gboolean | dbusmenu_client_add_type_handler_full ()

## Types and Values

#define | DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED
#define | DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED
#define | DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM
#define | DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT
#define | DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE
#define | DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED
#define | DBUSMENU_CLIENT_PROP_DBUS_NAME
#define | DBUSMENU_CLIENT_PROP_DBUS_OBJECT
#define | DBUSMENU_CLIENT_PROP_GROUP_EVENTS
#define | DBUSMENU_CLIENT_PROP_STATUS
#define | DBUSMENU_CLIENT_PROP_TEXT_DIRECTION
#define | DBUSMENU_CLIENT_TYPES_DEFAULT
#define | DBUSMENU_CLIENT_TYPES_SEPARATOR
#define | DBUSMENU_CLIENT_TYPES_IMAGE
struct | DbusmenuClient

## Includes

    #include <libdbusmenu-glib/client.h>

## Description

The client exists as a mirror to the server. For most folks all they will do with a client is set it up to connect to a server and then watch as the menu items on their side of the bus change. This is all they should need to know about the client, that it magically makes their menuitems dance.

It does this by setting up signal watchers and adjusting the menuitems appropriately. Most users should watch the menu items and the signal “layout-changed” for larger events so that they can be optimized. It is possible with that signal that even the root node would change. If that doesn't happen the normal signals on the individual nodes should be enough for most users.

## Functions

### DbusmenuClientTypeHandler ()

    gboolean
    (*DbusmenuClientTypeHandler) (DbusmenuMenuitem *newitem,
                                  DbusmenuMenuitem *parent,
                                  DbusmenuClient *client,
                                  gpointer user_data);

The type handler is called when a dbusmenu item is created with a matching type as setup in dbusmenu_client_add_type_handler

#### Parameters

newitem | The DbusmenuMenuitem that was created |
parent | The parent of `newitem` or NULL if none |
client | A pointer to the DbusmenuClient |
user_data | The data you gave us |

#### Returns

TRUE if the type has been handled. FALSE if this function was somehow unable to handle it.

### dbusmenu_client_new ()

    DbusmenuClient *
    dbusmenu_client_new (const gchar *name,
                         const gchar *object);

This function creates a new client that connects to a specific server on DBus. That server is at a specific location sharing a known object. The interface is assumed by the code to be the DBus menu interface. The newly created client will start sending out events as it syncs up with the server.

#### Parameters

name | The DBus name for the server to connect to |
object | The object on the server to monitor |

#### Returns

A brand new DbusmenuClient

### dbusmenu_client_get_icon_paths ()

    GStrv
    dbusmenu_client_get_icon_paths (DbusmenuClient *client);

Gets the stored and exported icon paths from the client.

#### Parameters

client | The DbusmenuClient to get the icon paths from |

#### Returns

A NULL-terminated list of icon paths with memory managed by the client. Duplicate if you want to keep them.

[transfer none]

### dbusmenu_client_get_root ()

    DbusmenuMenuitem *
    dbusmenu_client_get_root (DbusmenuClient *client);

Grabs the root node for the specified client `client` . This function may block. It will block if there is currently a call to update the layout, it will block on that layout updated and then return the newly updated layout. Chances are that this update is in the queue for the mainloop as it would have been requested some time ago, but in theory it could block longer.

#### Parameters

client | The DbusmenuClient to get the root node from |

#### Returns

A DbusmenuMenuitem representing the root of menu on the server. If there is no server or there is an error receiving its layout it'll return NULL.

[transfer none]

### dbusmenu_client_get_status ()

    DbusmenuStatus
    dbusmenu_client_get_status (DbusmenuClient *client);

Gets the recommended current status that the server is exporting for the menus. In situtations where the value is DBUSMENU_STATUS_NOTICE it is recommended that the client show the menus to the user an a more noticible way.

#### Parameters

client | DbusmenuClient to check the status on |

#### Returns

Status being exported.

### dbusmenu_client_get_text_direction ()

    DbusmenuTextDirection
    dbusmenu_client_get_text_direction (DbusmenuClient *client);

Gets the text direction that the server is exporting. If the server is not exporting a direction then the value DBUSMENU_TEXT_DIRECTION_NONE will be returned.

#### Parameters

client | DbusmenuClient to check the text direction on |

#### Returns

Text direction being exported.

### dbusmenu_client_add_type_handler ()

    gboolean
    dbusmenu_client_add_type_handler (DbusmenuClient *client,
                                      const gchar *type,
                                      DbusmenuClientTypeHandler newfunc);

This function connects into the type handling of the DbusmenuClient. Every new menuitem that comes in immediately gets asked for its properties. When we get those properties we check the 'type' property and look to see if it matches a handler that is known by the client. If so, the `newfunc` function is executed on that DbusmenuMenuitem. If not, then the DbusmenuClient::new-menuitem signal is sent.

In the future the known types will be sent to the server so that it can make choices about the menu item types availble.

#### Parameters

client | Client where we're getting types coming in |
type | A text string that will be matched with the 'type' property on incoming menu items |
newfunc | The function that will be executed with those new items when they come in. | [scope notified]

#### Returns

If registering the new type was successful.

### dbusmenu_client_add_type_handler_full ()

    gboolean
    dbusmenu_client_add_type_handler_full (DbusmenuClient *client,
                                           const gchar *type,
                                           DbusmenuClientTypeHandler newfunc,
                                           gpointer user_data,
                                           GDestroyNotify destroy_func);

This function connects into the type handling of the DbusmenuClient. Every new menuitem that comes in immediately gets asked for its properties. When we get those properties we check the 'type' property and look to see if it matches a handler that is known by the client. If so, the `newfunc` function is executed on that DbusmenuMenuitem. If not, then the DbusmenuClient::new-menuitem signal is sent.

In the future the known types will be sent to the server so that it can make choices about the menu item types availble.

#### Parameters

client | Client where we're getting types coming in |
type | A text string that will be matched with the 'type' property on incoming menu items |
newfunc | The function that will be executed with those new items when they come in. | [scope notified]
user_data | Data passed to `newfunc` when it is called |
destroy_func | A function that is called when the type handler is removed (usually on client destruction) which will free the resources in `user_data` . |

#### Returns

If registering the new type was successful.

## Types and Values

### DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED

    #define DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED  "layout-updated"

String to attach to signal “layout-updated”

### DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED

    #define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED    "root-changed"

String to attach to signal “root-changed”

### DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM

    #define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM    "new-menuitem"

String to attach to signal “new-menuitem”

### DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT

    #define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT    "event-result"

String to attach to signal “event-result”

### DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE

    #define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE   "item-activate"

String to attach to signal “item-activate”

### DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED

    #define DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED    "icon-theme-dirs-changed"

String to attach to signal “icon-theme-dirs-changed”

### DBUSMENU_CLIENT_PROP_DBUS_NAME

    #define DBUSMENU_CLIENT_PROP_DBUS_NAME     "dbus-name"

String to access property “dbus-name”

### DBUSMENU_CLIENT_PROP_DBUS_OBJECT

    #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT   "dbus-object"

String to access property “dbus-object”

### DBUSMENU_CLIENT_PROP_GROUP_EVENTS

    #define DBUSMENU_CLIENT_PROP_GROUP_EVENTS "group-events"

String to access property “group-events”

### DBUSMENU_CLIENT_PROP_STATUS

    #define DBUSMENU_CLIENT_PROP_STATUS        "status"

String to access property “status”

### DBUSMENU_CLIENT_PROP_TEXT_DIRECTION

    #define DBUSMENU_CLIENT_PROP_TEXT_DIRECTION "text-direction"

String to access property “text-direction”

### DBUSMENU_CLIENT_TYPES_DEFAULT

    #define DBUSMENU_CLIENT_TYPES_DEFAULT      "standard"

Used to set the 'type' property on a menu item to create a standard menu item.

### DBUSMENU_CLIENT_TYPES_SEPARATOR

    #define DBUSMENU_CLIENT_TYPES_SEPARATOR    "separator"

Used to set the 'type' property on a menu item to create a separator menu item.

### DBUSMENU_CLIENT_TYPES_IMAGE

    #define DBUSMENU_CLIENT_TYPES_IMAGE        "standard"

Used to set the 'type' property on a menu item to create an image menu item. Deprecated as standard menu items now support images as well.

### struct DbusmenuClient

    struct DbusmenuClient {
    };

The client for a DbusmenuServer creating a shared object set of DbusmenuMenuitem objects.