[gtk+/native-layout] Restore layout in get_desired_size() after guessing a wrap width
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/native-layout] Restore layout in get_desired_size() after guessing a wrap width
- Date: Tue, 20 Apr 2010 18:18:17 +0000 (UTC)
commit 80428e7745bc122c13ac4ea43c53e94c4120181f
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Tue Apr 20 14:16:13 2010 -0400
Restore layout in get_desired_size() after guessing a wrap width
This fixes the label layout in cases where gtk_widget_size_request()
is called on a label without a following size_allocate(), for instance
when a button state changes.
gtk/gtklabel.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index ff210fe..5446d91 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3350,11 +3350,10 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
* - minimum size should be MAX (width-chars, 0)
* - natural size should be MIN (max-width-chars, strlen (label->text))
*
- *
- *
*/
- /* Refresh layout if needed */
+ /* When calculating ->wrap sometimes we need to invent a size; Ideally we should be doing
+ * that stuff here instead of inside gtk_label_ensure_layout() */
if (label->wrap)
gtk_label_clear_layout (label);
gtk_label_ensure_layout (label, TRUE);
@@ -3430,6 +3429,16 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
*natural_size = natural_rect.height + label->misc.ypad * 2;
}
}
+
+ /* Restore real allocated size of layout; sometimes size-requests
+ * are randomly called without a following allocation; for this case
+ * we need to make sure we dont have a mucked up layout because we
+ * went and guessed the wrap-size.
+ */
+ if (label->wrap)
+ gtk_label_clear_layout (label);
+ gtk_label_ensure_layout (label, FALSE);
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]