]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkxid.c
Change GDK_WINDOWING_WIN32 usage to #ifdef also here.
[~andy/gtk] / gdk / win32 / gdkxid.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #include "config.h"
28
29 #include <stdio.h>
30 #include <gdk/gdk.h>
31
32 #include "gdkprivate.h"
33
34 static guint gdk_xid_hash    (XID *xid);
35 static gint  gdk_xid_compare (XID *a,
36                               XID *b);
37
38
39 static GHashTable *xid_ht = NULL;
40
41
42 void
43 gdk_xid_table_insert (XID      *xid,
44                       gpointer  data)
45 {
46   g_return_if_fail (xid != NULL);
47
48   if (!xid_ht)
49     xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
50                                (GCompareFunc) gdk_xid_compare);
51
52   g_hash_table_insert (xid_ht, xid, data);
53 }
54
55 void
56 gdk_xid_table_remove (XID xid)
57 {
58   if (!xid_ht)
59     xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
60                                (GCompareFunc) gdk_xid_compare);
61
62   g_hash_table_remove (xid_ht, &xid);
63 }
64
65 gpointer
66 gdk_xid_table_lookup (XID xid)
67 {
68   gpointer data = NULL;
69
70   if (xid_ht)
71     data = g_hash_table_lookup (xid_ht, &xid);
72   
73   return data;
74 }
75
76
77 static guint
78 gdk_xid_hash (XID *xid)
79 {
80   return (guint) *xid;
81 }
82
83 static gint
84 gdk_xid_compare (XID *a,
85                  XID *b)
86 {
87   return (*a == *b);
88 }