~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to icon-effect/src/applet-config.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
ImportĀ upstreamĀ versionĀ 2.0.8.1

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
 
 
22
This file is a part of the cairo-dock program, 
 
23
released under the terms of the GNU General Public License.
 
24
 
 
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
 
26
 
 
27
******************************************************************************/
 
28
 
 
29
#include <string.h>
 
30
#include <cairo-dock.h>
 
31
 
 
32
#include "applet-struct.h"
 
33
#include "applet-config.h"
 
34
 
 
35
 
 
36
#define _get_particle_system_config(cGroupName, parameters) \
 
37
        parameters.iDuration = CD_CONFIG_GET_INTEGER (cGroupName, "duration");\
 
38
        parameters.bContinue = CD_CONFIG_GET_BOOLEAN (cGroupName, "continue");\
 
39
        CD_CONFIG_GET_COLOR_RVB (cGroupName, "color1", parameters.pColor1);\
 
40
        CD_CONFIG_GET_COLOR_RVB (cGroupName, "color2", parameters.pColor2);\
 
41
        parameters.bMystical = CD_CONFIG_GET_BOOLEAN (cGroupName, "mystical");\
 
42
        parameters.iNbParticles = CD_CONFIG_GET_INTEGER (cGroupName, "nb part");\
 
43
        parameters.iParticleSize = CD_CONFIG_GET_INTEGER (cGroupName, "part size");\
 
44
        parameters.fParticleSpeed = CD_CONFIG_GET_DOUBLE (cGroupName, "part speed")
 
45
 
 
46
 
 
47
//\_________________ Here you have to get all your parameters from the conf file. Use the macros CD_CONFIG_GET_BOOLEAN, CD_CONFIG_GET_INTEGER, CD_CONFIG_GET_STRING, etc. myConfig has been reseted to 0 at this point. This function is called at the beginning of init and reload.
 
48
CD_APPLET_GET_CONFIG_BEGIN
 
49
        myConfig.bBackGround = CD_CONFIG_GET_BOOLEAN ("Global", "background");
 
50
        myConfig.bRotateEffects = CD_CONFIG_GET_BOOLEAN ("Global", "rotate");
 
51
        int i,j;
 
52
        for (i = 0; i < CD_ICON_EFFECT_NB_EFFECTS; i ++)
 
53
        {
 
54
                myConfig.iEffectsUsed[i] = -1;
 
55
        }
 
56
        for (j = 0; j < CAIRO_DOCK_NB_TYPES; j += 2)
 
57
        {
 
58
                for (i = 0; i < CD_ICON_EFFECT_NB_EFFECTS; i ++)
 
59
                {
 
60
                        myConfig.iEffectsOnClick[j][i] = -1;
 
61
                }
 
62
        }
 
63
        
 
64
        CD_CONFIG_GET_INTEGER_LIST ("Global", "effects", CD_ICON_EFFECT_NB_EFFECTS, (int *)myConfig.iEffectsUsed);
 
65
        
 
66
        CD_CONFIG_GET_INTEGER_LIST ("Global", "click launchers", CD_ICON_EFFECT_NB_EFFECTS,
 
67
                (int *)myConfig.iEffectsOnClick[CAIRO_DOCK_LAUNCHER]);
 
68
        
 
69
        CD_CONFIG_GET_INTEGER_LIST ("Global", "click applis", CD_ICON_EFFECT_NB_EFFECTS,
 
70
                (int *)myConfig.iEffectsOnClick[CAIRO_DOCK_APPLI]);
 
71
        
 
72
        CD_CONFIG_GET_INTEGER_LIST ("Global", "click applets", CD_ICON_EFFECT_NB_EFFECTS,
 
73
                (int *)myConfig.iEffectsOnClick[CAIRO_DOCK_APPLET]);
 
74
        
 
75
        myConfig.iFireDuration = CD_CONFIG_GET_INTEGER ("Fire", "duration");
 
76
        myConfig.bContinueFire = CD_CONFIG_GET_BOOLEAN ("Fire", "continue");
 
77
        CD_CONFIG_GET_COLOR_RVB ("Fire", "color1", myConfig.pFireColor1);
 
78
        CD_CONFIG_GET_COLOR_RVB ("Fire", "color2", myConfig.pFireColor2);
 
79
        myConfig.bMysticalFire = CD_CONFIG_GET_BOOLEAN ("Fire", "mystical");
 
80
        myConfig.iNbFireParticles = CD_CONFIG_GET_INTEGER ("Fire", "nb part");
 
81
        myConfig.iFireParticleSize = CD_CONFIG_GET_INTEGER ("Fire", "part size");
 
82
        myConfig.fFireParticleSpeed = CD_CONFIG_GET_DOUBLE ("Fire", "part speed");
 
