]> Pileus Git - ~andy/gtk/blob - gdk/quartz/gdkproperty-quartz.c
Fix ChangeLog entry
[~andy/gtk] / gdk / quartz / gdkproperty-quartz.c
1 /* gdkproperty-quartz.c
2  *
3  * Copyright (C) 2005 Imendio AB
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include <config.h>
22
23 #include "gdkproperty.h"
24
25 static GHashTable *names_to_atoms;
26 static GPtrArray *atoms_to_names;
27
28 static const gchar xatoms_string[] = 
29   /* These are all the standard predefined X atoms */
30   "NONE\0"
31   "PRIMARY\0"
32   "SECONDARY\0"
33   "ARC\0"
34   "ATOM\0"
35   "BITMAP\0"
36   "CARDINAL\0"
37   "COLORMAP\0"
38   "CURSOR\0"
39   "CUT_BUFFER0\0"
40   "CUT_BUFFER1\0"
41   "CUT_BUFFER2\0"
42   "CUT_BUFFER3\0"
43   "CUT_BUFFER4\0"
44   "CUT_BUFFER5\0"
45   "CUT_BUFFER6\0"
46   "CUT_BUFFER7\0"
47   "DRAWABLE\0"
48   "FONT\0"
49   "INTEGER\0"
50   "PIXMAP\0"
51   "POINT\0"
52   "RECTANGLE\0"
53   "RESOURCE_MANAGER\0"
54   "RGB_COLOR_MAP\0"
55   "RGB_BEST_MAP\0"
56   "RGB_BLUE_MAP\0"
57   "RGB_DEFAULT_MAP\0"
58   "RGB_GRAY_MAP\0"
59   "RGB_GREEN_MAP\0"
60   "RGB_RED_MAP\0"
61   "STRING\0"
62   "VISUALID\0"
63   "WINDOW\0"
64   "WM_COMMAND\0"
65   "WM_HINTS\0"
66   "WM_CLIENT_MACHINE\0"
67   "WM_ICON_NAME\0"
68   "WM_ICON_SIZE\0"
69   "WM_NAME\0"
70   "WM_NORMAL_HINTS\0"
71   "WM_SIZE_HINTS\0"
72   "WM_ZOOM_HINTS\0"
73   "MIN_SPACE\0"
74   "NORM_SPACE\0"
75   "MAX_SPACE\0"
76   "END_SPACE\0"
77   "SUPERSCRIPT_X\0"
78   "SUPERSCRIPT_Y\0"
79   "SUBSCRIPT_X\0"
80   "SUBSCRIPT_Y\0"
81   "UNDERLINE_POSITION\0"
82   "UNDERLINE_THICKNESS\0"
83   "STRIKEOUT_ASCENT\0"
84   "STRIKEOUT_DESCENT\0"
85   "ITALIC_ANGLE\0"
86   "X_HEIGHT\0"
87   "QUAD_WIDTH\0"
88   "WEIGHT\0"
89   "POINT_SIZE\0"
90   "RESOLUTION\0"
91   "COPYRIGHT\0"
92   "NOTICE\0"
93   "FONT_NAME\0"
94   "FAMILY_NAME\0"
95   "FULL_NAME\0"
96   "CAP_HEIGHT\0"
97   "WM_CLASS\0"
98   "WM_TRANSIENT_FOR\0"
99 ;
100
101 static const gint xatoms_offset[] = {
102     0,   5,  13,  23,  27,  32,  39,  48,  57,  64,  76,  88, 
103   100, 112, 124, 136, 148, 160, 169, 174, 182, 189, 195, 205, 
104   222, 236, 249, 262, 278, 291, 305, 317, 324, 333, 340, 351, 
105   360, 378, 391, 404, 412, 428, 442, 456, 466, 477, 487, 497, 
106   511, 525, 537, 549, 568, 588, 605, 623, 636, 645, 656, 663, 
107   674, 685, 695, 702, 712, 724, 734, 745, 754
108 };
109
110 #define N_CUSTOM_PREDEFINED 1
111
112 static void
113 ensure_atom_tables (void)
114 {
115   int i;
116   
117   if (names_to_atoms)
118     return;
119
120   names_to_atoms = g_hash_table_new (g_str_hash, g_str_equal);
121   atoms_to_names = g_ptr_array_sized_new (G_N_ELEMENTS (xatoms_offset));
122
123   for (i = 0; i < G_N_ELEMENTS (xatoms_offset); i++)
124     {
125       g_hash_table_insert(names_to_atoms, (gchar *)xatoms_string + xatoms_offset[i], GINT_TO_POINTER (i));
126       g_ptr_array_add(atoms_to_names, (gchar *)xatoms_string + xatoms_offset[i]);
127     }
128 }
129
130 static GdkAtom
131 intern_atom_internal (const gchar *atom_name, gboolean allocate)
132 {
133   gpointer result;
134   gchar *name;
135   g_return_val_if_fail (atom_name != NULL, GDK_NONE);
136
137   ensure_atom_tables ();
138   
139   if (g_hash_table_lookup_extended (names_to_atoms, atom_name, NULL, &result))
140     return result;
141   
142   result = GINT_TO_POINTER (atoms_to_names->len);
143   name = allocate ? g_strdup (atom_name) : (gchar *)atom_name;
144   g_hash_table_insert(names_to_atoms, name, result);
145   g_ptr_array_add(atoms_to_names, name);
146   
147   return result;  
148 }
149
150 GdkAtom
151 gdk_atom_intern (const gchar *atom_name,
152                  gboolean     only_if_exists)
153 {
154   return intern_atom_internal (atom_name, TRUE);
155 }
156
157 GdkAtom
158 gdk_atom_intern_static_string (const gchar *atom_name)
159 {
160   return intern_atom_internal (atom_name, FALSE);
161 }
162
163
164 gchar *
165 gdk_atom_name (GdkAtom atom)
166 {
167   if (!atoms_to_names)
168     return NULL;
169     
170   if (GPOINTER_TO_INT (atom) >= atoms_to_names->len)
171     return NULL;
172     
173   return g_ptr_array_index (atoms_to_names, GPOINTER_TO_INT (atom));
174 }
175
176 void
177 gdk_property_delete (GdkWindow *window,
178                      GdkAtom    property)
179 {
180   /* FIXME: Implement */
181 }
182
183 gint
184 gdk_property_get (GdkWindow   *window,
185                   GdkAtom      property,
186                   GdkAtom      type,
187                   gulong       offset,
188                   gulong       length,
189                   gint         pdelete,
190                   GdkAtom     *actual_property_type,
191                   gint        *actual_format_type,
192                   gint        *actual_length,
193                   guchar     **data)
194 {
195   /* FIXME: Implement */
196   return 0;
197 }
198
199 void
200 gdk_property_change (GdkWindow   *window,
201                      GdkAtom      property,
202                      GdkAtom      type,
203                      gint         format,
204                      GdkPropMode  mode,
205                      const guchar *data,
206                      gint         nelements)
207 {
208   /* FIXME: Implement */
209 }