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

« back to all changes in this revision

Viewing changes to src/cairo-dock-dock-factory.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_FACTORY__
22
 
#define  __CAIRO_DOCK_FACTORY__
23
 
 
24
 
#include <glib.h>
25
 
 
26
 
#include "cairo-dock-struct.h"
27
 
#include "cairo-dock-container.h"
28
 
G_BEGIN_DECLS
29
 
 
30
 
/**
31
 
*@file cairo-dock-dock-factory.h This class defines the Docks, and gives the way to create, destroy, and fill them.
32
 
*
33
 
* A dock is a container that holds a set of icons and a renderer (also known as view).
34
 
*
35
 
* It has the ability to be placed anywhere on the screen edges and to resize itself automatically to fit the screen's size.
36
 
*
37
 
* It supports internal dragging of its icons with the mouse, and dragging of itself with alt+mouse.
38
 
*
39
 
* A dock can be either a main-dock (not linked to any icon) or a sub-dock (linked to an icon of another dock), and there can be as many docks of each sort as you want.
40
 
*/
41
 
 
42
 
 
43
 
typedef enum {
44
 
        CAIRO_DOCK_BOTTOM = 0,
45
 
        CAIRO_DOCK_TOP,
46
 
        CAIRO_DOCK_RIGHT,
47
 
        CAIRO_DOCK_LEFT,
48
 
        CAIRO_DOCK_INSIDE_SCREEN,
49
 
        CAIRO_DOCK_NB_POSITIONS
50
 
        } CairoDockPositionType;
51
 
 
52
 
#define CAIRO_DOCK_UPDATE_DOCK_SIZE TRUE
53
 
#define CAIRO_DOCK_ANIMATE_ICON TRUE
54
 
#define CAIRO_DOCK_INSERT_SEPARATOR TRUE
55
 
 
56
 
typedef void (*CairoDockComputeSizeFunc) (CairoDock *pDock);
57
 
typedef Icon * (*CairoDockCalculateIconsFunc) (CairoDock *pDock);
58
 
typedef void (*CairoDockRenderFunc) (cairo_t *pCairoContext, CairoDock *pDock);
59
 
typedef void (*CairoDockRenderOptimizedFunc) (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea);
60
 
typedef void (*CairoDockSetSubDockPositionFunc) (Icon *pPointedIcon, CairoDock *pParentDock);
61
 
typedef void (*CairoDockGLRenderFunc) (CairoDock *pDock);
62
 
typedef void (*CairoDockRenderFreeDataFunc) (CairoDock *pDock);
63
 
 
64
 
/// Dock's renderer, also known as 'view'.
65
 
struct _CairoDockRenderer {
66
 
        /// function that computes the sizes of a dock.
67
 
        CairoDockComputeSizeFunc compute_size;
68
 
        /// function that computes all the icons' parameters.
69
 
        CairoDockCalculateIconsFunc calculate_icons;
70
 
        /// rendering function (cairo)
71
 
        CairoDockRenderFunc render;
72
 
        /// optimized rendering function (cairo) that only redraw a part of the dock.
73
 
        CairoDockRenderOptimizedFunc render_optimized;
74
 
        /// rendering function (OpenGL, optionnal).
75
 
        CairoDockGLRenderFunc render_opengl;
76
 
        /// function that computes the position of the dock when it's a sub-dock.
77
 
        CairoDockSetSubDockPositionFunc set_subdock_position;
78
 
        /// TRUE if the view uses the OpenGL stencil buffer.
79
 
        gboolean bUseStencil;
80
 
        /// TRUE is the view uses reflects.
81
 
        gboolean bUseReflect;
82
 
        /// name displayed in the GUI (translated).
83
 
        const gchar *cDisplayedName;
84
 
        /// path to a readme file that gives a short description of the view.
85
 
        gchar *cReadmeFilePath;
86
 
        /// path to a preview image.
87
 
        gchar *cPreviewFilePath;
88
 
        /// function called when the renderer is unset from the dock.
89
 
        CairoDockRenderFreeDataFunc free_data;
90
 
};
91
 
 
92
 
