summaryrefslogtreecommitdiff
path: root/tools/fmt-bindings
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-07-11 09:17:59 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-02-22 15:31:22 -0500
commitbbea11fe0f43ce598965fb217d1d5700ab477331 (patch)
tree80e0f9c3ea387c308e39bd30ba4d64a2dacc4e03 /tools/fmt-bindings
parente3db5c5c0555b755ac42cbc5329390c78ce61946 (diff)
hack up fmt-bindings so that it can generate native ardour bindings files
Diffstat (limited to 'tools/fmt-bindings')
-rwxr-xr-xtools/fmt-bindings42
1 files changed, 37 insertions, 5 deletions
diff --git a/tools/fmt-bindings b/tools/fmt-bindings
index aa76afe72f..7426d909e6 100755
--- a/tools/fmt-bindings
+++ b/tools/fmt-bindings
@@ -12,6 +12,8 @@ $group_key;
$group_number = 0;
%group_names;
%group_text;
+%group_files;
+%group_handles;
%group_bindings;
%modifier_map;
%group_numbering;
@@ -21,6 +23,7 @@ $platform = linux;
$winkey = 'Win';
$make_cheatsheet = 1;
$make_accelmap = 0;
+$ardour_bindings = 0;
$merge_from = "";
$html = 0;
@@ -28,6 +31,7 @@ GetOptions ("platform=s" => \$platform,
"winkey=s" => \$winkey,
"cheatsheet" => \$make_cheatsheet,
"accelmap" => \$make_accelmap,
+ "ardourbindings" => \$ardour_bindings,
"merge=s" => \$merge_from,
"html" => \$html);
@@ -185,7 +189,7 @@ if ($merge_from) {
close (BINDINGS);
}
-if ($make_accelmap && !$merge_from) {
+if ($make_accelmap && !$merge_from && !$ardour_bindings) {
print ";; this accelmap was produced by tools/fmt-bindings\n";
}
@@ -214,7 +218,14 @@ while (<>) {
s/^%//;
chop;
- ($group_key,$group_name) = split (/\s+/, $_, 2);
+ ($group_key,$group_file,$group_name) = split (/\s+/, $_, 3);
+ if ($make_accelmap && $ardour_bindings) {
+ if (!exists ($group_handles{$group_file})) {
+ print "Try to open ", $group_file . ".bindings\n";
+ open $group_handles{$group_file}, ">", $group_file . ".bindings" or die "Cannot open bindings file " . $group_file . ".bindings: $!"
+ }
+ $group_files{$group_key} = $group_handles{$group_file}
+ }
$group_number++;
$group_text = "";
$in_group_def = 1;
@@ -240,6 +251,9 @@ while (<>) {
chop;
($key,$action,$binding,$text) = split (/\|/, $_, 4);
+ $gkey = $key;
+ $gkey =~ s/^-//;
+
# substitute bindings
$gtk_binding = $binding;
@@ -266,10 +280,24 @@ while (<>) {
} else {
# include this in the accelmap
if (!$merge_from && $make_accelmap) {
- foreach $k (keys %gtk_modifier_map) {
- $gtk_binding =~ s/\@$k\@/$gtk_modifier_map{$k}/;
+ if (!$ardour_bindings) {
+ foreach $k (keys %gtk_modifier_map) {
+ $gtk_binding =~ s/\@$k\@/$gtk_modifier_map{$k}/;
+ }
+ print "(gtk_accel_path \"<Actions>/$action\" \"$gtk_binding\")\n";
+ } else {
+ $b = $binding;
+ $b =~ s/<@//g;
+ $b =~ s/@>//g;
+ $b =~ s/PRIMARY/Primary-/;
+ $b =~ s/SECONDARY/Secondary-/;
+ $b =~ s/TERTIARY/Tertiary-/;
+ $b =~ s/LEVEL4/Level4-/;
+
+ if (exists ($group_files{$gkey})) {
+ print { $group_files{$gkey} } "<Binding key=\"" . $b . "\" action=\"" . $action . "\"/>\n";
+ }
}
- print "(gtk_accel_path \"<Actions>/$action\" \"$gtk_binding\")\n";
}
}
@@ -287,6 +315,10 @@ while (<>) {
next;
}
+foreach my $key (keys %group_handles) {
+ close $group_handles{$key} or die "Group file $group_files{$key} not closed!"
+}
+
if ($make_accelmap || !$make_cheatsheet) {
exit 0;
}