[gnumeric] conf: handle gsettings schemas.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] conf: handle gsettings schemas.
- Date: Wed, 26 Oct 2011 16:52:39 +0000 (UTC)
commit c27de39c67510e40ba12e9647b2d5e83e83ade14
Author: Morten Welinder <terra gnome org>
Date: Wed Oct 26 12:52:16 2011 -0400
conf: handle gsettings schemas.
tools/ChangeLog | 4 ++
tools/handle-conf-options | 87 ++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 87 insertions(+), 4 deletions(-)
---
diff --git a/tools/ChangeLog b/tools/ChangeLog
index 71e4708..fab506a 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,3 +1,7 @@
+2011-10-26 Morten Welinder <terra gnome org>
+
+ * handle-conf-options: Parse gsettings schemas as well.
+
2011-10-18 Morten Welinder <terra gnome org>
* embedder (embed): Handler compression. Make data local to
diff --git a/tools/handle-conf-options b/tools/handle-conf-options
index 9e6ad74..2a15fc9 100644
--- a/tools/handle-conf-options
+++ b/tools/handle-conf-options
@@ -13,17 +13,32 @@ my ($do_hkcu_reg,$do_reg);
# -----------------------------------------------------------------------------
+my %typemap = ('b' => 'bool',
+ 's' => 'string',
+ 'i' => 'int',
+ 'd' => 'float',
+ 'as' => 'list:string');
+
+
my @schemas = ();
for my $filename (@ARGV) {
my $parser = new XML::Parser ('Style' => 'Tree');
my $tree = $parser->parsefile ($filename);
- &walk_tree ([], [{},@$tree]);
+ my $mode = $tree->[0];
+
+ if ($mode eq 'gconfschemafile') {
+ &walk_gconf_tree ([], [{},@$tree]);
+ } elsif ($mode eq 'schemalist') {
+ &walk_gsetting_tree ([], [{},@$tree]);
+ } else {
+ die "$0: Unknown type of xml [$mode].\n";
+ }
}
my $schema;
-sub walk_tree {
+sub walk_gconf_tree {
my ($parents,$contents) = @_;
if (ref ($contents) eq 'ARRAY') {
@@ -54,13 +69,65 @@ sub walk_tree {
# This handles empty defaults.
$schema->{$tag} = '';
}
- &walk_tree ([ $parents,$tag],$args);
+ &walk_gconf_tree ([ $parents,$tag],$args);
push @schemas, $schema if $tag eq 'schema';
}
}
}
}
+sub walk_gsetting_tree {
+ my ($parents,$contents) = @_;
+
+ if (ref ($contents) eq 'ARRAY') {
+ my @items = @$contents;
+ my $attrs = shift @items;
+
+ while (@items) {
+ my $tag = shift @items;
+ my $args = shift @items;
+
+ if ($tag eq '0') {
+ # Text
+ if (@$parents > 2 && $parents->[-2] eq 'key') {
+ my $key = $parents->[-1];
+ my $val = $args;
+ if ($key eq 'default' && $schema->{'type'} eq 'string') {
+ die "$0: invalid string value: $val\n" unless
+ (length($val) >= 2 &&
+ substr($val,0,1) eq substr($val,-1,1) &&
+ $val =~ /^['"]/);
+ $val = substr ($val, 1, length ($val) - 2);
+ }
+ $schema->{$key} = $val;
+ }
+ } else {
+ if ($tag eq 'key') {
+ $schema = {};
+
+ my $thisattrs = $args->[0];
+
+ $schema->{'applyto'} =
+ $attrs->{'path'} . $thisattrs->{'name'};
+ my $type = $typemap{$thisattrs->{'type'}};
+ if ($type =~ /^list:(.*)$/) {
+ $schema->{'type'} = 'list';
+ $schema->{'list_type'} = $1;
+ } else {
+ $schema->{'type'} = $type;
+ }
+ }
+ if (@$parents > 1 && $parents->[-1] eq 'schema') {
+ # This handles empty defaults.
+ $schema->{$tag} = '';
+ }
+ &walk_gsetting_tree ([ $parents,$tag],$args);
+ push @schemas, $schema if $tag eq 'key';
+ }
+ }
+ }
+}
+
# -----------------------------------------------------------------------------
my %extra_attributes =
@@ -75,6 +142,7 @@ my %extra_attributes =
},
'/apps/gnome-settings/gnumeric/toolbar_style' => {
+ 'noconfnode' => 1,
'gtype' => 'GTK_TYPE_TOOLBAR_STYLE',
'default' => 'GTK_TOOLBAR_ICONS', # Should match schema
},
@@ -259,6 +327,16 @@ my %extra_attributes =
},
);
+foreach my $key (keys %extra_attributes) {
+ my $newkey = $key;
+ if ($newkey eq '/apps/gnome-settings/gnumeric/toolbar_style') {
+ $newkey = '/apps/gnumeric/toolbar-style';
+ } else {
+ $newkey = lc $newkey;
+ $newkey =~ s/_/-/g;
+ }
+ $extra_attributes{$newkey} = $extra_attributes{$key};
+}
sub apply_extra_attributes {
foreach my $schema (@schemas) {
@@ -310,7 +388,7 @@ sub quote_c_string {
}
sub create_hcfile {
- @schemas = sort { $a->{'applyto'} cmp $b->{'applyto'} } @schemas;
+ &sort_schemas ();
&number_schemas ();
&apply_extra_attributes ();
@@ -356,6 +434,7 @@ sub create_hcfile {
my $dir = $key; $dir =~ s{/[^/]+$}{};
$dirs{$dir} = 1;
$needs_conf = 1;
+ $needs_conf = 0 if $schema->{'noconfnode'};
}
my $get_conf_code = "";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]