typedef enum {
93
 
        CAIRO_DOCK_MOUSE_INSIDE,
94
 
        CAIRO_DOCK_MOUSE_ON_THE_EDGE,
95
 
        CAIRO_DOCK_MOUSE_OUTSIDE
96
 
        } CairoDockMousePositionType;
97
 
 
98
 
typedef enum {
99
 
        CAIRO_DOCK_INPUT_ACTIVE,
100
 
        CAIRO_DOCK_INPUT_AT_REST,
101
 
        CAIRO_DOCK_INPUT_HIDDEN
102
 
        } CairoDockInputState;
103
 
 
104
 
/// Definition of a Dock, which derives from a Container.
105
 
struct _CairoDock {
106
 
        /// container.
107
 
        CairoContainer container;
108
 
        /// the list of icons.
109
 
        GList* icons;
110
 
        /// Set to TRUE for the main dock (the first to be created, and the one containing the taskbar).
111
 
        gboolean bIsMainDock;
112
 
        /// number of icons pointing on the dock (0 means it is a root dock, >0 a sub-dock).
113
 
        gint iRefCount;
114
 
 
115
 
        //\_______________ Config parameters.
116
 
        /// ecart de la fenetre par rapport au bord de l'ecran.
117
 
        gint iGapX;
118
 
        /// decalage de la fenetre par rapport au point d'alignement sur le bord de l'ecran.
119
 
        gint iGapY;
120
 
        /// alignment, between 0 and 1, on the screen's edge.
121
 
        gdouble fAlign;
122
 
        /// whether the dock automatically hides itself or not.
123
 
        gboolean bAutoHide;
124
 
        /// Horizontal offset of the screen where the dock lives, according to Xinerama.
125
 
        gint iScreenOffsetX;
126
 
        /// Vertical offset of the screen where the dock lives, according to Xinerama.
127
 
        gint iScreenOffsetY;
128
 
        /// number of the screen the dock is placed on (Xinerama).
129
 
        gint iNumScreen;
130
 
        
131
 
        /// maximum height of the icons.
132
 
        gdouble iMaxIconHeight;
133
 
        /// width of the dock, only taking into account an alignment of the icons.
134
 
        gdouble fFlatDockWidth;
135
 
        
136
 
        gint iMaxLabelWidth;
137
 
        gint iMinLeftMargin;
138
 
        gint iMinRightMargin;
139
 
        gint iMaxLeftMargin;
140
 
        gint iMaxRightMargin;
141
 
        gint iLeftMargin;
142
 
        gint iRightMargin;
143
 
 
144
 
        //\_______________ current state of the dock.
145
 
        /// pour faire defiler les icones avec la molette.
146
 
        gint iScrollOffset;
147
 
        /// indice de calcul du coef multiplicateur de l'amplitude de la sinusoide (entre 0 et CAIRO_DOCK_NB_MAX_ITERATIONS).
148
 
        gint iMagnitudeIndex;
149
 
        /// (un)folding factor, between 0(unfolded) to 1(folded). It's up to the renderer on how to make use of it.
150
 
        gdouble fFoldingFactor;
151
 
        /// type d'icone devant eviter la souris, -1 si aucun.
152
 
        gint iAvoidingMouseIconType;
153
 
        /// marge d'evitement de la souris, en fraction de la largeur d'an icon (entre 0 et 0.5)
154
 
        gdouble fAvoidingMouseMargin;
155
 
        /// pointeur sur le 1er element de la liste des icones a etre dessine, en partant de la gauche.
156
 
        GList *pFirstDrawnElement;
157
 
        /// decalage des decorations pour les faire suivre la souris.
158
 
        gdouble fDecorationsOffsetX;
159
 
        /// counter for the fade out effect.
160
 
        gint iFadeCounter;
161
 
        /// direction of the fade out effect.
162
 
        gboolean bFadeInOut;
163
 
        /// state of the input shape.
164
 
        /// counter for auto-hide.
165
 
        gdouble fHideOffset;
166
 
        
167
 
        /// Whether the dock is in a popped up state or not.
168
 
