~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

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-manager.h"
27
 
#include "cairo-dock-internal-taskbar.h"
28
 
#include "cairo-dock-internal-icons.h"
29
 
#include "cairo-dock-container.h"
30
 
#define _INTERNAL_MODULE_
31
 
#include "cairo-dock-internal-indicators.h"
32
 
 
33
 
CairoConfigIndicators myIndicators;
34
 
extern CairoDock *g_pMainDock;
35
 
 
36
 
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigIndicators *pIndicators)
37
 
{
38
 
        gboolean bFlushConfFileNeeded = FALSE;
39
 
        gchar *cIndicatorImageName;
40
 
        
41
 
        //\__________________ On recupere l'indicateur d'appli lancee.
42
 
        cIndicatorImageName = cairo_dock_get_string_key_value (pKeyFile, "Indicators", "indicator image", &bFlushConfFileNeeded, NULL, "Icons", NULL);
43
 
        if (cIndicatorImageName != NULL)
44
 
        {
45
 
                pIndicators->cIndicatorImagePath = cairo_dock_generate_file_path (cIndicatorImageName);
46
 
                g_free (cIndicatorImageName);
47
 
        }
48
 
        else
49
 
                pIndicators->cIndicatorImagePath = g_strdup (CAIRO_DOCK_SHARE_DATA_DIR"/"CAIRO_DOCK_DEFAULT_INDICATOR_NAME);
50
 
        
51
 
        pIndicators->bIndicatorAbove = cairo_dock_get_boolean_key_value (pKeyFile, "Indicators", "indicator above", &bFlushConfFileNeeded, FALSE, "Icons", NULL);
52
 
        
53
 
        pIndicators->fIndicatorRatio = cairo_dock_get_double_key_value (pKeyFile, "Indicators", "indicator ratio", &bFlushConfFileNeeded, 1., "Icons", NULL);
54
 
        
55
 
        pIndicators->bLinkIndicatorWithIcon = cairo_dock_get_boolean_key_value (pKeyFile, "Indicators", "link indicator", &bFlushConfFileNeeded, TRUE, "Icons", NULL);
56
 
        
57
 
        pIndicators->iIndicatorDeltaY = cairo_dock_get_integer_key_value (pKeyFile, "Indicators", "indicator deltaY", &bFlushConfFileNeeded, 2, "Icons", NULL);
58
 
        
59
 
        pIndicators->bRotateWithDock = cairo_dock_get_boolean_key_value (pKeyFile, "Indicators", "rotate indicator", &bFlushConfFileNeeded, TRUE, NULL, NULL);
60
 
        
61
 
        //\__________________ On recupere l'indicateur de fenetre active.
62
 
        int iIndicType = cairo_dock_get_integer_key_value (pKeyFile, "Indicators", "active indic type", &bFlushConfFileNeeded, -1, NULL, NULL);  // -1 pou rpouvoir intercepter le cas ou la cle n'existe pas.
63
 
        
64
 
        cIndicatorImageName = cairo_dock_get_string_key_value (pKeyFile, "Indicators", "active indicator", &bFlushConfFileNeeded, NULL, NULL, NULL);
65
 
        if (iIndicType == -1)  // nouvelle cle.
66
 
        {
67
 
                iIndicType = (cIndicatorImageName != NULL ? 0 : 1);
68
 
                g_key_file_set_integer (pKeyFile, "Indicators", "active indic type", iIndicType);
69
 
        }
70
 
        else
71
 
        {
72
 
                if (iIndicType != 0)
73
 
                {
74
 
                        g_free (cIndicatorImageName);
75
 
                        cIndicatorImageName = NULL;
76
 
                }
77
 
        }
78
 
        
79
 
        if (cIndicatorImageName != NULL)
80
 
        {
81
 
                pIndicators->cActiveIndicatorImagePath = cairo_dock_generate_file_path (cIndicatorImageName);
82
 
                g_free (cIndicatorImageName);
83
 
        }
84
 
        else
85
 
                pIndicators->cActiveIndicatorImagePath = NULL;
86
 
        
87
 
        double couleur_active[4] = {0., 0.4, 0.8, 0.5};
88
 
        cairo_dock_get_double_list_key_value (pKeyFile, "Indicators", "active color", &bFlushConfFileNeeded, pIndicators->fActiveColor, 4, couleur_active, "Icons", NULL);
89
 
        pIndicators->iActiveLineWidth = cairo_dock_get_integer_key_value (pKeyFile, "Indicators", "active line width", &bFlushConfFileNeeded, 3, "Icons", NULL);
90
 
        pIndicators->iActiveCornerRadius = cairo_dock_get_integer_key_value (pKeyFile, "Indicators", "active corner radius", &bFlushConfFileNeeded, 6, "Icons", NULL);
91
 
        
92
 
        pIndicators->bActiveIndicatorAbove = cairo_dock_get_boolean_key_value (pKeyFile, "Indicators", "active frame position", &bFlushConfFileNeeded, TRUE, "Icons", NULL);
93
 
        
94
 
        //\__________________ On recupere l'indicateur de classe groupee.
95
 
        cIndicatorImageName = cairo_dock_get_string_key_value (pKeyFile, "Indicators", "class indicator", &bFlushConfFileNeeded, NULL, NULL, NULL);
96
 
        if (cIndicatorImageName != NULL)
97
 
        {
98
 
                pIndicators->cClassIndicatorImagePath = cairo_dock_generate_file_path (cIndicatorImageName);
99
 
                g_free (cIndicatorImageName);
100
 
        }
101
 
        else
102
 
        {
103
 
                pIndicators->cClassIndicatorImagePath = g_strdup_printf ("%s/%s", CAIRO_DOCK_SHARE_DATA_DIR, CAIRO_DOCK_DEFAULT_CLASS_INDICATOR_NAME);
104
 
        }
105
 
        pIndicators->bZoomClassIndicator = cairo_dock_get_boolean_key_value (pKeyFile, "Indicators", "zoom class", &bFlushConfFileNeeded, FALSE, NULL, NULL);
106
 
        
107
 
        return bFlushConfFileNeeded;
108
 
}
109
 
 
110
 
 
111
 
