edelib  2.0.0
edelib/XSettingsCommon.h
00001 /*
00002  * $Id: XSettingsCommon.h 2839 2009-09-28 11:36:20Z karijes $
00003  *
00004  * Common stuff for XSETTINGS protocol
00005  * Based on implementation from Owen Tylor, copyright (c) 2001 Red Hat, inc.
00006  * Copyright (c) 2005-2007 edelib authors
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this library. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 #ifndef __EDELIB_XSETTINGSCOMMON_H__
00023 #define __EDELIB_XSETTINGSCOMMON_H__
00024 
00025 #include "edelib-global.h"
00026 #include <X11/Xlib.h>
00027 
00028 #define XSETTINGS_PAD(n, p) ((n + p - 1) & (~(p - 1)))
00029 
00030 EDELIB_NS_BEGIN
00031 
00036 enum XSettingsType {
00037         XSETTINGS_TYPE_INT = 0,      
00038         XSETTINGS_TYPE_STRING,       
00039         XSETTINGS_TYPE_COLOR         
00040 };
00041 
00046 struct XSettingsColor {
00048         unsigned short red;
00050         unsigned short green;
00052         unsigned short blue;
00054         unsigned short alpha;
00055 };
00056 
00061 struct XSettingsSetting {
00063         char* name;
00065         XSettingsType type;
00066 
00068         union {
00069                 int v_int;
00070                 char* v_string;
00071                 XSettingsColor v_color;
00072         } data;
00073 
00075         unsigned long last_change_serial;
00076 };
00077 
00082 struct XSettingsList {
00084         XSettingsSetting* setting;
00086         XSettingsList* next;
00087 };
00088 
00122 struct XSettingsData {
00124         Display* display;
00126         int screen;
00127 
00129         Window manager_win;
00130 
00132         Atom selection_atom;
00133 
00135         Atom manager_atom;
00136 
00138         Atom xsettings_atom;
00139 
00141         XSettingsList* settings;
00142 
00144         unsigned long serial;
00145 };
00146 
00147 #ifndef SKIP_DOCS
00148 struct XSettingsBuffer {
00149         char byte_order;
00150         int len;
00151         unsigned char* data;
00152         unsigned char* pos;
00153 };
00154 #endif
00155 
00159 EDELIB_API bool xsettings_list_add(XSettingsList** list, XSettingsSetting* setting);
00160 
00164 EDELIB_API bool xsettings_list_remove(XSettingsList** list, const char* name);
00165 
00169 EDELIB_API XSettingsSetting* xsettings_list_find(XSettingsList* list, const char* name);
00170 
00174 EDELIB_API void xsettings_list_free(XSettingsList* list);
00175 
00176 
00177 
00181 EDELIB_API XSettingsSetting* xsettings_setting_copy(XSettingsSetting* setting);
00182 
00186 EDELIB_API void xsettings_setting_free(XSettingsSetting* setting);
00187 
00191 EDELIB_API bool xsettings_setting_equal(XSettingsSetting* s1, XSettingsSetting* s2);
00192 
00196 EDELIB_API int  xsettings_setting_len(const XSettingsSetting* setting);
00197 
00201 EDELIB_API char xsettings_byte_order(void);
00202 
00203 
00208 EDELIB_API XSettingsList* xsettings_decode(unsigned char* data, /*size_t*/ int len, unsigned long* serial);
00209 
00213 EDELIB_API void xsettings_encode(const XSettingsSetting* setting, XSettingsBuffer* buffer);
00214 
00215 
00216 #ifndef SKIP_DOCS
00217 void xsettings_manager_notify(XSettingsData* data);
00218 void xsettings_manager_set_setting(XSettingsData* data, XSettingsSetting* setting);
00219 void xsettings_manager_delete_setting(XSettingsData* data, const char* name);
00220 #endif
00221 
00222 EDELIB_NS_END
00223 #endif