From bb4953f3e8e102264a82ea4938b7813b85320b22 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 10 Feb 2013 01:06:58 +0100 Subject: [PATCH] x11: Fold xsettings-common.[ch] into xsettings-client.[ch] --- gdk/x11/Makefile.am | 4 +- gdk/x11/xsettings-client.c | 41 +++++++++++++++ gdk/x11/xsettings-client.h | 64 ++++++++++++++++++++++- gdk/x11/xsettings-common.c | 71 ------------------------- gdk/x11/xsettings-common.h | 103 ------------------------------------- 5 files changed, 105 insertions(+), 178 deletions(-) delete mode 100644 gdk/x11/xsettings-common.c delete mode 100644 gdk/x11/xsettings-common.h diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am index 255a8727d..a00118eae 100644 --- a/gdk/x11/Makefile.am +++ b/gdk/x11/Makefile.am @@ -53,9 +53,7 @@ libgdk_x11_la_SOURCES = \ gdkx.h \ gdkprivate-x11.h \ xsettings-client.h \ - xsettings-client.c \ - xsettings-common.h \ - xsettings-common.c + xsettings-client.c libgdkinclude_HEADERS = \ gdkx.h diff --git a/gdk/x11/xsettings-client.c b/gdk/x11/xsettings-client.c index 87b7b0d2e..93d3bc1e5 100644 --- a/gdk/x11/xsettings-client.c +++ b/gdk/x11/xsettings-client.c @@ -25,6 +25,8 @@ #include "xsettings-client.h" +#include + #include #include #include @@ -574,3 +576,42 @@ xsettings_client_process_event (XSettingsClient *client, return False; } + +int +xsettings_setting_equal (XSettingsSetting *setting_a, + XSettingsSetting *setting_b) +{ + if (setting_a->type != setting_b->type) + return 0; + + if (strcmp (setting_a->name, setting_b->name) != 0) + return 0; + + switch (setting_a->type) + { + case XSETTINGS_TYPE_INT: + return setting_a->data.v_int == setting_b->data.v_int; + case XSETTINGS_TYPE_COLOR: + return (setting_a->data.v_color.red == setting_b->data.v_color.red && + setting_a->data.v_color.green == setting_b->data.v_color.green && + setting_a->data.v_color.blue == setting_b->data.v_color.blue && + setting_a->data.v_color.alpha == setting_b->data.v_color.alpha); + case XSETTINGS_TYPE_STRING: + return strcmp (setting_a->data.v_string, setting_b->data.v_string) == 0; + } + + return 0; +} + +void +xsettings_setting_free (XSettingsSetting *setting) +{ + if (setting->type == XSETTINGS_TYPE_STRING) + free (setting->data.v_string); + + if (setting->name) + free (setting->name); + + free (setting); +} + diff --git a/gdk/x11/xsettings-client.h b/gdk/x11/xsettings-client.h index 629e28079..348c68c73 100644 --- a/gdk/x11/xsettings-client.h +++ b/gdk/x11/xsettings-client.h @@ -24,14 +24,37 @@ #define XSETTINGS_CLIENT_H #include -#include "xsettings-common.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +/* Renames for GDK inclusion */ + +#define xsettings_client_destroy _gdk_x11_xsettings_client_destroy +#define xsettings_client_get_setting _gdk_x11_xsettings_client_get_setting +#define xsettings_client_new _gdk_x11_xsettings_client_new +#define xsettings_client_set_grab_func _gdk_x11_xsettings_client_set_grab_func +#define xsettings_client_set_ungrab_func _gdk_x11_xsettings_client_set_ungrab_func +#define xsettings_client_process_event _gdk_x11_xsettings_client_process_event +#define xsettings_setting_equal _gdk_x11_xsettings_setting_equal +#define xsettings_setting_free _gdk_x11_xsettings_setting_free + +typedef struct _XSettingsBuffer XSettingsBuffer; +typedef struct _XSettingsColor XSettingsColor; +typedef struct _XSettingsSetting XSettingsSetting; typedef struct _XSettingsClient XSettingsClient; +/* Types of settings possible. Enum values correspond to + * protocol values. + */ +typedef enum +{ + XSETTINGS_TYPE_INT = 0, + XSETTINGS_TYPE_STRING = 1, + XSETTINGS_TYPE_COLOR = 2 +} XSettingsType; + typedef enum { XSETTINGS_ACTION_NEW, @@ -39,6 +62,41 @@ typedef enum XSETTINGS_ACTION_DELETED } XSettingsAction; +typedef enum +{ + XSETTINGS_SUCCESS, + XSETTINGS_NO_MEM, + XSETTINGS_ACCESS, + XSETTINGS_FAILED, + XSETTINGS_NO_ENTRY, + XSETTINGS_DUPLICATE_ENTRY +} XSettingsResult; + +struct _XSettingsBuffer +{ + char byte_order; + size_t len; + unsigned char *data; + unsigned char *pos; +}; + +struct _XSettingsColor +{ + unsigned short red, green, blue, alpha; +}; + +struct _XSettingsSetting +{ + char *name; + XSettingsType type; + + union { + int v_int; + char *v_string; + XSettingsColor v_color; + } data; +}; + typedef void (*XSettingsNotifyFunc) (const char *name, XSettingsAction action, XSettingsSetting *setting, @@ -49,6 +107,10 @@ typedef Bool (*XSettingsWatchFunc) (Window window, void *cb_data); typedef void (*XSettingsGrabFunc) (Display *display); +void xsettings_setting_free (XSettingsSetting *setting); +int xsettings_setting_equal (XSettingsSetting *setting_a, + XSettingsSetting *setting_b); + XSettingsClient *xsettings_client_new (Display *display, int screen, XSettingsNotifyFunc notify, diff --git a/gdk/x11/xsettings-common.c b/gdk/x11/xsettings-common.c deleted file mode 100644 index d8f3d3756..000000000 --- a/gdk/x11/xsettings-common.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright © 2001 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Red Hat not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Red Hat makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Owen Taylor, Red Hat, Inc. - */ - -#include "config.h" - -#include "xsettings-common.h" - -#include "string.h" -#include "stdlib.h" - -#include -#include /* For CARD32 */ - -int -xsettings_setting_equal (XSettingsSetting *setting_a, - XSettingsSetting *setting_b) -{ - if (setting_a->type != setting_b->type) - return 0; - - if (strcmp (setting_a->name, setting_b->name) != 0) - return 0; - - switch (setting_a->type) - { - case XSETTINGS_TYPE_INT: - return setting_a->data.v_int == setting_b->data.v_int; - case XSETTINGS_TYPE_COLOR: - return (setting_a->data.v_color.red == setting_b->data.v_color.red && - setting_a->data.v_color.green == setting_b->data.v_color.green && - setting_a->data.v_color.blue == setting_b->data.v_color.blue && - setting_a->data.v_color.alpha == setting_b->data.v_color.alpha); - case XSETTINGS_TYPE_STRING: - return strcmp (setting_a->data.v_string, setting_b->data.v_string) == 0; - } - - return 0; -} - -void -xsettings_setting_free (XSettingsSetting *setting) -{ - if (setting->type == XSETTINGS_TYPE_STRING) - free (setting->data.v_string); - - if (setting->name) - free (setting->name); - - free (setting); -} - diff --git a/gdk/x11/xsettings-common.h b/gdk/x11/xsettings-common.h deleted file mode 100644 index e90471b9b..000000000 --- a/gdk/x11/xsettings-common.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright © 2001 Red Hat, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Red Hat not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Red Hat makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Owen Taylor, Red Hat, Inc. - */ -#ifndef XSETTINGS_COMMON_H -#define XSETTINGS_COMMON_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Renames for GDK inclusion */ - -#define xsettings_client_destroy _gdk_x11_xsettings_client_destroy -#define xsettings_client_get_setting _gdk_x11_xsettings_client_get_setting -#define xsettings_client_new _gdk_x11_xsettings_client_new -#define xsettings_client_set_grab_func _gdk_x11_xsettings_client_set_grab_func -#define xsettings_client_set_ungrab_func _gdk_x11_xsettings_client_set_ungrab_func -#define xsettings_client_process_event _gdk_x11_xsettings_client_process_event -#define xsettings_setting_equal _gdk_x11_xsettings_setting_equal -#define xsettings_setting_free _gdk_x11_xsettings_setting_free - -typedef struct _XSettingsBuffer XSettingsBuffer; -typedef struct _XSettingsColor XSettingsColor; -typedef struct _XSettingsSetting XSettingsSetting; - -/* Types of settings possible. Enum values correspond to - * protocol values. - */ -typedef enum -{ - XSETTINGS_TYPE_INT = 0, - XSETTINGS_TYPE_STRING = 1, - XSETTINGS_TYPE_COLOR = 2 -} XSettingsType; - -typedef enum -{ - XSETTINGS_SUCCESS, - XSETTINGS_NO_MEM, - XSETTINGS_ACCESS, - XSETTINGS_FAILED, - XSETTINGS_NO_ENTRY, - XSETTINGS_DUPLICATE_ENTRY -} XSettingsResult; - -struct _XSettingsBuffer -{ - char byte_order; - size_t len; - unsigned char *data; - unsigned char *pos; -}; - -struct _XSettingsColor -{ - unsigned short red, green, blue, alpha; -}; - -struct _XSettingsSetting -{ - char *name; - XSettingsType type; - - union { - int v_int; - char *v_string; - XSettingsColor v_color; - } data; -}; - -void xsettings_setting_free (XSettingsSetting *setting); -int xsettings_setting_equal (XSettingsSetting *setting_a, - XSettingsSetting *setting_b); - -#define XSETTINGS_PAD(n,m) ((n + m - 1) & (~(m-1))) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* XSETTINGS_COMMON_H */ -- 2.43.2