~ubuntu-branches/ubuntu/precise/cairo-dock/precise-updates

« 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: 2011-03-17 14:08:48 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20110317140848-b8efysl4ynhjm87k
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723994)
* Upstream short ChangeLog:
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
 - Updated default theme
 - Fixed a few bugs
 - Updated the man
* debian/control:
 - Added suggests apps for cairo-dock-core (needed by the default theme)
 - Updated the description (from launchpad.net/cairo-dock)
 - Added cairo-dock-plug-ins as a new suggestion for cairo-dock-core
* debian/patches:
 - Updated the default theme to use default apps of Ubuntu Natty 
* Switch to dpkg-source 3.0 (quilt) format
* Removed the desktop-file-category patch (sync with debian packages)
* debian/rules:
 - Added a CMake flag to disable the gtk grip
 - No longer used simple-patchsys
* Updated the debian/watch

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
 
        pDialogs->dialogTextDescription.fMaxRelativeWidth = .5;  // on limite a la moitie de l'ecran.
61
 
        
62
 
        if (g_key_file_has_key (pKeyFile, "Dialogs", "message size", NULL))  // anciens parametres.
63
 
        {
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;
70
 
                else
71
 
                        pDialogs->dialogTextDescription.iStyle = PANGO_STYLE_NORMAL;
72
 
                
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);
76
 
                
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;
81
 
        }
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;
86
 
        
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));
90
 
        
91
 
        pDialogs->cDecoratorName = cairo_dock_get_string_key_value (pKeyFile, "Dialogs", "decorator", &bFlushConfFileNeeded, "comics", NULL, NULL);
92
 
 
93
 
        return bFlushConfFileNeeded;
94
 
}
95
 
 
96
 
 
97
 
static void reset_config (CairoConfigDialogs *pDialogs)
98
 
{
99
 
        g_free (pDialogs->cButtonOkImage);
100
 
        g_free (pDialogs->cButtonCancelImage);
101
 
        g_free (pDialogs->dialogTextDescription.cFont);
102
 
        g_free (pDialogs->cDecoratorName);
103
 
}
104
 
 
105
 
 
106
 
static void reload (CairoConfigDialogs *pPrevDialogs, CairoConfigDialogs *pDialogs)
107
 
{
108
 
        if (cairo_dock_strings_differ (pPrevDialogs->cButtonOkImage, pDialogs->cButtonOkImage) ||
109
 
                cairo_dock_strings_differ (pPrevDialogs->cButtonCancelImage, pDialogs->cButtonCancelImage) ||
110
 
                pPrevDialogs->iDialogIconSize != pDialogs->iDialogIconSize)
111
 
        {
112
 
                cairo_dock_unload_dialog_buttons ();
113
 
                cairo_dock_load_dialog_buttons (pDialogs->cButtonOkImage, pDialogs->cButtonCancelImage);
114
 
        }
115
 
}
116
 
 
117
 
 
118
 
DEFINE_PRE_INIT (Dialogs)
119
 
{
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;
129
 
        
130
 
        pModule->reload = (CairoDockInternalModuleReloadFunc) reload;
131
 
        pModule->get_config = (CairoDockInternalModuleGetConfigFunc) get_config;
132
 
        pModule->reset_config = (CairoDockInternalModuleResetConfigFunc) reset_config;
133
 
        pModule->reset_data = NULL;
134
 
        
135
 
        pModule->pConfig = (CairoInternalModuleConfigPtr) &myDialogs;
136
 
        pModule->pData = NULL;
137
 
}