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-manager.h"
27
#include "cairo-dock-internal-taskbar.h"
28
#include "cairo-dock-file-manager.h"
29
#include "cairo-dock-renderer-manager.h"
30
#include "cairo-dock-desklet.h"
31
#define _INTERNAL_MODULE_
32
#include "cairo-dock-internal-desklets.h"
34
CairoConfigDesklets myDesklets;
35
extern CairoDock *g_pMainDock;
37
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigDesklets *pDesklets)
39
gboolean bFlushConfFileNeeded = FALSE;
41
pDesklets->cDeskletDecorationsName = cairo_dock_get_string_key_value (pKeyFile, "Desklets", "decorations", &bFlushConfFileNeeded, "dark", NULL, NULL);
42
CairoDeskletDecoration *pUserDeskletDecorations = cairo_dock_get_desklet_decoration ("personnal");
43
if (pUserDeskletDecorations == NULL)
45
pUserDeskletDecorations = g_new0 (CairoDeskletDecoration, 1);
46
pUserDeskletDecorations->cDisplayedName = _("_custom decoration_");
47
cairo_dock_register_desklet_decoration ("personnal", pUserDeskletDecorations);
49
if (pDesklets->cDeskletDecorationsName == NULL || strcmp (pDesklets->cDeskletDecorationsName, "personnal") == 0)
51
g_free (pUserDeskletDecorations->cBackGroundImagePath);
52
pUserDeskletDecorations->cBackGroundImagePath = cairo_dock_get_string_key_value (pKeyFile, "Desklets", "bg desklet", &bFlushConfFileNeeded, NULL, NULL, NULL);
53
g_free (pUserDeskletDecorations->cForeGroundImagePath);
54
pUserDeskletDecorations->cForeGroundImagePath = cairo_dock_get_string_key_value (pKeyFile, "Desklets", "fg desklet", &bFlushConfFileNeeded, NULL, NULL, NULL);
55
pUserDeskletDecorations->iLoadingModifier = CAIRO_DOCK_FILL_SPACE;
56
pUserDeskletDecorations->fBackGroundAlpha = cairo_dock_get_double_key_value (pKeyFile, "Desklets", "bg alpha", &bFlushConfFileNeeded, 1.0, NULL, NULL);
57
pUserDeskletDecorations->fForeGroundAlpha = cairo_dock_get_double_key_value (pKeyFile, "Desklets", "fg alpha", &bFlushConfFileNeeded, 1.0, NULL, NULL);
58
pUserDeskletDecorations->iLeftMargin = cairo_dock_get_integer_key_value (pKeyFile, "Desklets", "left offset", &bFlushConfFileNeeded, CAIRO_DOCK_FM_SORT_BY_NAME, NULL, NULL);
59
pUserDeskletDecorations->iTopMargin = cairo_dock_get_integer_key_value (pKeyFile, "Desklets", "top offset", &bFlushConfFileNeeded, CAIRO_DOCK_FM_SORT_BY_NAME, NULL, NULL);
60
pUserDeskletDecorations->iRightMargin = cairo_dock_get_integer_key_value (pKeyFile, "Desklets", "right offset", &bFlushConfFileNeeded, CAIRO_DOCK_FM_SORT_BY_NAME, NULL, NULL);
61
pUserDeskletDecorations->iBottomMargin = cairo_dock_get_integer_key_value (pKeyFile, "Desklets", "bottom offset", &bFlushConfFileNeeded, CAIRO_DOCK_FM_SORT_BY_NAME, NULL, NULL);
63
pDesklets->iDeskletButtonSize = cairo_dock_get_integer_key_value (pKeyFile, "Desklets", "button size", &bFlushConfFileNeeded, 16, NULL, NULL);
64
pDesklets->cRotateButtonImage = cairo_dock_get_string_key_value (pKeyFile, "Desklets", "rotate image", &bFlushConfFileNeeded, NULL, NULL, NULL);
65
pDesklets->cRetachButtonImage = cairo_dock_get_string_key_value (pKeyFile, "Desklets", "retach image", &bFlushConfFileNeeded, NULL, NULL, NULL);
66
pDesklets->cDepthRotateButtonImage = cairo_dock_get_string_key_value (pKeyFile, "Desklets", "depth rotate image", &bFlushConfFileNeeded, NULL, NULL, NULL);
67
return bFlushConfFileNeeded;
71
static void reset_config (CairoConfigDesklets *pDesklets)
73
g_free (pDesklets->cDeskletDecorationsName);
74
g_free (pDesklets->cRotateButtonImage);
75
g_free (pDesklets->cRetachButtonImage);
76
g_free (pDesklets->cDepthRotateButtonImage);
80
static void reload (CairoConfigDesklets *pPrevDesklets, CairoConfigDesklets *pDesklets)
82
CairoDock *pDock = g_pMainDock;
83
cairo_t* pCairoContext = cairo_dock_create_drawing_context_generic (CAIRO_CONTAINER (pDock));
84
if (cairo_dock_strings_differ (pPrevDesklets->cRotateButtonImage, pDesklets->cRotateButtonImage) ||
85
cairo_dock_strings_differ (pPrevDesklets->cRetachButtonImage, pDesklets->cRetachButtonImage) ||
86
cairo_dock_strings_differ (pPrevDesklets->cDepthRotateButtonImage, pDesklets->cDepthRotateButtonImage))
88
cairo_dock_unload_desklet_buttons ();
89
cairo_dock_load_desklet_buttons ();
91
if (cairo_dock_strings_differ (pPrevDesklets->cDeskletDecorationsName, pDesklets->cDeskletDecorationsName))
93
cairo_dock_reload_desklets_decorations (TRUE, pCairoContext); // TRUE <=> bDefaultThemeOnly
95
cairo_destroy (pCairoContext);
99
DEFINE_PRE_INIT (Desklets)
101
pModule->cModuleName = "Desklets";
102
pModule->cTitle = N_("Desklets");
103
pModule->cIcon = "icon-desklets.png";
104
pModule->cDescription = N_("The applets can be set on your desktop as widgets.");
105
pModule->iCategory = CAIRO_DOCK_CATEGORY_THEME;
106
pModule->iSizeOfConfig = sizeof (CairoConfigDesklets);
107
pModule->iSizeOfData = 0;
109
pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
110
pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
111
pModule->reset_config = (CairoDockInternalModuleResetConfigFunc) reset_config;
112
pModule->reset_data = NULL;
114
pModule->pConfig = (CairoInternalModuleConfigPtr) &myDesklets;
115
pModule->pData = NULL;