~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-desklet-factory.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • 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
** Login : <ctaf42@gmail.com>
 
3
** Started on  Sun Jan 27 18:35:38 2008 Cedric GESTES
 
4
** $Id$
 
5
**
 
6
** Author(s)
 
7
**  - Cedric GESTES <ctaf42@gmail.com>
 
8
**  - Fabrice REY
 
9
**
 
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.
 
15
**
 
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.
 
20
**
 
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
 
24
*/
 
25
 
 
26
#ifndef __CAIRO_DESKLET_FACTORY_H__
 
27
#define  __CAIRO_DESKLET_FACTORY_H__
 
28
 
 
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"
 
33
G_BEGIN_DECLS
 
34
 
 
35
 
 
36
/**
 
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.
 
41
*/
 
42
 
 
43
/// Type of accessibility of a Desklet.
 
44
typedef enum {
 
45
        /// Normal, like normal window
 
46
        CAIRO_DESKLET_NORMAL = 0,
 
47
        /// always above
 
48
        CAIRO_DESKLET_KEEP_ABOVE,
 
49
        /// always below
 
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;
 
56
 
 
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;
 
65
        gint iLeftMargin;
 
66
        gint iTopMargin;
 
67
        gint iRightMargin;
 
68
        gint iBottomMargin;
 
69
        };
 
70
 
 
71
/// Configuration attributes of a Desklet.
 
72
struct _CairoDeskletAttribute {
 
73
        gboolean bDeskletUseSize;
 
74
        gint iDeskletWidth;
 
75
        gint iDeskletHeight;
 
76
        gint iDeskletPositionX;
 
77
        gint iDeskletPositionY;
 
78
        gboolean bPositionLocked;
 
79
        gint iRotation;
 
80
        gint iDepthRotationY;
 
81
        gint iDepthRotationX;
 
82
        gchar *cDecorationTheme;
 
83
        CairoDeskletDecoration *pUserDecoration;
 
84
        CairoDeskletVisibility iVisibility;
 
85
        gboolean bOnAllDesktops;
 
86
        gint iNumDesktop;
 
87
        gboolean bNoInput;
 
88
} ;
 
89
 
 
90
typedef gpointer CairoDeskletRendererDataParameter;
 
91
typedef CairoDeskletRendererDataParameter* CairoDeskletRendererDataPtr;
 
92
typedef gpointer CairoDeskletRendererConfigParameter;
 
93
typedef CairoDeskletRendererConfigParameter* CairoDeskletRendererConfigPtr;
 
94
typedef struct {
 
95
        gchar *cName;
 
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;
 
125
};
 
126
 
 
127
 
 
128
/// Definition of a Desklet, which derives from a Container.
 
129
struct _CairoDesklet {
 
130
        //\________________ Core
 
131
        // container
 
132
        CairoContainer container;
 
133
        // L'icone de l'applet.
 
134
        Icon *pIcon;
 
135
        // Liste eventuelle d'icones placees sur le desklet, et susceptibles de recevoir des clics.
 
136
        GList *icons;
 
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;
 
145
        
 
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;
 
155
        
 
156
        //\________________ properties.
 
157
        gdouble fRotation;  // rotation.
 
158
        gdouble fDepthRotationY;
 
159
        gdouble fDepthRotationX;
 
160
        gboolean bFixedAttitude;
 
161
        gboolean bAllowNoClickable;
 
162
        gboolean bNoInput;
 
163
        GtkWidget *pInteractiveWidget;
 
164
        gboolean bPositionLocked;  // TRUE ssi on ne peut pas deplacer le widget a l'aide du simple clic gauche.
 
165
        
 
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).
 
175
        GTimer *pUnmapTimer;
 
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.
 
179
        
 
180
        //\________________ current state
 
181
        gboolean rotatingY;
 
182
        gboolean rotatingX;
 
183
        gboolean rotating;
 
184
        gboolean retaching;  // rattachement au dock.
 
185
        gboolean making_transparent;  // no input.
 
186
        gboolean moving;  // pour le deplacement manuel de la fenetre.
 
187
        gboolean bClicked;
 
188
        guint time;  // date du clic.
 
189
};
 
190
 
 
191
/** Say if a Container is a Desklet.
 
192
*@param pContainer the container.
 
193
*@return TRUE if the container is a desklet.
 
194
*/
 
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.
 
199
*/
 
200
#define CAIRO_DESKLET(pContainer) ((CairoDesklet *)pContainer)
 
201
 
 
202
#define cairo_dock_desklet_is_free(pDesklet) (! (pDesklet->bPositionLocked || pDesklet->bFixedAttitude))
 
203
 
 
204
 
 
205
/** Create a simple desklet container. This function should NOT be used directly.
 
206
*@return the newly allocated desklet.
 
207
*/
 
208
CairoDesklet *cairo_dock_new_desklet (void);
 
209
 
 
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.
 
212
*/
 
213
void cairo_dock_free_desklet (CairoDesklet *pDesklet);
 
214
 
 
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.
 
219
*/
 
220
void cairo_dock_configure_desklet (CairoDesklet *pDesklet, CairoDeskletAttribute *pAttribute);
 
221
 
 
222
#define cairo_dock_set_static_desklet(pDesklet) (pDesklet)->bFixedAttitude = TRUE
 
223
 
 
224
#define cairo_dock_allow_no_clickable_desklet(pDesklet) (pDesklet)->bAllowNoClickable = TRUE
 
225
 
 
226
void cairo_dock_load_desklet_decorations (CairoDesklet *pDesklet);
 
227
 
 
228
void cairo_dock_free_desklet_decoration (CairoDeskletDecoration *pDecoration);
 
229
 
 
230
 
 
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.
 
235
*/
 
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.
 
240
*/
 
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.
 
245
*/
 
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.
 
249
*@return the widget.
 
250
*/
 
251
GtkWidget *cairo_dock_steal_interactive_widget_from_desklet (CairoDesklet *pDesklet);
 
252
 
 
253
 
 
254
/** Hide a desklet.
 
255
*@param pDesklet the desklet.
 
256
*/
 
257
void cairo_dock_hide_desklet (CairoDesklet *pDesklet);
 
258
/** Show a desklet, and give it the focus.
 
259
*@param pDesklet the desklet.
 
260
*/
 
261
void cairo_dock_show_desklet (CairoDesklet *pDesklet);
 
262
 
 
263
/** Launch a "zoom out" animation on a desklet.
 
264
*@param pDesklet the desklet.
 
265
*/
 
266
void cairo_dock_zoom_out_desklet (CairoDesklet *pDesklet);
 
267
 
 
268
 
 
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.
 
273
*/
 
274
void cairo_dock_set_desklet_accessibility (CairoDesklet *pDesklet, CairoDeskletVisibility iVisibility, gboolean bSaveState);
 
275
 
 
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.
 
279
*/
 
280
void cairo_dock_set_desklet_sticky (CairoDesklet *pDesklet, gboolean bSticky);
 
281
 
 
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.
 
285
*/
 
286
void cairo_dock_lock_desklet_position (CairoDesklet *pDesklet, gboolean bPositionLocked);
 
287
 
 
288
 
 
289
void cairo_dock_update_desklet_icons (CairoDesklet *pDesklet);
 
290
 
 
291
void cairo_dock_insert_icon_in_desklet (Icon *icon, CairoDesklet *pDesklet);
 
292
 
 
293
gboolean cairo_dock_detach_icon_from_desklet (Icon *icon, CairoDesklet *pDesklet);
 
294
 
 
295
 
 
296
G_END_DECLS
 
297
 
 
298
#endif