~ubuntu-branches/ubuntu/oneiric/cairo-dock/oneiric

« back to all changes in this revision

Viewing changes to src/cairo-dock-notifications.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: (18.1.1 cairo-dock) (19.1.1 cairo-dock)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
* This file is a part of the Cairo-Dock project
3
 
*
4
 
* Copyright : (C) see the 'copyright' file.
5
 
* E-mail    : see the 'copyright' file.
6
 
*
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.
11
 
*
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/>.
18
 
*/
19
 
 
20
 
 
21
 
#ifndef __CAIRO_DOCK_NOTIFICATIONS__
22
 
#define  __CAIRO_DOCK_NOTIFICATIONS__
23
 
 
24
 
#include <glib.h>
25
 
#include "cairo-dock-struct.h"
26
 
 
27
 
G_BEGIN_DECLS
28
 
 
29
 
/**
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.
31
 
*/
32
 
 
33
 
/// Generic prototype of a notification callback.
34
 
typedef gboolean (* CairoDockNotificationFunc) (gpointer pUserData, ...);
35
 
 
36
 
typedef struct {
37
 
        CairoDockNotificationFunc pFunction;
38
 
        gpointer pUserData;
39
 
        } CairoDockNotificationRecord;
40
 
 
41
 
/// The list of all notifications.
42
 
typedef enum {
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}
56
 
        CAIRO_DOCK_DROP_DATA,
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,
61
 
        
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 : 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,
72
 
        
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,
79
 
        
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.
91
 
        CAIRO_DOCK_STOP_ICON,
92
 
        
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,
103
 
        
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,
114
 
        
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,
119
 
        
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 rendered.
123
 
        CAIRO_DOCK_RENDER_DIALOG,
124
 
        
125
 
        /// notification called for the fast rendering loop on a default container.
126
 
        CAIRO_DOCK_UPDATE_DEFAULT_CONTAINER,
127
 
        /// notification called for the slow rendering loop on a default container.
128
 
        CAIRO_DOCK_UPDATE_DEFAULT_CONTAINER_SLOW,
129
 
        /// notification called when a default container is rendered.
130
 
        CAIRO_DOCK_RENDER_DEFAULT_CONTAINER,
131
 
        
132
 
        /// notification called when the mouse leave a dock.
133
 
        CAIRO_DOCK_LEAVE_DOCK,
134
 
        /// notification called when the mouse leave a desklet.
135
 
        CAIRO_DOCK_LEAVE_DESKLET,
136
 
        
137
 
        /// notification called when the desktop is shown/hidden (data:NULL).
138
 
        CAIRO_DOCK_DESKTOP_VISIBILITY_CHANGED,
139
 
        /// notification called when the menu is being built on a container. data : {CairoContainer, GtkMenu}
140
 
        CAIRO_DOCK_BUILD_CONTAINER_MENU,
141
 
        
142
 
        /// notification called when an icon's sub-dock is starting to (un)fold. data : {Icon}
143
 
        CAIRO_DOCK_UNFOLD_SUBDOCK,
144
 
        
145
 
        CAIRO_DOCK_NB_NOTIFICATIONS
146
 
        } CairoDockNotificationType;
147
 
 
148
 
/// prototype of the callback to the CAIRO_DOCK_CLICK_ICON notification.
149
 
typedef gboolean (* CairoDockClickIconFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer, int iState);
150
 
/// prototype of the callback to the CAIRO_DOCK_DOUBLE_CLICK_ICON notification.
151
 
typedef gboolean (* CairoDockDoubleClickIconFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer);
152
 
/// prototype of the callback to the CAIRO_DOCK_MIDDLE_CLICK_ICON notification.
153
 
typedef gboolean (* CairoDockMiddleClickIconFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer);
154
 
/// prototype of the callback to the CAIRO_DOCK_SCROLL_ICON notification.
155
 
typedef gboolean (* CairoDockScrollIconFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer, int iDirection);
156
 
/// prototype of the callback to the CAIRO_DOCK_BUILD_ICON_MENU notification.
157
 
