Commit af7650ce authored by Paolo Borelli's avatar Paolo Borelli

Factor out a get_char_pixels method for clarity.

https://bugzilla.gnome.org/show_bug.cgi?id=647284
parent 76a571b6
......@@ -3660,6 +3660,23 @@ get_size_for_allocation (GtkLabel *label,
g_object_unref (layout);
}
static gint
get_char_pixels (GtkWidget *label,
PangoLayout *layout)
{
PangoContext *context;
PangoFontMetrics *metrics;
gint char_width, digit_width;
context = pango_layout_get_context (layout);
metrics = get_font_metrics (context, GTK_WIDGET (label));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
pango_font_metrics_unref (metrics);
return MAX (char_width, digit_width);;
}
static void
gtk_label_get_preferred_layout_size (GtkLabel *label,
PangoRectangle *required,
......@@ -3728,16 +3745,9 @@ gtk_label_get_preferred_layout_size (GtkLabel *label,
if (priv->ellipsize || priv->wrap)
{
PangoContext *context;
PangoFontMetrics *metrics;
gint char_width, digit_width, char_pixels;
context = pango_layout_get_context (layout);
metrics = get_font_metrics (context, GTK_WIDGET (label));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
char_pixels = MAX (char_width, digit_width);
pango_font_metrics_unref (metrics);
gint char_pixels;
char_pixels = get_char_pixels (GTK_WIDGET (label), layout);
required->width = char_pixels * MAX (priv->width_chars, ellipsize_chars);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment