Commit 7d832cfb authored by Johannes Schmid's avatar Johannes Schmid

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.
parent 7c18c4f5
......@@ -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"
......
# 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)
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment