3 # Updates http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms.h from upstream (X.org 7.x),
4 # from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
6 # Author : Simos Xenitellis <simos at gnome dot org>.
7 # Authos : Bastien Nocera <hadess@hadess.net>
10 # Input : http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
11 # Input : http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h
12 # Output : http://git.gnome.org/cgit/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://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\n";
27 die "Unable to download keysymdef.h from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\n"
28 unless system("wget -c -O keysymdef.h \"http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=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://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=keysymdef.h\n\n";
38 if ( ! -f "XF86keysym.h" )
40 print "Trying to download XF86keysym.h from\n";
41 print "http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h\n";
42 die "Unable to download keysymdef.h from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h\n"
43 unless system("wget -c -O XF86keysym.h \"http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=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://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=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://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=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, write to the
86 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
87 * Boston, MA 02111-1307, USA.
92 print OUT_GDKKEYSYMS $LICENSE_HEADER;
93 print OUT_GDKKEYSYMS_COMPAT $LICENSE_HEADER;
95 print OUT_GDKKEYSYMS<<EOF;
98 * File auto-generated from script http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms-update.pl
99 * using the input file
100 * http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
102 * http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=XF86keysym.h
106 * Modified by the GTK+ Team and others 1997-2007. See the AUTHORS
107 * file for a list of people on the GTK+ Team. See the ChangeLog
108 * files for a list of changes. These files are distributed with
109 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
112 #ifndef __GDK_KEYSYMS_H__
113 #define __GDK_KEYSYMS_H__
118 print OUT_GDKKEYSYMS_COMPAT<<EOF;
120 * Compatibility version of gdkkeysyms.h.
122 * In GTK3, keysyms changed to have a KEY_ prefix. This is a compatibility header
123 * your application can include to gain access to the old names as well. Consider
124 * porting to the new names instead.
127 #ifndef __GDK_KEYSYMS_COMPAT_H__
128 #define __GDK_KEYSYMS_COMPAT_H__
132 while (<IN_KEYSYMDEF>)
134 next if ( ! /^#define / );
136 @keysymelements = split(/\s+/);
137 die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
139 $_ = $keysymelements[1];
140 die "Internal error, was expecting \"XC_*\", found: $_\n" if ( ! /^XK_/ );
142 $_ = $keysymelements[2];
143 die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
145 my $element = $keysymelements[1];
146 my $binding = $element;
147 $binding =~ s/^XK_/GDK_KEY_/g;
148 my $compat_binding = $element;
149 $compat_binding =~ s/^XK_/GDK_/g;
151 printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
152 printf OUT_GDKKEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
157 #$gdksyms{"0"} = "0000";
159 # Source: http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=XF86keysym.h
160 die "Could not open file XF86keysym.h: $!\n" unless open(IN_XF86KEYSYM, "<:utf8", "XF86keysym.h");
162 while (<IN_XF86KEYSYM>)
164 next if ( ! /^#define / );
166 @keysymelements = split(/\s+/);
167 die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
169 $_ = $keysymelements[1];
170 die "Internal error, was expecting \"XF86XK_*\", found: $_\n" if ( ! /^XF86XK_/ );
172 # Work-around https://bugs.freedesktop.org/show_bug.cgi?id=11193
173 if ($_ eq "XF86XK_XF86BackForward") {
174 $keysymelements[1] = "XF86XK_AudioForward";
176 # XF86XK_Clear could end up a dupe of XK_Clear
177 # XF86XK_Select could end up a dupe of XK_Select
178 if ($_ eq "XF86XK_Clear") {
179 $keysymelements[1] = "XF86XK_WindowClear";
181 if ($_ eq "XF86XK_Select") {
182 $keysymelements[1] = "XF86XK_SelectButton";
186 next if ( $_ eq "XF86XK_Q");
187 # XF86XK_Calculater is misspelled, and a dupe
188 next if ( $_ eq "XF86XK_Calculater");
190 $_ = $keysymelements[2];
191 die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
193 my $element = $keysymelements[1];
194 my $binding = $element;
195 $binding =~ s/^XF86XK_/GDK_KEY_/g;
196 my $compat_binding = $element;
197 $compat_binding =~ s/^XF86XK_/GDK_/g;
199 printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
200 printf OUT_GDKKEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
206 print OUT_GDKKEYSYMS<<EOF;
208 #endif /* __GDK_KEYSYMS_H__ */
211 print OUT_GDKKEYSYMS_COMPAT<<EOF;
213 #endif /* __GDK_KEYSYMS_COMPAT_H__ */
216 printf "We just finished converting keysymdef.h to gdkkeysyms.h and gdkkeysyms-compat.h\nThank you\n";