action muxer: Propagate registrations further up

We were pretty aggressive about not registering
observers further than necessary, stopping at the
first muxer that provides an action.

But even though action changes further up in the tree
won't be relevant in that case, we need to listen to
accel changes, since they may come from higher up
in the tree (e.g. when using
gtk_application_set_accels_for_action with an action
that is defined on a widget.

So, register all the way to the top, and stop propagating
action changes when we hit a muxer that provides the action.
This commit is contained in:
Matthias Clasen 2021-06-17 08:37:42 -04:00
parent db93090ea8
commit d5054f9b99

View File

@ -966,21 +966,14 @@ gtk_action_muxer_register_observer (GtkActionObservable *observable,
if (action_muxer_query_action (muxer, name,
&enabled, &parameter_type,
NULL, NULL, &state, FALSE))
NULL, NULL, &state, TRUE))
{
gtk_action_muxer_action_added (muxer, name, parameter_type, enabled, state);
g_clear_pointer (&state, g_variant_unref);
}
else if (muxer->parent)
{
if (action_muxer_query_action (muxer->parent, name,
&enabled, &parameter_type,
NULL, NULL, &state, FALSE))
{
gtk_action_muxer_action_added (muxer, name, parameter_type, enabled, state);
g_clear_pointer (&state, g_variant_unref);
}
if (muxer->parent)
{
gtk_action_observable_register_observer (GTK_ACTION_OBSERVABLE (muxer->parent),
name,
GTK_ACTION_OBSERVER (muxer));
@ -1142,6 +1135,10 @@ gtk_action_muxer_observer_action_added (GtkActionObserver *observer,
gboolean enabled,
GVariant *state)
{
if (action_muxer_query_action (GTK_ACTION_MUXER (observer), action_name,
NULL, NULL, NULL, NULL, NULL, FALSE))
return;
gtk_action_muxer_action_added (GTK_ACTION_MUXER (observer),
action_name,
parameter_type,
@ -1154,6 +1151,10 @@ gtk_action_muxer_observer_action_removed (GtkActionObserver *observer,
GtkActionObservable *observable,
const char *action_name)
{
if (action_muxer_query_action (GTK_ACTION_MUXER (observer), action_name,
NULL, NULL, NULL, NULL, NULL, FALSE))
return;
gtk_action_muxer_action_removed (GTK_ACTION_MUXER (observer), action_name);
}
@ -1163,6 +1164,10 @@ gtk_action_muxer_observer_action_enabled_changed (GtkActionObserver *observer,
const char *action_name,
gboolean enabled)
{
if (action_muxer_query_action (GTK_ACTION_MUXER (observer), action_name,
NULL, NULL, NULL, NULL, NULL, FALSE))
return;
gtk_action_muxer_action_enabled_changed (GTK_ACTION_MUXER (observer), action_name, enabled);
}
@ -1172,6 +1177,10 @@ gtk_action_muxer_observer_action_state_changed (GtkActionObserver *observer,
const char *action_name,
GVariant *state)
{
if (action_muxer_query_action (GTK_ACTION_MUXER (observer), action_name,
NULL, NULL, NULL, NULL, NULL, FALSE))
return;
gtk_action_muxer_action_state_changed (GTK_ACTION_MUXER (observer), action_name, state);
}