[anjuta/gsettings-migration: 12/31] build-system: Generate GSettings schemas instead of gconf-schemas



commit 3f0b68d652c13e0a3ad9428792492d3642bfd802
Author: Johannes Schmid <jhs gnome org>
Date:   Thu Sep 30 22:08:42 2010 +0200

    build-system: Generate GSettings schemas instead of gconf-schemas
    
    Also known as "The big Hack"

 configure.in                                  |    3 +
 plugins/build-basic-autotools/Makefile.am     |    4 +-
 plugins/cvs-plugin/Makefile.am                |    4 +-
 plugins/document-manager/Makefile.am          |    8 +-
 plugins/file-manager/Makefile.am              |    4 +-
 plugins/language-support-cpp-java/Makefile.am |    4 +-
 plugins/language-support-python/Makefile.am   |    4 +-
 plugins/message-view/Makefile.am              |    4 +-
 plugins/sourceview/Makefile.am                |    8 +-
 plugins/starter/Makefile.am                   |    2 +-
 plugins/terminal/Makefile.am                  |    4 +-
 scripts/Makefile.am                           |   17 ++++-
 scripts/anjuta_project.template               |  120 -------------------------
 scripts/builder2schema.pl                     |   83 +++++++++--------
 scripts/generate-schema.sh                    |   21 +++++
 src/Makefile.am                               |    4 +-
 16 files changed, 110 insertions(+), 184 deletions(-)
---
diff --git a/configure.in b/configure.in
index a722cc9..1205c68 100644
--- a/configure.in
+++ b/configure.in
@@ -350,6 +350,9 @@ AC_SUBST(GLIB_GENMARSHAL)
 GLIB_MKENUMS="`$PKG_CONFIG --variable=glib_mkenums glib-2.0`"
 AC_SUBST(GLIB_MKENUMS)
 
+dnl Check for GSettings macros
+GLIB_GSETTINGS
+
 dnl Set up Glade 3 catlog information
 dnl ---------------------
 GLADE_PLUGINS_PATH="`$PKG_CONFIG --variable=moduledir gladeui-1.0`"
diff --git a/plugins/build-basic-autotools/Makefile.am b/plugins/build-basic-autotools/Makefile.am
index f6277fa..b77d1c1 100644
--- a/plugins/build-basic-autotools/Makefile.am
+++ b/plugins/build-basic-autotools/Makefile.am
@@ -58,8 +58,8 @@ libanjuta_build_basic_autotools_la_LIBADD = \
 
 libanjuta_build_basic_autotools_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
-prefs_ui_files = anjuta-build-basic-autotools-plugin.ui
-include $(top_srcdir)/scripts/build-schemas.mk
+
+
 
 EXTRA_DIST = \
 	$(plugin_in_files) \
diff --git a/plugins/cvs-plugin/Makefile.am b/plugins/cvs-plugin/Makefile.am
index c74d436..3f56aa0 100644
--- a/plugins/cvs-plugin/Makefile.am
+++ b/plugins/cvs-plugin/Makefile.am
@@ -42,8 +42,8 @@ libanjuta_cvs_plugin_la_SOURCES = \
 	cvs-interface.c \
 	cvs-interface.h
 	
-prefs_ui_files = anjuta-cvs-plugin.ui
-include $(top_srcdir)/scripts/build-schemas.mk
+
+
 
 EXTRA_DIST = \
 	$(plugin_in_files) \
diff --git a/plugins/document-manager/Makefile.am b/plugins/document-manager/Makefile.am
index 894ef6b..405aec3 100644
--- a/plugins/document-manager/Makefile.am
+++ b/plugins/document-manager/Makefile.am
@@ -47,15 +47,15 @@ libanjuta_document_manager_la_SOURCES= \
 	search-box.c \
 	anjuta-bookmarks.h \
 	anjuta-bookmarks.c
-	
-prefs_ui_files = anjuta-document-manager.ui
-include $(top_srcdir)/scripts/build-schemas.mk
+
+SCHEMA_PART_FILES = document-manager.gschema-part.xml
 
 EXTRA_DIST = \
 	$(document_manager_pixmaps_DATA) \
 	$(plugin_in_files) \
 	$(document_manager_plugin_DATA) \
 	$(document_manager_ui_DATA) \
