mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
Merge branch 'wip/chergert/builder-expose-object-fix' into 'main'
builder: gracefully handle re-exposing builder object See merge request GNOME/gtk!4913
This commit is contained in:
commit
9bce70ed8d
@ -1353,8 +1353,8 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
|
|||||||
* Main private entry point for building composite components
|
* Main private entry point for building composite components
|
||||||
* from template XML.
|
* from template XML.
|
||||||
*
|
*
|
||||||
* This is exported purely to let `gtk-builder-tool` validate
|
* Most likely you do not need to call this function in applications as
|
||||||
* templates, applications have no need to call this function.
|
* templates are handled by `GtkWidget`.
|
||||||
*
|
*
|
||||||
* Returns: A positive value on success, 0 if an error occurred
|
* Returns: A positive value on success, 0 if an error occurred
|
||||||
*/
|
*/
|
||||||
@ -1367,6 +1367,7 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||||
|
const char *name;
|
||||||
GError *tmp_error;
|
GError *tmp_error;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
@ -1384,8 +1385,15 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
|
|||||||
priv->resource_prefix = NULL;
|
priv->resource_prefix = NULL;
|
||||||
priv->template_type = template_type;
|
priv->template_type = template_type;
|
||||||
|
|
||||||
filename = g_strconcat ("<", g_type_name (template_type), " template>", NULL);
|
/* We specifically allow this function to be called multiple times with
|
||||||
gtk_builder_expose_object (builder, g_type_name (template_type), object);
|
* the same @template_type as that is used in applications like Builder
|
||||||
|
* to implement UI merging.
|
||||||
|
*/
|
||||||
|
name = g_type_name (template_type);
|
||||||
|
if (gtk_builder_get_object (builder, name) != object)
|
||||||
|
gtk_builder_expose_object (builder, name, object);
|
||||||
|
|
||||||
|
filename = g_strconcat ("<", name, " template>", NULL);
|
||||||
_gtk_builder_parser_parse_buffer (builder, filename,
|
_gtk_builder_parser_parse_buffer (builder, filename,
|
||||||
buffer, length,
|
buffer, length,
|
||||||
NULL,
|
NULL,
|
||||||
@ -1772,6 +1780,11 @@ gtk_builder_get_translation_domain (GtkBuilder *builder)
|
|||||||
*
|
*
|
||||||
* Add @object to the @builder object pool so it can be
|
* Add @object to the @builder object pool so it can be
|
||||||
* referenced just like any other object built by builder.
|
* referenced just like any other object built by builder.
|
||||||
|
*
|
||||||
|
* Only a single object may be added using @name. However,
|
||||||
|
* it is not an error to expose the same object under multiple
|
||||||
|
* names. `gtk_builder_get_object()` may be used to determine
|
||||||
|
* if an object has already been added with @name.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gtk_builder_expose_object (GtkBuilder *builder,
|
gtk_builder_expose_object (GtkBuilder *builder,
|
||||||
|
Loading…
Reference in New Issue
Block a user