[gnome-builder/wip/slaf/xml-pack: 253/254] xml-pack: automatic gtkbuilder.rng association for ui files
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/slaf/xml-pack: 253/254] xml-pack: automatic gtkbuilder.rng association for ui files
- Date: Thu, 13 Jul 2017 09:10:28 +0000 (UTC)
commit 8360aab7993072982083350d30f66c8b4059be2e
Author: Sebastien Lafargue <slafargue gnome org>
Date: Wed Jul 12 18:45:26 2017 +0200
xml-pack: automatic gtkbuilder.rng association for ui files
If the file is recognized as a gtk builder file,
the corresponding gtkbuilder.rng file from gresources
is automatically added.
plugins/xml-pack/ide-xml-parser-private.h | 1 +
plugins/xml-pack/ide-xml-parser.c | 19 +++++++++++++++++--
plugins/xml-pack/meson.build | 6 ++++++
3 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/plugins/xml-pack/ide-xml-parser-private.h b/plugins/xml-pack/ide-xml-parser-private.h
index d48589a..13e6649 100644
--- a/plugins/xml-pack/ide-xml-parser-private.h
+++ b/plugins/xml-pack/ide-xml-parser-private.h
@@ -78,6 +78,7 @@ typedef struct _ParserState
gint64 sequence;
guint error_missing_tag_end : 1;
+ guint file_is_ui : 1;
} ParserState;
void ide_xml_parser_set_post_processing_callback (IdeXmlParser *self,
diff --git a/plugins/xml-pack/ide-xml-parser.c b/plugins/xml-pack/ide-xml-parser.c
index 11c8f7b..c0310f5 100644
--- a/plugins/xml-pack/ide-xml-parser.c
+++ b/plugins/xml-pack/ide-xml-parser.c
@@ -523,7 +523,11 @@ ide_xml_parser_processing_instruction_sax_cb (ParserState *state,
entry->kind = kind;
ide_xml_sax_get_location (self->sax_parser, &entry->line, &entry->col, NULL, NULL, NULL, NULL);
- entry->file = get_absolute_schema_file (state->file, schema_url);
+ /* We skip adding gtkbuilder.rng here and add it from gresources after the parsing */
+ if (g_str_has_suffix (schema_url, "gtkbuilder.rng"))
+ return;
+ else
+ entry->file = get_absolute_schema_file (state->file, schema_url);
/* Needed to pass the kind to the service schema fetcher */
g_object_set_data (G_OBJECT (entry->file), "kind", GUINT_TO_POINTER (entry->kind));
@@ -568,6 +572,7 @@ ide_xml_parser_get_analysis_worker (GTask *task,
IdeXmlParser *self = (IdeXmlParser *)source_object;
ParserState *state = (ParserState *)task_data;
IdeXmlAnalysis *analysis;
+ IdeXmlSchemaCacheEntry *entry;
g_autoptr(IdeDiagnostics) diagnostics = NULL;
g_autofree gchar *uri = NULL;
const gchar *doc_data;
@@ -583,7 +588,8 @@ ide_xml_parser_get_analysis_worker (GTask *task,
doc_data = g_bytes_get_data (state->content, &doc_size);
- if (ide_xml_parser_file_is_ui (state->file, doc_data, doc_size))
+ state->file_is_ui = ide_xml_parser_file_is_ui (state->file, doc_data, doc_size);
+ if (state->file_is_ui)
ide_xml_parser_ui_setup (self, state);
else
ide_xml_parser_generic_setup (self, state);
@@ -607,6 +613,15 @@ ide_xml_parser_get_analysis_worker (GTask *task,
diagnostics = ide_diagnostics_new (g_steal_pointer (&state->diagnostics_array));
ide_xml_analysis_set_diagnostics (analysis, diagnostics);
+ if (state->file_is_ui)
+ {
+ entry = ide_xml_schema_cache_entry_new ();
+ entry->kind = SCHEMA_KIND_RNG;
+ entry->file = g_file_new_for_uri
("resource:///org/gnome/builder/plugins/xml-pack-plugin/schemas/gtkbuilder.rng");
+ g_object_set_data (G_OBJECT (entry->file), "kind", GUINT_TO_POINTER (entry->kind));
+ g_ptr_array_add (state->schemas, entry);
+ }
+
if (state->schemas != NULL && state->schemas->len > 0)
ide_xml_analysis_set_schemas (analysis, g_steal_pointer (&state->schemas));
diff --git a/plugins/xml-pack/meson.build b/plugins/xml-pack/meson.build
index 2459b2d..593d244 100644
--- a/plugins/xml-pack/meson.build
+++ b/plugins/xml-pack/meson.build
@@ -1,6 +1,12 @@
if get_option('with_xml_pack')
+xml_pack_resources = gnome.compile_resources(
+ 'ide-xml-resources',
+ 'ide-xml.gresource.xml',
+ c_name: 'ide_xml'
+)
xml_pack_sources = [
+ xml_pack_resources,
'ide-xml-analysis.c',
'ide-xml-analysis.h',
'ide-xml-completion-attributes.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]