libdbusmenu-glib Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#include <libdbusmenu-glib/client.h> #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_STATUS #define DBUSMENU_CLIENT_PROP_TEXT_DIRECTION #define DBUSMENU_CLIENT_TYPES_DEFAULT #define DBUSMENU_CLIENT_TYPES_SEPARATOR #define DBUSMENU_CLIENT_TYPES_IMAGE DbusmenuClient; struct DbusmenuClientClass; gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem *newitem
,DbusmenuMenuitem *parent
,DbusmenuClient *client
,gpointer user_data
); DbusmenuClient * dbusmenu_client_new (const gchar *name
,const gchar *object
); const GStrv dbusmenu_client_get_icon_paths (DbusmenuClient *client
); DbusmenuMenuitem * dbusmenu_client_get_root (DbusmenuClient *client
); DbusmenuStatus dbusmenu_client_get_status (DbusmenuClient *client
); DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient *client
); gboolean dbusmenu_client_add_type_handler (DbusmenuClient *client
,const gchar *type
,DbusmenuClientTypeHandler newfunc
); gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient *client
,const gchar *type
,DbusmenuClientTypeHandler newfunc
,gpointer user_data
,GDestroyNotify destroy_func
);
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.
#define DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED "layout-updated"
String to attach to signal "layout-updated"
#define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED "root-changed"
String to attach to signal "root-changed"
#define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM "new-menuitem"
String to attach to signal "new-menuitem"
#define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT "event-result"
String to attach to signal "event-result"
#define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE "item-activate"
String to attach to signal "item-activate"
#define DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED "icon-theme-dirs-changed"
String to attach to signal "icon-theme-dirs-changed"
#define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name"
String to access property "dbus-name"
#define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object"
String to access property "dbus-object"
#define DBUSMENU_CLIENT_PROP_STATUS "status"
String to access property "status"
#define DBUSMENU_CLIENT_PROP_TEXT_DIRECTION "text-direction"
String to access property "text-direction"
#define DBUSMENU_CLIENT_TYPES_DEFAULT "standard"
Used to set the 'type' property on a menu item to create a standard menu item.
#define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator"
Used to set the 'type' property on a menu item to create a separator menu item.
#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.
typedef struct _DbusmenuClient DbusmenuClient;
The client for a DbusmenuServer creating a shared object set of DbusmenuMenuitem objects.
struct DbusmenuClientClass { GObjectClass parent_class; void (*layout_updated)(void); void (*root_changed) (DbusmenuMenuitem * newroot); void (*new_menuitem) (DbusmenuMenuitem * newitem); void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); void (*event_result) (DbusmenuMenuitem * item, gchar * event, GVariant * data, guint timestamp, GError * error); void (*icon_theme_dirs) (DbusmenuMenuitem * item, gpointer theme_dirs, GError * error); /*< Private >*/ void (*reserved1) (void); void (*reserved2) (void); void (*reserved3) (void); void (*reserved4) (void); void (*reserved5) (void); };
A simple class that takes all of the information from a DbusmenuServer over DBus and makes the same set of DbusmenuMenuitem objects appear on the other side.
GObjectClass |
GObjectClass |
Slot for "layout-updated". | |
Slot for "root-changed". | |
Slot for "new-menuitem". | |
Slot for "item-activate". | |
Slot for "event-error". | |
Slot for "icon-theme-dirs-changed". | |
Reserved for future use. | |
Reserved for future use. | |
Reserved for future use. | |
Reserved for future use. | |
Reserved for future use. |
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
|
The DbusmenuMenuitem that was created |
|
The parent of newitem or NULL if none |
|
A pointer to the DbusmenuClient |
|
The data you gave us |
Returns : |
TRUE if the type has been handled. FALSE if this function was somehow unable to handle it. |
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.
|
The DBus name for the server to connect to |
|
The object on the server to monitor |
Returns : |
A brand new DbusmenuClient |
const GStrv dbusmenu_client_get_icon_paths (DbusmenuClient *client
);
Gets the stored and exported icon paths from the 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] |
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.
|
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] |
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.
|
DbusmenuClient to check the status on |
Returns : |
Status being exported. |
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.
|
DbusmenuClient to check the text direction on |
Returns : |
Text direction being exported. |
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 it's
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.
|
Client where we're getting types coming in |
|
A text string that will be matched with the 'type' property on incoming menu items |
|
The function that will be executed with those new items when they come in. [scope notified] |
Returns : |
If registering the new type was successful. |
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 it's
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.
|
Client where we're getting types coming in |
|
A text string that will be matched with the 'type' property on incoming menu items |
|
The function that will be executed with those new items when they come in. [scope notified] |
|
Data passed to newfunc when it is called |
|
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. |