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

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-internal-dialogs.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
#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"
 
28
 
 
29
CairoConfigDialogs myDialogs;
 
30
 
 
31
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigDialogs *pDialogs)
 
32
{
 
33
        gboolean bFlushConfFileNeeded = FALSE;
 
34
        
 
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);
 
37
 
 
38
        cairo_dock_get_size_key_value_helper (pKeyFile, "Dialogs", "button ", bFlushConfFileNeeded, pDialogs->iDialogButtonWidth, pDialogs->iDialogButtonHeight);
 
39
 
 
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));
 
43
        
 
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 ();
 
48
        
 
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;
 
56
        if (!bCustomFont)
 
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
        
 
61
        if (g_key_file_has_key (pKeyFile, "Dialogs", "message size", NULL))  // anciens parametres.
 
62
        {
 
63
                pDialogs->dialogTextDescription.iSize = g_key_file_get_integer (pKeyFile, "Dialogs", "message size", NULL);
 
64
                int iLabelWeight = g_key_file_get_integer (pKeyFile, "Dialogs", "message weight", NULL);
 
65
                pDialogs->dialogTextDescription.iWeight = cairo_dock_get_pango_weight_from_1_9 (iLabelWeight);
 
66
                gboolean bLabelStyleItalic = g_key_file_get_boolean (pKeyFile, "Dialogs", "message italic", NULL);
 
67
                if (bLabelStyleItalic)
 
68
                        pDialogs->dialogTextDescription.iStyle = PANGO_STYLE_ITALIC;
 
69
                else
 
70
                        pDialogs->dialogTextDescription.iStyle = PANGO_STYLE_NORMAL;
 
71
                
 
72
                pango_font_description_set_size (fd, pDialogs->dialogTextDescription.iSize * PANGO_SCALE);
 
73
                pango_font_description_set_weight (fd, pDialogs->dialogTextDescription.iWeight);
 
74
                pango_font_description_set_style (fd, pDialogs->dialogTextDescription.iStyle);
 
75
                
 
76
                g_free (cFontDescription);
 
77
                cFontDescription = pango_font_description_to_string (fd);
 
78
                g_key_file_set_string (pKeyFile, "Dialogs", "message police", cFontDescription);
 
79
                bFlushConfFileNeeded = TRUE;
 
80
        }
 
81
        pango_font_description_free (fd);
 
82
        g_free (cFontDescription);
 
83
        pDialogs->dialogTextDescription.bOutlined = cairo_dock_get_boolean_key_value (pKeyFile, "Dialogs", "outlined", &bFlushConfFileNeeded, FALSE, NULL, NULL);
 
84
        pDialogs->dialogTextDescription.iMargin = 0;
 
85
        
 
86
        double couleur_dtext[3] = {0., 0., 0.};
 
87
        cairo_dock_get_double_list_key_value (pKeyFile, "Dialogs", "text color", &bFlushConfFileNeeded, pDialogs->dialogTextDescription.fColorStart, 3, couleur_dtext, NULL, NULL);
 
88
        memcpy (&pDialogs->dialogTextDescription.fColorStop, &pDialogs->dialogTextDescription.fColorStart, 3*sizeof (double));
 
89
        
 
90
        pDialogs->cDecoratorName = cairo_dock_get_string_key_value (pKeyFile, "Dialogs", "decorator", &bFlushConfFileNeeded, "comics", NULL, NULL);
 
91
 
 
92
        return bFlushConfFileNeeded;
 
93
}
 
94
 
 
95
 
 
96
static void reset_config (CairoConfigDialogs *pDialogs)
 
97
{
 
98
        g_free (pDialogs->cButtonOkImage);
 
99
        g_free (pDialogs->cButtonCancelImage);
 
100
        g_free (pDialogs->dialogTextDescription.cFont);
 
101
        g_free (pDialogs->cDecoratorName);
 
102
}
 
103
 
 
104
 
 
105
static void reload (CairoConfigDialogs *pPrevDialogs, CairoConfigDialogs *pDialogs)
 
106
{
 
107
        if (cairo_dock_strings_differ (pPrevDialogs->cButtonOkImage, pDialogs->cButtonOkImage) ||
 
108
                cairo_dock_strings_differ (pPrevDialogs->cButtonCancelImage, pDialogs->cButtonCancelImage) ||
 
109
                pPrevDialogs->iDialogIconSize != pDialogs->iDialogIconSize)
 
110
        {
 
111
                cairo_dock_unload_dialog_buttons ();
 
112
                cairo_dock_load_dialog_buttons (pDialogs->cButtonOkImage, pDialogs->cButtonCancelImage);
 
113
        }
 
114
}
 
115
 
 
116
 
 
117
DEFINE_PRE_INIT (Dialogs)
 
118
{
 
119
        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};
 
120
        pModule->cModuleName = "Dialogs";
 
121
        pModule->cTitle = N_("Dialog boxes");
 
122
        pModule->cIcon = "icon-dialogs.svg";
 
123
        pModule->cDescription = N_("Configure text bubble appearance.");
 
124
        pModule->iCategory = CAIRO_DOCK_CATEGORY_THEME;
 
125
        pModule->iSizeOfConfig = sizeof (CairoConfigDialogs);
 
126
        pModule->iSizeOfData = 0;
 
127
        pModule->cDependencies = cDependencies;
 
128
        
 
129
        pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
 
130
        pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
 
131
        pModule->reset_config = (CairoDockInternalModuleResetConfigFunc) reset_config;
 
132
        pModule->reset_data = NULL;
 
133
        
 
134
        pModule->pConfig = (CairoInternalModuleConfigPtr) &myDialogs;
 
135
        pModule->pData = NULL;
 
136
}