forked from AuroraMiddleware/gtk
Speed up class action hookup
No need to construct a detailed signal name for every action when we can just look up the signal ID once and use the quark that the GParamSpec already has. Also, we don't need to loop over the actions every time we get a notification.
This commit is contained in:
parent
b968ced567
commit
c4a47e218f
@ -533,24 +533,15 @@ prop_action_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkActionMuxer *muxer = user_data;
|
||||
GtkWidgetClass *klass = GTK_WIDGET_GET_CLASS (muxer->widget);
|
||||
GtkWidgetClassPrivate *priv = klass->priv;
|
||||
GtkWidgetAction *action = NULL;
|
||||
GtkWidget *widget = GTK_WIDGET (object);
|
||||
GtkWidgetAction *action = user_data;
|
||||
GtkActionMuxer *muxer = _gtk_widget_get_action_muxer (widget, TRUE);
|
||||
GVariant *state;
|
||||
|
||||
g_assert ((GObject *)muxer->widget == object);
|
||||
|
||||
for (action = priv->actions; action; action = action->next)
|
||||
{
|
||||
if (action->pspec == pspec)
|
||||
break;
|
||||
}
|
||||
|
||||
g_assert (action != NULL);
|
||||
g_assert (muxer->widget == widget);
|
||||
g_assert (action->pspec == pspec);
|
||||
|
||||
state = prop_action_get_state (muxer->widget, action);
|
||||
state = prop_action_get_state (widget, action);
|
||||
gtk_action_muxer_action_state_changed (muxer, action->name, state);
|
||||
g_variant_unref (state);
|
||||
}
|
||||
@ -561,6 +552,7 @@ prop_actions_connect (GtkActionMuxer *muxer)
|
||||
GtkWidgetClassPrivate *priv;
|
||||
GtkWidgetAction *action;
|
||||
GtkWidgetClass *klass;
|
||||
guint signal_id;
|
||||
|
||||
if (!muxer->widget)
|
||||
return;
|
||||
@ -570,17 +562,20 @@ prop_actions_connect (GtkActionMuxer *muxer)
|
||||
if (!priv->actions)
|
||||
return;
|
||||
|
||||
signal_id = g_signal_lookup ("notify", G_TYPE_OBJECT);
|
||||
|
||||
for (action = priv->actions; action; action = action->next)
|
||||
{
|
||||
char *detailed;
|
||||
|
||||
if (!action->pspec)
|
||||
continue;
|
||||
|
||||
detailed = g_strconcat ("notify::", action->pspec->name, NULL);
|
||||
g_signal_connect (muxer->widget, detailed,
|
||||
G_CALLBACK (prop_action_notify), muxer);
|
||||
g_free (detailed);
|
||||
g_signal_connect_closure_by_id (muxer->widget,
|
||||
signal_id,
|
||||
g_param_spec_get_name_quark (action->pspec),
|
||||
g_cclosure_new (G_CALLBACK (prop_action_notify),
|
||||
action,
|
||||
NULL),
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user