forked from AuroraMiddleware/gtk
79d82223a2
2005-06-10 Matthias Clasen <mclasen@redhat.com> * gdk/gen-keyname-table.pl: Generate N_() calls for translatable key names. * gdk/keynames.txt: Mark some key names as translatable. * gdk/keyname-table.h: Regenerated. * gtk/gtkaccellabel.c (gtk_accel_label_class_init): Add some context to the msg ids for keyboard modifiers and key names. (_gtk_accel_label_class_get_accelerator_label): Try to translate key names. (#300224, Christian Rose)
115 lines
1.5 KiB
Perl
Executable File
115 lines
1.5 KiB
Perl
Executable File
#!/usr/bin/perl -w
|
|
|
|
if (@ARGV != 1) {
|
|
die "Usage: gen-keyname-table.pl keynames.txt > keyname-table.h\n";
|
|
}
|
|
|
|
open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n";
|
|
|
|
@keys = ();
|
|
@translate = ();
|
|
while (defined($_ = <IN>)) {
|
|
next if /^!/;
|
|
if (!/^\s*(0x[0-9a-f]+)\s+([\w_]*\S)\s+(1)?\s*$/) {
|
|
die "Cannot parse line $_";
|
|
}
|
|
|
|
push @keys, [$1, $2];
|
|
|
|
if (defined ($3)) {
|
|
push @translate, $2;
|
|
}
|
|
}
|
|
|
|
$offset = 0;
|
|
|
|
$date = gmtime;
|
|
|
|
print <<EOT;
|
|
/* keyname-table.h: Generated by gen-keyname-table.pl from keynames.txt
|
|
*
|
|
* Date: $date
|
|
*
|
|
* Do not edit.
|
|
*/
|
|
static const char keynames[] =
|
|
EOT
|
|
|
|
for $key (@keys) {
|
|
$name = $key->[1];
|
|
|
|
if ($offset != 0) {
|
|
print qq(\n);
|
|
}
|
|
print qq( "$name\\0");
|
|
|
|
$key->[3] = $offset;
|
|
$offset += length($name) + 1;
|
|
}
|
|
|
|
print ";\n\n";
|
|
|
|
print <<EOT;
|
|
typedef struct {
|
|
guint keyval;
|
|
guint offset;
|
|
} gdk_key;
|
|
|
|
static const gdk_key gdk_keys_by_keyval[] = {
|
|
EOT
|
|
|
|
$i = 0;
|
|
for $key (@keys) {
|
|
$keyval = $key->[0];
|
|
$name = $key->[1];
|
|
$offset = $key->[3];
|
|
|
|
if ($i != 0) {
|
|
print ",\n";
|
|
}
|
|
print " { $keyval, $offset }";
|
|
$i++;
|
|
}
|
|
|
|
print "\n};\n\n";
|
|
|
|
@keys = sort { $a->[1] cmp $b->[1] } @keys;
|
|
|
|
|
|
print <<EOT;
|
|
static const gdk_key gdk_keys_by_name[] = {
|
|
EOT
|
|
|
|
$i = 0;
|
|
for $key (@keys) {
|
|
$keyval = $key->[0];
|
|
$name = $key->[1];
|
|
$offset = $key->[3];
|
|
|
|
if ($i != 0) {
|
|
print ",\n";
|
|
}
|
|
print " { $keyval, $offset }";
|
|
$i++;
|
|
}
|
|
|
|
print <<EOT;
|
|
};
|
|
|
|
|
|
#if 0
|
|
|
|
EOT
|
|
|
|
for $key (@translate) {
|
|
print <<EOT;
|
|
N_("keyboard label|$key")
|
|
EOT
|
|
}
|
|
|
|
print <<EOT;
|
|
|
|
#endif
|
|
EOT
|
|
|