Index: docs/reference/gtk/gtk-sections.txt
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gtk/gtk-sections.txt,v
retrieving revision 1.141
diff -u -r1.141 gtk-sections.txt
--- docs/reference/gtk/gtk-sections.txt	16 Jul 2004 20:34:36 -0000	1.141
+++ docs/reference/gtk/gtk-sections.txt	17 Jul 2004 02:51:58 -0000
@@ -1850,6 +1850,7 @@
 gtk_label_set_markup_with_mnemonic
 gtk_label_set_pattern
 gtk_label_set_justify
+gtk_label_set_ellipsize
 gtk_label_get
 gtk_label_parse_uline
 gtk_label_set_line_wrap
@@ -1865,6 +1866,7 @@
 gtk_label_set_text_with_mnemonic
 gtk_label_get_attributes
 gtk_label_get_justify
+gtk_label_get_ellipsize
 gtk_label_get_label
 gtk_label_get_layout
 gtk_label_get_line_wrap
Index: gtk/gtklabel.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtklabel.c,v
retrieving revision 1.150
diff -u -r1.150 gtklabel.c
--- gtk/gtklabel.c	15 Mar 2004 14:57:54 -0000	1.150
+++ gtk/gtklabel.c	17 Jul 2004 02:51:59 -0000
@@ -69,7 +69,8 @@
   PROP_MNEMONIC_KEYVAL,
   PROP_MNEMONIC_WIDGET,
   PROP_CURSOR_POSITION,
-  PROP_SELECTION_BOUND
+  PROP_SELECTION_BOUND,
+  PROP_ELLIPSIZE
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -384,6 +385,15 @@
                                                      0,
                                                      G_PARAM_READABLE));
   
+  g_object_class_install_property (gobject_class,
+				   PROP_ELLIPSIZE,
+                                   g_param_spec_enum ("ellipsize",
+                                                      P_("Ellipsize"),
+                                                      P_("The preferred place to ellipsize the string, if the label does not have enough room to display the entire string, if at all"),
+						      PANGO_TYPE_ELLIPSIZE_MODE,
+						      PANGO_ELLIPSIZE_NONE,
+                                                      G_PARAM_READWRITE));
+  
   /*
    * Key bindings
    */
@@ -501,6 +511,9 @@
     case PROP_MNEMONIC_WIDGET:
       gtk_label_set_mnemonic_widget (label, (GtkWidget*) g_value_get_object (value));
       break;
+    case PROP_ELLIPSIZE:
+      gtk_label_set_ellipsize (label, g_value_get_enum (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -566,6 +579,9 @@
       else
 	g_value_set_int (value, 0);
       break;
+    case PROP_ELLIPSIZE:
+      g_value_set_enum (value, label->ellipsize);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -582,6 +598,7 @@
 
   label->jtype = GTK_JUSTIFY_LEFT;
   label->wrap = FALSE;
+  label->ellipsize = PANGO_ELLIPSIZE_NONE;
 
   label->use_underline = FALSE;
   label->use_markup = FALSE;
@@ -1267,6 +1284,50 @@
   return label->jtype;
 }
 
+
+/**
+ * gtk_label_set_ellipsize:
+ * @label: a #GtkLabel
+ * @mode: a #PangoEllipsizeMode
+ *
+ * Sets the mode used to ellipsize (add an ellipsis: "...") to the text if there
+ * is not enough space to render the entire string.
+ **/
+void
+gtk_label_set_ellipsize (GtkLabel          *label,
+			 PangoEllipsizeMode mode)
+{
+  g_return_if_fail (GTK_IS_LABEL (label));
+  g_return_if_fail (mode >= PANGO_ELLIPSIZE_NONE && mode <= PANGO_ELLIPSIZE_END);
+  
+  if ((PangoEllipsizeMode) label->ellipsize != mode)
+    {
+      label->ellipsize = mode;
+
+      /* No real need to be this drastic, but easier than duplicating the code */
+      gtk_label_clear_layout (label);
+      
+      g_object_notify (G_OBJECT (label), "ellipsize");
+      gtk_widget_queue_resize (GTK_WIDGET (label));
+    }
+}
+
+/**
+ * gtk_label_get_ellipsize:
+ * @label: a #GtkLabel
+ *
+ * Returns the ellipsizing position of the label. See gtk_label_set_ellipsize ().
+ *
+ * Return value: #PangoEllipsizeMode
+ **/
+PangoEllipsizeMode
+gtk_label_get_ellipsize (GtkLabel *label)
+{
+  g_return_val_if_fail (GTK_IS_LABEL (label), PANGO_ELLIPSIZE_NONE);
+
+  return label->ellipsize;
+}
+
 /**
  * gtk_label_set_line_wrap:
  * @label: a #GtkLabel
@@ -1454,6 +1515,7 @@
 	}
 
       pango_layout_set_alignment (label->layout, align);
+      pango_layout_set_ellipsize (label->layout, label->ellipsize);
 
       if (label->wrap)
 	{
@@ -1563,13 +1625,31 @@
   height = label->misc.ypad * 2;
 
   pango_layout_get_extents (label->layout, NULL, &logical_rect);
-  
   aux_info = _gtk_widget_get_aux_info (widget, FALSE);
-  if (label->wrap && aux_info && aux_info->width > 0)
-    width += aux_info->width;
-  else 
-    width += PANGO_PIXELS (logical_rect.width);
-  
+
+  if (label->ellipsize)
+    {
+      PangoContext *context;
+      PangoFontMetrics *metrics;
+      gint char_width;
+
+      /* The minimum size for ellipsized labels is ~ 3 chars */
+      context = pango_layout_get_context (label->layout);
+      metrics = pango_context_get_metrics (context, widget->style->font_desc, NULL);
+
+      char_width = pango_font_metrics_get_approximate_char_width (metrics);
+      pango_font_metrics_unref (metrics);
+
+      width += (PANGO_PIXELS (char_width) * 3);
+    }
+  else
+    {
+      if (label->wrap && aux_info && aux_info->width > 0)
+	width += aux_info->width;
+      else
+	width += PANGO_PIXELS (logical_rect.width);
+    }
+
   height += PANGO_PIXELS (logical_rect.height);
 
   requisition->width = width;
