mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-04 17:50:18 +00:00
stylecontext: Avoid style_context_save() calls
Introduce style_data_lookup_for_state() that does this.
This commit is contained in:
parent
2179580c8e
commit
35e36b9fe5
@ -994,6 +994,23 @@ style_data_lookup (GtkStyleContext *context)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static StyleData *
|
||||||
|
style_data_lookup_for_state (GtkStyleContext *context,
|
||||||
|
GtkStateFlags state)
|
||||||
|
{
|
||||||
|
StyleData *data;
|
||||||
|
|
||||||
|
if (context->priv->info->state_flags == state)
|
||||||
|
return style_data_lookup (context);
|
||||||
|
|
||||||
|
gtk_style_context_save (context);
|
||||||
|
gtk_style_context_set_state (context, state);
|
||||||
|
data = style_data_lookup (context);
|
||||||
|
gtk_style_context_restore (context);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_style_context_set_invalid (GtkStyleContext *context,
|
gtk_style_context_set_invalid (GtkStyleContext *context,
|
||||||
gboolean invalid)
|
gboolean invalid)
|
||||||
@ -1338,11 +1355,8 @@ gtk_style_context_get_property (GtkStyleContext *context,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_style_context_save (context);
|
data = style_data_lookup_for_state (context, state);
|
||||||
gtk_style_context_set_state (context, state);
|
|
||||||
data = style_data_lookup (context);
|
|
||||||
_gtk_style_property_query (prop, value, gtk_style_context_query_func, data->store);
|
_gtk_style_property_query (prop, value, gtk_style_context_query_func, data->store);
|
||||||
gtk_style_context_restore (context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2195,10 +2209,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
|
|||||||
|
|
||||||
priv = context->priv;
|
priv = context->priv;
|
||||||
|
|
||||||
gtk_style_context_save (context);
|
data = style_data_lookup_for_state (context, state);
|
||||||
gtk_style_context_set_state (context, state);
|
|
||||||
data = style_data_lookup (context);
|
|
||||||
gtk_style_context_restore (context);
|
|
||||||
|
|
||||||
key.widget_type = widget_type;
|
key.widget_type = widget_type;
|
||||||
key.state = state;
|
key.state = state;
|
||||||
@ -3421,10 +3432,7 @@ gtk_style_context_get_font (GtkStyleContext *context,
|
|||||||
priv = context->priv;
|
priv = context->priv;
|
||||||
g_return_val_if_fail (priv->widget != NULL || priv->widget_path != NULL, NULL);
|
g_return_val_if_fail (priv->widget != NULL || priv->widget_path != NULL, NULL);
|
||||||
|
|
||||||
gtk_style_context_save (context);
|
data = style_data_lookup_for_state (context, state);
|
||||||
gtk_style_context_set_state (context, state);
|
|
||||||
data = style_data_lookup (context);
|
|
||||||
gtk_style_context_restore (context);
|
|
||||||
|
|
||||||
/* Yuck, fonts are created on-demand but we don't return a ref.
|
/* Yuck, fonts are created on-demand but we don't return a ref.
|
||||||
* Do bad things to achieve this requirement */
|
* Do bad things to achieve this requirement */
|
||||||
|
Loading…
Reference in New Issue
Block a user