[gtk+] Factor out a get_char_pixels method for clarity.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Factor out a get_char_pixels method for clarity.
- Date: Sun, 17 Apr 2011 15:33:37 +0000 (UTC)
commit af7650ce1fb9ae8c33d9c76e5b34aae02b78366f
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Apr 9 22:19:51 2011 +0200
Factor out a get_char_pixels method for clarity.
https://bugzilla.gnome.org/show_bug.cgi?id=647284
gtk/gtklabel.c | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 23ae223..a85eabe 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]