summaryrefslogtreecommitdiff
path: root/gdk/gdkkeysyms-update.pl
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-09-08 13:35:51 -0400
committerColin Walters <walters@verbum.org>2010-09-08 18:51:44 -0400
commit913cdf3be750a1e74c09b20edf55a57f9a919fcc (patch)
tree0d2129a167579c0d896bb9213503619b2ef44d1f /gdk/gdkkeysyms-update.pl
parent03c19e37af1f7aa9af8a48bcc9dc023397f8693f (diff)
downloadgtk+-913cdf3be750a1e74c09b20edf55a57f9a919fcc.tar.gz
GDK: Prefix key names with KEY_
The keysyms create a lot of potential namespace conflicts for C, and are especially problematic for introspection, where we take constants into the namespace, so GDK_Display conflicts with GdkDisplay. For C application compatiblity, add gdkkeysyms-compat.h which uses the old names. Just one user in GTK+ continues to use gdkkeysyms-compat.h, which is the gtkimcontextsimple.c, since porting that requires porting more custom Perl code.
Diffstat (limited to 'gdk/gdkkeysyms-update.pl')
-rwxr-xr-xgdk/gdkkeysyms-update.pl50
1 files changed, 44 insertions, 6 deletions
diff --git a/gdk/gdkkeysyms-update.pl b/gdk/gdkkeysyms-update.pl
index bdfb9c29ec..f13671de60 100755
--- a/gdk/gdkkeysyms-update.pl
+++ b/gdk/gdkkeysyms-update.pl
@@ -63,7 +63,10 @@ die "Could not open file keysymdef.h: $!\n" unless open(IN_KEYSYMDEF, "<:utf8",
# Output: gtk+/gdk/gdkkeysyms.h
die "Could not open file gdkkeysyms.h: $!\n" unless open(OUT_GDKKEYSYMS, ">:utf8", "gdkkeysyms.h");
-print OUT_GDKKEYSYMS<<EOF;
+# Output: gtk+/gdk/gdkkeysyms-compat.h
+die "Could not open file gdkkeysyms-compat.h: $!\n" unless open(OUT_GDKKEYSYMS_COMPAT, ">:utf8", "gdkkeysyms-compat.h");
+
+my $LICENSE_HEADER= <<EOF;
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* Copyright (C) 2005, 2006, 2007, 2009 GNOME Foundation
@@ -84,6 +87,13 @@ print OUT_GDKKEYSYMS<<EOF;
* Boston, MA 02111-1307, USA.
*/
+EOF
+
+print OUT_GDKKEYSYMS $LICENSE_HEADER;
+print OUT_GDKKEYSYMS_COMPAT $LICENSE_HEADER;
+
+print OUT_GDKKEYSYMS<<EOF;
+
/*
* File auto-generated from script http://git.gnome.org/cgit/gtk+/tree/gdk/gdkkeysyms-update.pl
* using the input file
@@ -105,6 +115,19 @@ print OUT_GDKKEYSYMS<<EOF;
EOF
+print OUT_GDKKEYSYMS_COMPAT<<EOF;
+/*
+ * Compatibility version of gdkkeysyms.h.
+ *
+ * In GTK3, keysyms changed to have a KEY_ prefix. This is a compatibility header
+ * your application can include to gain access to the old names as well. Consider
+ * porting to the new names instead.
+ */
+
+#ifndef __GDK_KEYSYMS_COMPAT_H__
+#define __GDK_KEYSYMS_COMPAT_H__
+
+EOF
while (<IN_KEYSYMDEF>)
{
@@ -119,9 +142,14 @@ while (<IN_KEYSYMDEF>)
$_ = $keysymelements[2];
die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
- $keysymelements[1] =~ s/^XK_/GDK_/g;
+ my $element = $keysymelements[1];
+ my $binding = $element;
+ $binding =~ s/^XK_/GDK_KEY_/g;
+ my $compat_binding = $element;
+ $compat_binding =~ s/^XK_/GDK_/g;
- printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $keysymelements[1], hex($keysymelements[2]);
+ printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
+ printf OUT_GDKKEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
}
close IN_KEYSYMDEF;
@@ -162,9 +190,14 @@ while (<IN_XF86KEYSYM>)
$_ = $keysymelements[2];
die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
- $keysymelements[1] =~ s/^XF86XK_/GDK_/g;
+ my $element = $keysymelements[1];
+ my $binding = $element;
+ $binding =~ s/^XF86XK_/GDK_KEY_/g;
+ my $compat_binding = $element;
+ $compat_binding =~ s/^XF86XK_/GDK_/g;
- printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $keysymelements[1], hex($keysymelements[2]);
+ printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
+ printf OUT_GDKKEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
}
close IN_XF86KEYSYM;
@@ -175,4 +208,9 @@ print OUT_GDKKEYSYMS<<EOF;
#endif /* __GDK_KEYSYMS_H__ */
EOF
-printf "We just finished converting keysymdef.h to gdkkeysyms.h\nThank you\n";
+print OUT_GDKKEYSYMS_COMPAT<<EOF;
+
+#endif /* __GDK_KEYSYMS_COMPAT_H__ */
+EOF
+
+printf "We just finished converting keysymdef.h to gdkkeysyms.h and gdkkeysyms-compat.h\nThank you\n";