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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100809232612-yp4c6ig3jt1bzpdv
Tags: 2.2.0~0beta4-0ubuntu1
* New Upstream Version (LP: #614624)
* Fixed a few bugs on LP:
 - LP: #518453: Dock appears under all windows
                 (Compiz - fullscreen window)
 - LP: #521369: Separator are not removed when closing
                 grouped windows
 - LP: #521762: Some sentences are not correct
 - LP: #526466: Icons of apps with same class shouldn't
                 be stacked by default
 - LP: #535083: Dialogues looks ugly when a lot of them
                 appears at the same time
 - More details on the 'ChangeLog' file
* debian/rules:
 - Autotools has been replaced by CMake
 - Man pages are now included in the source code
* debian/copyright:
 - Updated with the new pathes and new files
* debian/control:
 - Autotools has been replaced by CMake
 - Added libcurl4-gnutls-dev as Build-deps
 - Bump Standard-Version to 3.9.1
* debian/cairo-dock-core.install:
 - Man pages are now included in the source code
 - All sonames are now installed into lib32 or lib64
* debian/cairo-dock-dev.install:
 - pkgconfig is now installed into lib32 or lib64

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_H__
27
 
#define  __CAIRO_DESKLET_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.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
 
*/
41
 
 
42
 
/// Type of accessibility of a Desklet.
43
 
typedef enum {
44
 
        /// Normal, like normal window
45
 
        CAIRO_DESKLET_NORMAL = 0,
46
 
        /// always above
47
 
        CAIRO_DESKLET_KEEP_ABOVE,
48
 
        /// always below
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;
55
 
 
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;
64
 
        gint iLeftMargin;
65
 
        gint iTopMargin;
66
 
        gint iRightMargin;
67
 
        gint iBottomMargin;
68
 
        };
69
 
 
70
 
/// Configuration attributes of a Desklet.
71
 
struct _CairoDeskletAttribute {
72
 
        gboolean bDeskletUseSize;
73
 
        gint iDeskletWidth;
74
 
        gint iDeskletHeight;
75
 
        gint iDeskletPositionX;
76
 
        gint iDeskletPositionY;
77
 
        gboolean bPositionLocked;
78
 
        gint iRotation;
79
 
        gint iDepthRotationY;
80
 
        gint iDepthRotationX;
81
 
        gchar *cDecorationTheme;
82
 
        CairoDeskletDecoration *pUserDecoration;
83
 
        CairoDeskletAccessibility iAccessibility;
84
 
        gboolean bOnAllDesktops;
85
 
        gint iNumDesktop;
86
 
        gboolean bNoInput;
87
 
} ;
88
 
 
89
 
typedef gpointer CairoDeskletRendererDataParameter;
90
 
typedef CairoDeskletRendererDataParameter* CairoDeskletRendererDataPtr;
91
 
typedef gpointer CairoDeskletRendererConfigParameter;
92
 
typedef CairoDeskletRendererConfigParameter* CairoDeskletRendererConfigPtr;
93
 
typedef struct {
94
 
        gchar *cName;
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;
124
 
};
125
 
 
126
 
 
127
 
/// Definition of a Desklet, which derives from a Container.
128
 
struct _CairoDesklet {
129
 
        //\________________ Core
130
 
        // container
131
 
        CairoContainer container;
132
 
        // L'icone de l'applet.
133
 
        Icon *pIcon;
134
 
        // Liste eventuelle d'icones placees sur le desklet, et susceptibles de recevoir des clics.
135
 
        GList *icons;
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;
144
 
        
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;
158
 
        gdouble fImageWidth;
159
 
        gdouble fImageHeight;
160
 
        gdouble fBackGroundAlpha;
161
 
        gdouble fForeGroundAlpha;
162
 
        
163
 
        //\________________ properties.
164
 
        gdouble fRotation;  // rotation.
165
 
        gdouble fDepthRotationY;
166
 
        gdouble fDepthRotationX;
167
 
        gboolean bFixedAttitude;
168
 
        gboolean bNoInput;
169
 
        GtkWidget *pInteractiveWidget;
170
 
        gboolean bPositionLocked;  // TRUE ssi on ne peut pas deplacer le widget a l'aide du simple clic gauche.
171
 
        
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).
184
 
        GTimer *pUnmapTimer;
185
 
        
186
 
        //\________________ current state
187
 
        gboolean rotatingY;
188
 
        gboolean rotatingX;
189
 
        gboolean rotating;
190
 
        gboolean retaching;  // rattachement au dock.
191
 
        gboolean making_transparent;  // no input.
192
 
        gboolean moving;  // pour le deplacement manuel de la fenetre.
193
 
        gboolean bClicked;
194
 
        guint time;  // date du clic.
195
 
};
196
 
 
197
 
