[gtk+] Small cleanup in label sizing code.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Small cleanup in label sizing code.
- Date: Sun, 17 Apr 2011 15:33:42 +0000 (UTC)
commit 1ad1c33f5224e9a810982e8f789fa8e3e65dfca2
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Apr 17 17:23:26 2011 +0200
Small cleanup in label sizing code.
Move ellipsized_chars calculation in the scope where it is used.
https://bugzilla.gnome.org/show_bug.cgi?id=647284
gtk/gtklabel.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index a85eabe..718e4bf 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3685,7 +3685,7 @@ gtk_label_get_preferred_layout_size (GtkLabel *label,
GtkLabelPrivate *priv = label->priv;
PangoLayout *layout;
PangoRectangle rect;
- gint text_width, ellipsize_chars, guess_width;
+ gint text_width, guess_width;
/* "width-chars" Hard-coded minimum width:
* - minimum size should be MAX (width-chars, strlen ("..."));
@@ -3718,12 +3718,6 @@ gtk_label_get_preferred_layout_size (GtkLabel *label,
pango_layout_get_extents (layout, NULL, &rect);
text_width = rect.width;
- /* enforce minimum width for ellipsized labels at ~3 chars */
- if (priv->ellipsize)
- ellipsize_chars = 3;
- else
- ellipsize_chars = 0;
-
/* "width-chars" Hard-coded minimum width:
* - minimum size should be MAX (width-chars, strlen ("..."));
* - natural size should be MAX (width-chars, strlen (priv->text));
@@ -3745,10 +3739,13 @@ gtk_label_get_preferred_layout_size (GtkLabel *label,
if (priv->ellipsize || priv->wrap)
{
- gint char_pixels;
+ gint char_pixels, ellipsize_chars;
char_pixels = get_char_pixels (GTK_WIDGET (label), layout);
+ /* enforce minimum width for ellipsized labels at ~3 chars */
+ ellipsize_chars = priv->ellipsize ? 3 : 0;
+
required->width = char_pixels * MAX (priv->width_chars, ellipsize_chars);
/* Default to the minimum width regularly guessed by GTK+ if no minimum
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]