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/>.
22
#include "cairo-dock-modules.h"
23
#include "cairo-dock-load.h"
24
#include "cairo-dock-draw.h"
25
#include "cairo-dock-dock-factory.h"
26
#include "cairo-dock-dock-facility.h"
27
#include "cairo-dock-dock-manager.h"
28
#include "cairo-dock-log.h"
29
#include "cairo-dock-internal-icons.h"
30
#include "cairo-dock-internal-accessibility.h"
31
#include "cairo-dock-container.h"
32
#define _INTERNAL_MODULE_
33
#include "cairo-dock-internal-background.h"
35
CairoConfigBackground myBackground;
36
extern CairoDock *g_pMainDock;
37
extern CairoDockImageBuffer g_pDockBackgroundBuffer;
39
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigBackground *pBackground)
41
gboolean bFlushConfFileNeeded = FALSE;
44
pBackground->iDockRadius = cairo_dock_get_integer_key_value (pKeyFile, "Background", "corner radius", &bFlushConfFileNeeded, 12, NULL, NULL);
46
pBackground->iDockLineWidth = cairo_dock_get_integer_key_value (pKeyFile, "Background", "line width", &bFlushConfFileNeeded, 2, NULL, NULL);
48
pBackground->iFrameMargin = cairo_dock_get_integer_key_value (pKeyFile, "Background", "frame margin", &bFlushConfFileNeeded, 2, NULL, NULL);
50
double couleur[4] = {0., 0., 0.6, 0.4};
51
cairo_dock_get_double_list_key_value (pKeyFile, "Background", "line color", &bFlushConfFileNeeded, pBackground->fLineColor, 4, couleur, NULL, NULL);
53
pBackground->bRoundedBottomCorner = cairo_dock_get_boolean_key_value (pKeyFile, "Background", "rounded bottom corner", &bFlushConfFileNeeded, TRUE, NULL, NULL);
56
gchar *cBgImage = cairo_dock_get_string_key_value (pKeyFile, "Background", "background image", &bFlushConfFileNeeded, NULL, NULL, NULL);
57
int iFillBg = cairo_dock_get_integer_key_value (pKeyFile, "Background", "fill bg", &bFlushConfFileNeeded, -1, NULL, NULL); // -1 pour intercepter le cas ou la cle n'existe pas.
60
iFillBg = (cBgImage != NULL ? 0 : 1);
61
g_key_file_set_integer (pKeyFile, "Background", "fill bg", iFillBg);
73
pBackground->cBackgroundImageFile = cBgImage;
74
pBackground->fBackgroundImageAlpha = cairo_dock_get_double_key_value (pKeyFile, "Background", "image alpha", &bFlushConfFileNeeded, 0.5, NULL, NULL);
76
pBackground->bBackgroundImageRepeat = cairo_dock_get_boolean_key_value (pKeyFile, "Background", "repeat image", &bFlushConfFileNeeded, FALSE, NULL, NULL);
79
if (pBackground->cBackgroundImageFile == NULL)
81
pBackground->iNbStripes = cairo_dock_get_integer_key_value (pKeyFile, "Background", "number of stripes", &bFlushConfFileNeeded, 10, NULL, NULL);
83
if (pBackground->iNbStripes != 0)
85
pBackground->fStripesWidth = MAX (.01, MIN (.99, cairo_dock_get_double_key_value (pKeyFile, "Background", "stripes width", &bFlushConfFileNeeded, 0.2, NULL, NULL))) / pBackground->iNbStripes;
87
double couleur3[4] = {.7, .7, 1., .7};
88
cairo_dock_get_double_list_key_value (pKeyFile, "Background", "stripes color dark", &bFlushConfFileNeeded, pBackground->fStripesColorDark, 4, couleur3, NULL, NULL);
90
double couleur2[4] = {.7, .9, .7, .4};
91
cairo_dock_get_double_list_key_value (pKeyFile, "Background", "stripes color bright", &bFlushConfFileNeeded, pBackground->fStripesColorBright, 4, couleur2, NULL, NULL);
93
pBackground->fStripesAngle = cairo_dock_get_double_key_value (pKeyFile, "Background", "stripes angle", &bFlushConfFileNeeded, 90., NULL, NULL);
97
pBackground->cVisibleZoneImageFile = cairo_dock_get_string_key_value (pKeyFile, "Background", "callback image", &bFlushConfFileNeeded, NULL, "Hidden dock", "callback image");
99
pBackground->fVisibleZoneAlpha = cairo_dock_get_double_key_value (pKeyFile, "Background", "callback alpha", &bFlushConfFileNeeded, 0.5, "Hidden dock", "alpha");
100
pBackground->bReverseVisibleImage = cairo_dock_get_boolean_key_value (pKeyFile, "Background", "callback reverse", &bFlushConfFileNeeded, TRUE, "Hidden dock", "reverse visible image");
104
if (! g_key_file_has_key (pKeyFile, "Background", "move bg", NULL)) // anciennes valeurs.
106
pBackground->fDecorationSpeed = g_key_file_get_double (pKeyFile, "System", "scroll speed factor", NULL);
107
if (pBackground->fDecorationSpeed != 0)
109
if (g_key_file_get_boolean (pKeyFile, "System", "decorations enslaved", NULL))
113
g_key_file_set_double (pKeyFile, "Background", "decorations speed", pBackground->fDecorationSpeed);
117
g_key_file_set_integer (pKeyFile, "Background", "move bg", iMovementType);
118
bFlushConfFileNeeded = TRUE;
120
iMovementType = cairo_dock_get_integer_key_value (pKeyFile, "Background", "move bg", &bFlushConfFileNeeded, 0, NULL, NULL);
121
if (iMovementType != 0)
123
pBackground->fDecorationSpeed = cairo_dock_get_double_key_value (pKeyFile, "Background", "decorations speed", &bFlushConfFileNeeded, 0.5, NULL, NULL);
124
pBackground->bDecorationsFollowMouse = (iMovementType == 2);
127
return bFlushConfFileNeeded;
131
static void reset_config (CairoConfigBackground *pBackground)
133
g_free (pBackground->cBackgroundImageFile);
134
g_free (pBackground->cVisibleZoneImageFile);
138
static void reload (CairoConfigBackground *pPrevBackground, CairoConfigBackground *pBackground)
140
CairoDock *pDock = g_pMainDock;
142
if (cairo_dock_strings_differ (pPrevBackground->cVisibleZoneImageFile, pBackground->cVisibleZoneImageFile))
144
cairo_dock_load_visible_zone (pDock, pBackground->cVisibleZoneImageFile, myAccessibility.iVisibleZoneWidth, myAccessibility.iVisibleZoneHeight, pBackground->fVisibleZoneAlpha);
147
g_pDockBackgroundBuffer.iWidth = g_pDockBackgroundBuffer.iHeight = 0.;
148
cairo_dock_set_all_views_to_default (0); // met a jour la taille (decorations incluses) de tous les docks.
149
cairo_dock_calculate_dock_icons (pDock);
150
cairo_dock_redraw_root_docks (FALSE); // main dock inclus.
154
DEFINE_PRE_INIT (Background)
156
pModule->cModuleName = "Background";
157
pModule->cTitle = N_("Background");
158
pModule->cIcon = "icon-background.svg";
159
pModule->cDescription = N_("Set a background to your dock.");
160
pModule->iCategory = CAIRO_DOCK_CATEGORY_THEME;
161
pModule->iSizeOfConfig = sizeof (CairoConfigBackground);
162
pModule->iSizeOfData = 0;
164
pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
165
pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
166
pModule->reset_config = (CairoDockInternalModuleResetConfigFunc) reset_config;
167
pModule->reset_data = NULL;
169
pModule->pConfig = (CairoInternalModuleConfigPtr) &myBackground;
170
pModule->pData = NULL;