[anjuta/gsettings-migration: 33/65] build: Generate an .geschema.xml file per plugin to keep GSettings happy



commit 7d832cfb7800db1e97822c7de185460015b143e3
Author: Johannes Schmid <jhs gnome org>
Date:   Fri Oct 8 16:59:31 2010 +0200

    build: Generate an .geschema.xml file per plugin to keep GSettings happy
    
    This will mean we need to create a specific GSettings instance for each plugin with its
    schema (org.gnome.anjuta.<plugin-name>) but as we cannot merge schemas external
    plugin would stop working if we used a single schema for all plugins.

 configure.in              |    3 +
 scripts/build-schemas.mk  |   29 +++----------
 scripts/builder2schema.pl |   98 ++++++++++++++++++++++++++------------------
 3 files changed, 68 insertions(+), 62 deletions(-)
---
diff --git a/configure.in b/configure.in
index a722cc9..7b2c605 100644
--- a/configure.in
+++ b/configure.in
@@ -94,6 +94,9 @@ ANJUTA_PLUGIN_LDFLAGS="-module -avoid-version -no-undefined"
 AC_SUBST(ANJUTA_LDFLAGS)
 AC_SUBST(ANJUTA_PLUGIN_LDFLAGS)
 
+dnl GSettings
+GLIB_GSETTINGS
+
 dnl Disable deprecated APIs
 dnl if test x$MAINT = x; then
 dnl 	DEPRECATED_FLAGS="-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
diff --git a/scripts/build-schemas.mk b/scripts/build-schemas.mk
index 9081f8b..0113c7c 100644
--- a/scripts/build-schemas.mk
+++ b/scripts/build-schemas.mk
@@ -1,29 +1,14 @@
 # Targets for handing ui-to-GConf schema conversion for prefs keys
 
-prefs_ui_schemasdir = @GCONF_SCHEMA_FILE_DIR@
-prefs_ui_schemas = $(prefs_ui_files:.ui=.schemas)
-prefs_ui_schemas_DATA = $(prefs_ui_schemas)
+prefs_ui_schemas = $(prefs_ui_files:.ui=.gschema.xml)
 
-%.schemas: %.ui
-	$(AM_V_GEN)$(top_srcdir)/scripts/builder2schema.pl $< > $@
+# gsettings_SCHEMAS is a list of all the schemas you want to install
+gsettings_SCHEMAS = $(prefs_ui_schemas)
 
-if GCONF_SCHEMAS_INSTALL
-install-data-local: $(prefs_ui_schemas)
-	        for p in $(prefs_ui_schemas) ; do \
-	            GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p ; \
-	        done
-		@killall -1 gconfd-2 || true
+%.gschema.xml: %.ui
+	$(AM_V_GEN)$(top_srcdir)/scripts/builder2schema.pl $< $(prefs_name) $(prefs_keyfile) >> $@
 
-uninstall-local: $(prefs_ui_schemas)
-	        for p in $(prefs_ui_schemas) ; do \
-	            GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-uninstall-rule $$p ; \
-	        done
-		@killall -1 gconfd-2 || true
-
-else
-install-data-local:
-
-uninstall-local:
-endif
+# include the appropriate makefile rules for schema handling
+ GSETTINGS_RULES@
 
 CLEANFILES = $(prefs_ui_schemas)
diff --git a/scripts/builder2schema.pl b/scripts/builder2schema.pl
index f9f9dad..20dc4df 100755
--- a/scripts/builder2schema.pl
+++ b/scripts/builder2schema.pl
@@ -3,64 +3,79 @@
 use XML::Parser;
 
 %datatypes = (
-	"bool" => "bool",
-	"int" => "int",
-	"string" => "string",
-	"text" => "string",
-	"float" => "float",
-	"color" => "string",
-	"font" => "string",
-	"folder" => "string",
-	"file" => "string"
+	"bool" => "b",
+	"int" => "i",
+	"string" => "s",
+	"text" => "s",
+	"float" => "f",
+	"color" => "s",
+	"font" => "s",
+	"folder" => "s",
+	"file" => "s"
 );
 
 %boolean = (
-	0 => "FALSE",
-	1 => "TRUE"
+	0 => "false",
+	1 => "true"
 );
 
-$schema_path = "/schemas/apps/anjuta/preferences/";
-$key_path ="/apps/anjuta/preferences/";
+print "<schemalist>\n";
+print "\t<schema id=\"$ARGV[1]\" path=\"/apps/anjuta/\">\n";
 
-my $parser = new XML::Parser(Style => "Stream");
-print "<gconfschemafile>\n";
-print "\t<schemalist>\n";
+if ($#ARGV == 2) {
+	open FILE, "<", $ARGV[2] or die $!;
+	while (<FILE>) { print "\t\t$_"; }
+}
 
+my $parser = new XML::Parser(Style => "Stream");
 $parser->parsefile($ARGV[0]);
 
-print "\t</schemalist>\n";
-print "</gconfschemafile>\n";
+my %keys = {};
 
 sub StartTag {
 	my $parser = shift;
 	my $key = shift;
 	if ($key =~ /object/) {
 		my $k = $_{"id"};
-		if ($k =~ /(preferences_color|entry|font|spin|text|toggle|menu|folder|file):(.*):(.*):(\d):(.*)/) {	
-			
-			my $type = $2;
-			my $default = $3;
-			my $flags = $4;
-			my $propkey = $5;
-			
-			
+		if ($k =~ /(preferences_(color|entry|font|spin|text|toggle|menu|folder|file|combo)):(.*):(.*):(\d):(.*)/) {
+			my $pref = $2;
+			my $type = $3;
+			my $default = $4;
+			my $flags = $5;
+			my $propkey = $6;
+			my $realtype = $datatypes{$type};
+
+			if (exists $keys{$propkey})
+			{
+				return;
+			}
+			else
+			{
+				$keys{$propkey} = 1;
+			}
+
 			if ($type =~ /bool/) {
 				$default = $boolean{$default};
 			}
-			
-			
-			
-			print "\t\t<schema>\n";
-			print "\t\t\t<key>$schema_path$propkey</key>\n";
-			print "\t\t\t<applyto>$key_path$propkey</applyto>\n";
-			print "\t\t\t<owner>anjuta</owner>\n";
-			print "\t\t\t<type>$datatypes{$type}</type>\n";
-			print "\t\t\t<default>$default</default>\n";
-			
-			# Hack to keep gconftool happy
-			print "\t\t\t<locale name=\"C\" />\n";
-			
-			print "\t\t</schema>\n\n";
+
+
+			print "\t\t<key name=\"$propkey\" type=\"$realtype\">\n";
+			if ($pref eq "combo") {
+				@values = split(',', $default);
+				print "\t\t\t<choices>\n";
+				foreach (@values) {
+					print "\t\t\t\t<choice value=\"$_\" />\n"
+				}
+				print "\t\t\t</choices>\n";
+				print "\t\t\t<default>\"$values[$flags]\"</default>\n";
+			}
+			elsif ($realtype ne "s") {
+				print "\t\t\t<default>$default</default>\n";
+			}
+			else {
+				print "\t\t\t<default>\"$default\"</default>\n";
+			}
+			print "\t\t</key>\n";
 		}
 	}
 }
@@ -68,3 +83,6 @@ sub StartTag {
 sub EndTag {}
 
 sub Text {}
+
+print "\t</schema>\n";
+print "</schemalist>";
\ No newline at end of file



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