~ubuntu-branches/ubuntu/maverick/cairo-dock/maverick

« back to all changes in this revision

Viewing changes to src/cairo-dock-internal-background.c

  • 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
 
* 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
 
#include <string.h>
21
 
 
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"
34
 
 
35
 
CairoConfigBackground myBackground;
36
 
extern CairoDock *g_pMainDock;
37
 
extern CairoDockImageBuffer g_pDockBackgroundBuffer;
38
 
 
39
 
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigBackground *pBackground)
40
 
{
41
 
        gboolean bFlushConfFileNeeded = FALSE;
42
 
        
43
 
        // cadre.
44
 
        pBackground->iDockRadius = cairo_dock_get_integer_key_value (pKeyFile, "Background", "corner radius", &bFlushConfFileNeeded, 12, NULL, NULL);
45
 
 
46
 
        pBackground->iDockLineWidth = cairo_dock_get_integer_key_value (pKeyFile, "Background", "line width", &bFlushConfFileNeeded, 2, NULL, NULL);
47
 
 
48
 
        pBackground->iFrameMargin = cairo_dock_get_integer_key_value (pKeyFile, "Background", "frame margin", &bFlushConfFileNeeded, 2, NULL, NULL);
49
 
 
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);
52
 
 
53
 
        pBackground->bRoundedBottomCorner = cairo_dock_get_boolean_key_value (pKeyFile, "Background", "rounded bottom corner", &bFlushConfFileNeeded, TRUE, NULL, NULL);
54
 
        
55
 
        
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.
58
 
        if (iFillBg == -1)
59
 
        {
60
 
                iFillBg = (cBgImage != NULL ? 0 : 1);
61
 
                g_key_file_set_integer (pKeyFile, "Background", "fill bg", iFillBg);
62
 
        }
63
 
        else
64
 
        {
65
 
                if (iFillBg != 0)
66
 
                {
67
 
                        g_free (cBgImage);
68
 
                        cBgImage = NULL;
69
 
                }
70
 
        }
71
 
        
72
 
        // image de fond.
73
 
        pBackground->cBackgroundImageFile = cBgImage;
74
 
        pBackground->fBackgroundImageAlpha = cairo_dock_get_double_key_value (pKeyFile, "Background", "image alpha", &bFlushConfFileNeeded, 0.5, NULL, NULL);
75
 
 
76
 
        pBackground->bBackgroundImageRepeat = cairo_dock_get_boolean_key_value (pKeyFile, "Background", "repeat image", &bFlushConfFileNeeded, FALSE, NULL, NULL);
77
 
        
78
 
        // degrade du fond.
79
 
        if (pBackground->cBackgroundImageFile == NULL)
80
 
        {
81
 
                pBackground->iNbStripes = cairo_dock_get_integer_key_value (pKeyFile, "Background", "number of stripes", &bFlushConfFileNeeded, 10, NULL, NULL);
82
 
                
83
 
                if (pBackground->iNbStripes != 0)
84
 
                {
85
 
                        pBackground->fStripesWidth = MAX (.01, MIN (.99, cairo_dock_get_double_key_value (pKeyFile, "Background", "stripes width", &bFlushConfFileNeeded, 0.2, NULL, NULL))) / pBackground->iNbStripes;
86
 
                }
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);
89
 
                
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);
92
 
                
93
 
                pBackground->fStripesAngle = cairo_dock_get_double_key_value (pKeyFile, "Background", "stripes angle", &bFlushConfFileNeeded, 90., NULL, NULL);
94
 
        }
95
 
        
96
 
        // zone de rappel.
97
 
        pBackground->cVisibleZoneImageFile = cairo_dock_get_string_key_value (pKeyFile, "Background", "callback image", &bFlushConfFileNeeded, NULL, "Hidden dock", "callback image");
98
 
        
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");
101
 
        
102
 
        // mouvements.
103
 
        int iMovementType;
104
 
        if (! g_key_file_has_key (pKeyFile, "Background", "move bg", NULL))  // anciennes valeurs.
105
 
        {
106
 
                pBackground->fDecorationSpeed = g_key_file_get_double (pKeyFile, "System", "scroll speed factor", NULL);
107
 
                if (pBackground->fDecorationSpeed != 0)
108
 
                {
109
 
                        if (g_key_file_get_boolean (pKeyFile, "System", "decorations enslaved", NULL))
110
 
                                iMovementType = 2;
111
 
                        else
112
 
                                iMovementType = 1;
113
 
                        g_key_file_set_double (pKeyFile, "Background", "decorations speed", pBackground->fDecorationSpeed);
114
 
                }
115
 
                else
116
 
                        iMovementType = 0;
117
 
                g_key_file_set_integer (pKeyFile, "Background", "move bg", iMovementType);
118
 
                bFlushConfFileNeeded = TRUE;
119
 
        }
120
 
        iMovementType = cairo_dock_get_integer_key_value (pKeyFile, "Background", "move bg", &bFlushConfFileNeeded, 0, NULL, NULL);
121
 
        if (iMovementType != 0)
122
 
        {
123
 
                pBackground->fDecorationSpeed = cairo_dock_get_double_key_value (pKeyFile, "Background", "decorations speed", &bFlushConfFileNeeded, 0.5, NULL, NULL);
124
 
                pBackground->bDecorationsFollowMouse = (iMovementType == 2);
125
 
        }
126
 
        
127
 
        return bFlushConfFileNeeded;
128
 
}
129
 
 
130
 
 
131
 
static void reset_config (CairoConfigBackground *pBackground)
132
 
{
133
 
        g_free (pBackground->cBackgroundImageFile);
134
 
        g_free (pBackground->cVisibleZoneImageFile);
135
 
}
136
 
 
137
 
 
138
 
static void reload (CairoConfigBackground *pPrevBackground, CairoConfigBackground *pBackground)
139
 
{
140
 
        CairoDock *pDock = g_pMainDock;
141
 
        
142
 
        if (cairo_dock_strings_differ (pPrevBackground->cVisibleZoneImageFile, pBackground->cVisibleZoneImageFile))
143
 
        {
144
 
                cairo_dock_load_visible_zone (pDock, pBackground->cVisibleZoneImageFile, myAccessibility.iVisibleZoneWidth, myAccessibility.iVisibleZoneHeight, pBackground->fVisibleZoneAlpha);
145
 
        }
146
 
        
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.
151
 
}
152
 
 
153
 
 
154
 
DEFINE_PRE_INIT (Background)
155
 
{
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;
163
 
        
164
 
        pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
165
 
        pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
166
 
        pModule->reset_config = (CairoDockInternalModuleResetConfigFunc) reset_config;
167
 
        pModule->reset_data = NULL;
168
 
        
169
 
        pModule->pConfig = (CairoInternalModuleConfigPtr) &myBackground;
170
 
        pModule->pData = NULL;
171
 
}