aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/client.h
blob: 2d3b0f91604e23fd8f6f3e8e6a2f34fdb7cb579f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/*
A library to communicate a menu object set accross DBus and
track updates and maintain consistency.

Copyright 2009 Canonical Ltd.

Authors:
    Ted Gould <ted@canonical.com>

This program is free software: you can redistribute it and/or modify it 
under the terms of either or both of the following licenses:

1) the GNU Lesser General Public License version 3, as published by the 
Free Software Foundation; and/or
2) the GNU Lesser General Public License version 2.1, as published by 
the Free Software Foundation.

This program is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranties of 
MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 
PURPOSE.  See the applicable version of the GNU Lesser General Public 
License for more details.

You should have received a copy of both the GNU Lesser General Public 
License version 3 and version 2.1 along with this program.  If not, see 
<http://www.gnu.org/licenses/>
*/

#ifndef __DBUSMENU_CLIENT_H__
#define __DBUSMENU_CLIENT_H__

#include <glib.h>
#include <glib-object.h>

#include "menuitem.h"
#include "types.h"

G_BEGIN_DECLS

#define DBUSMENU_TYPE_CLIENT            (dbusmenu_client_get_type ())
#define DBUSMENU_CLIENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_TYPE_CLIENT, DbusmenuClient))
#define DBUSMENU_CLIENT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_TYPE_CLIENT, DbusmenuClientClass))
#define DBUSMENU_IS_CLIENT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_TYPE_CLIENT))
#define DBUSMENU_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_CLIENT))
#define DBUSMENU_CLIENT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_CLIENT, DbusmenuClientClass))

/**
 * DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED:
 *
 * String to attach to signal #DbusmenuClient::layout-updated
 */
#define DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED  "layout-updated"
/**
 * DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED:
 *
 * String to attach to signal #DbusmenuClient::root-changed
 */
#define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED    "root-changed"
/**
 * DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM:
 *
 * String to attach to signal #DbusmenuClient::new-menuitem
 */
#define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM    "new-menuitem"
/**
 * DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE:
 *
 * String to attach to signal #DbusmenuClient::item-activate
 */
#define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE   "item-activate"
/**
 * DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT:
 *
 * String to attach to signal #DbusmenuClient::event-result
 */
#define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT    "event-result"
/**
 * DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED:
 *
 * String to attach to signal #DbusmenuClient::icon-theme-dirs-changed
 */
#define DBUSMENU_CLIENT_SIGNAL_ICON_THEME_DIRS_CHANGED    "icon-theme-dirs-changed"

/**
 * DBUSMENU_CLIENT_PROP_DBUS_NAME:
 *
 * String to access property #DbusmenuClient:dbus-name
 */
#define DBUSMENU_CLIENT_PROP_DBUS_NAME     "dbus-name"
/**
 * DBUSMENU_CLIENT_PROP_DBUS_OBJECT:
 *
 * String to access property #DbusmenuClient:dbus-object
 */
#define DBUSMENU_CLIENT_PROP_DBUS_OBJECT   "dbus-object"
/**
 * DBUSMENU_CLIENT_PROP_STATUS:
 *
 * String to access property #DbusmenuClient:status
 */
#define DBUSMENU_CLIENT_PROP_STATUS        "status"
/**
 * DBUSMENU_CLIENT_PROP_TEXT_DIRECTION:
 *
 * String to access property #DbusmenuClient:text-direction
 */
#define DBUSMENU_CLIENT_PROP_TEXT_DIRECTION "text-direction"
/**
 * DBUSMENU_CLIENT_PROP_GROUP_EVENTS:
 *
 * String to access property #DbusmenuClient:group-events
 */
#define DBUSMENU_CLIENT_PROP_GROUP_EVENTS "group-events"

/**
 * DBUSMENU_CLIENT_TYPES_DEFAULT:
 *
 * Used to set the 'type' property on a menu item to create
 * a standard menu item.
 */
#define DBUSMENU_CLIENT_TYPES_DEFAULT      "standard"
/**
 * DBUSMENU_CLIENT_TYPES_SEPARATOR:
 *
 * Used to set the 'type' property on a menu item to create
 * a separator menu item.
 */
#define DBUSMENU_CLIENT_TYPES_SEPARATOR    "separator"
/**
 * DBUSMENU_CLIENT_TYPES_IMAGE:
 *
 * 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.
 */
#define DBUSMENU_CLIENT_TYPES_IMAGE        "standard"

typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate;

/**
	DbusmenuClientClass:
	@parent_class: #GObjectClass
	@layout_updated: Slot for #DbusmenuClient::layout-updated.
	@root_changed: Slot for #DbusmenuClient::root-changed.
	@new_menuitem: Slot for #DbusmenuClient::new-menuitem.
	@item_activate: Slot for #DbusmenuClient::item-activate.
	@event_result: Slot for #DbusmenuClient::event-error.
	@icon_theme_dirs: Slot for #DbusmenuClient::icon-theme-dirs-changed.
	@reserved1: Reserved for future use.
	@reserved2: Reserved for future use.
	@reserved3: Reserved for future use.
	@reserved4: Reserved for future use.
	@reserved5: Reserved for future use.

	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.
*/
typedef struct _DbusmenuClientClass DbusmenuClientClass;
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);
};

/**
	DbusmenuClient:

	The client for a #DbusmenuServer creating a shared
	object set of #DbusmenuMenuitem objects.
*/
typedef struct _DbusmenuClient      DbusmenuClient;
struct _DbusmenuClient {
	/*< private >*/
	GObject parent;

	/*< Private >*/
	DbusmenuClientPrivate * priv;
};

/**
	DbusmenuClientTypeHandler:
	@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

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

	Return value: #TRUE if the type has been handled.  #FALSE if this
		function was somehow unable to handle it.
*/
typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data);

GType                dbusmenu_client_get_type          (void);
DbusmenuClient *     dbusmenu_client_new               (const gchar * name,
                                                        const gchar * object);
DbusmenuMenuitem *   dbusmenu_client_get_root          (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);
DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client);
DbusmenuStatus       dbusmenu_client_get_status        (DbusmenuClient * client);
GStrv                dbusmenu_client_get_icon_paths    (DbusmenuClient * client);

/**
	SECTION:client
	@short_description: The catcher of all the server traffic
	@stability: Unstable
	@include: libdbusmenu-glib/client.h

	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 #DbusmenuClient::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.
*/

G_END_DECLS

#endif