[gnumeric] conf: make gsettings stuff work for win32 stuff also.



commit 2d0b3ea9b314f1c369534cace2bb4ca866190572
Author: Morten Welinder <terra gnome org>
Date:   Wed Oct 26 15:00:17 2011 -0400

    conf: make gsettings stuff work for win32 stuff also.

 schemas/Makefile.am       |    4 ++--
 tools/handle-conf-options |   41 +++++++++++++++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 8 deletions(-)
---
diff --git a/schemas/Makefile.am b/schemas/Makefile.am
index 04b6c87..3a78a49 100644
--- a/schemas/Makefile.am
+++ b/schemas/Makefile.am
@@ -1,3 +1,4 @@
+SUFFIXES = .schemas.in .reg .hkcu.reg
 schema_in_files = gnumeric-dialogs.schemas.in gnumeric-general.schemas.in gnumeric-plugins.schemas.in
 if WITH_GCONF
 schemadir   	= @GCONF_SCHEMA_FILE_DIR@
@@ -40,14 +41,13 @@ install-data-local:
 endif
 
 if WITH_NATIVE_WIN32
-SUFFIXES = .schemas.in .reg .hkcu.reg
 regdir = $(prefix)/etc/win32/reg
 reg_DATA = $(schema_in_files:.schemas.in=.reg) $(schema_in_files:.schemas.in=.hkcu.reg)
 CLEANFILES += $(reg_DATA)
+endif
 
 .schemas.in.reg:
 	@PERL@ $(top_srcdir)/tools/handle-conf-options --reg $< >$(abs_builddir)/$@
 
 .schemas.in.hkcu.reg:
 	@PERL@ $(top_srcdir)/tools/handle-conf-options --hkcu-reg $< >$(abs_builddir)/$@
-endif
diff --git a/tools/handle-conf-options b/tools/handle-conf-options
index 2a15fc9..4e0cfc9 100644
--- a/tools/handle-conf-options
+++ b/tools/handle-conf-options
@@ -76,6 +76,35 @@ sub walk_gconf_tree {
     }
 }
 
+sub unquote_gschema_string {
+    my ($val) = @_;
+    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);
+    return $val;
+}
+
+sub unquote_gschema_string_list {
+    my ($val) = @_;
+    return undef if $val eq '[]';
+    die "$0: invalid string value: $val\n" unless
+	(length($val) >= 2 &&
+	 substr($val,0,1) eq '[' &&
+	 substr($val,-1,1) eq ']');
+    $val = substr ($val, 1, length ($val) - 2);
+    my $res = '';
+    while ($val =~ s/^'([^']*)'// or $val =~ s/^"([^']*)"//) {
+	$res .= $1;
+	last if $val eq '';
+	$val =~ s/^,//;
+	$res .= ',';
+    }
+
+    return "[$res]";
+}
+
 sub walk_gsetting_tree {
     my ($parents,$contents) = @_;
 
@@ -93,11 +122,11 @@ sub walk_gsetting_tree {
 		    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);
+			$val = &unquote_gschema_string ($val);
+		    } elsif ($key eq 'default' &&
+			     $schema->{'type'} eq 'list' &&
+			     $schema->{'list_type'} eq 'string') {
+			$val = &unquote_gschema_string_list ($val);
 		    }
 		    $schema->{$key} = $val;
 		}
@@ -388,7 +417,6 @@ sub quote_c_string {
 }
 
 sub create_hcfile {
-    &sort_schemas ();
     &number_schemas ();
     &apply_extra_attributes ();
 
@@ -659,6 +687,7 @@ sub create_reg {
 
 # -----------------------------------------------------------------------------
 
+&sort_schemas ();
 &create_hcfile () if $do_hfile || $do_cfile;
 &create_reg ("HKEY_USERS\\.DEFAULT\\Software") if $do_reg;
 &create_reg ("HKEY_CURRENT_USER\\Software") if $do_hkcu_reg;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]