]> Pileus Git - ~andy/gtk/blob - gdk/x11/xsettings-client.h
x11: Fold xsettings-common.[ch] into xsettings-client.[ch]
[~andy/gtk] / gdk / x11 / xsettings-client.h
1 /*
2  * Copyright © 2001, 2007 Red Hat, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name of Red Hat not be used in advertising or
9  * publicity pertaining to distribution of the software without specific,
10  * written prior permission.  Red Hat makes no representations about the
11  * suitability of this software for any purpose.  It is provided "as is"
12  * without express or implied warranty.
13  *
14  * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
16  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
19  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  *
21  * Author:  Owen Taylor, Red Hat, Inc.
22  */
23 #ifndef XSETTINGS_CLIENT_H
24 #define XSETTINGS_CLIENT_H
25
26 #include <X11/Xlib.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 /* Renames for GDK inclusion */
33
34 #define xsettings_client_destroy         _gdk_x11_xsettings_client_destroy
35 #define xsettings_client_get_setting     _gdk_x11_xsettings_client_get_setting
36 #define xsettings_client_new             _gdk_x11_xsettings_client_new
37 #define xsettings_client_set_grab_func   _gdk_x11_xsettings_client_set_grab_func
38 #define xsettings_client_set_ungrab_func _gdk_x11_xsettings_client_set_ungrab_func
39 #define xsettings_client_process_event   _gdk_x11_xsettings_client_process_event
40 #define xsettings_setting_equal          _gdk_x11_xsettings_setting_equal
41 #define xsettings_setting_free           _gdk_x11_xsettings_setting_free
42
43 typedef struct _XSettingsBuffer  XSettingsBuffer;
44 typedef struct _XSettingsColor   XSettingsColor;
45 typedef struct _XSettingsSetting XSettingsSetting;
46 typedef struct _XSettingsClient XSettingsClient;
47
48 /* Types of settings possible. Enum values correspond to
49  * protocol values.
50  */
51 typedef enum 
52 {
53   XSETTINGS_TYPE_INT     = 0,
54   XSETTINGS_TYPE_STRING  = 1,
55   XSETTINGS_TYPE_COLOR   = 2
56 } XSettingsType;
57
58 typedef enum 
59 {
60   XSETTINGS_ACTION_NEW,
61   XSETTINGS_ACTION_CHANGED,
62   XSETTINGS_ACTION_DELETED
63 } XSettingsAction;
64
65 typedef enum
66 {
67   XSETTINGS_SUCCESS,
68   XSETTINGS_NO_MEM,
69   XSETTINGS_ACCESS,
70   XSETTINGS_FAILED,
71   XSETTINGS_NO_ENTRY,
72   XSETTINGS_DUPLICATE_ENTRY
73 } XSettingsResult;
74
75 struct _XSettingsBuffer
76 {
77   char byte_order;
78   size_t len;
79   unsigned char *data;
80   unsigned char *pos;
81 };
82
83 struct _XSettingsColor
84 {
85   unsigned short red, green, blue, alpha;
86 };
87
88 struct _XSettingsSetting
89 {
90   char *name;
91   XSettingsType type;
92   
93   union {
94     int v_int;
95     char *v_string;
96     XSettingsColor v_color;
97   } data;
98 };
99
100 typedef void (*XSettingsNotifyFunc) (const char       *name,
101                                      XSettingsAction   action,
102                                      XSettingsSetting *setting,
103                                      void             *cb_data);
104 typedef Bool (*XSettingsWatchFunc)  (Window            window,
105                                      Bool              is_start,
106                                      long              mask,
107                                      void             *cb_data);
108 typedef void (*XSettingsGrabFunc)   (Display          *display);
109
110 void              xsettings_setting_free          (XSettingsSetting    *setting);
111 int               xsettings_setting_equal         (XSettingsSetting    *setting_a,
112                                                    XSettingsSetting    *setting_b);
113
114 XSettingsClient *xsettings_client_new             (Display             *display,
115                                                    int                  screen,
116                                                    XSettingsNotifyFunc  notify,
117                                                    XSettingsWatchFunc   watch,
118                                                    void                *cb_data,
119                                                    XSettingsGrabFunc    grab,
120                                                    XSettingsGrabFunc    ungrab);
121 void             xsettings_client_set_grab_func   (XSettingsClient     *client,
122                                                    XSettingsGrabFunc    grab);
123 void             xsettings_client_set_ungrab_func (XSettingsClient     *client,
124                                                    XSettingsGrabFunc    ungrab);
125 void             xsettings_client_destroy         (XSettingsClient     *client);
126 Bool             xsettings_client_process_event   (XSettingsClient     *client,
127                                                    XEvent              *xev);
128 const XSettingsSetting *
129                  xsettings_client_get_setting     (XSettingsClient     *client,
130                                                    const char          *name);
131
132 #ifdef __cplusplus
133 }
134 #endif /* __cplusplus */
135
136 #endif /* XSETTINGS_CLIENT_H */