3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
7 #include "gconfutility.h"
8 #include <gconf/gconf-client.h>
11 GConfUtility::GConfUtility(QObject *parent) :
14 /* Get a GConf client */
15 gconfClient = gconf_client_get_default();
16 g_assert(GCONF_IS_CLIENT(gconfClient));
19 GConfUtility::~GConfUtility(){
20 /* release GConf client */
21 g_object_unref(gconfClient);
25 QString GConfUtility::getGconfValueString(QString strKey){
27 char* strValue = NULL;
29 if (!strKey.isEmpty()) {
30 strKey.prepend(GCONF_DIR);
32 strValue = gconf_client_get_string(gconfClient, strKey.toAscii().constData(), NULL);
33 qDebug() << "Gconf: "<<strKey.toAscii().constData()<< " is "<<strValue;
36 return QString(strValue);
39 void GConfUtility::setGconfValueString(QString strKey,QString strValue){
41 if (!strKey.isEmpty()){
43 strKey.prepend(GCONF_DIR);
45 if (!strValue.isEmpty()){
46 gconf_client_set_string(gconfClient, strKey.toAscii().constData(), strValue.toAscii().constData(),NULL);
47 qDebug() << "Assigned "<<strKey.toAscii().constData()<< " to "<<strValue.toAscii().constData();
50 gconf_client_unset(gconfClient, strKey.toAscii().constData(),NULL);
51 qDebug() << "Assigned "<<strKey.toAscii().constData()<< " to NULL";
57 bool GConfUtility::getGconfValueBoolean(QString strKey){
59 bool boolValue = false;
61 if (!strKey.isEmpty()) {
62 strKey.prepend(GCONF_DIR);
64 boolValue = gconf_client_get_bool(gconfClient, strKey.toAscii().constData(), NULL);
65 qDebug() << "Gconf: "<<strKey.toAscii().constData()<< " is "<<boolValue;
71 void GConfUtility::setGconfValueBoolean(QString strKey,bool boolValue){
73 if (!strKey.isEmpty()){
75 strKey.prepend(GCONF_DIR);
77 gconf_client_set_bool(gconfClient, strKey.toAscii().constData(),boolValue,NULL);
78 qDebug() << "Assigned "<<strKey.toAscii().constData()<< " to "<<boolValue;
82 int GConfUtility::getGconfValueInteger(QString strKey){
86 if (!strKey.isEmpty()) {
87 strKey.prepend(GCONF_DIR);
89 intValue = gconf_client_get_int(gconfClient, strKey.toAscii().constData(), NULL);
90 qDebug() << "Gconf: "<<strKey.toAscii().constData()<< " is "<<intValue;
96 void GConfUtility::setGconfValueInteger(QString strKey,int intValue){
98 if (!strKey.isEmpty()){
100 strKey.prepend(GCONF_DIR);
102 gconf_client_set_int(gconfClient, strKey.toAscii().constData(),intValue,NULL);
103 qDebug() << "Assigned "<<strKey.toAscii().constData()<< " to "<<intValue;