2
** Login : <ctaf42@gmail.com>
3
** Started on Sun Jan 27 18:35:38 2008 Cedric GESTES
7
** - Cedric GESTES <ctaf42@gmail.com>
10
** Copyright (C) 2008 Cedric GESTES
11
** This program is free software; you can redistribute it and/or modify
12
** it under the terms of the GNU General Public License as published by
13
** the Free Software Foundation; either version 3 of the License, or
14
** (at your option) any later version.
16
** This program is distributed in the hope that it will be useful,
17
** but WITHOUT ANY WARRANTY; without even the implied warranty of
18
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
** GNU General Public License for more details.
21
** You should have received a copy of the GNU General Public License
22
** along with this program; if not, write to the Free Software
23
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
#ifndef __CAIRO_DESKLET_H__
27
#define __CAIRO_DESKLET_H__
29
#include "cairo-dock-struct.h"
30
#include "cairo-dock-surface-factory.h"
31
#include "cairo-dock-load.h"
32
#include "cairo-dock-container.h"
37
*@file cairo-dock-desklet.h This class defines the Desklets, that are Widgets placed directly on your desktop.
38
* A Desklet is a container that holds 1 applet's icon plus an optionnal list of other icons and an optionnal GTK widget, has a decoration, suports several accessibility types (like Compiz Widget Layer), and has a renderer.
39
* Desklets can be resized or moved directly with the mouse, and can be rotated in the 3 directions of space.
42
/// Type of accessibility of a Desklet.
44
/// Normal, like normal window
45
CAIRO_DESKLET_NORMAL = 0,
47
CAIRO_DESKLET_KEEP_ABOVE,
49
CAIRO_DESKLET_KEEP_BELOW,
50
/// on the Compiz widget layer
51
CAIRO_DESKLET_ON_WIDGET_LAYER,
52
/// prevent other windows form overlapping it
53
CAIRO_DESKLET_RESERVE_SPACE
54
} CairoDeskletAccessibility;
56
/// Decoration of a Desklet.
57
struct _CairoDeskletDecoration {
58
const gchar *cDisplayedName;
59
gchar *cBackGroundImagePath;
60
gchar *cForeGroundImagePath;
61
CairoDockLoadImageModifier iLoadingModifier;
62
gdouble fBackGroundAlpha;
63
gdouble fForeGroundAlpha;
70
/// Configuration attributes of a Desklet.
71
struct _CairoDeskletAttribute {
72
gboolean bDeskletUseSize;
75
gint iDeskletPositionX;
76
gint iDeskletPositionY;
77
gboolean bPositionLocked;
81
gchar *cDecorationTheme;
82
CairoDeskletDecoration *pUserDecoration;
83
CairoDeskletAccessibility iAccessibility;
84
gboolean bOnAllDesktops;
89
typedef gpointer CairoDeskletRendererDataParameter;
90
typedef CairoDeskletRendererDataParameter* CairoDeskletRendererDataPtr;
91
typedef gpointer CairoDeskletRendererConfigParameter;
92
typedef CairoDeskletRendererConfigParameter* CairoDeskletRendererConfigPtr;
95
CairoDeskletRendererConfigPtr pConfig;
96
} CairoDeskletRendererPreDefinedConfig;
97
typedef void (* CairoDeskletRenderFunc) (cairo_t *pCairoContext, CairoDesklet *pDesklet);
98
typedef void (*CairoDeskletGLRenderFunc) (CairoDesklet *pDesklet);
99
typedef gpointer (* CairoDeskletConfigureRendererFunc) (CairoDesklet *pDesklet, cairo_t *pSourceContext, CairoDeskletRendererConfigPtr pConfig);
100
typedef void (* CairoDeskletLoadRendererDataFunc) (CairoDesklet *pDesklet, cairo_t *pSourceContext);
101
typedef void (* CairoDeskletUpdateRendererDataFunc) (CairoDesklet *pDesklet, CairoDeskletRendererDataPtr pNewData);
102
typedef void (* CairoDeskletFreeRendererDataFunc) (CairoDesklet *pDesklet);
103
typedef void (* CairoDeskletLoadIconsFunc) (CairoDesklet *pDesklet, cairo_t *pSourceContext);
104
/// Definition of a Desklet's renderer.
105
struct _CairoDeskletRenderer {
106
/// rendering function with libcairo.
107
CairoDeskletRenderFunc render;
108
/// rendering function with OpenGL.
109
CairoDeskletGLRenderFunc render_opengl;
110
/// get the configuration of the renderer from a set of config attributes.
111
CairoDeskletConfigureRendererFunc configure;
112
/// load the internal data of the renderer.
113
CairoDeskletLoadRendererDataFunc load_data;
114
/// free all internal data of the renderer.
115
CairoDeskletFreeRendererDataFunc free_data;
116
/// define the icons' size and load them.
117
CairoDeskletLoadIconsFunc load_icons;
118
/// function called on each iteration of the rendering loop.
119
CairoDeskletUpdateRendererDataFunc update;
120
/// optionnal rendering function with OpenGL that only draws the bounding boxes of the icons (for picking).
121
CairoDeskletGLRenderFunc render_bounding_box;
122
/// An optionnal list of preset configs.
123
GList *pPreDefinedConfigList;
127
/// Definition of a Desklet, which derives from a Container.
128
struct _CairoDesklet {
129
//\________________ Core
131
CairoContainer container;
132
// L'icone de l'applet.
134
// Liste eventuelle d'icones placees sur le desklet, et susceptibles de recevoir des clics.
136
// le moteur de rendu utilise pour dessiner le desklet.
137
CairoDeskletRenderer *pRenderer;
138
// donnees pouvant etre utilisees par le moteur de rendu.
139
gpointer pRendererData;
140
// The following function outclasses the corresponding function of the renderer. This is useful if you don't want to pick icons but some elements that you draw yourself on the desklet.
141
CairoDeskletGLRenderFunc render_bounding_box;
142
// ID of the object that was picked in case the previous function is not null.
143
GLuint iPickedObject;
145
//\________________ decorations
146
gchar *cDecorationTheme;
147
CairoDeskletDecoration *pUserDecoration;
148
gint iLeftSurfaceOffset;
149
gint iTopSurfaceOffset;
150
gint iRightSurfaceOffset;
151
gint iBottomSurfaceOffset;
152
CairoDockImageBuffer backGroundImageBuffer;
153
CairoDockImageBuffer foreGroundImageBuffer;
154
cairo_surface_t *pBackGroundSurface;
155
cairo_surface_t *pForeGroundSurface;
156
GLuint iBackGroundTexture;
157
GLuint iForeGroundTexture;
159
gdouble fImageHeight;
160
gdouble fBackGroundAlpha;
161
gdouble fForeGroundAlpha;
163
//\________________ properties.
164
gdouble fRotation; // rotation.
165
gdouble fDepthRotationY;
166
gdouble fDepthRotationX;
167
gboolean bFixedAttitude;
169
GtkWidget *pInteractiveWidget;
170
gboolean bPositionLocked; // TRUE ssi on ne peut pas deplacer le widget a l'aide du simple clic gauche.
172
//\________________ internal
173
gint iSidWritePosition; // un timer pour retarder l'ecriture dans le fichier lors des deplacements.
174
gint iSidWriteSize; // un timer pour retarder l'ecriture dans le fichier lors des redimensionnements.
175
gint iGradationCount; // compteur pour le fondu lors de l'entree dans le desklet.
176
gint iSidGradationOnEnter; // timer associe.
177
gint iSidGrowUp; // un timer pour faire apparaitre le desklet avec un effet de zoom lors du detachage d'une applet.
178
gint iDesiredWidth, iDesiredHeight; // taille a atteindre (fixee par l'utilisateur dans le.conf)
179
gint iKnownWidth, iKnownHeight; // taille connue par l'applet associee.
180
gboolean bSpaceReserved; // l'espace est actuellement reserve.
181
gboolean bAllowMinimize; // TRUE to allow the desklet to be minimized once. The flag is reseted to FALSE after the desklet has minimized.
182
gint iMouseX2d; // X position of the pointer taking into account the 2D transformations on the desklet (for an opengl renderer, you'll have to use the picking).
183
gint iMouseY2d; // Y position of the pointer taking into account the 2D transformations on the desklet (for an opengl renderer, you'll have to use the picking).
186
//\________________ current state
190
gboolean retaching; // rattachement au dock.
191
gboolean making_transparent; // no input.
192
gboolean moving; // pour le deplacement manuel de la fenetre.
194
guint time; // date du clic.
197
/// Definition of a function that runs through all desklets.
198
typedef gboolean (* CairoDockForeachDeskletFunc) (CairoDesklet *pDesklet, CairoDockModuleInstance *pInstance, gpointer data);
201
/** Say if a Container is a desklet.
202
*@param pContainer the container.
203
*@return TRUE if the container is a desklet.
205
#define CAIRO_DOCK_IS_DESKLET(pContainer) (pContainer != NULL && CAIRO_CONTAINER(pContainer)->iType == CAIRO_DOCK_TYPE_DESKLET)
207
* Cast a Container into a Desklet.
208
*@param pContainer the container.
209
*@return the desklet.
211
#define CAIRO_DESKLET(pContainer) ((CairoDesklet *)pContainer)
213
void cairo_dock_init_desklet_manager (void);
214
void cairo_dock_load_desklet_buttons (void);
215
void cairo_dock_unload_desklet_buttons (void);
217
void cairo_dock_reload_desklets_decorations (gboolean bDefaultThemeOnly, cairo_t *pSourceContext);
218
void cairo_dock_free_desklet_decoration (CairoDeskletDecoration *pDecoration);
221
gboolean cairo_dock_render_desklet_notification (gpointer pUserData, CairoDesklet *pDesklet, cairo_t *pCairoContext);
223
/** Create a simple desklet, without placing it nor defining a renderer.
224
*@param pIcon the main icon.
225
*@param pInteractiveWidget an optionnal GTK widget, or NULL if none.
226
*@param iAccessibility accessibility of the desklet, needed to know if it should be placed on the WidgetLayer or if it should reserve its space.
227
*@return the newly allocated desklet.
229
CairoDesklet *cairo_dock_create_desklet (Icon *pIcon, GtkWidget *pInteractiveWidget, CairoDeskletAccessibility iAccessibility);
231
/** Configure a un desklet.
232
* It places it, resizes it, sets up its accessibility, locks its position, and sets up its decorations.
233
*@param pDesklet the desklet.
234
*@param pAttribute the attributes to configure the desklet.
236
void cairo_dock_configure_desklet (CairoDesklet *pDesklet, CairoDeskletAttribute *pAttribute);
238
/** Destroy a desklet, and free all the allocated ressources. The interactive widget is removed before, and can be inserted anywhere after that.
239
*@param pDesklet the desklet to destroy.
241
void cairo_dock_free_desklet (CairoDesklet *pDesklet);
244
/** Add a GtkWidget to a desklet. Only 1 widget is allowed per desklet, if you need more, you can just use a GtkContainer, and place as many widget as you want inside.
245
*@param pInteractiveWidget the widget to add.
246
*@param pDesklet the desklet.
247
*@param iRightMargin right margin, in pixels, useful to keep a clickable zone on the desklet, or 0 if you don't want a margin.
249
void cairo_dock_add_interactive_widget_to_desklet_full (GtkWidget *pInteractiveWidget, CairoDesklet *pDesklet, int iRightMargin);
250
/** Add a GtkWidget to a desklet. Only 1 widget is allowed per desklet, if you need more, you can just use a GtkContainer, and place as many widget as you want inside.
251
*@param pInteractiveWidget the widget to add.
252
*@param pDesklet the desklet.
254
#define cairo_dock_add_interactive_widget_to_desklet(pInteractiveWidget, pDesklet) cairo_dock_add_interactive_widget_to_desklet_full (pInteractiveWidget, pDesklet, 0)
255
/** Sezt the right margin of a desklet. This is useful to keep a clickable zone on the desklet when you put a GTK widget inside.
256
*@param pDesklet the desklet.
257
*@param iRightMargin right margin, in pixels.
259
void cairo_dock_set_desklet_margin (CairoDesklet *pDesklet, int iRightMargin);
261
/** Detach the interactive widget from a desklet. The widget can then be placed anywhere after that. You have to unref it after you placed it into a container, or to destroy it.
262
*@param pDesklet the desklet with an interactive widget.
265
GtkWidget *cairo_dock_steal_interactive_widget_from_desklet (CairoDesklet *pDesklet);
268
/** Find the currently pointed icon in a desklet, taking into account the 3D rotations.
269
*@param pDesklet the desklet.
270
*@return the pointed icon, or NULL if none.
272
Icon *cairo_dock_find_clicked_icon_in_desklet (CairoDesklet *pDesklet);
276
*@param pDesklet the desklet.
278
void cairo_dock_hide_desklet (CairoDesklet *pDesklet);
280
* Show a desklet, and give it the focus.
281
*@param pDesklet the desklet.
283
void cairo_dock_show_desklet (CairoDesklet *pDesklet);
285
/** Make all desklets visible. Their accessibility is set to #CAIRO_DESKLET_NORMAL.
286
*@param bOnWidgetLayerToo TRUE if you want to act on the desklet that are on the WidgetLayer as well.
288
void cairo_dock_set_all_desklets_visible (gboolean bOnWidgetLayerToo);
289
/** Reset the desklets accessibility to the state defined in their conf file.
291
void cairo_dock_set_desklets_visibility_to_default (void);
293
/** Get the desklet whose X ID matches the given one.
295
*@return the desklet that matches, or NULL if none match.
297
CairoDesklet *cairo_dock_get_desklet_by_Xid (Window Xid);
299
/** Launch a "zoom out" animation on a desklet.
300
*@param pDesklet the desklet.
302
void cairo_dock_zoom_out_desklet (CairoDesklet *pDesklet);
305
#define cairo_dock_set_static_desklet(pDesklet) (pDesklet)->bFixedAttitude = TRUE
308
void cairo_dock_reserve_space_for_desklet (CairoDesklet *pDesklet, gboolean bReserve);