2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef __CAIRO_DOCK_NOTIFICATIONS__
22
#define __CAIRO_DOCK_NOTIFICATIONS__
25
#include "cairo-dock-struct.h"
30
*@file cairo-dock-notifications.h This class defines the notification system. Each time an event occurs (like an icon being clicked), Cairo-Dock broadcasts the corresponding notification. Anybody that has registered to it will be called then.
33
/// Generic prototype of a notification callback.
34
typedef gboolean (* CairoDockNotificationFunc) (gpointer pUserData, ...);
37
CairoDockNotificationFunc pFunction;
39
} CairoDockNotificationRecord;
41
/// The list of all notifications.
43
/// notification called when use clicks on an icon data : {Icon, CairoDock, int}
44
CAIRO_DOCK_CLICK_ICON=0,
45
/// notification called when the user double-clicks on an icon. data : {Icon, CairoDock}
46
CAIRO_DOCK_DOUBLE_CLICK_ICON,
47
/// notification called when the user middle-clicks on an icon. data : {Icon, CairoDock}
48
CAIRO_DOCK_MIDDLE_CLICK_ICON,
49
/// notification called when the user scrolls on an icon. data : {Icon, CairoDock, int}
50
CAIRO_DOCK_SCROLL_ICON,
51
/// notification called when the menu is being built on an icon (possibly NULL). data : {Icon, CairoContainer, GtkMenu}
52
CAIRO_DOCK_BUILD_ICON_MENU,
53
/// notification called when the mouse enters a dock while dragging an object.
54
CAIRO_DOCK_START_DRAG_DATA,
55
/// notification called when something is dropped inside a container. data : {gchar*, Icon, double*, CairoDock}
57
/// notification called when the mouse has moved inside a container.
58
CAIRO_DOCK_MOUSE_MOVED,
59
/// notification called when a key is pressed in a container that has the focus.
60
CAIRO_DOCK_KEY_PRESSED,
62
/// notification called when the user switches to another desktop/viewport. data : NULL
63
CAIRO_DOCK_DESKTOP_CHANGED,
64
/// notification called when a window is resized or moved, or when the z-order of windows has changed. data : {Xid, XConfigureEvent or NULL}.
65
CAIRO_DOCK_WINDOW_CONFIGURED,
66
/// notification called when the geometry of the desktop has changed (number of viewports/desktops, dimensions). data : NULL
67
CAIRO_DOCK_SCREEN_GEOMETRY_ALTERED,
68
/// notification called when the active window has changed. data : Window* or NULL
69
CAIRO_DOCK_WINDOW_ACTIVATED,
70
/// notification called when the state of the keyboard has changed.
71
CAIRO_DOCK_KBD_STATE_CHANGED,
73
/// notification called when an icon has just been inserted into a dock. data : {Icon, CairoDock}
74
CAIRO_DOCK_INSERT_ICON,
75
/// notification called when an icon is going to be removed from a dock. data : {Icon, CairoDock}
76
CAIRO_DOCK_REMOVE_ICON,
77
/// notification called when someone asks for an animation for a given icon.
78
CAIRO_DOCK_REQUEST_ICON_ANIMATION,
80
/// notification called when the mouse enters an icon. data : {Icon, CairoDock, gboolean*}
81
CAIRO_DOCK_ENTER_ICON,
82
/// notification called when an icon is updated in the fast rendering loop.
83
CAIRO_DOCK_UPDATE_ICON,
84
/// notification called when an icon is updated in the slow rendering loop.
85
CAIRO_DOCK_UPDATE_ICON_SLOW,
86
/// notification called when the background of an icon is rendered.
87
CAIRO_DOCK_PRE_RENDER_ICON,
88
/// notification called when an icon is rendered.
89
CAIRO_DOCK_RENDER_ICON,
90
/// notification called when an icon is stopped, for instance before it is removed.
93
/// notification called when the mouse enters a dock.
94
CAIRO_DOCK_ENTER_DOCK,
95
/// notification called when a dock is updated in the fast rendering loop.
96
CAIRO_DOCK_UPDATE_DOCK,
97
/// notification called when when a dock is updated in the slow rendering loop.
98
CAIRO_DOCK_UPDATE_DOCK_SLOW,
99
/// notification called when a dock is rendered.
100
CAIRO_DOCK_RENDER_DOCK,
101
/// notification called when a dock is stopped, for instance before it is destroyed.
102
CAIRO_DOCK_STOP_DOCK,
104
/// notification called when the mouse enters a desklet.
105
CAIRO_DOCK_ENTER_DESKLET,
106
/// notification called when a desklet is updated in the fast rendering loop.
107
CAIRO_DOCK_UPDATE_DESKLET,
108
/// notification called when a desklet is updated in the slow rendering loop.
109
CAIRO_DOCK_UPDATE_DESKLET_SLOW,
110
/// notification called when a desklet is rendered.
111
CAIRO_DOCK_RENDER_DESKLET,
112
/// notification called when a desklet is stopped, for instance before it is destroyed.
113
CAIRO_DOCK_STOP_DESKLET,
115
/// notification called when a FlyingContainer is updated in the fast rendering loop.
116
CAIRO_DOCK_UPDATE_FLYING_CONTAINER,
117
/// notification called when a FlyingContainer is rendered.
118
CAIRO_DOCK_RENDER_FLYING_CONTAINER,
120
/// notification called when a Dialog is updated in the fast rendering loop.
121
CAIRO_DOCK_UPDATE_DIALOG,
122
/// notification called when a Dialog is updated in the slow rendering loop.
123
CAIRO_DOCK_UPDATE_DIALOG_SLOW,
124
/// notification called when a Dialog is rendered.
125
CAIRO_DOCK_RENDER_DIALOG,
127
/// notification called for the fast rendering loop on a default container.
128
CAIRO_DOCK_UPDATE_DEFAULT_CONTAINER,
129
/// notification called for the slow rendering loop on a default container.
130
CAIRO_DOCK_UPDATE_DEFAULT_CONTAINER_SLOW,
131
/// notification called when a default container is rendered.
132
CAIRO_DOCK_RENDER_DEFAULT_CONTAINER,
134
/// notification called when the mouse leave a dock.
135
CAIRO_DOCK_LEAVE_DOCK,
136
/// notification called when the mouse leave a desklet.
137
CAIRO_DOCK_LEAVE_DESKLET,
139
/// notification called when the desktop is shown/hidden. data:NULL.
140
CAIRO_DOCK_DESKTOP_VISIBILITY_CHANGED,
141
/// notification called when the menu is being built on a container. data : {Icon, CairoContainer, GtkMenu, gboolean*}
142
CAIRO_DOCK_BUILD_CONTAINER_MENU,
144
/// notification called when an icon's sub-dock is starting to (un)fold. data : {Icon}
145
CAIRO_DOCK_UNFOLD_SUBDOCK,
147
/// notification called when a window's property has changed. data : {Window, Atom, int}
148
CAIRO_DOCK_WINDOW_PROPERTY_CHANGED,
150
CAIRO_DOCK_NB_NOTIFICATIONS
151
} CairoDockNotificationType;
153
/// prototype of the callback to the CAIRO_DOCK_CLICK_ICON notification.
154
typedef gboolean (* CairoDockClickIconFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer, int iState);
155
/// prototype of the callback to the CAIRO_DOCK_DOUBLE_CLICK_ICON notification.
156
typedef gboolean (* CairoDockDoubleClickIconFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer);
157
/// prototype of the callback to the CAIRO_DOCK_MIDDLE_CLICK_ICON notification.
158
typedef gboolean (* CairoDockMiddleClickIconFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer);
159
/// prototype of the callback to the CAIRO_DOCK_SCROLL_ICON notification.
160
typedef gboolean (* CairoDockScrollIconFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer, int iDirection);
161
/// prototype of the callback to the CAIRO_DOCK_BUILD_ICON_MENU notification.
162
typedef gboolean (* CairoDockBuildMenuFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer, GtkMenu *pMenu);
163
/// prototype of the callback to the CAIRO_DOCK_START_DRAG_DATA notification.
164
typedef gboolean (* CairoDockStartDragDataFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bStartAnimation);
165
/// prototype of the callback to the CAIRO_DOCK_DROP_DATA notification.
166
typedef gboolean (* CairoDockDropDataFunc) (gpointer pUserData, gchar *cData, Icon *pIcon, double fPosition, CairoContainer *pContainer);
167
/// prototype of the callback to the CAIRO_DOCK_MOUSE_MOVED notification.
168
typedef gboolean (* CairoDockMouseMovedFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bStartAnimation);
169
/// prototype of the callback to the CAIRO_DOCK_KEY_PRESSED notification.
170
typedef gboolean (* CairoDockKeyPressedFunc) (gpointer pUserData, CairoDock *pDock, int keyval, int state, gchar *string);
172
/// prototype of the callback to the CAIRO_DOCK_DESKTOP_CHANGED notification.
173
typedef gboolean (* CairoDockDesktopChangedFunc) (gpointer pUserData);
174
/// prototype of the callback to the CAIRO_DOCK_WINDOW_CONFIGURED notification.
175
typedef gboolean (* CairoDockWindowConfiguredFunc) (gpointer pUserData, XConfigureEvent *pXEvent);
176
/// prototype of the callback to the CAIRO_DOCK_SCREEN_GEOMETRY_ALTERED notification.
177
typedef gboolean (* CairoDockScreenGeometryAlteredFunc) (gpointer pUserData);
178
/// prototype of the callback to the CAIRO_DOCK_WINDOW_ACTIVATED notification.
179
typedef gboolean (* CairoDockWindowActivatedFunc) (gpointer pUserData, Window *Xid);
180
/// prototype of the callback to the CAIRO_DOCK_KBD_STATE_CHANGED notification.
181
typedef gboolean (* CairoDockKeyboardStateChangedFunc) (gpointer pUserData, Window *Xid);
183
/// prototype of the callback to the CAIRO_DOCK_INSERT_ICON and CAIRO_DOCK_REMOVE_ICON notifications.
184
typedef gboolean (* CairoDockInsertRemoveIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock);
185
/// prototype of the callback to the CAIRO_DOCK_REQUEST_ICON_ANIMATION notification.
186
typedef gboolean (* CairoDockRequestAnimationFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gchar *cAnimationName, gint iNbRounds);
188
/// prototype of the callback to the CAIRO_DOCK_ENTER_ICON notification.
189
typedef gboolean (* CairoDockEnterIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bStartAnimation);
190
/// prototype of the callback to the CAIRO_DOCK_UPDATE_ICON and CAIRO_DOCK_UPDATE_ICON_SLOW notifications.
191
typedef gboolean (* CairoDockUpdateIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bContinueAnimation);
193
/// prototype of the callback to the CAIRO_DOCK_PRE_RENDER_ICON notification.
194
typedef gboolean (* CairoDockPreRenderIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock);
195
/// prototype of the callback to the CAIRO_DOCK_RENDER_ICON notification.
196
typedef gboolean (* CairoDockRenderIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bHasBeenRendered, cairo_t *pCairoContext);
197
/// prototype of the callback to the CAIRO_DOCK_STOP_ICON notification.
198
typedef gboolean (* CairoDockStopIconFunc) (gpointer pUserData, Icon *pIcon);
200
/// prototype of the callback to the CAIRO_DOCK_ENTER_DOCK and CAIRO_DOCK_ENTER_DESKLET notifications.
201
typedef gboolean (* CairoDockEnterContainerFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bStartAnimation);
202
/// prototype of the callback to the CAIRO_DOCK_UPDATE_DOCK, CAIRO_DOCK_UPDATE_DOCK_SLOW, CAIRO_DOCK_UPDATE_DESKLET, CAIRO_DOCK_UPDATE_DESKLET_SLOW, CAIRO_DOCK_UPDATE_DIALOG and CAIRO_DOCK_UPDATE_FLYING_CONTAINER notifications.
203
typedef gboolean (* CairoDockUpdateContainerFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bContinueAnimation);
204
/// prototype of the callback to the CAIRO_DOCK_RENDER_DOCK, CAIRO_DOCK_RENDER_DESKLET, CAIRO_DOCK_RENDER_DIALOG, CAIRO_DOCK_RENDER_FLYING_CONTAINER notifications. 'pCairoContext' is NULL for an OpenGL rendering.
205
typedef gboolean (* CairoDockRenderContainerFunc) (gpointer pUserData, CairoContainer *pContainer, cairo_t *pCairoContext);
206
/// prototype of the callback to the CAIRO_DOCK_STOP_DOCK and CAIRO_DOCK_STOP_DESKLET notifications.
207
typedef gboolean (* CairoDockStopContainerFunc) (gpointer pUserData, CairoContainer *pContainer);
208
/// prototype of the callback to the CAIRO_DOCK_LEAVE_DOCK and CAIRO_DOCK_LEAVE_DESKLET notifications.
209
typedef gboolean (* CairoDockLeaveContainerFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bStartAnimation);
212
/// Use this in \ref cairo_dock_register_notification to be called before the dock.
213
#define CAIRO_DOCK_RUN_FIRST TRUE
214
/// Use this in \ref cairo_dock_register_notification to be called after the dock.
215
#define CAIRO_DOCK_RUN_AFTER FALSE
217
/// Return this in your callback to prevent the other callbacks from being called after you.
218
#define CAIRO_DOCK_INTERCEPT_NOTIFICATION TRUE
219
/// Return this in your callback to let pass the notification to the other callbacks after you.
220
#define CAIRO_DOCK_LET_PASS_NOTIFICATION FALSE
223
GSList *cairo_dock_get_notifications_list (CairoDockNotificationType iNotifType);
225
/** Register an action to be called when a given notification is broadcasted.
226
*@param iNotifType type of the notification.
227
*@param pFunction callback.
228
*@param bRunFirst CAIRO_DOCK_RUN_FIRST to be called before Cairo-Dock, CAIRO_DOCK_RUN_AFTER to be called after.
229
*@param pUserData data to be passed as the first parameter of the callback.
231
void cairo_dock_register_notification (CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gboolean bRunFirst, gpointer pUserData);
233
/** Register an action to be called when a given notification is broadcasted from a given icon.
234
*@param pIcon the icon.
235
*@param iNotifType type of the notification.
236
*@param pFunction callback.
237
*@param bRunFirst CAIRO_DOCK_RUN_FIRST to be called before Cairo-Dock, CAIRO_DOCK_RUN_AFTER to be called after.
238
*@param pUserData data to be passed as the first parameter of the callback.
240
void cairo_dock_register_notification_on_icon (Icon *pIcon, CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gboolean bRunFirst, gpointer pUserData);
242
/** Register an action to be called when a given notification is broadcasted from a given container.
243
*@param pContainer the container.
244
*@param iNotifType type of the notification.
245
*@param pFunction callback.
246
*@param bRunFirst CAIRO_DOCK_RUN_FIRST to be called before Cairo-Dock, CAIRO_DOCK_RUN_AFTER to be called after.
247
*@param pUserData data to be passed as the first parameter of the callback.
249
void cairo_dock_register_notification_on_container (CairoContainer *pContainer, CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gboolean bRunFirst, gpointer pUserData);
251
/** Remove a callback from the list of callbacks for a given notification and a given data.
252
*@param iNotifType type of the notification.
253
*@param pFunction callback.
254
*@param pUserData data that was registerd with the callback.
256
void cairo_dock_remove_notification_func (CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gpointer pUserData);
258
/** Remove a callback from the list of callbacks of a given icon for a given notification and a given data.
259
*@param pIcon the icon for which the action has been registered.
260
*@param iNotifType type of the notification.
261
*@param pFunction callback.
262
*@param pUserData data that was registerd with the callback.
264
void cairo_dock_remove_notification_func_on_icon (Icon *pIcon, CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gpointer pUserData);
266
/** Remove a callback from the list of callbacks of a given container for a given notification and a given data.
267
*@param pContainer the container for which the action has been registered.
268
*@param iNotifType type of the notification.
269
*@param pFunction callback.
270
*@param pUserData data that was registerd with the callback.
272
void cairo_dock_remove_notification_func_on_container (CairoContainer *pContainer, CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gpointer pUserData);
275
#define _cairo_dock_notify(pNotificationRecordList, bStop, ...) do {\
276
if (pNotificationRecordList != NULL) {\
277
CairoDockNotificationRecord *pNotificationRecord;\
278
GSList *pElement = pNotificationRecordList, *pNextElement;\
279
while (pElement != NULL && ! bStop) {\
280
pNotificationRecord = pElement->data;\
281
pNextElement = pElement->next;\
282
bStop = pNotificationRecord->pFunction (pNotificationRecord->pUserData, ##__VA_ARGS__);\
283
pElement = pNextElement; } }\
286
/** Broadcast a notification.
287
*@param iNotifType type of the notification.
288
*@param ... parameters to be passed to the callbacks that has registerd to this notification.
290
#define cairo_dock_notify(iNotifType, ...) do {\
291
gboolean bStop = FALSE;\
292
GSList *pNotificationRecordList = cairo_dock_get_notifications_list (iNotifType);\
293
_cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);\
296
/** Broadcast a notification from a given icon.
297
*@param pIcon the icon.
298
*@param iNotifType type of the notification.
299
*@param ... parameters to be passed to the callbacks that has registerd to this notification.
301
#define cairo_dock_notify_on_icon(pIcon, iNotifType, ...) do {\
302
gboolean bStop = FALSE;\
303
GSList *pNotificationRecordList = cairo_dock_get_notifications_list (iNotifType);\
304
_cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);\
305
if (pIcon && pIcon->pNotificationsTab) {\
306
GSList *pNotificationRecordList = g_ptr_array_index (pIcon->pNotificationsTab, iNotifType);\
307
_cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);}\
310
/** Broadcast a notification form a given container.
311
*@param pContainer the container.
312
*@param iNotifType type of the notification.
313
*@param ... parameters to be passed to the callbacks that has registerd to this notification.
315
#define cairo_dock_notify_on_container(pContainer, iNotifType, ...) do {\
316
gboolean bStop = FALSE;\
317
GSList *pNotificationRecordList = cairo_dock_get_notifications_list (iNotifType);\
318
_cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);\
319
if (pContainer && pContainer->pNotificationsTab) {\
320
GSList *pNotificationRecordList = g_ptr_array_index (pContainer->pNotificationsTab, iNotifType);\
321
_cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);}\
325
void cairo_dock_free_notification_table (GPtrArray *pNotificationsTab);