atcontext: Factor out some code

Move the code that realizes an AT context if the parent is realized,
into to a separate function. This will make the next patch easier to
read.

No functional changes.
This commit is contained in:
Georges Basile Stavracas Neto 2024-10-02 14:51:33 -03:00
parent c2417dc107
commit 7d0cb2f006

View File

@ -512,6 +512,17 @@ gtk_at_context_get_accessible_parent (GtkATContext *self)
static GtkATContext * get_parent_context (GtkATContext *self);
static inline void
maybe_realize_context (GtkATContext *self)
{
GtkATContext *parent_context = get_parent_context (self);
if (parent_context && parent_context->realized)
gtk_at_context_realize (self);
g_clear_object (&parent_context);
}
/*< private >
* gtk_at_context_set_accessible_parent:
* @self: a `GtkAtContext`
@ -534,15 +545,10 @@ gtk_at_context_set_accessible_parent (GtkATContext *self,
self->accessible_parent = parent;
if (self->accessible_parent != NULL)
{
GtkATContext *parent_context = NULL;
g_object_add_weak_pointer (G_OBJECT (self->accessible_parent),
(gpointer *) &self->accessible_parent);
parent_context = get_parent_context (self);
if (parent_context && parent_context->realized)
gtk_at_context_realize (self);
g_clear_object (&parent_context);
maybe_realize_context (self);
}
}
}