[gtk+/extended-layout-jhs: 59/64] Announce size-for-allocation features only when ellipsis or wrapping with



commit fb03ba2b63a5234abe3dd8b0a62a1392da02d914
Author: Mathias Hasselmann <mathias hasselmann gmx de>
Date:   Mon Aug 20 18:50:04 2007 +0000

    Announce size-for-allocation features only when ellipsis or wrapping with
    
    2007-08-20  Mathias Hasselmann  <mathias hasselmann gmx de>
    
    	* gtk/gtklabel.c: Announce size-for-allocation features only when
    	ellipsis or wrapping with full size allocation are active.
    	* tests/testextendedlayout.c: Display size-for-allocation information
    	in statusbar.
    
    svn path=/branches/extended-layout/; revision=18659

 ChangeLog.gtk-extended-layout |    7 +++++++
 gtk/gtklabel.c                |   11 ++++++-----
 tests/testextendedlayout.c    |   21 +++++++++++++++++++--
 3 files changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog.gtk-extended-layout b/ChangeLog.gtk-extended-layout
index c1ae315..e928caf 100644
--- a/ChangeLog.gtk-extended-layout
+++ b/ChangeLog.gtk-extended-layout
@@ -1,5 +1,12 @@
 2007-08-20  Mathias Hasselmann  <mathias hasselmann gmx de>
 
+	* gtk/gtklabel.c: Announce size-for-allocation features only when
+	ellipsis or wrapping with full size allocation are active.
+	* tests/testextendedlayout.c: Display size-for-allocation information
+	in statusbar.
+
+2007-08-20  Mathias Hasselmann  <mathias hasselmann gmx de>
+
 	* tests/testextendedlayout.c: Improve contrast for currently
 	selected widget, show pointer address of widget in status bar.
 	Provider names in size-for-allocation test.
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index e738235..7cb287d 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -4351,13 +4351,14 @@ static GtkExtendedLayoutFeatures
 gtk_label_extended_layout_get_features (GtkExtendedLayout *layout)
 {
   GtkLabel *label = GTK_LABEL (layout);
+  GtkLabelPrivate *priv = GTK_LABEL_GET_PRIVATE (label);
   GtkExtendedLayoutFeatures features;
 
   features =
     GTK_EXTENDED_LAYOUT_NATURAL_SIZE |
     GTK_EXTENDED_LAYOUT_BASELINES;
 
-  if (label->wrap)
+  if (label->ellipsize || (label->wrap && priv->full_size))
     {
       gdouble angle = gtk_label_get_angle (label);
 
@@ -4371,8 +4372,8 @@ gtk_label_extended_layout_get_features (GtkExtendedLayout *layout)
 }
 
 static gint
-gtk_label_extended_layout_get_size_for_other (GtkExtendedLayout *layout,
-                                              gint               size)
+gtk_label_extended_layout_get_size_for_allocation (GtkExtendedLayout *layout,
+                                                   gint               size)
 {
   GtkLabel *label = GTK_LABEL (layout);
   gdouble angle = gtk_label_get_angle (label);
@@ -4460,8 +4461,8 @@ static void
 gtk_label_extended_layout_interface_init (GtkExtendedLayoutIface *iface)
 {
   iface->get_features = gtk_label_extended_layout_get_features;
-  iface->get_height_for_width = gtk_label_extended_layout_get_size_for_other;
-  iface->get_width_for_height = gtk_label_extended_layout_get_size_for_other;
+  iface->get_height_for_width = gtk_label_extended_layout_get_size_for_allocation;
+  iface->get_width_for_height = gtk_label_extended_layout_get_size_for_allocation;
   iface->get_natural_size = gtk_label_extended_layout_get_natural_size;
   iface->get_baselines = gtk_label_extended_layout_get_baselines;
   iface->set_baseline_offset = gtk_label_extended_layout_set_baseline_offset;
diff --git a/tests/testextendedlayout.c b/tests/testextendedlayout.c
index 4bfdc2a..60a60dd 100644
--- a/tests/testextendedlayout.c
+++ b/tests/testextendedlayout.c
@@ -244,17 +244,34 @@ update_status (TestSuite *suite,
 
   if (GTK_IS_EXTENDED_LAYOUT (child))
     {
+      GtkExtendedLayout *layout = (GtkExtendedLayout*) child;
+
       if (GTK_EXTENDED_LAYOUT_HAS_NATURAL_SIZE (child))
         {
           GtkRequisition requisition;
 
-          gtk_extended_layout_get_natural_size (GTK_EXTENDED_LAYOUT (child),
-                                                &requisition);
+          gtk_extended_layout_get_natural_size (layout, &requisition);
 
           g_string_append_printf (status, "; natural-size: %dx%d",
                                   requisition.width, requisition.height);
         }
 
+      if (GTK_EXTENDED_LAYOUT_HAS_HEIGHT_FOR_WIDTH (child))
+        {
+          gint height = gtk_extended_layout_get_height_for_width (layout, child->allocation.width);
+
+          g_string_append_printf (status, "; height-for-%d: %d",
+                                  child->allocation.width, height);
+        }
+
+      if (GTK_EXTENDED_LAYOUT_HAS_WIDTH_FOR_HEIGHT (child))
+        {
+          gint width = gtk_extended_layout_get_width_for_height (layout, child->allocation.height);
+
+          g_string_append_printf (status, "; width-for-%d: %d",
+                                  child->allocation.height, width);
+        }
+
       if (GTK_EXTENDED_LAYOUT_HAS_BASELINES (child))
         {
           gint *baselines = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]