-	$(document_manager_glade_DATA)
+	$(document_manager_glade_DATA) \
+	$(SCHEMA_PART_FILES)
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/file-manager/Makefile.am b/plugins/file-manager/Makefile.am
index 3bcbd94..ff99857 100644
--- a/plugins/file-manager/Makefile.am
+++ b/plugins/file-manager/Makefile.am
@@ -73,8 +73,8 @@ file-view-marshal.c: $(srcdir)/file-view-marshal.list
 	then mv -f .genmarshal-$@ $@; \
 	else rm -f .genmarshal-$@; fi
 
-prefs_ui_files = file-manager.ui
-include $(top_srcdir)/scripts/build-schemas.mk
+
+
 
 EXTRA_DIST = \
 	$(plugin_in_files) \
diff --git a/plugins/language-support-cpp-java/Makefile.am b/plugins/language-support-cpp-java/Makefile.am
index 16cdc72..0125751 100644
--- a/plugins/language-support-cpp-java/Makefile.am
+++ b/plugins/language-support-cpp-java/Makefile.am
@@ -63,8 +63,8 @@ libanjuta_language_cpp_java_la_LIBADD = \
 	$(LIBANJUTA_LIBS) \
 	cxxparser/libcxxparser.la
 	
-prefs_ui_files = anjuta-language-cpp-java.ui
-include $(top_srcdir)/scripts/build-schemas.mk
+
+
 
 EXTRA_DIST = \
 	$(plugin_in_files) \
diff --git a/plugins/language-support-python/Makefile.am b/plugins/language-support-python/Makefile.am
index 3d50d9a..739d3e4 100644
--- a/plugins/language-support-python/Makefile.am
+++ b/plugins/language-support-python/Makefile.am
@@ -40,8 +40,8 @@ libpython_plugin_la_SOURCES = plugin.c plugin.h python-assist.c python-assist.h
 libpython_plugin_la_LIBADD = \
 	$(LIBANJUTA_LIBS) 
 
-prefs_ui_files = $(python_plugin_glade_DATA)
-include $(top_srcdir)/scripts/build-schemas.mk
+
+
 
 EXTRA_DIST = \
 	$(plugin_in_files) \
diff --git a/plugins/message-view/Makefile.am b/plugins/message-view/Makefile.am
index 31af1bc..10a58cd 100644
--- a/plugins/message-view/Makefile.am
+++ b/plugins/message-view/Makefile.am
@@ -42,8 +42,8 @@ libanjuta_message_view_la_SOURCES = \
 	message-view.c\
 	message-view.h
 
-prefs_ui_files = anjuta-message-manager-plugin.ui
-include $(top_srcdir)/scripts/build-schemas.mk
+
+
 
 EXTRA_DIST = \
 	$(plugin_in_files) \
diff --git a/plugins/sourceview/Makefile.am b/plugins/sourceview/Makefile.am
index 46c317c..1bacbc1 100644
--- a/plugins/sourceview/Makefile.am
+++ b/plugins/sourceview/Makefile.am
@@ -78,17 +78,17 @@ libanjuta_sourceview_la_LIBADD = \
 	$(PLUGIN_SOURCEVIEW_LIBS) \
 	$(LIBANJUTA_LIBS)
 
-prefs_ui_files = anjuta-editor-sourceview.ui
-include $(top_srcdir)/scripts/build-schemas.mk
-
 endif
 
+SCHEMA_PART_FILES = sourceview.gschema-part.xml
+
 EXTRA_DIST = \
 	anjuta-marshal.list \
 	$(plugin_in_files) \
 	$(sourceview_plugin_DATA) \
 	$(sourceview_pixmaps_DATA) \
-	$(sourceview_xml_DATA)
+	$(sourceview_xml_DATA) \
+	$(SCHEMA_PART_FILES)
 
 
 
