Reshuffle action muxer initialization

We were having a problem where property actions were
not getting state updates because prop_actions_connect
was triggered from some instance_init function while
the widget class is not in place yet.

Delay that call until the widget is fully constructed,
so we can guarantee that we are dealing with the
correct class private struct, and see all class actions.
This commit is contained in:
Matthias Clasen 2020-04-28 18:34:23 -04:00
parent 65c56ea812
commit b968ced567
3 changed files with 18 additions and 7 deletions

View File

@ -864,14 +864,10 @@ gtk_action_muxer_dispose (GObject *object)
->dispose (object);
}
static void
gtk_action_muxer_constructed (GObject *object)
void
gtk_action_muxer_connect_class_actions (GtkActionMuxer *muxer)
{
GtkActionMuxer *muxer = GTK_ACTION_MUXER (object);
prop_actions_connect (muxer);
G_OBJECT_CLASS (gtk_action_muxer_parent_class)->constructed (object);
}
static void
@ -949,7 +945,6 @@ gtk_action_muxer_class_init (GObjectClass *class)
{
class->get_property = gtk_action_muxer_get_property;
class->set_property = gtk_action_muxer_set_property;
class->constructed = gtk_action_muxer_constructed;
class->finalize = gtk_action_muxer_finalize;
class->dispose = gtk_action_muxer_dispose;

View File

@ -81,6 +81,7 @@ gtk_action_muxer_action_state_changed (GtkActionMuxer *muxer,
const gchar *action_name,
GVariant *state);
void gtk_action_muxer_connect_class_actions (GtkActionMuxer *muxer);
/* No better place for these... */
gchar * gtk_print_action_and_target (const gchar *action_namespace,

View File

@ -865,6 +865,20 @@ gtk_widget_real_unroot (GtkWidget *widget)
gtk_widget_forall (widget, (GtkCallback) gtk_widget_unroot, NULL);
}
static void
gtk_widget_constructed (GObject *object)
{
G_OBJECT_CLASS (gtk_widget_parent_class)->constructed (object);
if (GTK_WIDGET_GET_CLASS (object)->priv->actions)
{
GtkActionMuxer *muxer;
muxer = _gtk_widget_get_action_muxer (GTK_WIDGET (object), TRUE);
gtk_action_muxer_connect_class_actions (muxer);
}
}
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
@ -882,6 +896,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
quark_font_options = g_quark_from_static_string ("gtk-widget-font-options");
quark_font_map = g_quark_from_static_string ("gtk-widget-font-map");
gobject_class->constructed = gtk_widget_constructed;
gobject_class->dispose = gtk_widget_dispose;
gobject_class->finalize = gtk_widget_finalize;
gobject_class->set_property = gtk_widget_set_property;