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

« back to all changes in this revision

Viewing changes to src/gldit/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
 
 
37
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigBackground *pBackground)
 
38
{
 
39
        gboolean bFlushConfFileNeeded = FALSE;
 
40
        
 
41
        // cadre.
 
42
        pBackground->iDockRadius = cairo_dock_get_integer_key_value (pKeyFile, "Background", "corner radius", &bFlushConfFileNeeded, 12, NULL, NULL);
 
43
 
 
44
        pBackground->iDockLineWidth = cairo_dock_get_integer_key_value (pKeyFile, "Background", "line width", &bFlushConfFileNeeded, 2, NULL, NULL);
 
45
 
 
46
        pBackground->iFrameMargin = cairo_dock_get_integer_key_value (pKeyFile, "Background", "frame margin", &bFlushConfFileNeeded, 2, NULL, NULL);
 
47
 
 
48
        double couleur[4] = {0., 0., 0.6, 0.4};
 
49
        cairo_dock_get_double_list_key_value (pKeyFile, "Background", "line color", &bFlushConfFileNeeded, pBackground->fLineColor, 4, couleur, NULL, NULL);
 
50
 
 
51
        pBackground->bRoundedBottomCorner = cairo_dock_get_boolean_key_value (pKeyFile, "Background", "rounded bottom corner", &bFlushConfFileNeeded, TRUE, NULL, NULL);
 
52
        
 
53
        
 
54
        gchar *cBgImage = cairo_dock_get_string_key_value (pKeyFile, "Background", "background image", &bFlushConfFileNeeded, NULL, NULL, NULL);
 
55
        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.
 
56
        if (iFillBg == -1)
 
57
        {
 
58
                iFillBg = (cBgImage != NULL ? 0 : 1);
 
59
                g_key_file_set_integer (pKeyFile, "Background", "fill bg", iFillBg);
 
60
        }
 
61
        else
 
62
        {
 
63
                if (iFillBg != 0)
 
64
                {
 
65
                        g_free (cBgImage);
 
66
                        cBgImage = NULL;
 
67
                }
 
68
        }
 
69
        
 
70
        // image de fond.
 
71
        pBackground->cBackgroundImageFile = cairo_dock_generate_file_path (cBgImage);
 
72
        g_free (cBgImage);
 
73
        
 
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
        /**
 
97
        // zone de rappel.
 
98
        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");*/
 
101
        
 
102
        /**
 
103
        // mouvements.
 
104
        int iMovementType;
 
105
        if (! g_key_file_has_key (pKeyFile, "Background", "move bg", NULL))  // anciennes valeurs.
 
106
        {
 
107
                pBackground->fDecorationSpeed = g_key_file_get_double (pKeyFile, "System", "scroll speed factor", NULL);
 
108
                if (pBackground->fDecorationSpeed != 0)
 
109
                {
 
110
                        if (g_key_file_get_boolean (pKeyFile, "System", "decorations enslaved", NULL))
 
111
                                iMovementType = 2;
 
112
                        else
 
113
                                iMovementType = 1;
 
114
                        g_key_file_set_double (pKeyFile, "Background", "decorations speed", pBackground->fDecorationSpeed);
 
115
                }
 
116
                else
 
117
                        iMovementType = 0;
 
118
                g_key_file_set_integer (pKeyFile, "Background", "move bg", iMovementType);
 
119
                bFlushConfFileNeeded = TRUE;
 
120
        }
 
121
        iMovementType = cairo_dock_get_integer_key_value (pKeyFile, "Background", "move bg", &bFlushConfFileNeeded, 0, NULL, NULL);
 
122
        if (iMovementType != 0)
 
123
        {
 
124
                pBackground->fDecorationSpeed = cairo_dock_get_double_key_value (pKeyFile, "Background", "decorations speed", &bFlushConfFileNeeded, 0.5, NULL, NULL);
 
125
                pBackground->bDecorationsFollowMouse = (iMovementType == 2);
 
126
        }*/
 
127
        
 
128
        return bFlushConfFileNeeded;
 
129
}
 
130
 
 
131
 
 
132
static void reset_config (CairoConfigBackground *pBackground)
 
133
{
 
134
        g_free (pBackground->cBackgroundImageFile);
 
135
        ///g_free (pBackground->cVisibleZoneImageFile);
 
136
}
 
137
 
 
138
 
 
139
static void _reload_bg (const gchar *cDockName, CairoDock *pDock, gpointer data)
 
140
{
 
141
        cairo_dock_update_dock_size (pDock);
 
142
        if (pDock->iRefCount == 0)
 
143
        {
 
144
                cairo_dock_load_dock_background (pDock);  // pour forcer le chargement du fond.
 
145
                cairo_dock_calculate_dock_icons (pDock);
 
146
                gtk_widget_queue_draw (pDock->container.pWidget);
 
147
        }
 
148
        if (pDock->iRefCount == 0 && pDock->iVisibility == CAIRO_DOCK_VISI_RESERVE)
 
149
                cairo_dock_reserve_space_for_dock (pDock, TRUE);
 
150
}
 
151
static void reload (CairoConfigBackground *pPrevBackground, CairoConfigBackground *pBackground)
 
152
{
 
153
        cairo_dock_foreach_docks ((GHFunc)_reload_bg, NULL);
 
154
}
 
155
 
 
156
 
 
157
DEFINE_PRE_INIT (Background)
 
158
{
 
159
        pModule->cModuleName = "Background";
 
160
        pModule->cTitle = N_("Background");
 
161
        pModule->cIcon = "icon-background.svg";
 
162
        pModule->cDescription = N_("Set a background for your dock.");
 
163
        pModule->iCategory = CAIRO_DOCK_CATEGORY_THEME;
 
164
        pModule->iSizeOfConfig = sizeof (CairoConfigBackground);
 
165
        pModule->iSizeOfData = 0;
 
166
        
 
167
        pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
 
168
        pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
 
169
        pModule->reset_config = (CairoDockInternalModuleResetConfigFunc) reset_config;
 
170
        pModule->reset_data = NULL;
 
171
        
 
172
        pModule->pConfig = (CairoInternalModuleConfigPtr) &myBackground;
 
173
        pModule->pData = NULL;
 
174
}