| 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 "powermanager-struct.h" |
| 23 |
#include "powermanager-config.h" |
| 24 |
|
| 25 |
|
| 26 |
CD_APPLET_GET_CONFIG_BEGIN |
| 27 |
|
| 28 |
myConfig.defaultTitle = CD_CONFIG_GET_STRING ("Icon", "name"); |
| 29 |
|
| 30 |
myConfig.iCheckInterval = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "check interval", 10); |
| 31 |
|
| 32 |
myConfig.quickInfoType = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "quick-info_type", POWER_MANAGER_TIME); |
| 33 |
|
| 34 |
|
| 35 |
myConfig.lowBatteryWitness = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "low battery", TRUE); |
| 36 |
|
| 37 |
myConfig.highBatteryWitness = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "high battery", TRUE); |
| 38 |
|
| 39 |
myConfig.criticalBatteryWitness = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "critical battery", TRUE); |
| 40 |
|
| 41 |
myConfig.iNotificationType = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "notifications", 2) + 1; |
| 42 |
myConfig.cNotificationAnimation = CD_CONFIG_GET_STRING ("Configuration", "battery_animation"); |
| 43 |
myConfig.iNotificationDuration = CD_CONFIG_GET_INTEGER ("Configuration", "notif_duration"); |
| 44 |
|
| 45 |
myConfig.lowBatteryValue = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "low value", 15); |
| 46 |
|
| 47 |
if (! g_key_file_has_key (CD_APPLET_MY_KEY_FILE, "Configuration", "renderer", NULL)) // old version. |
| 48 |
{ |
| 49 |
myConfig.iDisplayType = (g_key_file_get_boolean (CD_APPLET_MY_KEY_FILE, "Configuration", "use gauge", NULL) ? CD_POWERMANAGER_GAUGE : CD_POWERMANAGER_ICONS); |
| 50 |
// int dummy = CD_CONFIG_GET_INTEGER ("Configuration", "renderer"); |
| 51 |
} |
| 52 |
else |
| 53 |
myConfig.iDisplayType = CD_CONFIG_GET_INTEGER ("Configuration", "renderer"); |
| 54 |
|
| 55 |
myConfig.cGThemePath = CD_CONFIG_GET_GAUGE_THEME ("Configuration", "theme"); |
| 56 |
|
| 57 |
myConfig.iGraphType = CD_CONFIG_GET_INTEGER ("Configuration", "graphic type"); |
| 58 |
CD_CONFIG_GET_COLOR_RGB ("Configuration", "low color", myConfig.fLowColor); |
| 59 |
CD_CONFIG_GET_COLOR_RGB ("Configuration", "high color", myConfig.fHigholor); |
| 60 |
CD_CONFIG_GET_COLOR_RGBA ("Configuration", "bg color", myConfig.fBgColor); |
| 61 |
|
| 62 |
myConfig.cUserBatteryIconName = CD_CONFIG_GET_STRING ("Configuration", "battery icon"); |
| 63 |
myConfig.cUserChargeIconName = CD_CONFIG_GET_STRING ("Configuration", "charge icon"); |
| 64 |
myConfig.cEmblemIconName = CD_CONFIG_GET_STRING ("Configuration", "emblem icon"); |
| 65 |
myConfig.bHideNotOnBattery = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "hide not on battery", FALSE); |
| 66 |
|
| 67 |
|
| 68 |
GString *sKeyName = g_string_new (""); |
| 69 |
int i; |
| 70 |
for (i = 0; i < POWER_MANAGER_NB_CHARGE_LEVEL; i ++) |
| 71 |
{ |
| 72 |
g_string_printf (sKeyName, "sound_%d", i); |
| 73 |
myConfig.cSoundPath[i] = CD_CONFIG_GET_STRING ("Configuration", sKeyName->str); |
| 74 |
} |
| 75 |
g_string_free (sKeyName, TRUE); |
| 76 |
|
| 77 |
myConfig.fLastDischargeMeanRate = CD_CONFIG_GET_DOUBLE ("Configuration", "discharge rate"); |
| 78 |
myConfig.fLastChargeMeanRate = CD_CONFIG_GET_DOUBLE ("Configuration", "charge rate"); |
| 79 |
CD_APPLET_GET_CONFIG_END |
| 80 |
|
| 81 |
|
| 82 |
CD_APPLET_RESET_CONFIG_BEGIN |
| 83 |
|
| 84 |
g_free (myConfig.defaultTitle); |
| 85 |
g_free (myConfig.cUserBatteryIconName); |
| 86 |
g_free (myConfig.cUserChargeIconName); |
| 87 |
g_free (myConfig.cNotificationAnimation); |
| 88 |
g_free (myConfig.cEmblemIconName); |
| 89 |
g_free (myConfig.cGThemePath); |
| 90 |
|
| 91 |
int i; |
| 92 |
for (i = 0; i < POWER_MANAGER_NB_CHARGE_LEVEL; i ++) |
| 93 |
{ |
| 94 |
g_free (myConfig.cSoundPath[i]); |
| 95 |
} |
| 96 |
|
| 97 |
CD_APPLET_RESET_CONFIG_END |
| 98 |
|
| 99 |
|
| 100 |
CD_APPLET_RESET_DATA_BEGIN |
| 101 |
|
| 102 |
CD_APPLET_REMOVE_MY_DATA_RENDERER; |
| 103 |
|
| 104 |
g_free (myData.cBatteryStateFilePath); |
| 105 |
|
| 106 |
g_free (myData.cTechnology); |
| 107 |
g_free (myData.cVendor); |
| 108 |
g_free (myData.cModel); |
| 109 |
|
| 110 |
CD_APPLET_RESET_DATA_END |