@@ -1586,6 +1666,9 @@
 
   (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
 
+  if (label->ellipsize)
+    pango_layout_set_width (label->layout, allocation->width * PANGO_SCALE);
+
   if (label->select_info && label->select_info->window)
     {
       gdk_window_move_resize (label->select_info->window,
@@ -1676,7 +1759,7 @@
   GtkMisc *misc;
   GtkWidget *widget;
   gfloat xalign;
-  gint x, y;
+  gint req_width, x, y;
   
   misc = GTK_MISC (label);
   widget = GTK_WIDGET (label);
@@ -1686,16 +1769,27 @@
   else
     xalign = 1.0 - misc->xalign;
 
+  if (label->ellipsize)
+    {
+      PangoRectangle ink_rect;
+
+      pango_layout_get_extents (label->layout, &ink_rect, NULL);
+
+      req_width = PANGO_PIXELS (ink_rect.width);
+    }
+  else
+    req_width = widget->requisition.width;
+
   x = floor (widget->allocation.x + (gint)misc->xpad +
-	     xalign * (widget->allocation.width - widget->requisition.width)
-	     + 0.5);
+	      xalign * (widget->allocation.width - req_width)
+	      + 0.5);
 
   if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
     x = MAX (x, widget->allocation.x + misc->xpad);
   else
     x = MIN (x,
 	     widget->allocation.x + widget->allocation.width -
-	     widget->requisition.width - misc->xpad);
+	     req_width - misc->xpad);
 
   y = floor (widget->allocation.y + (gint)misc->ypad 
              + MAX (((widget->allocation.height - widget->requisition.height) * misc->yalign)
Index: gtk/gtklabel.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtklabel.h,v
retrieving revision 1.38
diff -u -r1.38 gtklabel.h
--- gtk/gtklabel.h	5 Oct 2002 23:15:36 -0000	1.38
+++ gtk/gtklabel.h	17 Jul 2004 02:51:59 -0000
@@ -60,6 +60,7 @@
   guint   wrap : 1;
   guint   use_underline : 1;
   guint   use_markup : 1;
+  guint   ellipsize : 3;
 
   guint   mnemonic_keyval;
   
@@ -128,6 +129,9 @@
 void     gtk_label_set_justify                    (GtkLabel         *label,
 						   GtkJustification  jtype);
 GtkJustification gtk_label_get_justify            (GtkLabel         *label);
+void     gtk_label_set_ellipsize		  (GtkLabel         *label,
+						   PangoEllipsizeMode mode);
+PangoEllipsizeMode gtk_label_get_ellipsize        (GtkLabel         *label);
 void     gtk_label_set_pattern                    (GtkLabel         *label,
 						   const gchar      *pattern);
 void     gtk_label_set_line_wrap                  (GtkLabel         *label,
Index: docs/reference/gtk/tmpl/gtklabel.sgml
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gtk/tmpl/gtklabel.sgml,v
retrieving revision 1.21
diff -u -r1.21 gtklabel.sgml
--- docs/reference/gtk/tmpl/gtklabel.sgml	24 Feb 2004 22:23:58 -0000	1.21
+++ docs/reference/gtk/tmpl/gtklabel.sgml	17 Jul 2004 02:51:59 -0000
@@ -180,6 +180,11 @@
 
 </para>
 
+<!-- ##### ARG GtkLabel:ellipsize ##### -->
+<para>
+
+</para>
+
 <!-- ##### ARG GtkLabel:justify ##### -->
 <para>
 
@@ -296,6 +301,15 @@
 @jtype: 
 
 
+<!-- ##### FUNCTION gtk_label_set_ellipsize ##### -->
+<para>
+
+</para>
+
+@label: 
+@mode: 
+
+
 <!-- ##### FUNCTION gtk_label_get ##### -->
 <para>
 Gets the current string of text within the #GtkLabel and writes it to
@@ -431,6 +445,15 @@
 
 
 <!-- ##### FUNCTION gtk_label_get_justify ##### -->
+<para>
+
+</para>
+
+@label: 
+@Returns: 
+
+
+<!-- ##### FUNCTION gtk_label_get_ellipsize ##### -->
 <para>
 
 </para>