typedef gboolean (* CairoDockBuildMenuFunc) (gpointer pUserData, Icon *pIcon, CairoContainer *pContainer, GtkMenu *pMenu);
158
 
/// prototype of the callback to the CAIRO_DOCK_START_DRAG_DATA notification.
159
 
typedef gboolean (* CairoDockStartDragDataFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bStartAnimation);
160
 
/// prototype of the callback to the CAIRO_DOCK_DROP_DATA notification.
161
 
typedef gboolean (* CairoDockDropDataFunc) (gpointer pUserData, gchar *cData, Icon *pIcon, double fPosition, CairoContainer *pContainer);
162
 
/// prototype of the callback to the CAIRO_DOCK_MOUSE_MOVED notification.
163
 
typedef gboolean (* CairoDockMouseMovedFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bStartAnimation);
164
 
/// prototype of the callback to the CAIRO_DOCK_KEY_PRESSED notification.
165
 
typedef gboolean (* CairoDockKeyPressedFunc) (gpointer pUserData, CairoDock *pDock, int keyval, int state, gchar *string);
166
 
 
167
 
/// prototype of the callback to the CAIRO_DOCK_DESKTOP_CHANGED notification.
168
 
typedef gboolean (* CairoDockDesktopChangedFunc) (gpointer pUserData);
169
 
/// prototype of the callback to the CAIRO_DOCK_WINDOW_CONFIGURED notification.
170
 
typedef gboolean (* CairoDockWindowConfiguredFunc) (gpointer pUserData, XConfigureEvent *pXEvent);
171
 
/// prototype of the callback to the CAIRO_DOCK_SCREEN_GEOMETRY_ALTERED notification.
172
 
typedef gboolean (* CairoDockScreenGeometryAlteredFunc) (gpointer pUserData);
173
 
/// prototype of the callback to the CAIRO_DOCK_WINDOW_ACTIVATED notification.
174
 
typedef gboolean (* CairoDockWindowActivatedFunc) (gpointer pUserData, Window *Xid);
175
 
/// prototype of the callback to the CAIRO_DOCK_KBD_STATE_CHANGED notification.
176
 
typedef gboolean (* CairoDockKeyboardStateChangedFunc) (gpointer pUserData, Window *Xid);
177
 
 
178
 
/// prototype of the callback to the CAIRO_DOCK_INSERT_ICON and CAIRO_DOCK_REMOVE_ICON notifications.
179
 
typedef gboolean (* CairoDockInsertRemoveIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock);
180
 
/// prototype of the callback to the CAIRO_DOCK_REQUEST_ICON_ANIMATION notification.
181
 
typedef gboolean (* CairoDockRequestAnimationFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gchar *cAnimationName, gint iNbRounds);
182
 
 
183
 
/// prototype of the callback to the CAIRO_DOCK_ENTER_ICON notification.
184
 
typedef gboolean (* CairoDockEnterIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bStartAnimation);
185
 
/// prototype of the callback to the CAIRO_DOCK_UPDATE_ICON and CAIRO_DOCK_UPDATE_ICON_SLOW notifications.
186
 
typedef gboolean (* CairoDockUpdateIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bContinueAnimation);
187
 
 
188
 
/// prototype of the callback to the CAIRO_DOCK_PRE_RENDER_ICON notification.
189
 
typedef gboolean (* CairoDockPreRenderIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock);
190
 
/// prototype of the callback to the CAIRO_DOCK_RENDER_ICON notification.
191
 
typedef gboolean (* CairoDockRenderIconFunc) (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bHasBeenRendered, cairo_t *pCairoContext);
192
 
/// prototype of the callback to the CAIRO_DOCK_STOP_ICON notification.
193
 
typedef gboolean (* CairoDockStopIconFunc) (gpointer pUserData, Icon *pIcon);
194
 
 
195
 
/// prototype of the callback to the CAIRO_DOCK_ENTER_DOCK and CAIRO_DOCK_ENTER_DESKLET notifications.
196
 
typedef gboolean (* CairoDockEnterContainerFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bStartAnimation);
197
 
/// 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.
198
 
typedef gboolean (* CairoDockUpdateContainerFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bContinueAnimation);
199
 
/// 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.
200
 
typedef gboolean (* CairoDockRenderContainerFunc) (gpointer pUserData, CairoContainer *pContainer, cairo_t *pCairoContext);
201
 
/// prototype of the callback to the CAIRO_DOCK_STOP_DOCK and CAIRO_DOCK_STOP_DESKLET notifications.
202
 
typedef gboolean (* CairoDockStopContainerFunc) (gpointer pUserData, CairoContainer *pContainer);
203
 
/// prototype of the callback to the CAIRO_DOCK_LEAVE_DOCK and CAIRO_DOCK_LEAVE_DESKLET notifications.
204
 
typedef gboolean (* CairoDockLeaveContainerFunc) (gpointer pUserData, CairoContainer *pContainer, gboolean *bStartAnimation);
205
 
 
206
 
 
207
 
/// Use this in \ref cairo_dock_register_notification to be called before the dock.
208
 
#define CAIRO_DOCK_RUN_FIRST TRUE
209
 
/// Use this in \ref cairo_dock_register_notification to be called after the dock.
210
 
#define CAIRO_DOCK_RUN_AFTER FALSE
211
 
 
212
 
/// Return this in your callback to prevent the other callbacks from being called after you.
213
 
#define CAIRO_DOCK_INTERCEPT_NOTIFICATION TRUE
214
 
/// Return this in your callback to let pass the notification to the other callbacks after you.
215
 
#define CAIRO_DOCK_LET_PASS_NOTIFICATION FALSE
216
 
 
217
 
 
218
 
GSList *cairo_dock_get_notifications_list (CairoDockNotificationType iNotifType);
219
 
 
220
 
/** Register an action to be called when a given notification is broadcasted.
221
 
*@param iNotifType type of the notification.
222
 
*@param pFunction callback.
223
 
*@param bRunFirst CAIRO_DOCK_RUN_FIRST to be called before Cairo-Dock, CAIRO_DOCK_RUN_AFTER to be called after.
224
 
*@param pUserData data to be passed as the first parameter of the callback.
225
 
*/
226
 
void cairo_dock_register_notification (CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gboolean bRunFirst, gpointer pUserData);
227
 
 
228
 
/** Register an action to be called when a given notification is broadcasted from a given icon.
229
 
*@param pIcon the icon.
230
 
*@param iNotifType type of the notification.
231
 
*@param pFunction callback.
232
 
*@param bRunFirst CAIRO_DOCK_RUN_FIRST to be called before Cairo-Dock, CAIRO_DOCK_RUN_AFTER to be called after.
233
 
*@param pUserData data to be passed as the first parameter of the callback.
234
 
*/
235
 
void cairo_dock_register_notification_on_icon (Icon *pIcon, CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gboolean bRunFirst, gpointer pUserData);
236
 
 
237
 
/** Register an action to be called when a given notification is broadcasted from a given container.
238
 
*@param pContainer the container.
239
 
*@param iNotifType type of the notification.
240
 
*@param pFunction callback.
241
 
*@param bRunFirst CAIRO_DOCK_RUN_FIRST to be called before Cairo-Dock, CAIRO_DOCK_RUN_AFTER to be called after.
242
 
*@param pUserData data to be passed as the first parameter of the callback.
243
 
*/
244
 
void cairo_dock_register_notification_on_container (CairoContainer *pContainer, CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gboolean bRunFirst, gpointer pUserData);
245
 
 
246
 
/** Remove a callback from the list of callbacks for a given notification and a given data.
247
 
*@param iNotifType type of the notification.
248
 
*@param pFunction callback.
249
 
*@param pUserData data that was registerd with the callback.
250
 
*/
251
 
void cairo_dock_remove_notification_func (CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gpointer pUserData);
252
 
 
253
 
