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_FACTORY_H__
27
#define __CAIRO_DESKLET_FACTORY_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-factory.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.
40
* To actually create or destroy a Desklet, use the Desklet Manager's functoins in \ref cairo-dock-desklet-manager.h.
43
/// Type of accessibility of a Desklet.
45
/// Normal, like normal window
46
CAIRO_DESKLET_NORMAL = 0,
48
CAIRO_DESKLET_KEEP_ABOVE,
50
CAIRO_DESKLET_KEEP_BELOW,
51
/// on the Compiz widget layer
52
CAIRO_DESKLET_ON_WIDGET_LAYER,
53
/// prevent other windows form overlapping it
54
CAIRO_DESKLET_RESERVE_SPACE
55
} CairoDeskletVisibility;
57
/// Decoration of a Desklet.
58
struct _CairoDeskletDecoration {
59
const gchar *cDisplayedName;
60
gchar *cBackGroundImagePath;
61
gchar *cForeGroundImagePath;
62
CairoDockLoadImageModifier iLoadingModifier;
63
gdouble fBackGroundAlpha;
64
gdouble fForeGroundAlpha;
71
/// Configuration attributes of a Desklet.
72
struct _CairoDeskletAttribute {
73
gboolean bDeskletUseSize;
76
gint iDeskletPositionX;
77
gint iDeskletPositionY;
78
gboolean bPositionLocked;
82
gchar *cDecorationTheme;
83
CairoDeskletDecoration *pUserDecoration;
84
CairoDeskletVisibility iVisibility;
85
gboolean bOnAllDesktops;
90
typedef gpointer CairoDeskletRendererDataParameter;
91
typedef CairoDeskletRendererDataParameter* CairoDeskletRendererDataPtr;
92
typedef gpointer CairoDeskletRendererConfigParameter;
93
typedef CairoDeskletRendererConfigParameter* CairoDeskletRendererConfigPtr;
96
CairoDeskletRendererConfigPtr pConfig;
97
} CairoDeskletRendererPreDefinedConfig;
98
typedef void (* CairoDeskletRenderFunc) (cairo_t *pCairoContext, CairoDesklet *pDesklet);
99
typedef void (*CairoDeskletGLRenderFunc) (CairoDesklet *pDesklet);
100
typedef gpointer (* CairoDeskletConfigureRendererFunc) (CairoDesklet *pDesklet, CairoDeskletRendererConfigPtr pConfig);
101
typedef void (* CairoDeskletLoadRendererDataFunc) (CairoDesklet *pDesklet);
102
typedef void (* CairoDeskletUpdateRendererDataFunc) (CairoDesklet *pDesklet, CairoDeskletRendererDataPtr pNewData);
103
typedef void (* CairoDeskletFreeRendererDataFunc) (CairoDesklet *pDesklet);
104
typedef void (* CairoDeskletCalculateIconsFunc) (CairoDesklet *pDesklet);
105
/// Definition of a Desklet's renderer.
106
struct _CairoDeskletRenderer {
107
/// rendering function with libcairo.
108
CairoDeskletRenderFunc render;
109
/// rendering function with OpenGL.
110
CairoDeskletGLRenderFunc render_opengl;
111
/// get the configuration of the renderer from a set of config attributes.
112
CairoDeskletConfigureRendererFunc configure;
113
/// load the internal data of the renderer.
114
CairoDeskletLoadRendererDataFunc load_data;
115
/// free all internal data of the renderer.
116
CairoDeskletFreeRendererDataFunc free_data;
117
/// define the icons' size and load them.
118
CairoDeskletCalculateIconsFunc calculate_icons;
119
/// function called on each iteration of the rendering loop.
120
CairoDeskletUpdateRendererDataFunc update;
121
/// optionnal rendering function with OpenGL that only draws the bounding boxes of the icons (for picking).
122
CairoDeskletGLRenderFunc render_bounding_box;
123
/// An optionnal list of preset configs.
124
GList *pPreDefinedConfigList;
128
/// Definition of a Desklet, which derives from a Container.
129
struct _CairoDesklet {
130
//\________________ Core
132
CairoContainer container;
133
// L'icone de l'applet.
135
// Liste eventuelle d'icones placees sur le desklet, et susceptibles de recevoir des clics.
137
// le moteur de rendu utilise pour dessiner le desklet.
138
CairoDeskletRenderer *pRenderer;
139
// donnees pouvant etre utilisees par le moteur de rendu.
140
gpointer pRendererData;
141
// 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.
142
CairoDeskletGLRenderFunc render_bounding_box;
143
// ID of the object that was picked in case the previous function is not null.
144
GLuint iPickedObject;
146
//\________________ decorations
147
gchar *cDecorationTheme;
148
CairoDeskletDecoration *pUserDecoration;
149
gint iLeftSurfaceOffset;
150
gint iTopSurfaceOffset;
151
gint iRightSurfaceOffset;
152
gint iBottomSurfaceOffset;
153
CairoDockImageBuffer backGroundImageBuffer;
154
CairoDockImageBuffer foreGroundImageBuffer;
156
//\________________ properties.
157
gdouble fRotation; // rotation.
158
gdouble fDepthRotationY;
159
gdouble fDepthRotationX;
160
gboolean bFixedAttitude;
161
gboolean bAllowNoClickable;
163
GtkWidget *pInteractiveWidget;
164
gboolean bPositionLocked; // TRUE ssi on ne peut pas deplacer le widget a l'aide du simple clic gauche.
166
//\________________ internal
167
gint iSidWritePosition; // un timer pour retarder l'ecriture dans le fichier lors des deplacements.
168
gint iSidWriteSize; // un timer pour retarder l'ecriture dans le fichier lors des redimensionnements.
169
gint iDesiredWidth, iDesiredHeight; // taille a atteindre (fixee par l'utilisateur dans le.conf)
170
gint iKnownWidth, iKnownHeight; // taille connue par l'applet associee.
171
gboolean bSpaceReserved; // l'espace est actuellement reserve.
172
gboolean bAllowMinimize; // TRUE to allow the desklet to be minimized once. The flag is reseted to FALSE after the desklet has minimized.
173
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).
174
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).
176
gdouble fButtonsAlpha; // pour le fondu des boutons lors de l'entree dans le desklet.
177
gboolean bButtonsApparition; // si les boutons sont en train d'apparaitre ou de disparaitre.
178
gboolean bGrowingUp; // pour le zoom initial.
180
//\________________ current state
184
gboolean retaching; // rattachement au dock.
185
gboolean making_transparent; // no input.
186
gboolean moving; // pour le deplacement manuel de la fenetre.
188
guint time; // date du clic.
191
/** Say if a Container is a Desklet.
192
*@param pContainer the container.
193
*@return TRUE if the container is a desklet.
195
#define CAIRO_DOCK_IS_DESKLET(pContainer) (pContainer != NULL && CAIRO_CONTAINER(pContainer)->iType == CAIRO_DOCK_TYPE_DESKLET)
196
/** Cast a Container into a Desklet.
197
*@param pContainer the container.
198
*@return the desklet.
200
#define CAIRO_DESKLET(pContainer) ((CairoDesklet *)pContainer)
202
#define cairo_dock_desklet_is_free(pDesklet) (! (pDesklet->bPositionLocked || pDesklet->bFixedAttitude))
205
/** Create a simple desklet container. This function should NOT be used directly.
206
*@return the newly allocated desklet.
208
CairoDesklet *cairo_dock_new_desklet (void);
210
/** Destroy a desklet, and free all the allocated ressources. The interactive widget is removed before, and can be inserted anywhere after that. This function should NOT be used directly.
211
*@param pDesklet the desklet to destroy.
213
void cairo_dock_free_desklet (CairoDesklet *pDesklet);
215
/** Configure a un desklet.
216
* It places it, resizes it, sets up its accessibility, locks its position, and sets up its decorations.
217
*@param pDesklet the desklet.
218
*@param pAttribute the attributes to configure the desklet.
220
void cairo_dock_configure_desklet (CairoDesklet *pDesklet, CairoDeskletAttribute *pAttribute);
222
#define cairo_dock_set_static_desklet(pDesklet) (pDesklet)->bFixedAttitude = TRUE
224
#define cairo_dock_allow_no_clickable_desklet(pDesklet) (pDesklet)->bAllowNoClickable = TRUE
226
void cairo_dock_load_desklet_decorations (CairoDesklet *pDesklet);
228
void cairo_dock_free_desklet_decoration (CairoDeskletDecoration *pDecoration);
231
/** 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.
232
*@param pInteractiveWidget the widget to add.
233
*@param pDesklet the desklet.
234
*@param iRightMargin right margin, in pixels, useful to keep a clickable zone on the desklet, or 0 if you don't want a margin.
236
void cairo_dock_add_interactive_widget_to_desklet_full (GtkWidget *pInteractiveWidget, CairoDesklet *pDesklet, int iRightMargin);
237
/** 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.
238
*@param pInteractiveWidget the widget to add.
239
*@param pDesklet the desklet.
241
#define cairo_dock_add_interactive_widget_to_desklet(pInteractiveWidget, pDesklet) cairo_dock_add_interactive_widget_to_desklet_full (pInteractiveWidget, pDesklet, 0)
242
/** 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.
243
*@param pDesklet the desklet.
244
*@param iRightMargin right margin, in pixels.
246
void cairo_dock_set_desklet_margin (CairoDesklet *pDesklet, int iRightMargin);
247
/** 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.
248
*@param pDesklet the desklet with an interactive widget.
251
GtkWidget *cairo_dock_steal_interactive_widget_from_desklet (CairoDesklet *pDesklet);
255
*@param pDesklet the desklet.
257
void cairo_dock_hide_desklet (CairoDesklet *pDesklet);
258
/** Show a desklet, and give it the focus.
259
*@param pDesklet the desklet.
261
void cairo_dock_show_desklet (CairoDesklet *pDesklet);
263
/** Launch a "zoom out" animation on a desklet.
264
*@param pDesklet the desklet.
266
void cairo_dock_zoom_out_desklet (CairoDesklet *pDesklet);
269
/** Set a desklet's accessibility. For Widget Layer, the WM must support it and the correct rule must be set up in the WM (for instance for Compiz : class=Cairo-dock & type=utility). The function automatically sets up the rule for Compiz (if Dbus is activated).
270
*@param pDesklet the desklet.
271
*@param iVisibility the new accessibility.
272
*@param bSaveState whether to save the new state in the conf file.
274
void cairo_dock_set_desklet_accessibility (CairoDesklet *pDesklet, CairoDeskletVisibility iVisibility, gboolean bSaveState);
276
/** Set a desklet sticky (i.e. visible on all desktops), or not. In case the desklet is set unsticky, its current desktop/viewport is saved.
277
*@param pDesklet the desklet.
278
*@param bSticky whether the desklet should be sticky or not.
280
void cairo_dock_set_desklet_sticky (CairoDesklet *pDesklet, gboolean bSticky);
282
/** Lock the position of a desklet. This makes the desklet impossible to rotate, drag with the mouse, or retach to the dock. The new state is saved in conf.
283
*@param pDesklet the desklet.
284
*@param bPositionLocked whether the position should be locked or not.
286
void cairo_dock_lock_desklet_position (CairoDesklet *pDesklet, gboolean bPositionLocked);
289
void cairo_dock_update_desklet_icons (CairoDesklet *pDesklet);
291
void cairo_dock_insert_icon_in_desklet (Icon *icon, CairoDesklet *pDesklet);
293
gboolean cairo_dock_detach_icon_from_desklet (Icon *icon, CairoDesklet *pDesklet);