diff --git a/plugins/starter/Makefile.am b/plugins/starter/Makefile.am
index 146e587..b7730e0 100644
--- a/plugins/starter/Makefile.am
+++ b/plugins/starter/Makefile.am
@@ -30,7 +30,7 @@ libanjuta_starter_la_SOURCES= \
 	starter.h \
 	starter.c
 
-include $(top_srcdir)/scripts/build-schemas.mk
+
 
 EXTRA_DIST = \
 	$(plugin_in_files) \
diff --git a/plugins/terminal/Makefile.am b/plugins/terminal/Makefile.am
index 92cc2c9..13f29a4 100644
--- a/plugins/terminal/Makefile.am
+++ b/plugins/terminal/Makefile.am
@@ -43,8 +43,8 @@ libanjuta_terminal_la_LIBADD = \
 	$(VTE_LIBS) \
 	$(LIBANJUTA_LIBS)
 	
-prefs_ui_files = anjuta-terminal-plugin.ui
-include $(top_srcdir)/scripts/build-schemas.mk
+
+
 
 EXTRA_DIST = \
 	$(plugin_in_files) \
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 944da1f..a26323a 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1,11 +1,26 @@
 anjuta_datadir = $(anjuta_data_dir)
 
-anjuta_data_DATA = anjuta_project.template
+anjuta_data_DATA = org.gnome.anjuta.gschema.xml
 
 EXTRA_DIST = $(anjuta_data_DATA)
 
+# Generate a schema from the ui files
+org.gnome.anjuta.gschema.xml: generate-schema.sh
+	$(AM_V_GEN)$(srcdir)/generate-schema.sh $(top_srcdir) $(srcdir)
+
+# gsettings_SCHEMAS is a list of all the schemas you want to install
+gsettings_SCHEMAS = org.gnome.anjuta.gschema.xml
+
+# include the appropriate makefile rules for schema handling
+ GSETTINGS_RULES@
+
+
 # Distribute but don't install builder2schema.pl
 dist-hook:
 	cp $(srcdir)/builder2schema.pl $(distdir)
+	cp $(srcdir)/generate-schema.sh $(distdir)
 	chmod +x $(distdir)/builder2schema.pl
+	chmod +x $(distdir)/generate-schema.sh
 -include $(top_srcdir)/git.mk
+
+CLEANFILES = $(gsettings_SCHEMAS)
diff --git a/scripts/builder2schema.pl b/scripts/builder2schema.pl
index f9f9dad..2cdde0b 100755
--- a/scripts/builder2schema.pl
+++ b/scripts/builder2schema.pl
@@ -3,64 +3,71 @@
 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/";
-
 my $parser = new XML::Parser(Style => "Stream");
-print "<gconfschemafile>\n";
-print "\t<schemalist>\n";
-
 $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";
 		}
 	}
 }
diff --git a/scripts/generate-schema.sh b/scripts/generate-schema.sh
new file mode 100755
index 0000000..2eea5c8
--- /dev/null
+++ b/scripts/generate-schema.sh
@@ -0,0 +1,21 @@
+#/bin/sh
+UIFILES=`find $1 -name *.ui`
+SCHEMA_FILES=`find $1 -name *.gschema-part.xml`
+OUTPUT=org.gnome.anjuta.gschema.xml
+
+# Prefix
+echo -e "<schemalist>\n\t<schema id=\"org.gnome.anjuta\" path=\"/apps/anjuta/\">\n" > $OUTPUT
+
+for f in $UIFILES
+do
+	$2/builder2schema.pl $f >> $OUTPUT
+done
+
+for f in $SCHEMA_FILES
+do
+	cat $f >> $OUTPUT
+done
+
+# Suffix
+echo -e "\t</schema>\n</schemalist>" >> $OUTPUT
+
diff --git a/src/Makefile.am b/src/Makefile.am
index e9609ef..d4fa058 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,8 +50,8 @@ anjuta_LDADD =  \
 
 anjuta_LDFLAGS = $(ANJUTA_LDFLAGS)
 
-prefs_ui_files = preferences.ui
-include $(top_srcdir)/scripts/build-schemas.mk
+
+
 
 noinst_PROGRAMS =  anjuta-shell
 



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