forked from AuroraMiddleware/gtk
x11: Fold xsettings-common.[ch] into xsettings-client.[ch]
This commit is contained in:
parent
63f0797e70
commit
bb4953f3e8
@ -53,9 +53,7 @@ libgdk_x11_la_SOURCES = \
|
|||||||
gdkx.h \
|
gdkx.h \
|
||||||
gdkprivate-x11.h \
|
gdkprivate-x11.h \
|
||||||
xsettings-client.h \
|
xsettings-client.h \
|
||||||
xsettings-client.c \
|
xsettings-client.c
|
||||||
xsettings-common.h \
|
|
||||||
xsettings-common.c
|
|
||||||
|
|
||||||
libgdkinclude_HEADERS = \
|
libgdkinclude_HEADERS = \
|
||||||
gdkx.h
|
gdkx.h
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "xsettings-client.h"
|
#include "xsettings-client.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -574,3 +576,42 @@ xsettings_client_process_event (XSettingsClient *client,
|
|||||||
|
|
||||||
return False;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -24,14 +24,37 @@
|
|||||||
#define XSETTINGS_CLIENT_H
|
#define XSETTINGS_CLIENT_H
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include "xsettings-common.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#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;
|
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
|
typedef enum
|
||||||
{
|
{
|
||||||
XSETTINGS_ACTION_NEW,
|
XSETTINGS_ACTION_NEW,
|
||||||
@ -39,6 +62,41 @@ typedef enum
|
|||||||
XSETTINGS_ACTION_DELETED
|
XSETTINGS_ACTION_DELETED
|
||||||
} XSettingsAction;
|
} 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,
|
typedef void (*XSettingsNotifyFunc) (const char *name,
|
||||||
XSettingsAction action,
|
XSettingsAction action,
|
||||||
XSettingsSetting *setting,
|
XSettingsSetting *setting,
|
||||||
@ -49,6 +107,10 @@ typedef Bool (*XSettingsWatchFunc) (Window window,
|
|||||||
void *cb_data);
|
void *cb_data);
|
||||||
typedef void (*XSettingsGrabFunc) (Display *display);
|
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,
|
XSettingsClient *xsettings_client_new (Display *display,
|
||||||
int screen,
|
int screen,
|
||||||
XSettingsNotifyFunc notify,
|
XSettingsNotifyFunc notify,
|
||||||
|
@ -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 <X11/Xlib.h>
|
|
||||||
#include <X11/Xmd.h> /* 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);
|
|
||||||
}
|
|
||||||
|
|
@ -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 <glib.h>
|
|
||||||
#include <sys/types.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;
|
|
||||||
|
|
||||||
/* 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 */
|
|
Loading…
Reference in New Issue
Block a user