]> Pileus Git - ~andy/gtk/blob - gdk/x11/xsettings-common.c
d8f3d37569a63d0693b6b24199208bb429bbd4fb
[~andy/gtk] / gdk / x11 / xsettings-common.c
1 /*
2  * Copyright © 2001 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
24 #include "config.h"
25
26 #include "xsettings-common.h"
27
28 #include "string.h"
29 #include "stdlib.h"
30
31 #include <X11/Xlib.h>
32 #include <X11/Xmd.h>            /* For CARD32 */
33
34 int
35 xsettings_setting_equal (XSettingsSetting *setting_a,
36                          XSettingsSetting *setting_b)
37 {
38   if (setting_a->type != setting_b->type)
39     return 0;
40
41   if (strcmp (setting_a->name, setting_b->name) != 0)
42     return 0;
43
44   switch (setting_a->type)
45     {
46     case XSETTINGS_TYPE_INT:
47       return setting_a->data.v_int == setting_b->data.v_int;
48     case XSETTINGS_TYPE_COLOR:
49       return (setting_a->data.v_color.red == setting_b->data.v_color.red &&
50               setting_a->data.v_color.green == setting_b->data.v_color.green &&
51               setting_a->data.v_color.blue == setting_b->data.v_color.blue &&
52               setting_a->data.v_color.alpha == setting_b->data.v_color.alpha);
53     case XSETTINGS_TYPE_STRING:
54       return strcmp (setting_a->data.v_string, setting_b->data.v_string) == 0;
55     }
56
57   return 0;
58 }
59
60 void
61 xsettings_setting_free (XSettingsSetting *setting)
62 {
63   if (setting->type == XSETTINGS_TYPE_STRING)
64     free (setting->data.v_string);
65
66   if (setting->name)
67     free (setting->name);
68   
69   free (setting);
70 }
71