Index: gtk/gtkcellrenderertext.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkcellrenderertext.c,v
retrieving revision 1.74
diff -u -r1.74 gtkcellrenderertext.c
--- gtk/gtkcellrenderertext.c	9 Jan 2005 17:32:25 -0000	1.74
+++ gtk/gtkcellrenderertext.c	18 Jan 2005 21:27:00 -0000
@@ -75,6 +75,7 @@
   PROP_ATTRIBUTES,
   PROP_SINGLE_PARAGRAPH_MODE,
   PROP_WIDTH_CHARS,
+  PROP_WRAP_WIDTH,
   
   /* Style args */
   PROP_BACKGROUND,
@@ -97,6 +98,7 @@
   PROP_RISE,
   PROP_LANGUAGE,
   PROP_ELLIPSIZE,
+  PROP_WRAP,
   
   /* Whether-a-style-arg-is-set args */
   PROP_BACKGROUND_SET,
@@ -113,7 +115,8 @@
   PROP_UNDERLINE_SET,
   PROP_RISE_SET,
   PROP_LANGUAGE_SET,
-  PROP_ELLIPSIZE_SET
+  PROP_ELLIPSIZE_SET,
+  PROP_WRAP_SET
 };
 
 static gpointer parent_class;
@@ -130,16 +133,19 @@
   guint language_set : 1;
   guint markup_set : 1;
   guint ellipsize_set : 1;
+  guint wrap_set : 1;
   
   gulong focus_out_id;
   PangoLanguage *language;
   PangoEllipsizeMode ellipsize;
+  PangoWrapMode wrap;
   
   gulong populate_popup_id;
   gulong entry_menu_popdown_timeout;
   gboolean in_entry_menu;
   
   gint width_chars;
+  gint wrap_width;
   
   GtkWidget *entry;
 };
@@ -188,6 +194,7 @@
   celltext->font = pango_font_description_new ();
 
   priv->width_chars = -1;
+  priv->wrap_width = -1;
 }
 
 static void
@@ -419,6 +426,25 @@
 						      PANGO_ELLIPSIZE_NONE,
 						      G_PARAM_READWRITE));
 
+  g_object_class_install_property (object_class,
+                                   PROP_WRAP,
+                                   g_param_spec_enum ("wrap",
+						      P_("Wrap mode"),
+						      P_("How to break the string into muliple lines, if the cell renderer does not have enough room to display the entire string, if at all"),							
+						      PANGO_TYPE_WRAP_MODE,
+						      PANGO_WRAP_CHAR,
+						      G_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class,
+				   PROP_WRAP_WIDTH,
+				   g_param_spec_int ("wrap_width",
+						     P_("Wrap width"),
+						     P_("The width at which the text is wrapped"),
+						     -1,
+						     G_MAXINT,
+						     -1,
+						     G_PARAM_READWRITE));
+
   /**
    * GtkCellRendererText:width-chars:
    * 
@@ -502,6 +528,10 @@
   ADD_SET_PROP ("ellipsize_set", PROP_ELLIPSIZE_SET,
                 P_("Ellipsize set"),
                 P_("Whether this tag affects the ellipsize mode"));
+
+  ADD_SET_PROP ("wrap_set", PROP_WRAP_SET,
+                P_("Wrap set"),
+                P_("Whether the wrap property affects the rendering"));
   
   text_cell_renderer_signals [EDITED] =
     g_signal_new ("edited",
@@ -681,6 +711,14 @@
       g_value_set_enum (value, priv->ellipsize);
       break;
       
+    case PROP_WRAP:
+      g_value_set_enum (value, priv->wrap);
+      break;
+
+    case PROP_WRAP_WIDTH:
+      g_value_set_int (value, priv->wrap_width);
+      break;
+      
     case PROP_BACKGROUND_SET:
       g_value_set_boolean (value, celltext->background_set);
       break;
@@ -730,6 +768,10 @@
       g_value_set_boolean (value, priv->ellipsize_set);
       break;
       
+    case PROP_WRAP_SET:
+      g_value_set_boolean (value, priv->wrap_set);
+      break;
+      
     case PROP_WIDTH_CHARS:
       g_value_set_int (value, priv->width_chars);
       break;  
@@ -1169,10 +1211,20 @@
       g_object_notify (object, "ellipsize_set");
       break;
       
+    case PROP_WRAP:
+      priv->wrap = g_value_get_enum (value);
+      priv->wrap_set = TRUE;
+      g_object_notify (object, "wrap_set");
+      break;
+      
+    case PROP_WRAP_WIDTH:
+      priv->wrap_width = g_value_get_int (value);
+      break;
+            
     case PROP_WIDTH_CHARS:
       priv->width_chars = g_value_get_int (value);
-      g_object_notify (object, "width_chars");
       break;  
+
     case PROP_BACKGROUND_SET:
       celltext->background_set = g_value_get_boolean (value);
       break;
@@ -1230,6 +1282,10 @@
       priv->ellipsize_set = g_value_get_boolean (value);
       break;
       
+    case PROP_WRAP_SET:
+      priv->wrap_set = g_value_get_boolean (value);
+      break;
+      
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
       break;
@@ -1352,9 +1408,19 @@
     pango_layout_set_ellipsize (layout, priv->ellipsize);
   else
     pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
-  
+
+  if (priv->wrap_width != -1)
+    {
+      pango_layout_set_width (layout, priv->wrap_width * PANGO_SCALE);
+      pango_layout_set_wrap (layout, priv->wrap);
+    }
+  else
+    {
+      pango_layout_set_width (layout, -1);
+      pango_layout_set_wrap (layout, PANGO_WRAP_CHAR);
+    }
+
   pango_layout_set_attributes (layout, attr_list);
-  pango_layout_set_width (layout, -1);
 
   pango_attr_list_unref (attr_list);
   
@@ -1421,8 +1487,14 @@
   else
     layout = get_layout (celltext, widget, FALSE, 0);
 
+  if (priv->wrap_width != -1 && pango_layout_get_line_count (layout) == 1)
+    {
+      pango_layout_set_width (layout, -1);
+      pango_layout_set_wrap (layout, PANGO_WRAP_CHAR);
+    }
+
   pango_layout_get_pixel_extents (layout, NULL, &rect);
-  
+
   if (height)
     *height = GTK_CELL_RENDERER (celltext)->ypad * 2 + rect.height;
 
@@ -1458,7 +1530,7 @@
 	  else 
 	    *x_offset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad));
 
-	  if (priv->ellipsize)
+	  if (priv->ellipsize_set || priv->wrap_set)
 	    *x_offset = MAX(*x_offset, 0);
 	}
       if (y_offset)
@@ -1559,9 +1631,12 @@
       g_object_unref (gc);
     }
 
-  if (priv->ellipsize)
+  if (priv->ellipsize_set)
     pango_layout_set_width (layout, 
 			    (cell_area->width - x_offset - 2 * cell->xpad) * PANGO_SCALE);
+  else if (priv->wrap_width != -1)
+    pango_layout_set_width (layout, 
+			    priv->wrap_width * PANGO_SCALE);      
   else
     pango_layout_set_width (layout, -1);
   
