summaryrefslogtreecommitdiff
path: root/src/gsettings.h
blob: ee0d51c3e7ffaf194c9221b6b53567de359ef31e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/**
 *
 * GSettings libccs backend
 *
 * gconf-integration.c
 *
 * Copyright (c) 2011 Canonical Ltd
 *
 * Based on the original compizconfig-backend-gconf
 *
 * Copyright (c) 2007 Danny Baumann <maniac@opencompositing.org>
 *
 * Parts of this code are taken from libberylsettings 
 * gconf backend, written by:
 *
 * Copyright (c) 2006 Robert Carr <racarr@opencompositing.org>
 * Copyright (c) 2007 Dennis Kasprzyk <onestone@opencompositing.org>
 *
 * 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 <sam.spilsbury@canonical.com>
 *
 **/

#ifndef _COMPIZCONFIG_BACKEND_GSETTINGS_GSETTINGS_H
#define _COMPIZCONFIG_BACKEND_GSETTINGS_GSETTINGS_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <string.h>
#include <dirent.h>

#include <ccs.h>
#include <ccs-backend.h>

#include <gio/gio.h>

#include <X11/X.h>
#include <X11/Xlib.h>

#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 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 COMPIZ_PROFILEPATH COMPIZ "/profiles"
#define COMPIZCONFIG "/org/freedesktop/compizconfig"
#define PROFILEPATH  COMPIZCONFIG "/profiles"
#define DEFAULTPROF "Default"
#define CORE_NAME   "core"

#define BUFSIZE 512

#define NUM_WATCHED_DIRS 3

#define KEYNAME(sn)     char keyName[BUFSIZE]; \
                    snprintf (keyName, BUFSIZE, "screen%i", sn);

#define PATHNAME(p,k)    char pathName[BUFSIZE]; \
                    if (!p || \
			strcmp (p, "core") == 0) \
                        snprintf (pathName, BUFSIZE, \
				 "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \
				 p, k); \
                    else \
			snprintf(pathName, BUFSIZE, \
				 "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \
				 p, k);

#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 <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <gconf/gconf-value.h>

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