From dc7a61ff42237af3eb57e97e1680903a318e2cd8 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 15 Jul 2011 05:24:16 +0800 Subject: Moved all the GConf integration support into a separate file keep the USE_GCONF markers --- src/gsettings.h | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 src/gsettings.h (limited to 'src/gsettings.h') diff --git a/src/gsettings.h b/src/gsettings.h new file mode 100644 index 0000000..b6a02af --- /dev/null +++ b/src/gsettings.h @@ -0,0 +1,153 @@ +/** + * + * GSettings libccs backend + * + * gconf-integration.c + * + * Copyright (c) 2011 Canonical Ltd + * + * Based on the original compizconfig-backend-gconf + * + * Copyright (c) 2007 Danny Baumann + * + * Parts of this code are taken from libberylsettings + * gconf backend, written by: + * + * Copyright (c) 2006 Robert Carr + * Copyright (c) 2007 Dennis Kasprzyk + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Authored By: + * Sam Spilsbury + * + **/ + +#ifndef _COMPIZCONFIG_BACKEND_GSETTINGS_GSETTINGS_H +#define _COMPIZCONFIG_BACKEND_GSETTINGS_GSETTINGS_H + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + +#define CompAltMask (1 << 16) +#define CompMetaMask (1 << 17) +#define CompSuperMask (1 << 18) +#define CompHyperMask (1 << 19) +#define CompModeSwitchMask (1 << 20) +#define CompNumLockMask (1 << 21) +#define CompScrollLockMask (1 << 22) + +#define SCHEMA_ID "org.freedesktop.compiz" +#define METACITY "/apps/metacity" +#define COMPIZ "/apps/compiz-1" +#define COMPIZCONFIG "/apps/compizconfig-1" +#define PROFILEPATH COMPIZCONFIG "/profiles" +#define DEFAULTPROF "Default" +#define CORE_NAME "core" + +#define BUFSIZE 512 + +#define NUM_WATCHED_DIRS 3 + +#define CLEAN_SETTING_NAME char *cleanSettingName = gsettings_backend_clean (setting->name) + +#define KEYNAME(sn) char keyName[BUFSIZE]; \ + snprintf (keyName, BUFSIZE, "screen%i", sn); + +#define PATHNAME char pathName[BUFSIZE]; \ + if (!setting->parent->name || \ + strcmp (setting->parent->name, "core") == 0) \ + snprintf (pathName, BUFSIZE, \ + "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \ + setting->parent->name, keyName); \ + else \ + snprintf(pathName, BUFSIZE, \ + "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \ + setting->parent->name, keyName); + +#define CLEANUP_CLEAN_SETTING_NAME free (cleanSettingName); + +#define _GNU_SOURCE + +typedef enum { + OptionInt, + OptionBool, + OptionKey, + OptionString, + OptionSpecial, +} SpecialOptionType; + +char *currentProfile; + +Bool readInit (CCSContext * context); +void readSetting (CCSContext * context, CCSSetting * setting); +Bool readOption (CCSSetting * setting); +Bool writeInit (CCSContext * context); +void writeOption (CCSSetting *setting); + +#ifdef USE_GCONF + +#include +#include +#include + +GConfClient *client; +guint gnomeGConfNotifyIds[NUM_WATCHED_DIRS]; + +typedef struct _SpecialOptionGConf { + const char* settingName; + const char* pluginName; + Bool screen; + const char* gnomeName; + SpecialOptionType type; +} SpecialOptionGConf; + +Bool +isGConfIntegratedOption (CCSSetting *setting, + int *index); + +void +gnomeGConfValueChanged (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer user_data); + +void +initGConfClient (CCSContext *context); + +void +finiGConfClient (void); + +Bool +readGConfIntegratedOption (CCSContext *context, + CCSSetting *setting, + int index); + +void +writeGConfIntegratedOption (CCSContext *context, + CCSSetting *setting, + int index); + +#endif + +#endif -- cgit v1.1 From fff0e2a2b330fe02610d2798edc5dbd9b547f98a Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 15 Jul 2011 05:44:48 +0800 Subject: Coding style .. change foo_bar to camelCase --- src/gsettings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gsettings.h') diff --git a/src/gsettings.h b/src/gsettings.h index b6a02af..125bc65 100644 --- a/src/gsettings.h +++ b/src/gsettings.h @@ -69,7 +69,7 @@ #define NUM_WATCHED_DIRS 3 -#define CLEAN_SETTING_NAME char *cleanSettingName = gsettings_backend_clean (setting->name) +#define CLEAN_SETTING_NAME char *cleanSettingName = translateKeyForGSettings (setting->name) #define KEYNAME(sn) char keyName[BUFSIZE]; \ snprintf (keyName, BUFSIZE, "screen%i", sn); -- cgit v1.1 From 0a46b1c16b67bbccb74c6244a1f2ea046980e770 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 15 Jul 2011 05:50:17 +0800 Subject: Move strings describing schema id's and paths to #define's --- src/gsettings.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/gsettings.h') diff --git a/src/gsettings.h b/src/gsettings.h index 125bc65..c432d17 100644 --- a/src/gsettings.h +++ b/src/gsettings.h @@ -57,10 +57,13 @@ #define CompNumLockMask (1 << 21) #define CompScrollLockMask (1 << 22) -#define SCHEMA_ID "org.freedesktop.compiz" +#define COMPIZ_SCHEMA_ID "org.freedesktop.compiz" +#define COMPIZCONFIG_SCHEMA_ID "org.freedesktop.compizconfig" +#define PROFILE_SCHEMA_ID "org.freedesktop.compizconfig.profile" #define METACITY "/apps/metacity" #define COMPIZ "/apps/compiz-1" -#define COMPIZCONFIG "/apps/compizconfig-1" +#define COMPIZ_PROFILEPATH COMPIZ "/profiles" +#define COMPIZCONFIG "/org/freedesktop/compizconfig" #define PROFILEPATH COMPIZCONFIG "/profiles" #define DEFAULTPROF "Default" #define CORE_NAME "core" -- cgit v1.1 From fcea48cc8c78af202e7b104223220a997d0c1171 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 15 Jul 2011 05:51:57 +0800 Subject: Remove an ugly #define --- src/gsettings.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/gsettings.h') diff --git a/src/gsettings.h b/src/gsettings.h index c432d17..5220a6d 100644 --- a/src/gsettings.h +++ b/src/gsettings.h @@ -72,8 +72,6 @@ #define NUM_WATCHED_DIRS 3 -#define CLEAN_SETTING_NAME char *cleanSettingName = translateKeyForGSettings (setting->name) - #define KEYNAME(sn) char keyName[BUFSIZE]; \ snprintf (keyName, BUFSIZE, "screen%i", sn); @@ -88,8 +86,6 @@ "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \ setting->parent->name, keyName); -#define CLEANUP_CLEAN_SETTING_NAME free (cleanSettingName); - #define _GNU_SOURCE typedef enum { -- cgit v1.1 From 12e267452e11b9fb31960a8c965ec797b70aeebc Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 15 Jul 2011 05:55:30 +0800 Subject: Replace by a #define where appropriate --- src/gsettings.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gsettings.h') diff --git a/src/gsettings.h b/src/gsettings.h index 5220a6d..ee0d51c 100644 --- a/src/gsettings.h +++ b/src/gsettings.h @@ -75,16 +75,16 @@ #define KEYNAME(sn) char keyName[BUFSIZE]; \ snprintf (keyName, BUFSIZE, "screen%i", sn); -#define PATHNAME char pathName[BUFSIZE]; \ - if (!setting->parent->name || \ - strcmp (setting->parent->name, "core") == 0) \ +#define PATHNAME(p,k) char pathName[BUFSIZE]; \ + if (!p || \ + strcmp (p, "core") == 0) \ snprintf (pathName, BUFSIZE, \ "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \ - setting->parent->name, keyName); \ + p, k); \ else \ snprintf(pathName, BUFSIZE, \ "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \ - setting->parent->name, keyName); + p, k); #define _GNU_SOURCE -- cgit v1.1