Compare commits

...

1 Commits

Author SHA1 Message Date
Alexander Larsson
b128e52915 Use pre-parsed xml for GtkBuilder resource files
This enables the xml-preparser gresource option which
runs the xml through g_markup_parser_context_record(), and saves
the generated binary format instead of the xml. We then check
for the magic marker in the GtkBuilder code so that this automatically
uses g_markup_parser_context_replay() instead, to avoid any
parsing. The binary format is also smaller.
2018-09-10 05:09:12 +02:00
2 changed files with 14 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ for f in get_files('gesture', '.symbolic.png'):
xml += '\n'
for f in get_files('ui', '.ui'):
xml += ' <file preprocess=\'xml-stripblanks\'>ui/{0}</file>\n'.format(f)
xml += ' <file preprocess=\'xml-stripblanks,xml-preparse\'>ui/{0}</file>\n'.format(f)
xml += '\n'

View File

@@ -1269,8 +1269,19 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
G_MARKUP_TREAT_CDATA_AS_TEXT,
&data, NULL);
if (!g_markup_parse_context_parse (data.ctx, buffer, length, error))
goto out;
if (buffer[0] == 'G' &&
buffer[1] == 'M' &&
buffer[2] == 'U' &&
buffer[3] == 0)
{
if (!g_markup_parse_context_replay (data.ctx, buffer, length, error))
goto out;
}
else
{
if (!g_markup_parse_context_parse (data.ctx, buffer, length, error))
goto out;
}
_gtk_builder_finish (builder);
if (_gtk_builder_lookup_failed (builder, error))