        gboolean bPopped;
169
 
        /// whether the menu is visible (to keep the dock on high position).
170
 
        gboolean bMenuVisible;
171
 
        /// whether the user is dragging something over the dock.
172
 
        gboolean bIsDragging;
173
 
        /// Backup of the auto-hide state before quick-hide.
174
 
        gboolean bAutoHideInitialValue;
175
 
        /// whether mouse can't enter into the dock.
176
 
        gboolean bEntranceDisabled;
177
 
        /// whether the dock is shrinking down.
178
 
        gboolean bIsShrinkingDown;
179
 
        /// whether the dock is growing up.
180
 
        gboolean bIsGrowingUp;
181
 
        /// whether the dock is hiding.
182
 
        gboolean bIsHiding;
183
 
        /// whether the dock is showing.
184
 
        gboolean bIsShowing;
185
 
        /// whether an icon is being dragged away from the dock
186
 
        gboolean bIconIsFlyingAway;
187
 
        
188
 
        //\_______________ Source ID of events running on the dock.
189
 
        /// Source ID for window resizing.
190
 
        guint iSidMoveResize;
191
 
        /// Source ID for window popping down to the bottom layer.
192
 
        guint iSidPopDown;
193
 
        /// Source ID of the timer that delays the "leave" event.
194
 
        guint iSidLeaveDemand;
195
 
        /// Source ID for pending update of WM icons geometry.
196
 
        guint iSidUpdateWMIcons;
197
 
        
198
 
        //\_______________ Renderer and fields set by it.
199
 
        /// nom de la vue, utile pour (re)charger les fonctions de rendu posterieurement a la creation du dock.
200
 
        gchar *cRendererName;
201
 
        /// current renderer, never NULL.
202
 
        CairoDockRenderer *pRenderer;
203
 
        /// data that can be used by the renderer.
204
 
        gpointer pRendererData;
205
 
        /// Set to TRUE by the renderer if one can drop between 2 icons.
206
 
        gboolean bCanDrop;
207
 
        /// set by the view to say if the mouse is currently on icons, on the egde, or outside of icons.
208
 
        CairoDockMousePositionType iMousePositionType;
209
 
        /// minimum width of the dock.
210
 
        gint iMinDockWidth;
211
 
        /// minimum height of the dock.
212
 
        gint iMinDockHeight;
213
 
        /// maximum width of the dock.
214
 
        gint iMaxDockWidth;
215
 
        /// maximum height of the dock.
216
 
        gint iMaxDockHeight;
217
 
        /// width of background decorations.
218
 
        gint iDecorationsWidth;
219
 
        /// height of background decorations.
220
 
        gint iDecorationsHeight;
221
 
        /// maximal magnitude of the zoom, between 0 and 1.
222
 
        gdouble fMagnitudeMax;
223
 
        
224
 
        //\_______________ input shape.
225
 
        /// state of the input shape (active, at rest, hidden).
226
 
        CairoDockInputState iInputState;
227
 
        /// input shape of the window when the dock is at rest.
228
 
        GdkBitmap* pShapeBitmap;
229
 
        /// input shape of the window when the dock is hidden.
230
 
        GdkBitmap* pHiddenShapeBitmap;
231
 
        
232
 
        gint iOffsetForExtend;
233
 
        gboolean bWMIconsNeedUpdate;
234
 
        gchar reserved[8];
235
 
};
236
 
 
237
 
 
238
 
/** Say if a Container is a Dock.
239
 
* @param pContainer the container.
240
 
* @return TRUE if the container is a Dock.
241
 
*/
242
 
#define CAIRO_DOCK_IS_DOCK(pContainer) (pContainer != NULL && ((CairoContainer*)pContainer)->iType == CAIRO_DOCK_TYPE_DOCK)
243
 
 
244
 
/** Cast a Container into a Dock.
245
 
* @param pDock the container to consider as a dock.
246
 
* @return the dock.
247
 
*/
248
 
#define CAIRO_DOCK(pDock) ((CairoDock *)pDock)
249
 
 
250
 
 
251
 
