Update Indonesian translation
[anjuta-extras.git] / scripts / builder2schema.pl
blob0d9c4dfcc3b1507df1dae1e502990e28101974a3
1 #!/usr/bin/perl
3 use XML::Parser;
5 %datatypes = (
6 "bool" => "b",
7 "int" => "i",
8 "string" => "s",
9 "text" => "s",
10 "float" => "f",
11 "color" => "s",
12 "font" => "s",
13 "folder" => "s",
14 "file" => "s"
17 %boolean = (
18 0 => "false",
19 1 => "true"
22 print "<schemalist>\n";
23 print "\t<schema id=\"$ARGV[1]\" path=\"/apps/anjuta/\">\n";
25 if ($#ARGV == 2) {
26 open FILE, "<", $ARGV[2] or die $!;
27 while (<FILE>) { print "\t\t$_"; }
30 my $parser = new XML::Parser(Style => "Stream");
31 $parser->parsefile($ARGV[0]);
33 print "\t</schema>\n";
34 print "</schemalist>";
36 sub StartTag {
37 my %keys = {};
38 my $parser = shift;
39 my $key = shift;
40 if ($key =~ /object/) {
41 my $k = $_{"id"};
42 if ($k =~ /(preferences_(color|entry|font|spin|text|toggle|menu|folder|file|combo)):(.*):(.*):(\d):(.*)/) {
43 my $pref = $2;
44 my $type = $3;
45 my $default = $4;
46 my $flags = $5;
47 my $propkey = $6;
48 my $realtype = $datatypes{$type};
50 if (exists $keys{$propkey})
52 return;
54 else
56 $keys{$propkey} = 1;
59 if ($type =~ /bool/) {
60 $default = $boolean{$default};
64 print "\t\t<key name=\"$propkey\" type=\"$realtype\">\n";
65 if ($pref eq "combo") {
66 @values = split(',', $default);
67 print "\t\t\t<choices>\n";
68 foreach (@values) {
69 print "\t\t\t\t<choice value=\"$_\" />\n"
71 print "\t\t\t</choices>\n";
72 print "\t\t\t<default>\"$values[$flags]\"</default>\n";
74 elsif ($realtype ne "s") {
75 print "\t\t\t<default>$default</default>\n";
77 else {
78 print "\t\t\t<default>\"$default\"</default>\n";
80 print "\t\t</key>\n";
85 sub EndTag {}
87 sub Text {}