/** Remove a callback from the list of callbacks of a given icon for a given notification and a given data.
254
 
*@param pIcon the icon for which the action has been registered.
255
 
*@param iNotifType type of the notification.
256
 
*@param pFunction callback.
257
 
*@param pUserData data that was registerd with the callback.
258
 
*/
259
 
void cairo_dock_remove_notification_func_on_icon (Icon *pIcon, CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gpointer pUserData);
260
 
 
261
 
/** Remove a callback from the list of callbacks of a given container for a given notification and a given data.
262
 
*@param pContainer the container for which the action has been registered.
263
 
*@param iNotifType type of the notification.
264
 
*@param pFunction callback.
265
 
*@param pUserData data that was registerd with the callback.
266
 
*/
267
 
void cairo_dock_remove_notification_func_on_container (CairoContainer *pContainer, CairoDockNotificationType iNotifType, CairoDockNotificationFunc pFunction, gpointer pUserData);
268
 
 
269
 
 
270
 
#define _cairo_dock_notify(pNotificationRecordList, bStop, ...) do {\
271
 
        if (pNotificationRecordList != NULL) {\
272
 
                CairoDockNotificationRecord *pNotificationRecord;\
273
 
                GSList *pElement = pNotificationRecordList, *pNextElement;\
274
 
                while (pElement != NULL && ! bStop) {\
275
 
                        pNotificationRecord = pElement->data;\
276
 
                        pNextElement = pElement->next;\
277
 
                        bStop = pNotificationRecord->pFunction (pNotificationRecord->pUserData, ##__VA_ARGS__);\
278
 
                        pElement = pNextElement; } }\
279
 
        } while (0)
280
 
 
281
 
/** Broadcast a notification.
282
 
*@param iNotifType type of the notification.
283
 
*@param ... parameters to be passed to the callbacks that has registerd to this notification.
284
 
*/
285
 
#define cairo_dock_notify(iNotifType, ...) do {\
286
 
        gboolean bStop = FALSE;\
287
 
        GSList *pNotificationRecordList = cairo_dock_get_notifications_list (iNotifType);\
288
 
        _cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);\
289
 
        } while (0)
290
 
 
291
 
/** Broadcast a notification from a given icon.
292
 
*@param pIcon the icon.
293
 
*@param iNotifType type of the notification.
294
 
*@param ... parameters to be passed to the callbacks that has registerd to this notification.
295
 
*/
296
 
#define cairo_dock_notify_on_icon(pIcon, iNotifType, ...) do {\
297
 
        gboolean bStop = FALSE;\
298
 
        GSList *pNotificationRecordList = cairo_dock_get_notifications_list (iNotifType);\
299
 
        _cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);\
300
 
        if (pIcon && pIcon->pNotificationsTab) {\
301
 
                GSList *pNotificationRecordList = g_ptr_array_index (pIcon->pNotificationsTab, iNotifType);\
302
 
                _cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);}\
303
 
        } while (0)
304
 
 
305
 
/** Broadcast a notification form a given container.
306
 
*@param pContainer the container.
307
 
*@param iNotifType type of the notification.
308
 
*@param ... parameters to be passed to the callbacks that has registerd to this notification.
309
 
*/
310
 
#define cairo_dock_notify_on_container(pContainer, iNotifType, ...) do {\
311
 
        gboolean bStop = FALSE;\
312
 
        GSList *pNotificationRecordList = cairo_dock_get_notifications_list (iNotifType);\
313
 
        _cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);\
314
 
        if (pContainer && pContainer->pNotificationsTab) {\
315
 
                GSList *pNotificationRecordList = g_ptr_array_index (pContainer->pNotificationsTab, iNotifType);\
316
 
                _cairo_dock_notify(pNotificationRecordList, bStop, ##__VA_ARGS__);}\
317
 
        } while (0)
318
 
 
319
 
 
320
 
void cairo_dock_free_notification_table (GPtrArray *pNotificationsTab);
321
 
 
322
 
 
323
 
G_END_DECLS
324
 
#endif