2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
20
/************************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Cchumi & Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
27
************************************************************************************/
30
#include "applet-struct.h"
31
#include "applet-desktops.h"
32
#include "applet-load-icons.h"
33
#include "applet-draw.h"
36
static GList * _load_icons (void)
38
GList *pIconList = NULL;
39
int iIndex = cd_switcher_compute_index (myData.switcher.iCurrentDesktop, myData.switcher.iCurrentViewportX, myData.switcher.iCurrentViewportY);
42
for (i = 0; i < myData.switcher.iNbViewportTotal; i ++)
44
pIcon = g_new0 (Icon, 1);
48
pIcon->acName = g_strdup_printf ("%s (%d)", D_("Current"), i+1);
49
pIcon->bHasIndicator = TRUE;
54
pIcon->acName = g_strdup_printf ("%s %d", D_("Desktop"), i+1);
55
pIcon->bHasIndicator = FALSE;
58
pIcon->cQuickInfo = g_strdup_printf ("%d",i+1);
60
pIcon->fWidthFactor = 1.;
61
pIcon->fHeightFactor = 1.;
62
pIcon->acCommand = g_strdup ("none");
63
pIcon->cParentDockName = g_strdup (myIcon->acName);
64
pIcon->acFileName = (myConfig.bMapWallpaper ? NULL : (myConfig.cDefaultIcon != NULL ? g_strdup (myConfig.cDefaultIcon) : g_strdup (MY_APPLET_SHARE_DATA_DIR"/default.svg")));
66
pIconList = g_list_append (pIconList, pIcon);
74
void cd_switcher_load_icons (void)
76
if (myConfig.bCompactView)
78
CD_APPLET_DELETE_MY_ICONS_LIST;
79
if (myIcon->pSubDock != NULL) // si on est passe de expanded a compact, le sous-dock vide reste.
81
CD_APPLET_DESTROY_MY_SUBDOCK;
85
CD_APPLET_SET_DESKLET_RENDERER ("Simple");
87
cd_switcher_load_default_map_surface ();
89
cd_message ("SWITCHER : chargement de l'icone Switcher sans sous-dock");
93
//\_______________________ On cree la liste des icones de prevision.
94
GList *pIconList = _load_icons ();
96
/*//\_______________________ On efface l'ancienne liste.
97
if (myIcon->pSubDock != NULL)
99
g_list_foreach (myIcon->pSubDock->icons, (GFunc) cairo_dock_free_icon, NULL);
100
g_list_free (myIcon->pSubDock->icons);
101
myIcon->pSubDock->icons = NULL;
104
//\_______________________ On charge la nouvelle liste.
105
gpointer pConfig[2] = {GINT_TO_POINTER (myConfig.bDesklet3D), GINT_TO_POINTER (FALSE)};
106
CD_APPLET_LOAD_MY_ICONS_LIST (pIconList, myConfig.cRenderer, "Caroussel", pConfig);
109
if (myIcon->pSubDock == NULL)
111
if (pIconList != NULL)
113
CD_APPLET_CREATE_MY_SUBDOCK (pIconList, myConfig.cRenderer);
116
else // on a deja notre sous-dock, on remplace juste ses icones.
118
if (pIconList == NULL) // inutile de le garder.
120
CD_APPLET_DESTROY_MY_SUBDOCK;
125
CD_APPLET_LOAD_ICONS_IN_MY_SUBDOCK (pIconList);
131
if (myIcon->pSubDock != NULL)
133
CD_APPLET_DESTROY_MY_SUBDOCK;
135
if (myDesklet->icons != NULL) // si on recharge la liste a cause d'un changement de configuration du bureau.
137
g_list_foreach (myDesklet->icons, (GFunc) cairo_dock_free_icon, NULL);
138
g_list_free (myDesklet->icons);
140
myDesklet->icons = pIconList;
142
gpointer pConfig[2] = {GINT_TO_POINTER (myConfig.bDesklet3D), GINT_TO_POINTER (FALSE)};
143
CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Caroussel", pConfig);
146
//\_______________________ On peint les icones.
147
cd_switcher_paint_icons ();
151
void cd_switcher_paint_icons (void)
153
//\_______________________ On applique la surface.
154
CairoContainer *pContainer = CD_APPLET_MY_ICONS_LIST_CONTAINER;
155
GList *pIconList = CD_APPLET_MY_ICONS_LIST;
156
if (pIconList == NULL)
159
cairo_surface_t *pSurface = NULL;
160
double fZoomX, fZoomY;
161
Icon *pFirstIcon = pIconList->data;
164
cairo_dock_get_icon_extent (pFirstIcon, pContainer, &iWidth, &iHeight);
166
if (myConfig.bMapWallpaper)
168
cd_switcher_draw_main_icon();
169
pSurface = cairo_dock_get_desktop_bg_surface ();
170
double fMaxScale = cairo_dock_get_max_scale (pContainer);
171
fZoomX = 1. * iWidth / g_iXScreenWidth[CAIRO_DOCK_HORIZONTAL];
172
fZoomY = 1. * iHeight / g_iXScreenHeight[CAIRO_DOCK_HORIZONTAL];
175
if (pSurface == NULL)
177
int _iWidth, _iHeight;
178
CD_APPLET_GET_MY_ICON_EXTENT (&_iWidth, &_iHeight);
179
cd_switcher_load_default_map_surface ();
180
pSurface = myData.pDefaultMapSurface;
181
fZoomX = 1. * iWidth / _iWidth;
182
fZoomY = 1. * iHeight / _iHeight;
185
cairo_t *pIconContext;
188
for (ic = pIconList; ic != NULL; ic = ic->next)
191
//g_print (" (%.2f; %.2f) %.2fx%.2f\n", icon->fDrawX, icon->fDrawY, icon->fWidth, icon->fHeight);
192
pIconContext = cairo_create (icon->pIconBuffer);
193
cairo_scale (pIconContext,
197
cairo_dock_set_icon_surface_with_reflect (pIconContext, pSurface, icon, pContainer);
198
cairo_destroy (pIconContext);
203
void cd_switcher_load_default_map_surface (void)
205
g_return_if_fail (myDrawContext != NULL);
206
if (myData.pDefaultMapSurface != NULL)
207
cairo_surface_destroy (myData.pDefaultMapSurface);
208
cd_debug ("%s (%.2fx%.2f)", __func__, myIcon->fWidth, myIcon->fHeight);
209
myData.pDefaultMapSurface = CD_APPLET_LOAD_SURFACE_FOR_MY_APPLET (myConfig.cDefaultIcon);