forked from AuroraMiddleware/gtk
all: avoid boxed structs copying where possible (and 2)
Use the GtkStyleContext accessors for boxed properties where possible, to reduce allocations.
This commit is contained in:
parent
e5c7daa828
commit
fb9e4c2c37
@ -5252,7 +5252,7 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
||||
gint font_size, arrow_size;
|
||||
PangoContext *context;
|
||||
PangoFontMetrics *metrics;
|
||||
PangoFontDescription *font_desc;
|
||||
const PangoFontDescription *font_desc;
|
||||
GtkWidget *child;
|
||||
gint minimum_width = 0, natural_width = 0;
|
||||
gint child_min, child_nat;
|
||||
@ -5277,9 +5277,7 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
||||
state = gtk_widget_get_state_flags (widget);
|
||||
|
||||
get_widget_padding (widget, &padding);
|
||||
gtk_style_context_get (style_context, state,
|
||||
"font", &font_desc,
|
||||
NULL);
|
||||
font_desc = gtk_style_context_get_font (style_context, state);
|
||||
|
||||
context = gtk_widget_get_pango_context (GTK_WIDGET (widget));
|
||||
metrics = pango_context_get_metrics (context, font_desc,
|
||||
@ -5287,7 +5285,6 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
||||
font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
|
||||
pango_font_metrics_get_descent (metrics));
|
||||
pango_font_metrics_unref (metrics);
|
||||
pango_font_description_free (font_desc);
|
||||
|
||||
arrow_size = MAX (arrow_size, font_size) * arrow_scaling;
|
||||
|
||||
|
@ -3200,19 +3200,16 @@ static PangoFontMetrics *
|
||||
get_font_metrics (PangoContext *context, GtkWidget *widget)
|
||||
{
|
||||
GtkStyleContext *style_context;
|
||||
PangoFontDescription *font;
|
||||
const PangoFontDescription *font;
|
||||
PangoFontMetrics *retval;
|
||||
|
||||
style_context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style_context, 0, "font", &font, NULL);
|
||||
font = gtk_style_context_get_font (style_context, GTK_STATE_FLAG_NORMAL);
|
||||
|
||||
retval = pango_context_get_metrics (context,
|
||||
font,
|
||||
pango_context_get_language (context));
|
||||
|
||||
if (font != NULL)
|
||||
pango_font_description_free (font);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -9008,22 +9008,18 @@ static void
|
||||
update_pango_context (GtkWidget *widget,
|
||||
PangoContext *context)
|
||||
{
|
||||
PangoFontDescription *font_desc;
|
||||
const PangoFontDescription *font_desc;
|
||||
GtkStyleContext *style_context;
|
||||
|
||||
style_context = gtk_widget_get_style_context (widget);
|
||||
|
||||
gtk_style_context_get (style_context,
|
||||
gtk_widget_get_state_flags (widget),
|
||||
"font", &font_desc,
|
||||
NULL);
|
||||
font_desc = gtk_style_context_get_font (style_context,
|
||||
gtk_widget_get_state_flags (widget));
|
||||
|
||||
pango_context_set_font_description (context, font_desc);
|
||||
pango_context_set_base_dir (context,
|
||||
gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
|
||||
PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
|
||||
|
||||
pango_font_description_free (font_desc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user