]> Pileus Git - ~andy/gtk/blob - gdk/gdkkeysyms-update.pl
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gdk / gdkkeysyms-update.pl
1 #!/usr/bin/env perl
2
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
5
6 # Author  : Simos Xenitellis <simos at gnome dot org>.
7 # Author  : Bastien Nocera <hadess@hadess.net>
8 # Version : 1.2
9 #
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
13
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.
17
18 use strict;
19
20 # Used for reading the keysymdef symbols.
21 my @keysymelements;
22
23 if ( ! -f "keysymdef.h" )
24 {
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;
29         print " done.\n\n";
30 }
31 else
32 {
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";
36 }
37
38 if ( ! -f "XF86keysym.h" )
39 {
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;
44         print " done.\n\n";
45 }
46 else
47 {
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";
51 }
52
53 if ( -f "gdkkeysyms.h" )
54 {
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";
57         die "Exiting...\n\n";
58 }
59
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");
62
63 # Output: gtk+/gdk/gdkkeysyms.h
64 die "Could not open file gdkkeysyms.h: $!\n" unless open(OUT_GDKKEYSYMS, ">:utf8", "gdkkeysyms.h");
65
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");
68
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
73  *
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.
78  *
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.
83  *
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/>.
86  */
87
88 EOF
89
90 print OUT_GDKKEYSYMS $LICENSE_HEADER;
91 print OUT_GDKKEYSYMS_COMPAT $LICENSE_HEADER;
92
93 print OUT_GDKKEYSYMS<<EOF;
94
95 /*
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
99  * and
100  * http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
101  */
102
103 /*
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/.
108  */
109
110 #ifndef __GDK_KEYSYMS_H__
111 #define __GDK_KEYSYMS_H__
112
113
114 EOF
115
116 print OUT_GDKKEYSYMS_COMPAT<<EOF;
117 /*
118  * Compatibility version of gdkkeysyms.h.
119  *
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.
123  */
124
125 #ifndef __GDK_KEYSYMS_COMPAT_H__
126 #define __GDK_KEYSYMS_COMPAT_H__
127
128 EOF
129
130 while (<IN_KEYSYMDEF>)
131 {
132         next if ( ! /^#define / );
133
134         @keysymelements = split(/\s+/);
135         die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
136
137         $_ = $keysymelements[1];
138         die "Internal error, was expecting \"XC_*\", found: $_\n" if ( ! /^XK_/ );
139         
140         $_ = $keysymelements[2];
141         die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
142
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;
148
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]);
151 }
152
153 close IN_KEYSYMDEF;
154
155 #$gdksyms{"0"} = "0000";
156
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");
159
160 while (<IN_XF86KEYSYM>)
161 {
162         next if ( ! /^#define / );
163
164         @keysymelements = split(/\s+/);
165         die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
166
167         $_ = $keysymelements[1];
168         die "Internal error, was expecting \"XF86XK_*\", found: $_\n" if ( ! /^XF86XK_/ );
169
170         # Work-around https://bugs.freedesktop.org/show_bug.cgi?id=11193
171         if ($_ eq "XF86XK_XF86BackForward") {
172                 $keysymelements[1] = "XF86XK_AudioForward";
173         }
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";
178         }
179         if ($_ eq "XF86XK_Select") {
180                 $keysymelements[1] = "XF86XK_SelectButton";
181         }
182
183         # Ignore XF86XK_Q
184         next if ( $_ eq "XF86XK_Q");
185         # XF86XK_Calculater is misspelled, and a dupe
186         next if ( $_ eq "XF86XK_Calculater");
187
188         $_ = $keysymelements[2];
189         die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
190
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;
196
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]);
199 }
200
201 close IN_XF86KEYSYM;
202
203
204 print OUT_GDKKEYSYMS<<EOF;
205
206 #endif /* __GDK_KEYSYMS_H__ */
207 EOF
208
209 print OUT_GDKKEYSYMS_COMPAT<<EOF;
210
211 #endif /* __GDK_KEYSYMS_COMPAT_H__ */
212 EOF
213
214 printf "We just finished converting keysymdef.h to gdkkeysyms.h and gdkkeysyms-compat.h\nThank you\n";