static void reset_config (CairoConfigIndicators *pIndicators)
112
 
{
113
 
        g_free (pIndicators->cIndicatorImagePath);
114
 
        g_free (pIndicators->cActiveIndicatorImagePath);
115
 
        g_free (pIndicators->cClassIndicatorImagePath);
116
 
}
117
 
 
118
 
 
119
 
static void reload (CairoConfigIndicators *pPrevIndicators, CairoConfigIndicators *pIndicators)
120
 
{
121
 
        CairoDock *pDock = g_pMainDock;
122
 
        double fMaxScale = cairo_dock_get_max_scale (pDock);
123
 
        cairo_t* pCairoContext = cairo_dock_create_drawing_context_generic (CAIRO_CONTAINER (pDock));
124
 
        
125
 
        if (cairo_dock_strings_differ (pPrevIndicators->cIndicatorImagePath, pIndicators->cIndicatorImagePath) ||
126
 
                pPrevIndicators->bLinkIndicatorWithIcon != pIndicators->bLinkIndicatorWithIcon ||
127
 
                pPrevIndicators->fIndicatorRatio != pIndicators->fIndicatorRatio)
128
 
        {
129
 
                cairo_dock_load_task_indicator (myTaskBar.bShowAppli && (myTaskBar.bMixLauncherAppli || myTaskBar.bDrawIndicatorOnAppli) ? pIndicators->cIndicatorImagePath : NULL, fMaxScale, pIndicators->fIndicatorRatio);
130
 
        }
131
 
        
132
 
        if (cairo_dock_strings_differ (pPrevIndicators->cActiveIndicatorImagePath, pIndicators->cActiveIndicatorImagePath) ||
133
 
                pPrevIndicators->iActiveCornerRadius != pIndicators->iActiveCornerRadius ||
134
 
                pPrevIndicators->iActiveLineWidth != pIndicators->iActiveLineWidth ||
135
 
                cairo_dock_colors_differ (pPrevIndicators->fActiveColor, pIndicators->fActiveColor))
136
 
        {
137
 
                cairo_dock_load_active_window_indicator (pIndicators->cActiveIndicatorImagePath,
138
 
                        fMaxScale,
139
 
                        pIndicators->iActiveCornerRadius,
140
 
                        pIndicators->iActiveLineWidth,
141
 
                        pIndicators->fActiveColor);
142
 
        }
143
 
        
144
 
        if (cairo_dock_strings_differ (pPrevIndicators->cClassIndicatorImagePath, pIndicators->cClassIndicatorImagePath))
145
 
        {
146
 
                cairo_dock_load_class_indicator (myTaskBar.bShowAppli && myTaskBar.bGroupAppliByClass ? pIndicators->cClassIndicatorImagePath : NULL, fMaxScale);
147
 
        }
148
 
        
149
 
        cairo_destroy (pCairoContext);
150
 
        
151
 
        cairo_dock_redraw_root_docks (FALSE);  // main dock inclus.
152
 
}
153
 
 
154
 
 
155
 
DEFINE_PRE_INIT (Indicators)
156
 
{
157
 
        pModule->cModuleName = "Indicators";
158
 
        pModule->cTitle = N_("Indicators");
159
 
        pModule->cIcon = "icon-indicators.png";
160
 
        pModule->cDescription = N_("Indicators are extra indications on your icons.");
161
 
        pModule->iCategory = CAIRO_DOCK_CATEGORY_THEME;
162
 
        pModule->iSizeOfConfig = sizeof (CairoConfigIndicators);
163
 
        pModule->iSizeOfData = 0;
164
 
        
165
 
        pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
166
 
        pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
167
 
        pModule->reset_config = (CairoDockInternalModuleResetConfigFunc) reset_config;
168
 
        pModule->reset_data = NULL;
169
 
        
170
 
        pModule->pConfig = (CairoInternalModuleConfigPtr) &myIndicators;
171
 
        pModule->pData = NULL;
172
 
}