/// Definition of a function that runs through all desklets.
198
 
typedef gboolean (* CairoDockForeachDeskletFunc) (CairoDesklet *pDesklet, CairoDockModuleInstance *pInstance, gpointer data);
199
 
 
200
 
 
201
 
/** Say if a Container is a desklet.
202
 
*@param pContainer the container.
203
 
*@return TRUE if the container is a desklet.
204
 
*/
205
 
#define CAIRO_DOCK_IS_DESKLET(pContainer) (pContainer != NULL && CAIRO_CONTAINER(pContainer)->iType == CAIRO_DOCK_TYPE_DESKLET)
206
 
/**
207
 
* Cast a Container into a Desklet.
208
 
*@param pContainer the container.
209
 
*@return the desklet.
210
 
*/
211
 
#define CAIRO_DESKLET(pContainer) ((CairoDesklet *)pContainer)
212
 
 
213
 
void cairo_dock_init_desklet_manager (void);
214
 
void cairo_dock_load_desklet_buttons (void);
215
 
void cairo_dock_unload_desklet_buttons (void);
216
 
 
217
 
void cairo_dock_reload_desklets_decorations (gboolean bDefaultThemeOnly, cairo_t *pSourceContext);
218
 
void cairo_dock_free_desklet_decoration (CairoDeskletDecoration *pDecoration);
219
 
 
220
 
 
221
 
gboolean cairo_dock_render_desklet_notification (gpointer pUserData, CairoDesklet *pDesklet, cairo_t *pCairoContext);
222
 
 
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.
228
 
*/
229
 
CairoDesklet *cairo_dock_create_desklet (Icon *pIcon, GtkWidget *pInteractiveWidget, CairoDeskletAccessibility iAccessibility);
230
 
 
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.
235
 
*/
236
 
void cairo_dock_configure_desklet (CairoDesklet *pDesklet, CairoDeskletAttribute *pAttribute);
237
 
 
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.
240
 
*/
241
 
void cairo_dock_free_desklet (CairoDesklet *pDesklet);
242
 
 
243
 
 
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.
248
 
*/
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.
253
 
*/
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.
258
 
*/
259
 
void cairo_dock_set_desklet_margin (CairoDesklet *pDesklet, int iRightMargin);
260
 
 
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.
263
 
*@return the widget.
264
 
*/
265
 
GtkWidget *cairo_dock_steal_interactive_widget_from_desklet (CairoDesklet *pDesklet);
266
 
 
267
 
 
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.
271
 
*/
272
 
Icon *cairo_dock_find_clicked_icon_in_desklet (CairoDesklet *pDesklet);
273
 
 
274
 
 
275
 
/** Hide a desklet.
276
 
*@param pDesklet the desklet.
277
 
*/
278
 
void cairo_dock_hide_desklet (CairoDesklet *pDesklet);
279
 
/**
280
 
* Show a desklet, and give it the focus.
281
 
*@param pDesklet the desklet.
282
 
*/
283
 
void cairo_dock_show_desklet (CairoDesklet *pDesklet);
284
 
 
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.
287
 
*/
288
 
void cairo_dock_set_all_desklets_visible (gboolean bOnWidgetLayerToo);
289
 
/** Reset the desklets accessibility to the state defined in their conf file.
290
 
*/
291
 
void cairo_dock_set_desklets_visibility_to_default (void);
292
 
 
293
 
/** Get the desklet whose X ID matches the given one.
294
 
*@param Xid an X ID.
295
 
*@return the desklet that matches, or NULL if none match.
296
 
*/
297
 
CairoDesklet *cairo_dock_get_desklet_by_Xid (Window Xid);
298
 
 
299
 
/** Launch a "zoom out" animation on a desklet.
300
 
*@param pDesklet the desklet.
301
 
*/
302
 
void cairo_dock_zoom_out_desklet (CairoDesklet *pDesklet);
303
 
 
304
 
 
305
 
#define cairo_dock_set_static_desklet(pDesklet) (pDesklet)->bFixedAttitude = TRUE
306
 
 
307
 
 
308
 
void cairo_dock_reserve_space_for_desklet (CairoDesklet *pDesklet, gboolean bReserve);
309
 
 
310
 
 
311
 
G_END_DECLS
312
 
 
313
 
#endif