/** Create a new root dock.
252
 
* @param cDockName name of the dock, used to identify it quickly. If the name is already used, the corresponding dock is returned.
253
 
* @param cRendererName name of a renderer. If NULL, the default renderer will be applied.
254
 
* @return the newly allocated dock, to destroy with #cairo_dock_destroy_dock
255
 
*/
256
 
CairoDock *cairo_dock_create_new_dock (const gchar *cDockName, const gchar *cRendererName);
257
 
 
258
 
/*
259
 
* Desactive a dock : le rend inoperant, en detruisant tout ce qu'il contient, sauf sa liste d'icones.
260
 
* @param pDock the dock.
261
 
*/
262
 
void cairo_dock_deactivate_one_dock (CairoDock *pDock);
263
 
 
264
 
/** Decrease the number of pointing icons, and destroy the dock if no more icons point on it. Also destroy all of its sub-docks, and free any allocated ressources. Do nothing for the main dock, use #cairo_dock_free_all_docks for it.
265
 
* @param pDock the dock to be destroyed.
266
 
* @param cDockName its name.
267
 
* @param ReceivingDock a dock that will get its icons, or NULL to also destroy its icons.
268
 
* @param cReceivingDockName the name of the dock that will get its icons, or NULL if none is provided.
269
 
*/
270
 
void cairo_dock_destroy_dock (CairoDock *pDock, const gchar *cDockName, CairoDock *ReceivingDock, const gchar *cReceivingDockName);
271
 
 
272
 
/** Increase by 1 the number of pointing icons. If the dock was a root dock, it becomes a sub-dock.
273
 
* @param pDock a dock.
274
 
* @param pParentDock its parent dock, if it becomes a sub-dock, otherwise it can be NULL.
275
 
*/
276
 
void cairo_dock_reference_dock (CairoDock *pDock, CairoDock *pParentDock);
277
 
 
278
 
/** Create a new dock of type "sub-dock", and load a given list of icons inside. The list then belongs to the dock, so it must not be freeed after that. The buffers of each icon are loaded, so they just need to have an image filename and a name.
279
 
* @param pIconList a list of icons that will be loaded and inserted into the new dock.
280
 
* @param cDockName desired name for the new dock.
281
 
* @param pParentDock the parent dock.
282
 
* @return the newly allocated dock.
283
 
*/
284
 
CairoDock *cairo_dock_create_subdock_from_scratch (GList *pIconList, gchar *cDockName, CairoDock *pParentDock);
285
 
 
286
 
/** Load a set of .desktop files that define icons, and build the corresponding tree of docks.
287
 
* All the icons are created and placed inside their dock, which is created if necessary.
288
 
* In the end, each dock is computed and placed on the screen.
289
 
* @param pMainDock a dock, needed to have an initial cairo context (because icons are created before their container).
290
 
* @param cDirectory a folder containing some .desktop files.
291
 
*/
292
 
void cairo_dock_build_docks_tree_with_desktop_files (CairoDock *pMainDock, gchar *cDirectory);
293
 
 
294
 
/** Destroy all docks and all icons contained inside, and free all allocated ressources. Applets and Taskbar are stopped beforehand.
295
 
*/
296
 
void cairo_dock_free_all_docks (void);
297
 
 
298
 
 
299
 
/** Insert an icon into a dock.
300
 
* Do nothing if the icon already exists inside the dock.
301
 
* @param icon the icon to be inserted. It should have been filled beforehand.
302
 
* @param pDock the dock to insert inside.
303
 
* @param bUpdateSize TRUE to update the size of the dock after the insertion.
304
 
* @param bAnimated TRUE to arm the icon's animation for insertion.
305
 
* @param bInsertSeparator TRUE to insert an automatic separator if needed.
306
 
* @param pCompareFunc a sorting function to place the new icon amongst the others, or NULL to sort by group/order.
307
 
*/
308
 
void cairo_dock_insert_icon_in_dock_full (Icon *icon, CairoDock *pDock, gboolean bUpdateSize, gboolean bAnimated, gboolean bInsertSeparator, GCompareFunc pCompareFunc);
309
 
 
310
 