83
        myConfig.bFireLuminance = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Fire", "luminous", TRUE);
 
84
        
 
85
        myConfig.iStarDuration = CD_CONFIG_GET_INTEGER ("Stars", "duration");
 
86
        myConfig.bContinueStar = CD_CONFIG_GET_BOOLEAN ("Stars", "continue");
 
87
        CD_CONFIG_GET_COLOR_RVB ("Stars", "color1", myConfig.pStarColor1);
 
88
        CD_CONFIG_GET_COLOR_RVB ("Stars", "color2", myConfig.pStarColor2);
 
89
        myConfig.bMysticalStars = CD_CONFIG_GET_BOOLEAN ("Stars", "mystical");
 
90
        myConfig.iNbStarParticles = CD_CONFIG_GET_INTEGER ("Stars", "nb part");
 
91
        myConfig.iStarParticleSize = CD_CONFIG_GET_INTEGER ("Stars", "part size");
 
92
        
 
93
        myConfig.iRainDuration = CD_CONFIG_GET_INTEGER ("Rain", "duration");
 
94
        myConfig.bContinueRain = CD_CONFIG_GET_BOOLEAN ("Rain", "continue");
 
95
        CD_CONFIG_GET_COLOR_RVB ("Rain", "color1", myConfig.pRainColor1);
 
96
        CD_CONFIG_GET_COLOR_RVB ("Rain", "color2", myConfig.pRainColor2);
 
97
        myConfig.iNbRainParticles = CD_CONFIG_GET_INTEGER ("Rain", "nb part");
 
98
        myConfig.iRainParticleSize = CD_CONFIG_GET_INTEGER ("Rain", "part size") / 2;  // cette texture est pleine alors que les 2 precedentes sont floutees, donc pour conserver un ordre de grandeur identique on divise par 2.
 
99
        myConfig.fRainParticleSpeed = CD_CONFIG_GET_DOUBLE ("Rain", "part speed");
 
100
        
 
101
        myConfig.iSnowDuration = CD_CONFIG_GET_INTEGER ("Snow", "duration");
 
102
        myConfig.bContinueSnow = CD_CONFIG_GET_BOOLEAN ("Snow", "continue");
 
103
        CD_CONFIG_GET_COLOR_RVB ("Snow", "color1", myConfig.pSnowColor1);
 
104
        CD_CONFIG_GET_COLOR_RVB ("Snow", "color2", myConfig.pSnowColor2);
 
105
        myConfig.iNbSnowParticles = CD_CONFIG_GET_INTEGER ("Snow", "nb part");
 
106
        myConfig.iSnowParticleSize = CD_CONFIG_GET_INTEGER ("Snow", "part size") / 2;  // meme remarque.
 
107
        myConfig.fSnowParticleSpeed = CD_CONFIG_GET_DOUBLE ("Snow", "part speed");
 
108
        
 
109
        myConfig.iStormDuration = CD_CONFIG_GET_INTEGER ("Storm", "duration");
 
110
        myConfig.bContinueStorm = CD_CONFIG_GET_BOOLEAN ("Storm", "continue");
 
111
        CD_CONFIG_GET_COLOR_RVB ("Storm", "color1", myConfig.pStormColor1);
 
112
        CD_CONFIG_GET_COLOR_RVB ("Storm", "color2", myConfig.pStormColor2);
 
113
        myConfig.iNbStormParticles = CD_CONFIG_GET_INTEGER ("Storm", "nb part");
 
114
        myConfig.iStormParticleSize = CD_CONFIG_GET_INTEGER ("Storm", "part size");  // meme remarque.
 
115
CD_APPLET_GET_CONFIG_END
 
116
 
 
117
 
 
118
//\_________________ Here you have to free all ressources allocated for myConfig. This one will be reseted to 0 at the end of this function. This function is called right before you get the applet's config, and when your applet is stopped, in the end.
 
119
CD_APPLET_RESET_CONFIG_BEGIN
 
120
        
 
121
        
 
122
CD_APPLET_RESET_CONFIG_END
 
123
 
 
124
 
 
125
//\_________________ Here you have to free all ressources allocated for myData. This one will be reseted to 0 at the end of this function. This function is called when your applet is stopped, in the very end.
 
126
CD_APPLET_RESET_DATA_BEGIN
 
127
        if (myData.iFireTexture != 0)
 
128
                glDeleteTextures (1, &myData.iFireTexture);
 
129
        if (myData.iRainTexture != 0)
 
130
                glDeleteTextures (1, &myData.iRainTexture);
 
131
        if (myData.iSnowTexture != 0)
 
132
                glDeleteTextures (1, &myData.iSnowTexture);
 
133
        if (myData.iStarTexture != 0)
 
134
                glDeleteTextures (1, &myData.iStarTexture);
 
135
        
 
136
CD_APPLET_RESET_DATA_END