1 /*
2  * Compiz configuration system library
3  *
4  * Copyright (C) 2007  Dennis Kasprzyk <onestone@beryl-project.org>
5  * Copyright (C) 2007  Danny Baumann <maniac@beryl-project.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11 
12  * This library 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 GNU
15  * Lesser General Public License for more details.
16 
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 
23 #ifndef _CSS_H
24 #define _CSS_H
25 
26 #define D_NONE   0
27 #define D_NORMAL 1
28 #define D_FULL   2
29 
30 #ifndef DEBUGLEVEL
31 # define DEBUGLEVEL D_NONE
32 #endif
33 #define D(x, fmt, args...)  { if (x <= DEBUGLEVEL) printf(fmt, ##args); }
34 
35 #ifndef Bool
36 #define Bool int
37 #endif
38 
39 #ifndef TRUE
40 #define TRUE ~0
41 #endif
42 
43 #ifndef FALSE
44 #define FALSE 0
45 #endif
46 
47 /**
48  * list functions:
49  * for each list there is a set of functions, explained using String as example
50  *
51  * ccsStringListAppend (list, item)
52  * Adds an item at the end of the list. Returns the new list.
53  *
54  * ccsStringListPrepend (list, item)
55  * Adds an item at the beginning of the list. Returns the new list.
56  *
57  * ccsStringListInsert (list, item, position)
58  * Adds an item at a given position. Position is 0-based. If position is
59  * larger than the amount of items in the list, the item is inserted at the
60  * end of the list. Returns the new list.
61  *
62  * ccsStringListInsertBefore (list, sibling, item)
63  * Inserts item before sibling into the list. If sibling is no list member,
64  * item is inserted at the end. Returns the new list.
65  *
66  * ccsStringListLength (list)
67  * Returns the amount of items in list.
68  *
69  * ccsStringListFind (list, item)
70  * Finds and returns an item matching <item>. If nothing is found, returns NULL.
71  *
72  * ccsStringListGetItem (list, index)
73  * Returns the list item at position <index>. If index is larger than the
74  * amount of items in the list, returns NULL.
75  *
76  * ccsStringListRemove (list, item, freeObj)
77  * Removes item from the list. If freeObj is TRUE, also frees the data item.
78  * Returns the new list.
79  *
80  * ccsStringListFree (list, freeObj)
81  * Frees the complete list. If freeObj is TRUE, also frees the data items.
82  * Returns the new list (NULL).
83  */
84 #define CCSLIST_HDR(type,dtype)		\
85     typedef struct _CCS##type##List *	CCS##type##List;\
86     struct _CCS##type##List	\
87     {								\
88 	dtype   * data;			\
89 	CCS##type##List next;		\
90     }; \
91     CCS##type##List ccs##type##ListAppend (CCS##type##List list, dtype *data); \
92     CCS##type##List ccs##type##ListPrepend (CCS##type##List list, dtype *data); \
93     CCS##type##List ccs##type##ListInsert (CCS##type##List list, dtype *data, int position); \
94     CCS##type##List ccs##type##ListInsertBefore (CCS##type##List list, CCS##type##List sibling, dtype *data); \
95     unsigned int ccs##type##ListLength (CCS##type##List list); \
96     CCS##type##List ccs##type##ListFind (CCS##type##List list, dtype *data); \
97     CCS##type##List ccs##type##ListGetItem (CCS##type##List list, unsigned int index); \
98     CCS##type##List ccs##type##ListRemove (CCS##type##List list, dtype *data, Bool freeObj); \
99     CCS##type##List ccs##type##ListFree (CCS##type##List list, Bool freeObj);
100 
101 typedef struct _CCSContext	  CCSContext;
102 typedef struct _CCSPlugin	  CCSPlugin;
103 typedef struct _CCSSetting	  CCSSetting;
104 typedef struct _CCSGroup	  CCSGroup;
105 typedef struct _CCSSubGroup	  CCSSubGroup;
106 typedef struct _CCSPluginCategory CCSPluginCategory;
107 typedef struct _CCSSettingValue	  CCSSettingValue;
108 typedef struct _CCSPluginConflict CCSPluginConflict;
109 typedef struct _CCSBackendInfo	  CCSBackendInfo;
110 typedef struct _CCSIntDesc	  CCSIntDesc;
111 typedef struct _CCSStrRestriction CCSStrRestriction;
112 typedef struct _CCSStrExtension   CCSStrExtension;
113 
114 CCSLIST_HDR (Plugin, CCSPlugin)
115 CCSLIST_HDR (Setting, CCSSetting)
116 CCSLIST_HDR (String, char)
117 CCSLIST_HDR (Group, CCSGroup)
118 CCSLIST_HDR (SubGroup, CCSSubGroup)
119 CCSLIST_HDR (SettingValue, CCSSettingValue)
120 CCSLIST_HDR (PluginConflict, CCSPluginConflict)
121 CCSLIST_HDR (BackendInfo, CCSBackendInfo)
122 CCSLIST_HDR (IntDesc, CCSIntDesc)
123 CCSLIST_HDR (StrRestriction, CCSStrRestriction)
124 CCSLIST_HDR (StrExtension, CCSStrExtension)
125 
126 struct _CCSContext
127 {
128     CCSPluginList     plugins;         /* list of plugins settings
129 					  were loaded for */
130     CCSPluginCategory *categories;     /* list of plugin categories */
131     void              *privatePtr;     /* private pointer that can be used
132 					  by the caller */
133     void              *ccsPrivate;     /* private pointer for compizconfig
134 					  internal usage */
135 
136     CCSSettingList    changedSettings; /* list of settings changed since last
137 					  settings write */
138 
139     unsigned int      *screens;        /* numbers of the available screens */
140     unsigned int      numScreens;      /* number of screens */
141 };
142 
143 struct _CCSBackendInfo
144 {
145     char *name;              /* name of the backend */
146     char *shortDesc;         /* backend's short description */
147     char *longDesc;          /* backend's long description */
148     Bool integrationSupport; /* does the backend support DE integration? */
149     Bool profileSupport;     /* does the backend support profiles? */
150 };
151 
152 struct _CCSPlugin
153 {
154     char *name;                    /* plugin name */
155     char *shortDesc;		   /* plugin short description */
156     char *longDesc;		   /* plugin long description */
157     char *hints;                   /* currently unused */
158     char *category;		   /* plugin category name */
159 
160     CCSStringList loadAfter;       /* list of plugin names this plugin needs to
161 				      be loaded after */
162     CCSStringList loadBefore;      /* list of plugin names this plugin needs to
163 				      be loaded before */
164     CCSStringList requiresPlugin;  /* list of plugin names this plugin
165 				      requires */
166     CCSStringList conflictPlugin;  /* list of plugin names this plugin
167 				      conflicts with */
168     CCSStringList conflictFeature; /* list of feature names this plugin
169 				      conflicts with */
170     CCSStringList providesFeature; /* list of feature names this plugin
171 				      provides */
172     CCSStringList requiresFeature; /* list of feature names this plugin
173 				      requires */
174 
175     void       *privatePtr;        /* private pointer that can be used
176 				      by the caller */
177     CCSContext *context;           /* context this plugin belongs to */
178 
179     void *ccsPrivate;              /* private pointer for compizconfig
180 				      internal usage */
181 };
182 
183 typedef enum _CCSSettingType
184 {
185     /* This needs to be in the same order as CompOptionType for consistency */
186     TypeBool,
187     TypeInt,
188     TypeFloat,
189     TypeString,
190     TypeColor,
191     TypeAction,
192     TypeKey,
193     TypeButton,
194     TypeEdge,
195     TypeBell,
196     TypeMatch,
197     TypeList,
198     TypeNum
199 } CCSSettingType;
200 
201 struct _CCSSubGroup
202 {
203     char           *name;    /* sub group name in current locale */
204     CCSSettingList settings; /* list of settings in this sub group */
205 };
206 
207 struct _CCSGroup
208 {
209     char            *name;     /* group name in current locale */
210     CCSSubGroupList subGroups; /* list of sub groups in this group */
211 };
212 
213 typedef enum _CCSPluginConflictType
214 {
215     /* produced on plugin activation */
216     ConflictRequiresPlugin,
217     ConflictRequiresFeature,
218     ConflictFeature,
219     ConflictPlugin,
220     /* produced on plugin deactivation */
221     ConflictFeatureNeeded,
222     ConflictPluginNeeded,
223     ConflictPluginError,
224 } CCSPluginConflictType;
225 
226 struct _CCSPluginConflict
227 {
228     char *                value;   /* item (plugin / feature) name that
229 				      caused the conflict */
230     CCSPluginConflictType type;    /* type of the conflict */
231     CCSPluginList         plugins; /* list of conflicting plugins */
232 };
233 
234 union _CCSSettingInfo;
235 
236 struct _CCSIntDesc
237 {
238     int  value; /* value the description is assigned to */
239     char *name; /* description */
240 };
241 
242 struct _CCSStrRestriction
243 {
244     char *value; /* value the restriction is assigned to */
245     char *name;  /* description */
246 };
247 
248 struct _CCSStrExtension
249 {
250     char *basePlugin;           /* plugin this extension extends */
251     CCSStringList baseSettings; /* list of settings this extension extends */
252     CCSStrRestrictionList restriction; /* list of added restriction items */
253 
254     Bool isScreen;          /* is this extension a screen setting extension? */
255 };
256 
257 typedef struct _CCSSettingIntInfo
258 {
259     int            min;  /* minimum value for this setting */
260     int            max;  /* maximum value */
261     CCSIntDescList desc; /* list of item descriptions */
262 } CCSSettingIntInfo;
263 
264 typedef struct _CCSSettingFloatInfo
265 {
266     float min;       /* minimum value for this setting */
267     float max;       /* maximum value */
268     float precision; /* precision (allowed increment) */
269 } CCSSettingFloatInfo;
270 
271 typedef struct _CCSSettingStringInfo
272 {
273     CCSStrRestrictionList restriction;  /* list of restriction items */
274     int                sortStartsAt; /* the restriction index to start sorting
275 					at (defaults to -1 for no sorting) */
276     Bool               extensible;   /* whether extension is allowed for
277 					this setting */
278 } CCSSettingStringInfo;
279 
280 typedef struct _CCSSettingListInfo
281 {
282     CCSSettingType        listType;  /* type of setting this list contains */
283     union _CCSSettingInfo *listInfo; /* list of settings */
284 } CCSSettingListInfo;
285 
286 typedef struct _CCSSettingActionInfo
287 {
288     Bool internal; /* is this binding global or plugin internal*/
289 } CCSSettingActionInfo;
290 
291 typedef union _CCSSettingInfo
292 {
293     CCSSettingIntInfo    forInt;
294     CCSSettingFloatInfo  forFloat;
295     CCSSettingStringInfo forString;
296     CCSSettingListInfo   forList;
297     CCSSettingActionInfo forAction;
298 } CCSSettingInfo;
299 
300 typedef struct _CCSSettingColorValueColor
301 {
302     unsigned short red;
303     unsigned short green;
304     unsigned short blue;
305     unsigned short alpha;
306 }
307 
308 CCSSettingColorValueColor;
309 
310 typedef struct _CCSSettingColorValueArray
311 {
312     unsigned short array[4];
313 }
314 
315 CCSSettingColorValueArray;
316 
317 typedef union _CCSSettingColorValue
318 {
319     CCSSettingColorValueColor color;
320     CCSSettingColorValueArray array;
321 } CCSSettingColorValue;
322 
323 
324 typedef struct _CCSSettingKeyValue
325 {
326     int          keysym;
327     unsigned int keyModMask;
328 } CCSSettingKeyValue;
329 
330 typedef struct _CCSSettingButtonValue
331 {
332     int          button;
333     unsigned int buttonModMask;
334     unsigned int edgeMask;
335 } CCSSettingButtonValue;
336 
337 typedef union _CCSSettingValueUnion
338 {
339     Bool		  asBool;
340     int			  asInt;
341     float		  asFloat;
342     char *		  asString;
343     char *		  asMatch;
344     CCSSettingColorValue  asColor;
345     CCSSettingValueList   asList;
346     CCSSettingKeyValue    asKey;
347     CCSSettingButtonValue asButton;
348     unsigned int	  asEdge;
349     Bool		  asBell;
350 } CCSSettingValueUnion;
351 
352 struct _CCSSettingValue
353 {
354     CCSSettingValueUnion value;
355     CCSSetting *	 parent;
356     Bool		 isListChild;
357 };
358 
359 struct _CCSSetting
360 {
361     char *name;             /* setting name */
362     char *shortDesc;        /* setting short description in current locale */
363     char *longDesc;         /* setting long description in current locale */
364 
365     CCSSettingType type;    /* setting type */
366 
367     Bool	 isScreen;  /* is this setting a screen setting? */
368     unsigned int screenNum; /* screen number this setting is assigned to, valid
369 			       if isScreen is TRUE */
370 
371     CCSSettingInfo info;    /* information assigned to this setting,
372 			       valid if the setting is an int, float, string
373 			       or list setting */
374 
375     char *group;	    /* group name in current locale */
376     char *subGroup;	    /* sub group name in current locale */
377     char *hints;	    /* hints in current locale */
378 
379     CCSSettingValue defaultValue; /* default value of this setting */
380     CCSSettingValue *value;       /* actual value of this setting */
381     Bool	    isDefault;    /* does the actual value match the default
382 				     value? */
383 
384     CCSPlugin *parent;            /* plugin this setting belongs to */
385     void      *privatePtr;        /* private pointer for usage by the caller */
386 };
387 
388 struct _CCSPluginCategory
389 {
390     const char *name;      /* plugin category name */
391     const char *shortDesc; /* plugin category short description */
392     const char *longDesc;  /* plugin category long description */
393 
394     CCSStringList plugins; /* list of plugins in this category */
395 };
396 
397 /* set basic metadata to TRUE and no additional
398    metadata informations will be parsed */
399 void ccsSetBasicMetadata (Bool value);
400 
401 /* Creates a new context for the screens given in screens and numScreens.
402    Set numScreens to 0 to initialize for all screens.
403    All plugin settings are automatically enumerated. */
404 CCSContext* ccsContextNew (unsigned int *screens,
405 			   unsigned int numScreens);
406 
407 /* Creates a new context without auto-enumerating any plugin or setting.
408    Behaves otherwise exactly like ccsContextNew. */
409 CCSContext* ccsEmptyContextNew (unsigned int *screens,
410 				unsigned int numScreens);
411 
412 /* Destroys the allocated context. */
413 void ccsContextDestroy (CCSContext * context);
414 
415 /* Load the plugin and setting metadata for a given plugin.
416    Returns TRUE on success, FALSE otherwise. */
417 Bool ccsLoadPlugin (CCSContext *context,
418 		    char       *name);
419 
420 /* Searches for a plugin identified by its name in the context.
421    Returns the plugin struct if it could be found, NULL otherwise. */
422 CCSPlugin* ccsFindPlugin (CCSContext *context,
423 			  const char *name);
424 
425 /* Searches for a setting in a plugin. screenNum is only valid if isScreen is
426    TRUE. Returns the setting struct if the search was successful (setting with
427    name <name> found and isScreen and screenNum matched the values of the
428    setting), NULL otherwise. */
429 CCSSetting* ccsFindSetting (CCSPlugin    *plugin,
430 			    const char   *name,
431 			    Bool         isScreen,
432 			    unsigned int screenNum);
433 
434 /* Returns TRUE if the named plugin is in the context and marked as currently
435    active in Compiz, FALSE otherwise. */
436 Bool ccsPluginIsActive (CCSContext *context,
437 			char       *name);
438 
439 void ccsFreeContext (CCSContext *context);
440 void ccsFreePlugin (CCSPlugin *plugin);
441 void ccsFreeSetting (CCSSetting *setting);
442 void ccsFreeGroup (CCSGroup *group);
443 void ccsFreeSubGroup (CCSSubGroup *subGroup);
444 void ccsFreeSettingValue (CCSSettingValue *value);
445 void ccsFreePluginConflict (CCSPluginConflict *value);
446 void ccsFreeBackendInfo (CCSBackendInfo *value);
447 void ccsFreeIntDesc (CCSIntDesc *value);
448 void ccsFreeStrRestriction (CCSStrRestriction *restriction);
449 void ccsFreeStrExtension (CCSStrExtension *extension);
450 
451 #define ccsFreeString(val) free(val)
452 
453 /* Setting setters. Set <setting> to value <data>. Return TRUE if new value
454    matches data. If the new value doesn't match the old value, the setting
455    is added to the context's changedSettings list. */
456 Bool ccsSetInt (CCSSetting *setting,
457 		int        data);
458 Bool ccsSetFloat (CCSSetting *setting,
459 		  float      data);
460 Bool ccsSetBool (CCSSetting *setting,
461 		 Bool       data);
462 Bool ccsSetString (CCSSetting *setting,
463 		   const char *data);
464 Bool ccsSetColor (CCSSetting           *setting,
465 		  CCSSettingColorValue data);
466 Bool ccsSetMatch (CCSSetting *setting,
467 		  const char *data);
468 Bool ccsSetKey (CCSSetting         *setting,
469 		CCSSettingKeyValue data);
470 Bool ccsSetButton (CCSSetting            *setting,
471 		   CCSSettingButtonValue data);
472 Bool ccsSetEdge (CCSSetting   *setting,
473 		 unsigned int data);
474 Bool ccsSetBell (CCSSetting *setting,
475 		 Bool       data);
476 Bool ccsSetList (CCSSetting          *setting,
477 		 CCSSettingValueList data);
478 Bool ccsSetValue (CCSSetting      *setting,
479 		  CCSSettingValue *data);
480 
481 /* Compares two setting values. Returns TRUE if values match,
482    FALSE otherwise. */
483 Bool ccsIsEqualColor (CCSSettingColorValue c1,
484 		      CCSSettingColorValue c2);
485 Bool ccsIsEqualKey (CCSSettingKeyValue c1,
486 		    CCSSettingKeyValue c2);
487 Bool ccsIsEqualButton (CCSSettingButtonValue c1,
488 		       CCSSettingButtonValue c2);
489 
490 /* Setting getters. Returns TRUE if the setting value was successfully
491    copied into <data>, FALSE otherwise. */
492 Bool ccsGetInt (CCSSetting *setting,
493 		int        *data);
494 Bool ccsGetFloat (CCSSetting *setting,
495 		  float      *data);
496 Bool ccsGetBool (CCSSetting *setting,
497 		 Bool       *data);
498 Bool ccsGetString (CCSSetting *setting,
499 		   char       **data);
500 Bool ccsGetColor (CCSSetting           *setting,
501 		  CCSSettingColorValue *data);
502 Bool ccsGetMatch (CCSSetting *setting,
503 		  char       **data);
504 Bool ccsGetKey (CCSSetting         *setting,
505 		CCSSettingKeyValue *data);
506 Bool ccsGetButton (CCSSetting            *setting,
507 		   CCSSettingButtonValue *data);
508 Bool ccsGetEdge (CCSSetting  *setting,
509 		 unsigned int *data);
510 Bool ccsGetBell (CCSSetting *setting,
511 		 Bool       *data);
512 Bool ccsGetList (CCSSetting          *setting,
513 		 CCSSettingValueList *data);
514 
515 /* Retrieves a list of settings in a plugin */
516 CCSSettingList ccsGetPluginSettings (CCSPlugin *plugin);
517 
518 /* Retrieves a list of setting groups in a plugin */
519 CCSGroupList ccsGetPluginGroups (CCSPlugin *plugin);
520 
521 /* Converts a string list into a list of string settings.
522    Return value needs to be freed by the caller. */
523 CCSSettingValueList ccsGetValueListFromStringList (CCSStringList list,
524 						   CCSSetting    *parent);
525 /* Converts a string setting value list into a string list.
526    Return value needs to be freed by the caller. */
527 CCSStringList ccsGetStringListFromValueList (CCSSettingValueList list);
528 
529 /* Converts a string list into a string array. If the return value is not
530    NULL, the item count is copied into <num>. Return value needs to be freed
531    by the caller. */
532 char** ccsGetStringArrayFromList (CCSStringList list,
533 				  int           *num);
534 /* Converts a string array with <num> items into a string list. Return value
535    needs to be freed by the caller. */
536 CCSStringList ccsGetListFromStringArray (char **array,
537 					 int  num);
538 
539 /* Converts a setting value list into an array of the setting item data type.
540    Behaves similar to ccsGetStringArrayFromList. */
541 char** ccsGetStringArrayFromValueList (CCSSettingValueList list,
542 				       int                 *num);
543 char** ccsGetMatchArrayFromValueList (CCSSettingValueList list,
544 				      int                 *num);
545 
546 int* ccsGetIntArrayFromValueList (CCSSettingValueList list,
547 				  int                 *num);
548 float* ccsGetFloatArrayFromValueList (CCSSettingValueList list,
549 				      int                 *num);
550 Bool * ccsGetBoolArrayFromValueList (CCSSettingValueList list,
551 				     int                 *num);
552 CCSSettingColorValue* ccsGetColorArrayFromValueList (CCSSettingValueList list,
553 	       					     int                 *num);
554 
555 /* Converts an array of data items to a setting value list. Behaves similar
556    to ccsGetListFromStringArray */
557 CCSSettingValueList ccsGetValueListFromStringArray (char       **array,
558 						    int        num,
559 						    CCSSetting *parent);
560 CCSSettingValueList ccsGetValueListFromMatchArray (char       **array,
561 						   int        num,
562 						   CCSSetting *parent);
563 CCSSettingValueList ccsGetValueListFromIntArray (int        *array,
564 						 int        num,
565 						 CCSSetting *parent);
566 CCSSettingValueList ccsGetValueListFromFloatArray (float      *array,
567 						   int        num,
568 						   CCSSetting *parent);
569 CCSSettingValueList ccsGetValueListFromBoolArray (Bool       *array,
570 						  int        num,
571 						  CCSSetting *parent);
572 CCSSettingValueList ccsGetValueListFromColorArray (CCSSettingColorValue *array,
573 						   int                  num,
574 						   CCSSetting           *parent);
575 
576 /* Retrieves a list of plugins marked as active in Compiz for this context */
577 CCSPluginList ccsGetActivePluginList (CCSContext *context);
578 
579 /* Retrieves a list of plugin names which are active in Compiz for a given
580    context, sorted as needed according to load after/before/etc. rules */
581 CCSStringList ccsGetSortedPluginStringList (CCSContext *context);
582 
583 /* Switches the backend for a context. Returns TRUE on successful switch,
584    FALSE otherwise. */
585 Bool ccsSetBackend (CCSContext *context,
586 		    char       *name);
587 /* Retrieves the name of the backend active for the context. */
588 char * ccsGetBackend (CCSContext *context);
589 
590 /* Enable/disable DE integration for a context. */
591 void ccsSetIntegrationEnabled (CCSContext *context,
592 			       Bool       value);
593 
594 /* Sets the profile for a context. */
595 void ccsSetProfile (CCSContext *context,
596 		    char       *name);
597 
598 /* Set plugin list autosort for a context. */
599 void ccsSetPluginListAutoSort (CCSContext *context,
600 			       Bool       value);
601 
602 /* Retrieve current profile of the context. */
603 char * ccsGetProfile (CCSContext *context);
604 
605 /* Retrieves current DE integration status for a context */
606 Bool ccsGetIntegrationEnabled (CCSContext *context);
607 
608 /* Retrieves the autosort setting for a context. */
609 Bool ccsGetPluginListAutoSort (CCSContext *context);
610 
611 /* Changes the plugin activeness status in compiz. If plugin list autosort
612    is enabled, automatically writes a new sorted plugin list to the
613    active_plugins setting. If autosort is disabled, it's up to the caller
614    to do that. */
615 Bool ccsPluginSetActive (CCSPlugin *plugin,
616 			 Bool      value);
617 
618 /* functions parsing/creating an action string -
619    the returned strings must be free'd after usage! */
620 
621 char * ccsModifiersToString (unsigned int modMask);
622 
623 char * ccsEdgesToString (unsigned int edge);
624 
625 char * ccsEdgesToModString (unsigned int edge);
626 
627 char * ccsKeyBindingToString (CCSSettingKeyValue *key);
628 
629 char * ccsButtonBindingToString (CCSSettingButtonValue *button);
630 
631 char * ccsColorToString (CCSSettingColorValue *color);
632 
633 unsigned int ccsStringToModifiers (const char *binding);
634 
635 unsigned int ccsStringToEdges (const char *edge);
636 
637 unsigned int ccsModStringToEdges (const char *edge);
638 
639 Bool ccsStringToKeyBinding (const char         *binding,
640 			    CCSSettingKeyValue *key);
641 
642 Bool ccsStringToButtonBinding (const char            *binding,
643 			       CCSSettingButtonValue *button);
644 
645 Bool ccsStringToColor (const char           *value,
646 		       CCSSettingColorValue *color);
647 
648 /* flag values for ccsProcessEvents */
649 #define ProcessEventsNoGlibMainLoopMask (1 << 0)
650 
651 void ccsProcessEvents (CCSContext   *context,
652 		       unsigned int flags);
653 
654 /* Read all setting values from disk */
655 void ccsReadSettings (CCSContext *context);
656 
657 /* Read setting values for a given plugin */
658 void ccsReadPluginSettings (CCSPlugin *plugin);
659 
660 /* Write all settings to disk */
661 void ccsWriteSettings (CCSContext *context);
662 
663 /* Write changed settings to disk */
664 void ccsWriteChangedSettings (CCSContext *context);
665 
666 /* Reset all settings to defaults. Settings that were non-default
667    previously are added to the changedSettings list of the context. */
668 void ccsResetToDefault (CCSSetting * setting);
669 
670 /* Exports a profile to a file. If skipDefaults is TRUE, only exports
671    non-default settings. Returns TRUE on successful export, FALSE otherwise. */
672 Bool ccsExportToFile (CCSContext *context,
673 		      const char *fileName,
674 		      Bool skipDefaults);
675 
676 /* Imports a profile from a file. If overwriteNonDefault is TRUE, also
677    overwrites settings that were non-default before. Returns TRUE on success,
678    FALSE otherwise. */
679 Bool ccsImportFromFile (CCSContext *context,
680 			const char *fileName,
681 			Bool       overwriteNonDefault);
682 
683 /* File watch stuff */
684 
685 typedef void (*FileWatchCallbackProc) (unsigned int watchId, void *closure);
686 
687 unsigned int ccsAddFileWatch (const char            *fileName,
688 			      Bool                  enable,
689 			      FileWatchCallbackProc callback,
690 			      void                  *closure);
691 
692 void ccsRemoveFileWatch (unsigned int watchId);
693 void ccsDisableFileWatch (unsigned int watchId);
694 void ccsEnableFileWatch (unsigned int watchId);
695 
696 /* INI file stuff */
697 
698 typedef struct _dictionary_
699 {
700     /** Number of entries in dictionary */
701     int n;
702     /** Storage size */
703     int size;
704     /** List of string values */
705     char **val;
706     /** List of string keys */
707     char **key ;
708     /** List of hash values for keys */
709     unsigned *hash;
710 } IniDictionary;
711 
712 IniDictionary* ccsIniNew (void);
713 IniDictionary* ccsIniOpen (const char *fileName);
714 void ccsIniClose (IniDictionary *dictionary);
715 void ccsIniSave (IniDictionary *dictionary,
716 		 const char    *fileName);
717 
718 Bool ccsCreateDirFor (const char *fileName);
719 
720 Bool ccsIniGetString (IniDictionary *dictionary,
721 		      const char    *section,
722 		      const char    *entry,
723 		      char          **value);
724 Bool ccsIniGetInt (IniDictionary *dictionary,
725 		   const char    *section,
726 		   const char    *entry,
727 		   int           *value);
728 Bool ccsIniGetFloat (IniDictionary *dictionary,
729 		     const char    *section,
730 		     const char    *entry,
731 		     float         *value);
732 Bool ccsIniGetBool (IniDictionary *dictionary,
733 		    const char    *section,
734 		    const char    *entry,
735 		    Bool          *value);
736 Bool ccsIniGetColor (IniDictionary        *dictionary,
737 		     const char           *section,
738 		     const char           *entry,
739 		     CCSSettingColorValue *value);
740 Bool ccsIniGetKey (IniDictionary        *dictionary,
741 		   const char           *section,
742 		   const char           *entry,
743 		   CCSSettingKeyValue   *value);
744 Bool ccsIniGetButton (IniDictionary         *dictionary,
745 		      const char            *section,
746 		      const char            *entry,
747 		      CCSSettingButtonValue *value);
748 Bool ccsIniGetEdge (IniDictionary *dictionary,
749 		    const char    *section,
750 		    const char    *entry,
751 		    unsigned int  *value);
752 Bool ccsIniGetBell (IniDictionary *dictionary,
753 		    const char    *section,
754 		    const char    *entry,
755 		    Bool          *value);
756 Bool ccsIniGetList (IniDictionary       *dictionary,
757 		    const char          *section,
758 		    const char          *entry,
759 		    CCSSettingValueList *value,
760 		    CCSSetting          *parent);
761 
762 void ccsIniSetString (IniDictionary *dictionary,
763 		      const char    *section,
764 		      const char    *entry,
765 		      char          *value);
766 void ccsIniSetInt (IniDictionary *dictionary,
767 		   const char    *section,
768 		   const char    *entry,
769 		   int           value);
770 void ccsIniSetFloat (IniDictionary *dictionary,
771 		     const char    *section,
772 		     const char    *entry,
773 		     float         value);
774 void ccsIniSetBool (IniDictionary *dictionary,
775 		    const char    *section,
776 		    const char    *entry,
777 		    Bool          value);
778 void ccsIniSetColor (IniDictionary        *dictionary,
779 		     const char           *section,
780 		     const char           *entry,
781 		     CCSSettingColorValue value);
782 void ccsIniSetKey (IniDictionary      *dictionary,
783 		   const char         *section,
784 		   const char         *entry,
785 		   CCSSettingKeyValue value);
786 void ccsIniSetButton (IniDictionary         *dictionary,
787 		      const char            *section,
788 		      const char            *entry,
789 		      CCSSettingButtonValue value);
790 void ccsIniSetEdge (IniDictionary *dictionary,
791 		     const char   *section,
792 		     const char   *entry,
793 		     unsigned int value);
794 void ccsIniSetBell (IniDictionary *dictionary,
795 		    const char    *section,
796 		    const char    *entry,
797 		    Bool          value);
798 void ccsIniSetList (IniDictionary       *dictionary,
799 		    const char          *section,
800 		    const char          *entry,
801 		    CCSSettingValueList value,
802 		    CCSSettingType      listType);
803 
804 void ccsIniRemoveEntry (IniDictionary *dictionary,
805 			const char    *section,
806 			const char    *entry);
807 
808 /* Checks if a plugin can be enabled. Returns a list of conflicts that
809    would occur when loading the plugin. A return value of NULL means that
810    the plugin can be enabled without problems. */
811 CCSPluginConflictList ccsCanEnablePlugin (CCSContext *context,
812 					  CCSPlugin  *plugin);
813 
814 /* Checks if a plugin can be disabled. The meaning of the return value is the
815    same as for ccsCanEnablePlugin */
816 CCSPluginConflictList ccsCanDisablePlugin (CCSContext *context,
817 					   CCSPlugin *plugin);
818 
819 /* Enumerates the available profiles for the current backend. */
820 CCSStringList ccsGetExistingProfiles (CCSContext * context);
821 
822 /* Deletes the profile with the given name. */
823 void ccsDeleteProfile (CCSContext *context,
824 		       char       *name);
825 
826 /* Enumerates the available backends. */
827 CCSBackendInfoList ccsGetExistingBackends (void);
828 
829 /* Checks if a given setting is integrated in the desktop environment. */
830 Bool ccsSettingIsIntegrated (CCSSetting *setting);
831 
832 /* Checks if a given setting is read-only. */
833 Bool ccsSettingIsReadOnly (CCSSetting *setting);
834 
835 CCSStrExtensionList ccsGetPluginStrExtensions (CCSPlugin *plugin);
836 
837 #endif
838