source: trunk/debathena/debathena/dotfiles/gnome/gen-schemas.pl @ 21800

Revision 21800, 1.6 KB checked in by rbasch, 19 years ago (diff)
Change the owner from "gnome-panel" to the more generic "gnome", and generalize a comment.
  • Property svn:executable set to *
Line 
1#!/usr/athena/bin/perl
2
3# gen-schema: A tool for generating GNOME config schema from a
4# readable file format.  This isn't a very generic tool; it only handles
5# strings (with no special characters in them), integers, booleans,
6# and lists of strings.
7
8print "<?xml version=\"1.0\"?>\n";
9print "<gconfschemafile>\n";
10print " <schemalist>\n";
11print "\n";
12
13$path[0] = "";
14while (<>) {
15    chop;
16    /^( *)(.*)$/;
17    $indent = length($1);
18    $line = $2;
19    next if ($line =~ /^#/ || $line eq "");
20    if ($line =~ /^\[(.*)\]$/) {
21        $path[$indent + 1] = $path[$indent] . "/" . $1;
22    } elsif ($line =~ /^([\w-]+) *= *(.*)$/) {
23        $key = $path[$indent] . "/" . $1;
24        $valspec = $2;
25        if ($valspec =~ /^"(.*)"$/) {
26            $type = "string";
27            $val = $1;
28        } elsif ($valspec =~ /^-?\d+$/) {
29            $type = "int";
30            $val = $valspec;
31        } elsif ($valspec =~ /^true|false$/) {
32            $type = "bool";
33            $val = $valspec;
34        } elsif ($valspec =~ /^\[.*\]$/) {
35            $type = "list";
36            $val = $valspec;
37        } elsif ($valspec =~ /^\[/) {
38            $type = "list";
39            $val = $valspec;
40            while (<>) {
41                chop;
42                s/^ *//;
43                $val .= $_;
44                last if /\]$/;
45            }
46        } else {
47            die "Unrecognized valspec format '$valspec'.\n";
48        }
49        print "  <schema>\n";
50        print "   <key>/schemas$key</key>\n";
51        print "   <applyto>$key</applyto>\n";
52        print "   <owner>gnome</owner>\n";
53        print "   <type>$type</type>\n";
54        if ($type eq "list") {
55            print "   <list_type>string</list_type>\n";
56        }
57        print "   <default>$val</default>\n";
58        print "   <locale name=\"C\" />\n";
59        print "  </schema>\n";
60        print "\n";
61    } else {
62        die "Unrecognized line format '$line'.\n";
63    }
64}
65
66print " </schemalist>\n";
67print "</gconfschemafile>\n";
68
Note: See TracBrowser for help on using the repository browser.