[gtk+] x11: Fold xsettings-common.[ch] into xsettings-client.[ch]
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] x11: Fold xsettings-common.[ch] into xsettings-client.[ch]
- Date: Tue, 19 Feb 2013 13:47:27 +0000 (UTC)
commit bb4953f3e8e102264a82ea4938b7813b85320b22
Author: Benjamin Otte <otte redhat com>
Date: Sun Feb 10 01:06:58 2013 +0100
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(-)
---
diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
index 255a872..a00118e 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 87b7b0d..93d3bc1 100644
--- a/gdk/x11/xsettings-client.c
+++ b/gdk/x11/xsettings-client.c
@@ -25,6 +25,8 @@
#include "xsettings-client.h"
+#include <glib.h>
+
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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 629e280..348c68c 100644
--- a/gdk/x11/xsettings-client.h
+++ b/gdk/x11/xsettings-client.h
@@ -24,14 +24,37 @@
#define XSETTINGS_CLIENT_H
#include <X11/Xlib.h>
-#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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]