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/>.
21
#include "cairo-dock-modules.h"
22
#include "cairo-dock-config.h"
23
#include "cairo-dock-dialog-manager.h"
24
#include "cairo-dock-internal-labels.h"
25
#include "cairo-dock-internal-background.h"
26
#define _INTERNAL_MODULE_
27
#include "cairo-dock-internal-dialogs.h"
29
CairoConfigDialogs myDialogs;
31
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigDialogs *pDialogs)
33
gboolean bFlushConfFileNeeded = FALSE;
35
pDialogs->cButtonOkImage = cairo_dock_get_string_key_value (pKeyFile, "Dialogs", "button_ok image", &bFlushConfFileNeeded, NULL, NULL, NULL);
36
pDialogs->cButtonCancelImage = cairo_dock_get_string_key_value (pKeyFile, "Dialogs", "button_cancel image", &bFlushConfFileNeeded, NULL, NULL, NULL);
38
cairo_dock_get_size_key_value_helper (pKeyFile, "Dialogs", "button ", bFlushConfFileNeeded, pDialogs->iDialogButtonWidth, pDialogs->iDialogButtonHeight);
40
double couleur_bulle[4] = {1.0, 1.0, 1.0, 0.7};
41
cairo_dock_get_double_list_key_value (pKeyFile, "Dialogs", "background color", &bFlushConfFileNeeded, pDialogs->fDialogColor, 4, couleur_bulle, NULL, NULL);
42
pDialogs->iDialogIconSize = MAX (16, cairo_dock_get_integer_key_value (pKeyFile, "Dialogs", "icon size", &bFlushConfFileNeeded, 48, NULL, NULL));
44
gboolean bCustomFont = cairo_dock_get_boolean_key_value (pKeyFile, "Dialogs", "custom", &bFlushConfFileNeeded, TRUE, NULL, NULL);
45
gchar *cFontDescription = (bCustomFont ? cairo_dock_get_string_key_value (pKeyFile, "Dialogs", "message police", &bFlushConfFileNeeded, NULL, "Icons", NULL) : NULL);
46
if (cFontDescription == NULL)
47
cFontDescription = cairo_dock_get_default_system_font ();
49
PangoFontDescription *fd = pango_font_description_from_string (cFontDescription);
50
pDialogs->dialogTextDescription.cFont = g_strdup (pango_font_description_get_family (fd));
51
pDialogs->dialogTextDescription.iSize = pango_font_description_get_size (fd);
52
if (!pango_font_description_get_size_is_absolute (fd))
53
pDialogs->dialogTextDescription.iSize /= PANGO_SCALE;
54
if (pDialogs->dialogTextDescription.iSize == 0)
55
pDialogs->dialogTextDescription.iSize = 14;
57
pDialogs->dialogTextDescription.iSize *= 1.33; // c'est pas beau, mais ca evite de casser tous les themes.
58
pDialogs->dialogTextDescription.iWeight = pango_font_description_get_weight (fd);
59
pDialogs->dialogTextDescription.iStyle = pango_font_description_get_style (fd);
60
pDialogs->dialogTextDescription.fMaxRelativeWidth = .5; // on limite a la moitie de l'ecran.
62
if (g_key_file_has_key (pKeyFile, "Dialogs", "message size", NULL)) // anciens parametres.
64
pDialogs->dialogTextDescription.iSize = g_key_file_get_integer (pKeyFile, "Dialogs", "message size", NULL);
65
int iLabelWeight = g_key_file_get_integer (pKeyFile, "Dialogs", "message weight", NULL);
66
pDialogs->dialogTextDescription.iWeight = cairo_dock_get_pango_weight_from_1_9 (iLabelWeight);
67
gboolean bLabelStyleItalic = g_key_file_get_boolean (pKeyFile, "Dialogs", "message italic", NULL);
68
if (bLabelStyleItalic)
69
pDialogs->dialogTextDescription.iStyle = PANGO_STYLE_ITALIC;
71
pDialogs->dialogTextDescription.iStyle = PANGO_STYLE_NORMAL;
73
pango_font_description_set_size (fd, pDialogs->dialogTextDescription.iSize * PANGO_SCALE);
74
pango_font_description_set_weight (fd, pDialogs->dialogTextDescription.iWeight);
75
pango_font_description_set_style (fd, pDialogs->dialogTextDescription.iStyle);
77
g_free (cFontDescription);
78
cFontDescription = pango_font_description_to_string (fd);
79
g_key_file_set_string (pKeyFile, "Dialogs", "message police", cFontDescription);
80
bFlushConfFileNeeded = TRUE;
82
pango_font_description_free (fd);
83
g_free (cFontDescription);
84
pDialogs->dialogTextDescription.bOutlined = cairo_dock_get_boolean_key_value (pKeyFile, "Dialogs", "outlined", &bFlushConfFileNeeded, FALSE, NULL, NULL);
85
pDialogs->dialogTextDescription.iMargin = 0;
87
double couleur_dtext[3] = {0., 0., 0.};
88
cairo_dock_get_double_list_key_value (pKeyFile, "Dialogs", "text color", &bFlushConfFileNeeded, pDialogs->dialogTextDescription.fColorStart, 3, couleur_dtext, NULL, NULL);
89
memcpy (&pDialogs->dialogTextDescription.fColorStop, &pDialogs->dialogTextDescription.fColorStart, 3*sizeof (double));
91
pDialogs->cDecoratorName = cairo_dock_get_string_key_value (pKeyFile, "Dialogs", "decorator", &bFlushConfFileNeeded, "comics", NULL, NULL);
93
return bFlushConfFileNeeded;
97
static void reset_config (CairoConfigDialogs *pDialogs)
99
g_free (pDialogs->cButtonOkImage);
100
g_free (pDialogs->cButtonCancelImage);
101
g_free (pDialogs->dialogTextDescription.cFont);
102
g_free (pDialogs->cDecoratorName);
106
static void reload (CairoConfigDialogs *pPrevDialogs, CairoConfigDialogs *pDialogs)
108
if (cairo_dock_strings_differ (pPrevDialogs->cButtonOkImage, pDialogs->cButtonOkImage) ||
109
cairo_dock_strings_differ (pPrevDialogs->cButtonCancelImage, pDialogs->cButtonCancelImage) ||
110
pPrevDialogs->iDialogIconSize != pDialogs->iDialogIconSize)
112
cairo_dock_unload_dialog_buttons ();
113
cairo_dock_load_dialog_buttons (pDialogs->cButtonOkImage, pDialogs->cButtonCancelImage);
118
DEFINE_PRE_INIT (Dialogs)
120
static const gchar *cDependencies[3] = {"dialog rendering", N_("This provides different window decorators. Enable this first if you want to select a different decorator for your dialog boxes."), NULL};
121
pModule->cModuleName = "Dialogs";
122
pModule->cTitle = N_("Dialog boxes");
123
pModule->cIcon = "icon-dialogs.svg";
124
pModule->cDescription = N_("Configure text bubble appearance.");
125
pModule->iCategory = CAIRO_DOCK_CATEGORY_THEME;
126
pModule->iSizeOfConfig = sizeof (CairoConfigDialogs);
127
pModule->iSizeOfData = 0;
128
pModule->cDependencies = cDependencies;
130
pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
131
pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
132
pModule->reset_config = (CairoDockInternalModuleResetConfigFunc) reset_config;
133
pModule->reset_data = NULL;
135
pModule->pConfig = (CairoInternalModuleConfigPtr) &myDialogs;
136
pModule->pData = NULL;