3 # Updates http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h from upstream (X.org 7.x),
4 # from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
6 # Author : Simos Xenitellis <simos at gnome dot org>.
7 # Author : Bastien Nocera <hadess@hadess.net>
10 # Input : http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
11 # Input : http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
12 # Output : http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h
14 # Notes : It downloads keysymdef.h from the Internet, if not found locally,
15 # Notes : and creates an updated gdkkeysyms.h
16 # Notes : This version updates the source of gdkkeysyms.h from CVS to the GIT server.
20 # Used for reading the keysymdef symbols.
23 if ( ! -f "keysymdef.h" )
25 print "Trying to download keysymdef.h from\n";
26 print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n";
27 die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n"
28 unless system("wget -c -O keysymdef.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\"") == 0;
33 print "We are using existing keysymdef.h found in this directory.\n";
34 print "It is assumed that you took care and it is a recent version\n";
35 print "as found at http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n\n";
38 if ( ! -f "XF86keysym.h" )
40 print "Trying to download XF86keysym.h from\n";
41 print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n";
42 die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n"
43 unless system("wget -c -O XF86keysym.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\"") == 0;
48 print "We are using existing XF86keysym.h found in this directory.\n";
49 print "It is assumed that you took care and it is a recent version\n";
50 print "as found at http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n\n";
53 if ( -f "gdkkeysyms.h" )
55 print "There is already a gdkkeysyms.h file in this directory. We are not overwriting it.\n";
56 print "Please move it somewhere else in order to run this script.\n";
60 # Source: http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
61 die "Could not open file keysymdef.h: $!\n" unless open(IN_KEYSYMDEF, "<:utf8", "keysymdef.h");
63 # Output: gtk+/gdk/gdkkeysyms.h
64 die "Could not open file gdkkeysyms.h: $!\n" unless open(OUT_GDKKEYSYMS, ">:utf8", "gdkkeysyms.h");
66 # Output: gtk+/gdk/gdkkeysyms-compat.h
67 die "Could not open file gdkkeysyms-compat.h: $!\n" unless open(OUT_GDKKEYSYMS_COMPAT, ">:utf8", "gdkkeysyms-compat.h");
69 my $LICENSE_HEADER= <<EOF;
70 /* GDK - The GIMP Drawing Kit
71 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
72 * Copyright (C) 2005, 2006, 2007, 2009 GNOME Foundation
74 * This library is free software; you can redistribute it and/or
75 * modify it under the terms of the GNU Lesser General Public
76 * License as published by the Free Software Foundation; either
77 * version 2 of the License, or (at your option) any later version.
79 * This library is distributed in the hope that it will be useful,
80 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
82 * Lesser General Public License for more details.
84 * You should have received a copy of the GNU Lesser General Public
85 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
90 print OUT_GDKKEYSYMS $LICENSE_HEADER;
91 print OUT_GDKKEYSYMS_COMPAT $LICENSE_HEADER;
93 print OUT_GDKKEYSYMS<<EOF;
96 * File auto-generated from script http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms-update.pl
97 * using the input file
98 * http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
100 * http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
104 * Modified by the GTK+ Team and others 1997-2007. See the AUTHORS
105 * file for a list of people on the GTK+ Team. See the ChangeLog
106 * files for a list of changes. These files are distributed with
107 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
110 #ifndef __GDK_KEYSYMS_H__
111 #define __GDK_KEYSYMS_H__
116 print OUT_GDKKEYSYMS_COMPAT<<EOF;
118 * Compatibility version of gdkkeysyms.h.
120 * In GTK3, keysyms changed to have a KEY_ prefix. This is a compatibility header
121 * your application can include to gain access to the old names as well. Consider
122 * porting to the new names instead.
125 #ifndef __GDK_KEYSYMS_COMPAT_H__
126 #define __GDK_KEYSYMS_COMPAT_H__
130 while (<IN_KEYSYMDEF>)
132 next if ( ! /^#define / );
134 @keysymelements = split(/\s+/);
135 die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
137 $_ = $keysymelements[1];
138 die "Internal error, was expecting \"XC_*\", found: $_\n" if ( ! /^XK_/ );
140 $_ = $keysymelements[2];
141 die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
143 my $element = $keysymelements[1];
144 my $binding = $element;
145 $binding =~ s/^XK_/GDK_KEY_/g;
146 my $compat_binding = $element;
147 $compat_binding =~ s/^XK_/GDK_/g;
149 printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
150 printf OUT_GDKKEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
155 #$gdksyms{"0"} = "0000";
157 # Source: http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
158 die "Could not open file XF86keysym.h: $!\n" unless open(IN_XF86KEYSYM, "<:utf8", "XF86keysym.h");
160 while (<IN_XF86KEYSYM>)
162 next if ( ! /^#define / );
164 @keysymelements = split(/\s+/);
165 die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
167 $_ = $keysymelements[1];
168 die "Internal error, was expecting \"XF86XK_*\", found: $_\n" if ( ! /^XF86XK_/ );
170 # Work-around https://bugs.freedesktop.org/show_bug.cgi?id=11193
171 if ($_ eq "XF86XK_XF86BackForward") {
172 $keysymelements[1] = "XF86XK_AudioForward";
174 # XF86XK_Clear could end up a dupe of XK_Clear
175 # XF86XK_Select could end up a dupe of XK_Select
176 if ($_ eq "XF86XK_Clear") {
177 $keysymelements[1] = "XF86XK_WindowClear";
179 if ($_ eq "XF86XK_Select") {
180 $keysymelements[1] = "XF86XK_SelectButton";
184 next if ( $_ eq "XF86XK_Q");
185 # XF86XK_Calculater is misspelled, and a dupe
186 next if ( $_ eq "XF86XK_Calculater");
188 $_ = $keysymelements[2];
189 die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
191 my $element = $keysymelements[1];
192 my $binding = $element;
193 $binding =~ s/^XF86XK_/GDK_KEY_/g;
194 my $compat_binding = $element;
195 $compat_binding =~ s/^XF86XK_/GDK_/g;
197 printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
198 printf OUT_GDKKEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
204 print OUT_GDKKEYSYMS<<EOF;
206 #endif /* __GDK_KEYSYMS_H__ */
209 print OUT_GDKKEYSYMS_COMPAT<<EOF;
211 #endif /* __GDK_KEYSYMS_COMPAT_H__ */
214 printf "We just finished converting keysymdef.h to gdkkeysyms.h and gdkkeysyms-compat.h\nThank you\n";