/** Insert an icon into a dock, at the position given by its 'fOrder' field.
311
 
* Insert an automatic separator if needed. Do nothing if the icon already exists inside the dock.
312
 
* @param icon the icon to be inserted. It should have been filled beforehand.
313
 
* @param pDock the dock to insert inside.
314
 
* @param bUpdateSize TRUE to update the size of the dock after the insertion.
315
 
* @param bAnimated TRUE to arm the icon's animation for insertion.
316
 
*/
317
 
#define cairo_dock_insert_icon_in_dock(icon, pDock, bUpdateSize, bAnimated) cairo_dock_insert_icon_in_dock_full (icon, pDock, bUpdateSize, bAnimated, myIcons.iSeparateIcons, NULL)
318
 
 
319
 
/** Detach an icon from its dock, removing the unnecessary separators. The icon is not destroyed, and can be directly re-inserted in another container; it keeps its sub-dock, but loose its dialogs. Do nothing if the icon doesn't exist inside the dock.
320
 
*@param icon the icon to detach.
321
 
*@param pDock the dock containing the icon.
322
 
*@param bCheckUnusedSeparator TRUE to check and remove unnecessary separators.
323
 
*@return TRUE if the icon has been detached.
324
 
*/
325
 
gboolean cairo_dock_detach_icon_from_dock (Icon *icon, CairoDock *pDock, gboolean bCheckUnusedSeparator);
326
 
 
327
 
void cairo_dock_remove_icon_from_dock_full (CairoDock *pDock, Icon *icon, gboolean bCheckUnusedSeparator);
328
 
 
329
 
/** Completely remove an icon from the dock, that is to say detach the icon, and remove all links with Cairo-Dock : its .desktop is deleted, its module is deactivated, and its Xid is removed from the Taskbar (its class is handled too).
330
 
* Unnecessary separators are not tested.
331
 
* The icon is not yet destroyed, but looses its sub-dock in case of a container launcher.
332
 
*@param pDock the dock containing the icon, or NULL if the icon is already detached.
333
 
*@param icon the icon to be removed.
334
 
*/
335
 
#define cairo_dock_remove_one_icon_from_dock(pDock, icon) cairo_dock_remove_icon_from_dock_full (pDock, icon, FALSE)
336
 
 
337
 
/** Completely remove an icon from the dock, that is to say detach the icon, and  remove all links with Cairo-Dock : its .desktop is deleted, its module is deactivated, and its Xid is removed from the Taskbar (its class is handled too).
338
 
* Unnecessary separators are removed as well.
339
 
* The icon is not yet destroyed, but looses its sub-dock in case of a container launcher.
340
 
*@param pDock the dock containing the icon, or NULL if the icon is already detached.
341
 
*@param icon the icon to be removed.
342
 
*/
343
 
#define cairo_dock_remove_icon_from_dock(pDock, icon) cairo_dock_remove_icon_from_dock_full (pDock, icon, TRUE)
344
 
 
345
 
/** Remove and destroy all automatic separators inside a dock.
346
 
*@param pDock the dock.
347
 
*/
348
 
void cairo_dock_remove_automatic_separators (CairoDock *pDock);
349
 
 
350
 
/** Add automatic separators between the different types of icons inside a dock.
351
 
*@param pDock the dock.
352
 
*/
353
 
void cairo_dock_insert_separators_in_dock (CairoDock *pDock);
354
 
 
355
 
/** Add a launcher from a common desktop file : create and add the corresponding .desktop file with the others, load the corresponding icon, and insert it inside a dock with an animtion.
356
 
*@param cExternDesktopFileURI path to a desktop file.
357
 
*@param pReceivingDock the dock that will hold the new launcher.
358
 
*@param fOrder the order of the icon inside the dock.
359
 
*/
360
 
void cairo_dock_add_new_launcher_by_uri (const gchar *cExternDesktopFileURI, CairoDock *pReceivingDock, double fOrder);
361
 
 
362
 
 
363
 
G_END_DECLS
364
 
#endif