]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkprogressbar.c
Bug 526987 - GtkCellRendererCombo should allow model to be NULL
[~andy/gtk] / gtk / gtkprogressbar.c
index 0979f3a693fd201947212bbac6f6029e20e5ae3d..babb6ac9ec5143fd7725df4ba15ea14e1faebacf 100644 (file)
@@ -45,7 +45,6 @@
 #define MIN_VERTICAL_BAR_WIDTH     22
 #define MIN_VERTICAL_BAR_HEIGHT    80
 #define MAX_TEXT_LENGTH            80
-#define TEXT_SPACING               2
 
 enum {
   PROP_0,
@@ -65,8 +64,6 @@ enum {
   PROP_DISCRETE_BLOCKS
 };
 
-static void gtk_progress_bar_class_init    (GtkProgressBarClass *klass);
-static void gtk_progress_bar_init          (GtkProgressBar      *pbar);
 static void gtk_progress_bar_set_property  (GObject             *object,
                                            guint                prop_id,
                                            const GValue        *value,
@@ -75,8 +72,12 @@ static void gtk_progress_bar_get_property  (GObject             *object,
                                            guint                prop_id,
                                            GValue              *value,
                                            GParamSpec          *pspec);
+static gboolean gtk_progress_bar_expose    (GtkWidget           *widget,
+                                           GdkEventExpose      *event);
 static void gtk_progress_bar_size_request  (GtkWidget           *widget,
                                            GtkRequisition      *requisition);
+static void gtk_progress_bar_style_set     (GtkWidget           *widget,
+                                           GtkStyle            *previous);
 static void gtk_progress_bar_real_update   (GtkProgress         *progress);
 static void gtk_progress_bar_paint         (GtkProgress         *progress);
 static void gtk_progress_bar_act_mode_enter (GtkProgress        *progress);
@@ -91,33 +92,7 @@ static void gtk_progress_bar_set_activity_blocks_internal (GtkProgressBar *pbar,
                                                           guint           blocks);
 
 
-GType
-gtk_progress_bar_get_type (void)
-{
-  static GType progress_bar_type = 0;
-
-  if (!progress_bar_type)
-    {
-      static const GTypeInfo progress_bar_info =
-      {
-       sizeof (GtkProgressBarClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-       (GClassInitFunc) gtk_progress_bar_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-       sizeof (GtkProgressBar),
-       0,              /* n_preallocs */
-       (GInstanceInitFunc) gtk_progress_bar_init,
-      };
-
-      progress_bar_type =
-       g_type_register_static (GTK_TYPE_PROGRESS, "GtkProgressBar",
-                               &progress_bar_info, 0);
-    }
-
-  return progress_bar_type;
-}
+G_DEFINE_TYPE (GtkProgressBar, gtk_progress_bar, GTK_TYPE_PROGRESS)
 
 static void
 gtk_progress_bar_class_init (GtkProgressBarClass *class)
@@ -133,7 +108,9 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
   gobject_class->set_property = gtk_progress_bar_set_property;
   gobject_class->get_property = gtk_progress_bar_get_property;
   
+  widget_class->expose_event = gtk_progress_bar_expose;
   widget_class->size_request = gtk_progress_bar_size_request;
+  widget_class->style_set = gtk_progress_bar_style_set;
 
   progress_class->paint = gtk_progress_bar_paint;
   progress_class->update = gtk_progress_bar_real_update;
@@ -170,9 +147,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                    g_param_spec_uint ("activity-step",
                                                      P_("Activity Step"),
                                                      P_("The increment used for each iteration in activity mode (Deprecated)"),
-                                                     -G_MAXUINT,
-                                                     G_MAXUINT,
-                                                     3,
+                                                     0, G_MAXUINT, 3,
                                                      GTK_PARAM_READWRITE));
 
   g_object_class_install_property (gobject_class,
@@ -180,9 +155,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                    g_param_spec_uint ("activity-blocks",
                                                      P_("Activity Blocks"),
                                                      P_("The number of blocks which can fit in the progress bar area in activity mode (Deprecated)"),
-                                                     2,
-                                                     G_MAXUINT,
-                                                     5,
+                                                     2, G_MAXUINT, 5,
                                                      GTK_PARAM_READWRITE));
 
   g_object_class_install_property (gobject_class,
@@ -190,9 +163,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                    g_param_spec_uint ("discrete-blocks",
                                                      P_("Discrete Blocks"),
                                                      P_("The number of discrete blocks in a progress bar (when shown in the discrete style)"),
-                                                     2,
-                                                     G_MAXUINT,
-                                                     10,
+                                                     2, G_MAXUINT, 10,
                                                      GTK_PARAM_READWRITE));
   
   g_object_class_install_property (gobject_class,
@@ -200,9 +171,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                   g_param_spec_double ("fraction",
                                                        P_("Fraction"),
                                                        P_("The fraction of total work that has been completed"),
-                                                       0.0,
-                                                       1.0,
-                                                       0.0,
+                                                       0.0, 1.0, 0.0,
                                                        GTK_PARAM_READWRITE));  
   
   g_object_class_install_property (gobject_class,
@@ -210,9 +179,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                   g_param_spec_double ("pulse-step",
                                                        P_("Pulse Step"),
                                                        P_("The fraction of total progress to move the bouncing block when pulsed"),
-                                                       0.0,
-                                                       1.0,
-                                                       0.1,
+                                                       0.0, 1.0, 0.1,
                                                        GTK_PARAM_READWRITE));  
   
   g_object_class_install_property (gobject_class,
@@ -220,7 +187,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                   g_param_spec_string ("text",
                                                        P_("Text"),
                                                        P_("Text to be displayed in the progress bar"),
-                                                       "%P %%",
+                                                       NULL,
                                                        GTK_PARAM_READWRITE));
 
   /**
@@ -241,11 +208,23 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                   PROP_ELLIPSIZE,
                                    g_param_spec_enum ("ellipsize",
                                                       P_("Ellipsize"),
-                                                      P_("The preferred place to ellipsize the string, if the progressbar does not have enough room to display the entire string, if at all"),
+                                                      P_("The preferred place to ellipsize the string, if the progress bar "
+                                                         "does not have enough room to display the entire string, if at all."),
                                                      PANGO_TYPE_ELLIPSIZE_MODE,
                                                      PANGO_ELLIPSIZE_NONE,
                                                       GTK_PARAM_READWRITE));
-
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_int ("xspacing",
+                                                             P_("XSpacing"),
+                                                             P_("Extra spacing applied to the width of a progress bar."),
+                                                             0, G_MAXINT, 7,
+                                                             G_PARAM_READWRITE));
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_int ("yspacing",
+                                                             "YSpacing",
+                                                             "Extra spacing applied to the height of a progress bar.",
+                                                             0, G_MAXINT, 7,
+                                                             G_PARAM_READWRITE));
 }
 
 static void
@@ -466,7 +445,7 @@ gtk_progress_bar_real_update (GtkProgress *progress)
                }
            }
        }
-      gtk_progress_bar_paint (progress);
+      pbar->dirty = TRUE;
       gtk_widget_queue_draw (GTK_WIDGET (progress));
     }
   else
@@ -479,12 +458,28 @@ gtk_progress_bar_real_update (GtkProgress *progress)
       if (pbar->in_block != in_block)
        {
          pbar->in_block = in_block;
-         gtk_progress_bar_paint (progress);
+         pbar->dirty = TRUE;
          gtk_widget_queue_draw (GTK_WIDGET (progress));
        }
     }
 }
 
+static gboolean
+gtk_progress_bar_expose (GtkWidget      *widget,
+                    GdkEventExpose *event)
+{
+  GtkProgressBar *pbar;
+
+  g_return_val_if_fail (GTK_IS_PROGRESS_BAR (widget), FALSE);
+
+  pbar = GTK_PROGRESS_BAR (widget);
+
+  if (GTK_WIDGET_DRAWABLE (widget) && pbar->dirty)
+    gtk_progress_bar_paint (GTK_PROGRESS (pbar));
+
+  return GTK_WIDGET_CLASS (gtk_progress_bar_parent_class)->expose_event (widget, event);
+}
+
 static void
 gtk_progress_bar_size_request (GtkWidget      *widget,
                               GtkRequisition *requisition)
@@ -495,15 +490,21 @@ gtk_progress_bar_size_request (GtkWidget      *widget,
   PangoRectangle logical_rect;
   PangoLayout *layout;
   gint width, height;
+  gint xspacing, yspacing;
 
   g_return_if_fail (GTK_IS_PROGRESS_BAR (widget));
   g_return_if_fail (requisition != NULL);
 
+  gtk_widget_style_get (widget,
+                        "xspacing", &xspacing,
+                        "yspacing", &yspacing,
+                        NULL);
+
   progress = GTK_PROGRESS (widget);
   pbar = GTK_PROGRESS_BAR (widget);
 
-  width = 2 * widget->style->xthickness + 3 + 2 * TEXT_SPACING;
-  height = 2 * widget->style->ythickness + 3 + 2 * TEXT_SPACING;
+  width = 2 * widget->style->xthickness + xspacing;
+  height = 2 * widget->style->ythickness + yspacing;
 
   if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE)
     {
@@ -543,38 +544,32 @@ gtk_progress_bar_size_request (GtkWidget      *widget,
   if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
       pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
     {
-      if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE)
-       {
-         requisition->width = MAX (MIN_HORIZONTAL_BAR_WIDTH, width);
-         requisition->height = MAX (MIN_HORIZONTAL_BAR_HEIGHT, height);
-       }
-      else
-       {
-         requisition->width = MIN_HORIZONTAL_BAR_WIDTH;
-         requisition->height = MIN_HORIZONTAL_BAR_HEIGHT;
-       }
+      requisition->width = MAX (MIN_HORIZONTAL_BAR_WIDTH, width);
+      requisition->height = MAX (MIN_HORIZONTAL_BAR_HEIGHT, height);
     }
   else
     {
-      if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE)
-       {         
-         requisition->width = MAX (MIN_VERTICAL_BAR_WIDTH, width);
-         requisition->height = MAX (MIN_VERTICAL_BAR_HEIGHT, height);
-       }
-      else
-       {
-         requisition->width = MIN_VERTICAL_BAR_WIDTH;
-         requisition->height = MIN_VERTICAL_BAR_HEIGHT;
-       }
+      requisition->width = MAX (MIN_VERTICAL_BAR_WIDTH, width);
+      requisition->height = MAX (MIN_VERTICAL_BAR_HEIGHT, height);
     }
 }
 
+static void
+gtk_progress_bar_style_set (GtkWidget      *widget,
+    GtkStyle *previous)
+{
+  GtkProgressBar *pbar = GTK_PROGRESS_BAR (widget);
+
+  pbar->dirty = TRUE;
+
+  GTK_WIDGET_CLASS (gtk_progress_bar_parent_class)->style_set (widget, previous);
+}
+
 static void
 gtk_progress_bar_act_mode_enter (GtkProgress *progress)
 {
   GtkProgressBar *pbar;
   GtkWidget *widget;
-  gint size;
   GtkProgressBarOrientation orientation;
 
   pbar = GTK_PROGRESS_BAR (progress);
@@ -594,8 +589,6 @@ gtk_progress_bar_act_mode_enter (GtkProgress *progress)
   if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
       orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
     {
-      size = MAX (2, widget->allocation.width / pbar->activity_blocks);
-
       if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
        {
          pbar->activity_pos = widget->style->xthickness;
@@ -611,8 +604,6 @@ gtk_progress_bar_act_mode_enter (GtkProgress *progress)
     }
   else
     {
-      size = MAX (2, widget->allocation.height / pbar->activity_blocks);
-
       if (orientation == GTK_PROGRESS_TOP_TO_BOTTOM)
        {
          pbar->activity_pos = widget->style->ythickness;
@@ -628,30 +619,52 @@ gtk_progress_bar_act_mode_enter (GtkProgress *progress)
     }
 }
 
+static void
+gtk_progress_bar_get_activity (GtkProgressBar            *pbar,
+                              GtkProgressBarOrientation  orientation,
+                              gint                      *offset,
+                              gint                      *amount)
+{
+  GtkWidget *widget = GTK_WIDGET (pbar);
+
+  *offset = pbar->activity_pos;
+
+  switch (orientation)
+    {
+    case GTK_PROGRESS_LEFT_TO_RIGHT:
+    case GTK_PROGRESS_RIGHT_TO_LEFT:
+      *amount = MAX (2, widget->allocation.width / pbar->activity_blocks);
+      break;
+
+    case GTK_PROGRESS_TOP_TO_BOTTOM:
+    case GTK_PROGRESS_BOTTOM_TO_TOP:
+      *amount = MAX (2, widget->allocation.height / pbar->activity_blocks);
+      break;
+    }
+}
+
 static void
 gtk_progress_bar_paint_activity (GtkProgressBar            *pbar,
                                 GtkProgressBarOrientation  orientation)
 {
   GtkWidget *widget = GTK_WIDGET (pbar);
   GtkProgress *progress = GTK_PROGRESS (pbar);
-  gint x, y, w, h;
+  GdkRectangle area;
 
   switch (orientation)
     {
     case GTK_PROGRESS_LEFT_TO_RIGHT:
     case GTK_PROGRESS_RIGHT_TO_LEFT:
-      x = pbar->activity_pos;
-      y = widget->style->ythickness;
-      w = MAX (2, widget->allocation.width / pbar->activity_blocks);
-      h = widget->allocation.height - 2 * widget->style->ythickness;
+      gtk_progress_bar_get_activity (pbar, orientation, &area.x, &area.width);
+      area.y = widget->style->ythickness;
+      area.height = widget->allocation.height - 2 * widget->style->ythickness;
       break;
 
     case GTK_PROGRESS_TOP_TO_BOTTOM:
     case GTK_PROGRESS_BOTTOM_TO_TOP:
-      x = widget->style->xthickness;
-      y = pbar->activity_pos;
-      w = widget->allocation.width - 2 * widget->style->xthickness;
-      h = MAX (2, widget->allocation.height / pbar->activity_blocks);
+      gtk_progress_bar_get_activity (pbar, orientation, &area.y, &area.height);
+      area.x = widget->style->xthickness;
+      area.width = widget->allocation.width - 2 * widget->style->xthickness;
       break;
 
     default:
@@ -662,8 +675,8 @@ gtk_progress_bar_paint_activity (GtkProgressBar            *pbar,
   gtk_paint_box (widget->style,
                 progress->offscreen_pixmap,
                 GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
-                NULL, widget, "bar",
-                x, y, w, h);
+                &area, widget, "bar",
+                area.x, area.y, area.width, area.height);
 }
 
 static void
@@ -671,8 +684,8 @@ gtk_progress_bar_paint_continuous (GtkProgressBar            *pbar,
                                   gint                       amount,
                                   GtkProgressBarOrientation  orientation)
 {
+  GdkRectangle area;
   GtkWidget *widget = GTK_WIDGET (pbar);
-  gint x, y, w, h;
 
   if (amount <= 0)
     return;
@@ -681,24 +694,24 @@ gtk_progress_bar_paint_continuous (GtkProgressBar            *pbar,
     {
     case GTK_PROGRESS_LEFT_TO_RIGHT:
     case GTK_PROGRESS_RIGHT_TO_LEFT:
-      w = amount;
-      h = widget->allocation.height - widget->style->ythickness * 2;
-      y = widget->style->ythickness;
+      area.width = amount;
+      area.height = widget->allocation.height - widget->style->ythickness * 2;
+      area.y = widget->style->ythickness;
       
-      x = widget->style->xthickness;
+      area.x = widget->style->xthickness;
       if (orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
-       x = widget->allocation.width - amount - x;
+       area.x = widget->allocation.width - amount - area.x;
       break;
       
     case GTK_PROGRESS_TOP_TO_BOTTOM:
     case GTK_PROGRESS_BOTTOM_TO_TOP:
-      w = widget->allocation.width - widget->style->xthickness * 2;
-      h = amount;
-      x = widget->style->xthickness;
+      area.width = widget->allocation.width - widget->style->xthickness * 2;
+      area.height = amount;
+      area.x = widget->style->xthickness;
       
-      y = widget->style->ythickness;
+      area.y = widget->style->ythickness;
       if (orientation == GTK_PROGRESS_BOTTOM_TO_TOP)
-       y = widget->allocation.height - amount - y;
+       area.y = widget->allocation.height - amount - area.y;
       break;
       
     default:
@@ -709,8 +722,8 @@ gtk_progress_bar_paint_continuous (GtkProgressBar            *pbar,
   gtk_paint_box (widget->style,
                 GTK_PROGRESS (pbar)->offscreen_pixmap,
                 GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
-                NULL, widget, "bar",
-                x, y, w, h);
+                &area, widget, "bar",
+                area.x, area.y, area.width, area.height);
 }
 
 static void
@@ -722,7 +735,8 @@ gtk_progress_bar_paint_discrete (GtkProgressBar            *pbar,
 
   for (i = 0; i <= pbar->in_block; i++)
     {
-      gint x, y, w, h, space;
+      GdkRectangle area;
+      gint space;
 
       switch (orientation)
        {
@@ -730,26 +744,26 @@ gtk_progress_bar_paint_discrete (GtkProgressBar            *pbar,
        case GTK_PROGRESS_RIGHT_TO_LEFT:
          space = widget->allocation.width - 2 * widget->style->xthickness;
          
-         x = widget->style->xthickness + (i * space) / pbar->blocks;
-         y = widget->style->ythickness;
-         w = widget->style->xthickness + ((i + 1) * space) / pbar->blocks - x;
-         h = widget->allocation.height - 2 * widget->style->ythickness;
+         area.x = widget->style->xthickness + (i * space) / pbar->blocks;
+         area.y = widget->style->ythickness;
+         area.width = widget->style->xthickness + ((i + 1) * space) / pbar->blocks - area.x;
+         area.height = widget->allocation.height - 2 * widget->style->ythickness;
 
          if (orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
-           x = widget->allocation.width - w - x;
+           area.x = widget->allocation.width - area.width - area.x;
          break;
          
        case GTK_PROGRESS_TOP_TO_BOTTOM:
        case GTK_PROGRESS_BOTTOM_TO_TOP:
          space = widget->allocation.height - 2 * widget->style->ythickness;
          
-         x = widget->style->xthickness;
-         y = widget->style->ythickness + (i * space) / pbar->blocks;
-         w = widget->allocation.width - 2 * widget->style->xthickness;
-         h = widget->style->ythickness + ((i + 1) * space) / pbar->blocks - y;
+         area.x = widget->style->xthickness;
+         area.y = widget->style->ythickness + (i * space) / pbar->blocks;
+         area.width = widget->allocation.width - 2 * widget->style->xthickness;
+         area.height = widget->style->ythickness + ((i + 1) * space) / pbar->blocks - area.y;
          
          if (orientation == GTK_PROGRESS_BOTTOM_TO_TOP)
-           y = widget->allocation.height - h - y;
+           area.y = widget->allocation.height - area.height - area.y;
          break;
 
        default:
@@ -760,27 +774,32 @@ gtk_progress_bar_paint_discrete (GtkProgressBar            *pbar,
       gtk_paint_box (widget->style,
                     GTK_PROGRESS (pbar)->offscreen_pixmap,
                     GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
-                    NULL, widget, "bar",
-                    x, y, w, h);
+                    &area, widget, "bar",
+                    area.x, area.y, area.width, area.height);
     }
 }
 
 static void
 gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
+                            gint                       offset,
                             gint                       amount,
                             GtkProgressBarOrientation  orientation)
 {
   GtkProgress *progress = GTK_PROGRESS (pbar);
   GtkWidget *widget = GTK_WIDGET (pbar);
-  
   gint x;
   gint y;
   gchar *buf;
   GdkRectangle rect;
   PangoLayout *layout;
   PangoRectangle logical_rect;
-  GdkRectangle prelight_clip, normal_clip;
-  
+  GdkRectangle prelight_clip, start_clip, end_clip;
+  gfloat text_xalign = progress->x_align;
+  gfloat text_yalign = progress->y_align;
+
+  if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
+    text_xalign = 1.0 - text_xalign;
+
   buf = gtk_progress_get_current_text (progress);
   
   layout = gtk_widget_create_pango_layout (widget, buf);
@@ -790,50 +809,86 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
 
   pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
   
-  x = widget->style->xthickness + 1 +
-    (widget->allocation.width - 2 * widget->style->xthickness -
-     2 - logical_rect.width)
-    * progress->x_align; 
+  x = widget->style->xthickness + 1 + text_xalign *
+      (widget->allocation.width - 2 * widget->style->xthickness -
+       2 - logical_rect.width);
 
-  y = widget->style->ythickness + 1 +
-    (widget->allocation.height - 2 * widget->style->ythickness -
-     2 - logical_rect.height)
-    * progress->y_align;
+  y = widget->style->ythickness + 1 + text_yalign *
+      (widget->allocation.height - 2 * widget->style->ythickness -
+       2 - logical_rect.height);
 
   rect.x = widget->style->xthickness;
   rect.y = widget->style->ythickness;
   rect.width = widget->allocation.width - 2 * widget->style->xthickness;
   rect.height = widget->allocation.height - 2 * widget->style->ythickness;
 
-  prelight_clip = normal_clip = rect;
+  prelight_clip = start_clip = end_clip = rect;
 
   switch (orientation)
     {
     case GTK_PROGRESS_LEFT_TO_RIGHT:
+      if (offset != -1)
+       prelight_clip.x = offset;
       prelight_clip.width = amount;
-      normal_clip.x += amount;
-      normal_clip.width -= amount;
+      start_clip.width = prelight_clip.x - start_clip.x;
+      end_clip.x = start_clip.x + start_clip.width + prelight_clip.width;
+      end_clip.width -= prelight_clip.width + start_clip.width;
       break;
       
     case GTK_PROGRESS_RIGHT_TO_LEFT:
-      normal_clip.width -= amount;
-      prelight_clip.x += normal_clip.width;
-      prelight_clip.width -= normal_clip.width;
+      if (offset != -1)
+       prelight_clip.x = offset;
+      else
+       prelight_clip.x = rect.x + rect.width - amount;
+      prelight_clip.width = amount;
+      start_clip.width = prelight_clip.x - start_clip.x;
+      end_clip.x = start_clip.x + start_clip.width + prelight_clip.width;
+      end_clip.width -= prelight_clip.width + start_clip.width;
       break;
        
     case GTK_PROGRESS_TOP_TO_BOTTOM:
+      if (offset != -1)
+       prelight_clip.y = offset;
       prelight_clip.height = amount;
-      normal_clip.y += amount;
-      normal_clip.height -= amount;
+      start_clip.height = prelight_clip.y - start_clip.y;
+      end_clip.y = start_clip.y + start_clip.height + prelight_clip.height;
+      end_clip.height -= prelight_clip.height + start_clip.height;
       break;
       
     case GTK_PROGRESS_BOTTOM_TO_TOP:
-      normal_clip.height -= amount;
-      prelight_clip.y += normal_clip.height;
-      prelight_clip.height -= normal_clip.height;
+      if (offset != -1)
+       prelight_clip.y = offset;
+      else
+       prelight_clip.y = rect.y + rect.height - amount;
+      prelight_clip.height = amount;
+      start_clip.height = prelight_clip.y - start_clip.y;
+      end_clip.y = start_clip.y + start_clip.height + prelight_clip.height;
+      end_clip.height -= prelight_clip.height + start_clip.height;
       break;
     }
-  
+
+  if (start_clip.width > 0 && start_clip.height > 0)
+    gtk_paint_layout (widget->style,
+                     progress->offscreen_pixmap,
+                     GTK_STATE_NORMAL,
+                     FALSE,
+                     &start_clip,
+                     widget,
+                     "progressbar",
+                     x, y,
+                     layout);
+
+  if (end_clip.width > 0 && end_clip.height > 0)
+    gtk_paint_layout (widget->style,
+                     progress->offscreen_pixmap,
+                     GTK_STATE_NORMAL,
+                     FALSE,
+                     &end_clip,
+                     widget,
+                     "progressbar",
+                     x, y,
+                     layout);
+
   gtk_paint_layout (widget->style,
                    progress->offscreen_pixmap,
                    GTK_STATE_PRELIGHT,
@@ -843,16 +898,6 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
                    "progressbar",
                    x, y,
                    layout);
-  
-  gtk_paint_layout (widget->style,
-                   progress->offscreen_pixmap,
-                   GTK_STATE_NORMAL,
-                   FALSE,
-                   &normal_clip,
-                   widget,
-                   "progressbar",
-                   x, y,
-                   layout);
 
   g_object_unref (layout);
   g_free (buf);
@@ -893,6 +938,15 @@ gtk_progress_bar_paint (GtkProgress *progress)
       if (progress->activity_mode)
        {
          gtk_progress_bar_paint_activity (pbar, orientation);
+
+         if (GTK_PROGRESS (pbar)->show_text)
+           {
+             gint offset;
+             gint amount;
+
+             gtk_progress_bar_get_activity (pbar, orientation, &offset, &amount);
+             gtk_progress_bar_paint_text (pbar, offset, amount, orientation);
+           }
        }
       else
        {
@@ -913,11 +967,13 @@ gtk_progress_bar_paint (GtkProgress *progress)
              gtk_progress_bar_paint_continuous (pbar, amount, orientation);
 
              if (GTK_PROGRESS (pbar)->show_text)
-               gtk_progress_bar_paint_text (pbar, amount, orientation);
+               gtk_progress_bar_paint_text (pbar, -1, amount, orientation);
            }
          else
            gtk_progress_bar_paint_discrete (pbar, orientation);
        }
+
+      pbar->dirty = FALSE;
     }
 }
 
@@ -934,7 +990,7 @@ gtk_progress_bar_set_bar_style_internal (GtkProgressBar     *pbar,
       if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (pbar)))
        gtk_widget_queue_resize (GTK_WIDGET (pbar));
 
-      g_object_notify (G_OBJECT (pbar), "bar_style");
+      g_object_notify (G_OBJECT (pbar), "bar-style");
     }
 }
 
@@ -952,7 +1008,7 @@ gtk_progress_bar_set_discrete_blocks_internal (GtkProgressBar *pbar,
       if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (pbar)))
        gtk_widget_queue_resize (GTK_WIDGET (pbar));
 
-      g_object_notify (G_OBJECT (pbar), "discrete_blocks");
+      g_object_notify (G_OBJECT (pbar), "discrete-blocks");
     }
 }
 
@@ -965,7 +1021,7 @@ gtk_progress_bar_set_activity_step_internal (GtkProgressBar *pbar,
   if (pbar->activity_step != step)
     {
       pbar->activity_step = step;
-      g_object_notify (G_OBJECT (pbar), "activity_step");
+      g_object_notify (G_OBJECT (pbar), "activity-step");
     }
 }
 
@@ -979,7 +1035,7 @@ gtk_progress_bar_set_activity_blocks_internal (GtkProgressBar *pbar,
   if (pbar->activity_blocks != blocks)
     {
       pbar->activity_blocks = blocks;
-      g_object_notify (G_OBJECT (pbar), "activity_blocks");
+      g_object_notify (G_OBJECT (pbar), "activity-blocks");
     }
 }
 
@@ -1038,7 +1094,7 @@ gtk_progress_bar_pulse (GtkProgressBar *pbar)
 /**
  * gtk_progress_bar_set_text:
  * @pbar: a #GtkProgressBar
- * @text: a UTF-8 string
+ * @text: a UTF-8 string, or %NULL 
  * 
  * Causes the given @text to appear superimposed on the progress bar.
  **/
@@ -1076,7 +1132,7 @@ gtk_progress_bar_set_pulse_step   (GtkProgressBar *pbar,
   
   pbar->pulse_fraction = fraction;
 
-  g_object_notify (G_OBJECT (pbar), "pulse_step");
+  g_object_notify (G_OBJECT (pbar), "pulse-step");
 }
 
 void