]> Pileus Git - ~andy/gtk/blob - gtk/gtkprogress.c
Always queue a resize ... we rely on the size-allocate to do the update,
[~andy/gtk] / gtk / gtkprogress.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #include <glib/gprintf.h>
28 #include <math.h>
29 #include <string.h>
30 #include "gtkprogress.h" 
31 #include "gtkintl.h"
32
33 #define EPSILON  1e-5
34 #define DEFAULT_FORMAT "%P %%"
35
36 enum {
37   PROP_0,
38   PROP_ACTIVITY_MODE,
39   PROP_SHOW_TEXT,
40   PROP_TEXT_XALIGN,
41   PROP_TEXT_YALIGN
42 };
43
44
45 static void gtk_progress_class_init      (GtkProgressClass *klass);
46 static void gtk_progress_init            (GtkProgress      *progress);
47 static void gtk_progress_set_property    (GObject          *object,
48                                           guint             prop_id,
49                                           const GValue     *value,
50                                           GParamSpec       *pspec);
51 static void gtk_progress_get_property    (GObject          *object,
52                                           guint             prop_id,
53                                           GValue           *value,
54                                           GParamSpec       *pspec);
55 static void gtk_progress_destroy         (GtkObject        *object);
56 static void gtk_progress_finalize        (GObject          *object);
57 static void gtk_progress_realize         (GtkWidget        *widget);
58 static gint gtk_progress_expose          (GtkWidget        *widget,
59                                           GdkEventExpose   *event);
60 static void gtk_progress_size_allocate   (GtkWidget        *widget,
61                                           GtkAllocation    *allocation);
62 static void gtk_progress_create_pixmap   (GtkProgress      *progress);
63 static void gtk_progress_value_changed   (GtkAdjustment    *adjustment,
64                                           GtkProgress      *progress);
65 static void gtk_progress_changed         (GtkAdjustment    *adjustment,
66                                           GtkProgress      *progress);
67
68
69 static GtkWidgetClass *parent_class = NULL;
70
71
72 GType
73 gtk_progress_get_type (void)
74 {
75   static GType progress_type = 0;
76
77   if (!progress_type)
78     {
79       static const GTypeInfo progress_info =
80       {
81         sizeof (GtkProgressClass),
82         NULL,           /* base_init */
83         NULL,           /* base_finalize */
84         (GClassInitFunc) gtk_progress_class_init,
85         NULL,           /* class_finalize */
86         NULL,           /* class_data */
87         sizeof (GtkProgress),
88         0,              /* n_preallocs */
89         (GInstanceInitFunc) gtk_progress_init,
90       };
91
92       progress_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkProgress",
93                                               &progress_info, 0);
94     }
95
96   return progress_type;
97 }
98
99 static void
100 gtk_progress_class_init (GtkProgressClass *class)
101 {
102   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
103   GtkObjectClass *object_class;
104   GtkWidgetClass *widget_class;
105
106   object_class = (GtkObjectClass *) class;
107   widget_class = (GtkWidgetClass *) class;
108
109   parent_class = gtk_type_class (GTK_TYPE_WIDGET);
110
111   gobject_class->finalize = gtk_progress_finalize;
112
113   gobject_class->set_property = gtk_progress_set_property;
114   gobject_class->get_property = gtk_progress_get_property;
115   object_class->destroy = gtk_progress_destroy;
116
117   widget_class->realize = gtk_progress_realize;
118   widget_class->expose_event = gtk_progress_expose;
119   widget_class->size_allocate = gtk_progress_size_allocate;
120
121   /* to be overridden */
122   class->paint = NULL;
123   class->update = NULL;
124   class->act_mode_enter = NULL;
125
126   g_object_class_install_property (gobject_class,
127                                    PROP_ACTIVITY_MODE,
128                                    g_param_spec_boolean ("activity_mode",
129                                                          _("Activity mode"),
130                                                          _("If TRUE the GtkProgress is in activity mode, meaning that it signals something is happening, but not how much of the activity is finished. This is used when you're doing something that you don't know how long it will take"),
131                                                          FALSE,
132                                                          G_PARAM_READWRITE));
133
134   g_object_class_install_property (gobject_class,
135                                    PROP_SHOW_TEXT,
136                                    g_param_spec_boolean ("show_text",
137                                                          _("Show text"),
138                                                          _("Whether the progress is shown as text"),
139                                                          FALSE,
140                                                          G_PARAM_READWRITE));
141
142   g_object_class_install_property (gobject_class,
143                                    PROP_TEXT_XALIGN,
144                                    g_param_spec_float ("text_xalign",
145                                                        _("Text x alignment"),
146                                                        _("A number between 0.0 and 1.0 specifying the horizontal alignment of the text in the progress widget"),
147                                                        0.0,
148                                                        1.0,
149                                                        0.5,
150                                                        G_PARAM_READWRITE));  
151     g_object_class_install_property (gobject_class,
152                                    PROP_TEXT_YALIGN,
153                                    g_param_spec_float ("text_yalign",
154                                                        _("Text y alignment"),
155                                                        _("A number between 0.0 and 1.0 specifying the vertical alignment of the text in the progress widget"),
156                                                        0.0,
157                                                        1.0,
158                                                        0.5,
159                                                        G_PARAM_READWRITE));
160 }
161
162 static void
163 gtk_progress_set_property (GObject      *object,
164                            guint         prop_id,
165                            const GValue *value,
166                            GParamSpec   *pspec)
167 {
168   GtkProgress *progress;
169   
170   progress = GTK_PROGRESS (object);
171
172   switch (prop_id)
173     {
174     case PROP_ACTIVITY_MODE:
175       gtk_progress_set_activity_mode (progress, g_value_get_boolean (value));
176       break;
177     case PROP_SHOW_TEXT:
178       gtk_progress_set_show_text (progress, g_value_get_boolean (value));
179       break;
180     case PROP_TEXT_XALIGN:
181       gtk_progress_set_text_alignment (progress,
182                                        g_value_get_float (value),
183                                        progress->y_align);
184       break;
185     case PROP_TEXT_YALIGN:
186       gtk_progress_set_text_alignment (progress,
187                                        progress->x_align,
188                                        g_value_get_float (value));
189       break;
190     default:
191       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
192       break;
193     }
194 }
195
196 static void
197 gtk_progress_get_property (GObject      *object,
198                            guint         prop_id,
199                            GValue       *value,
200                            GParamSpec   *pspec)
201 {
202   GtkProgress *progress;
203   
204   progress = GTK_PROGRESS (object);
205
206   switch (prop_id)
207     {
208     case PROP_ACTIVITY_MODE:
209       g_value_set_boolean (value, (progress->activity_mode != FALSE));
210       break;
211     case PROP_SHOW_TEXT:
212       g_value_set_boolean (value, (progress->show_text != FALSE));
213       break;
214     case PROP_TEXT_XALIGN:
215       g_value_set_float (value, progress->x_align);
216       break;
217     case PROP_TEXT_YALIGN:
218       g_value_set_float (value, progress->y_align);
219       break;
220     default:
221       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
222       break;
223     }
224 }
225
226 static void
227 gtk_progress_init (GtkProgress *progress)
228 {
229   progress->adjustment = NULL;
230   progress->offscreen_pixmap = NULL;
231   progress->format = g_strdup (DEFAULT_FORMAT);
232   progress->x_align = 0.5;
233   progress->y_align = 0.5;
234   progress->show_text = FALSE;
235   progress->activity_mode = FALSE;
236   progress->use_text_format = TRUE;
237 }
238
239 static void
240 gtk_progress_realize (GtkWidget *widget)
241 {
242   GtkProgress *progress;
243   GdkWindowAttr attributes;
244   gint attributes_mask;
245
246   g_return_if_fail (GTK_IS_PROGRESS (widget));
247
248   progress = GTK_PROGRESS (widget);
249   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
250
251   attributes.window_type = GDK_WINDOW_CHILD;
252   attributes.x = widget->allocation.x;
253   attributes.y = widget->allocation.y;
254   attributes.width = widget->allocation.width;
255   attributes.height = widget->allocation.height;
256   attributes.wclass = GDK_INPUT_OUTPUT;
257   attributes.visual = gtk_widget_get_visual (widget);
258   attributes.colormap = gtk_widget_get_colormap (widget);
259   attributes.event_mask = gtk_widget_get_events (widget);
260   attributes.event_mask |= GDK_EXPOSURE_MASK;
261
262   attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
263
264   widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
265                                    &attributes, attributes_mask);
266   gdk_window_set_user_data (widget->window, progress);
267
268   widget->style = gtk_style_attach (widget->style, widget->window);
269   gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE);
270
271   gtk_progress_create_pixmap (progress);
272 }
273
274 static void
275 gtk_progress_destroy (GtkObject *object)
276 {
277   GtkProgress *progress;
278
279   g_return_if_fail (GTK_IS_PROGRESS (object));
280
281   progress = GTK_PROGRESS (object);
282
283   if (progress->adjustment)
284     {
285       g_signal_handlers_disconnect_by_func (progress->adjustment,
286                                             gtk_progress_value_changed,
287                                             progress);
288       g_signal_handlers_disconnect_by_func (progress->adjustment,
289                                             gtk_progress_changed,
290                                             progress);
291       g_object_unref (progress->adjustment);
292       progress->adjustment = NULL;
293     }
294
295   GTK_OBJECT_CLASS (parent_class)->destroy (object);
296 }
297
298 static void
299 gtk_progress_finalize (GObject *object)
300 {
301   GtkProgress *progress;
302
303   g_return_if_fail (GTK_IS_PROGRESS (object));
304
305   progress = GTK_PROGRESS (object);
306
307   if (progress->offscreen_pixmap)
308     g_object_unref (progress->offscreen_pixmap);
309
310   if (progress->format)
311     g_free (progress->format);
312
313   G_OBJECT_CLASS (parent_class)->finalize (object);
314 }
315
316 static gint
317 gtk_progress_expose (GtkWidget      *widget,
318                      GdkEventExpose *event)
319 {
320   g_return_val_if_fail (GTK_IS_PROGRESS (widget), FALSE);
321   g_return_val_if_fail (event != NULL, FALSE);
322
323   if (GTK_WIDGET_DRAWABLE (widget))
324     gdk_draw_drawable (widget->window,
325                        widget->style->black_gc,
326                        GTK_PROGRESS (widget)->offscreen_pixmap,
327                        event->area.x, event->area.y,
328                        event->area.x, event->area.y,
329                        event->area.width,
330                        event->area.height);
331
332   return FALSE;
333 }
334
335 static void
336 gtk_progress_size_allocate (GtkWidget     *widget,
337                             GtkAllocation *allocation)
338 {
339   g_return_if_fail (GTK_IS_PROGRESS (widget));
340   g_return_if_fail (allocation != NULL);
341
342   widget->allocation = *allocation;
343
344   if (GTK_WIDGET_REALIZED (widget))
345     {
346       gdk_window_move_resize (widget->window,
347                               allocation->x, allocation->y,
348                               allocation->width, allocation->height);
349
350       gtk_progress_create_pixmap (GTK_PROGRESS (widget));
351     }
352 }
353
354 static void
355 gtk_progress_create_pixmap (GtkProgress *progress)
356 {
357   GtkWidget *widget;
358
359   g_return_if_fail (GTK_IS_PROGRESS (progress));
360
361   if (GTK_WIDGET_REALIZED (progress))
362     {
363       widget = GTK_WIDGET (progress);
364
365       if (progress->offscreen_pixmap)
366         g_object_unref (progress->offscreen_pixmap);
367
368       progress->offscreen_pixmap = gdk_pixmap_new (widget->window,
369                                                    widget->allocation.width,
370                                                    widget->allocation.height,
371                                                    -1);
372       GTK_PROGRESS_GET_CLASS (progress)->paint (progress);
373     }
374 }
375
376 static void
377 gtk_progress_changed (GtkAdjustment *adjustment,
378                       GtkProgress   *progress)
379 {
380   /* A change in the value of adjustment->upper can change
381    * the size request
382    */
383   if (progress->use_text_format && progress->show_text)
384     gtk_widget_queue_resize (progress);
385   else
386     GTK_PROGRESS_GET_CLASS (progress)->update (progress);
387 }
388
389 static void
390 gtk_progress_value_changed (GtkAdjustment *adjustment,
391                             GtkProgress   *progress)
392 {
393   GTK_PROGRESS_GET_CLASS (progress)->update (progress);
394 }
395
396 static gchar *
397 gtk_progress_build_string (GtkProgress *progress,
398                            gdouble      value,
399                            gdouble      percentage)
400 {
401   gchar buf[256] = { 0 };
402   gchar tmp[256] = { 0 };
403   gchar *src;
404   gchar *dest;
405   gchar fmt[10];
406
407   src = progress->format;
408
409   /* This is the new supported version of this function */
410   if (!progress->use_text_format)
411     return g_strdup (src);
412
413   /* And here's all the deprecated goo. */
414   
415   dest = buf;
416  
417   while (src && *src)
418     {
419       if (*src != '%')
420         {
421           *dest = *src;
422           dest++;
423         }
424       else
425         {
426           gchar c;
427           gint digits;
428
429           c = *(src + sizeof(gchar));
430           digits = 0;
431
432           if (c >= '0' && c <= '2')
433             {
434               digits = (gint) (c - '0');
435               src++;
436               c = *(src + sizeof(gchar));
437             }
438
439           switch (c)
440             {
441             case '%':
442               *dest = '%';
443               src++;
444               dest++;
445               break;
446             case 'p':
447             case 'P':
448               if (digits)
449                 {
450                   g_snprintf (fmt, sizeof (fmt), "%%.%df", digits);
451                   g_snprintf (tmp, sizeof (tmp), fmt, 100 * percentage);
452                 }
453               else
454                 g_snprintf (tmp, sizeof (tmp), "%.0f", 100 * percentage);
455               strcat (buf, tmp);
456               dest = &(buf[strlen (buf)]);
457               src++;
458               break;
459             case 'v':
460             case 'V':
461               if (digits)
462                 {
463                   g_snprintf (fmt, sizeof (fmt), "%%.%df", digits);
464                   g_snprintf (tmp, sizeof (tmp), fmt, value);
465                 }
466               else
467                 g_snprintf (tmp, sizeof (tmp), "%.0f", value);
468               strcat (buf, tmp);
469               dest = &(buf[strlen (buf)]);
470               src++;
471               break;
472             case 'l':
473             case 'L':
474               if (digits)
475                 {
476                   g_snprintf (fmt, sizeof (fmt), "%%.%df", digits);
477                   g_snprintf (tmp, sizeof (tmp), fmt, progress->adjustment->lower);
478                 }
479               else
480                 g_snprintf (tmp, sizeof (tmp), "%.0f", progress->adjustment->lower);
481               strcat (buf, tmp);
482               dest = &(buf[strlen (buf)]);
483               src++;
484               break;
485             case 'u':
486             case 'U':
487               if (digits)
488                 {
489                   g_snprintf (fmt, sizeof (fmt), "%%.%df", digits);
490                   g_snprintf (tmp, sizeof (tmp), fmt, progress->adjustment->upper);
491                 }
492               else
493                 g_snprintf (tmp, sizeof (tmp), "%.0f", progress->adjustment->upper);
494               strcat (buf, tmp);
495               dest = &(buf[strlen (buf)]);
496               src++;
497               break;
498             default:
499               break;
500             }
501         }
502       src++;
503     }
504
505   return g_strdup (buf);
506 }
507
508 /***************************************************************/
509
510 void
511 gtk_progress_set_adjustment (GtkProgress   *progress,
512                              GtkAdjustment *adjustment)
513 {
514   g_return_if_fail (GTK_IS_PROGRESS (progress));
515   if (adjustment)
516     g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
517   else
518     adjustment = (GtkAdjustment*) gtk_adjustment_new (0, 0, 100, 0, 0, 0);
519
520   if (progress->adjustment != adjustment)
521     {
522       if (progress->adjustment)
523         {
524           g_signal_handlers_disconnect_by_func (progress->adjustment,
525                                                 gtk_progress_changed,
526                                                 progress);
527           g_signal_handlers_disconnect_by_func (progress->adjustment,
528                                                 gtk_progress_value_changed,
529                                                 progress);
530           g_object_unref (progress->adjustment);
531         }
532       progress->adjustment = adjustment;
533       if (adjustment)
534         {
535           g_object_ref (adjustment);
536           gtk_object_sink (GTK_OBJECT (adjustment));
537           g_signal_connect (adjustment, "changed",
538                             G_CALLBACK (gtk_progress_changed),
539                             progress);
540           g_signal_connect (adjustment, "value_changed",
541                             G_CALLBACK (gtk_progress_value_changed),
542                             progress);
543         }
544
545       gtk_progress_changed (adjustment, progress);
546     }
547 }
548
549 void
550 gtk_progress_configure (GtkProgress *progress,
551                         gdouble      value,
552                         gdouble      min,
553                         gdouble      max)
554 {
555   GtkAdjustment *adj;
556   gboolean changed = FALSE;
557
558   g_return_if_fail (GTK_IS_PROGRESS (progress));
559   g_return_if_fail (min <= max);
560   g_return_if_fail (value >= min && value <= max);
561
562   if (!progress->adjustment)
563     gtk_progress_set_adjustment (progress, NULL);
564   adj = progress->adjustment;
565
566   if (fabs (adj->lower - min) > EPSILON || fabs (adj->upper - max) > EPSILON)
567     changed = TRUE;
568
569   adj->value = value;
570   adj->lower = min;
571   adj->upper = max;
572
573   gtk_adjustment_value_changed (adj);
574   if (changed)
575     gtk_adjustment_changed (adj);
576 }
577
578 void
579 gtk_progress_set_percentage (GtkProgress *progress,
580                              gdouble      percentage)
581 {
582   g_return_if_fail (GTK_IS_PROGRESS (progress));
583   g_return_if_fail (percentage >= 0 && percentage <= 1.0);
584
585   if (!progress->adjustment)
586     gtk_progress_set_adjustment (progress, NULL);
587   gtk_progress_set_value (progress, progress->adjustment->lower + percentage * 
588                  (progress->adjustment->upper - progress->adjustment->lower));
589 }
590
591 gdouble
592 gtk_progress_get_current_percentage (GtkProgress *progress)
593 {
594   g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
595
596   if (!progress->adjustment)
597     gtk_progress_set_adjustment (progress, NULL);
598
599   return gtk_progress_get_percentage_from_value (progress, progress->adjustment->value);
600 }
601
602 gdouble
603 gtk_progress_get_percentage_from_value (GtkProgress *progress,
604                                         gdouble      value)
605 {
606   g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
607
608   if (!progress->adjustment)
609     gtk_progress_set_adjustment (progress, NULL);
610
611   if (progress->adjustment->lower < progress->adjustment->upper &&
612       value >= progress->adjustment->lower &&
613       value <= progress->adjustment->upper)
614     return (value - progress->adjustment->lower) /
615       (progress->adjustment->upper - progress->adjustment->lower);
616   else
617     return 0.0;
618 }
619
620 void
621 gtk_progress_set_value (GtkProgress *progress,
622                         gdouble      value)
623 {
624   g_return_if_fail (GTK_IS_PROGRESS (progress));
625
626   if (!progress->adjustment)
627     gtk_progress_set_adjustment (progress, NULL);
628
629   if (fabs (progress->adjustment->value - value) > EPSILON)
630     gtk_adjustment_set_value (progress->adjustment, value);
631 }
632
633 gdouble
634 gtk_progress_get_value (GtkProgress *progress)
635 {
636   g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
637
638   return progress->adjustment ? progress->adjustment->value : 0;
639 }
640
641 void
642 gtk_progress_set_show_text (GtkProgress *progress,
643                             gboolean     show_text)
644 {
645   g_return_if_fail (GTK_IS_PROGRESS (progress));
646
647   if (progress->show_text != show_text)
648     {
649       progress->show_text = show_text;
650
651       gtk_widget_queue_resize (GTK_WIDGET (progress));
652
653       g_object_notify (G_OBJECT (progress), "show_text");
654     }
655 }
656
657 void
658 gtk_progress_set_text_alignment (GtkProgress *progress,
659                                  gfloat       x_align,
660                                  gfloat       y_align)
661 {
662   g_return_if_fail (GTK_IS_PROGRESS (progress));
663   g_return_if_fail (x_align >= 0.0 && x_align <= 1.0);
664   g_return_if_fail (y_align >= 0.0 && y_align <= 1.0);
665
666   if (progress->x_align != x_align || progress->y_align != y_align)
667     {
668       g_object_freeze_notify (G_OBJECT (progress));
669       if (progress->x_align != x_align)
670         {
671           progress->x_align = x_align;
672           g_object_notify (G_OBJECT (progress), "text_xalign");
673         }
674
675       if (progress->y_align != y_align)
676         {
677           progress->y_align = y_align;
678           g_object_notify (G_OBJECT (progress), "text_yalign");
679         }
680       g_object_thaw_notify (G_OBJECT (progress));
681
682       if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (progress)))
683         gtk_widget_queue_resize (GTK_WIDGET (progress));
684     }
685 }
686
687 void
688 gtk_progress_set_format_string (GtkProgress *progress,
689                                 const gchar *format)
690 {
691   gchar *old_format;
692   
693   g_return_if_fail (GTK_IS_PROGRESS (progress));
694
695   /* Turn on format, in case someone called
696    * gtk_progress_bar_set_text() and turned it off.
697    */
698   progress->use_text_format = TRUE;
699
700   old_format = progress->format;
701
702   if (!format)
703     format = DEFAULT_FORMAT;
704
705   progress->format = g_strdup (format);
706   g_free (old_format);
707   
708   gtk_widget_queue_resize (GTK_WIDGET (progress));
709 }
710
711 gchar *
712 gtk_progress_get_current_text (GtkProgress *progress)
713 {
714   g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
715
716   if (!progress->adjustment)
717     gtk_progress_set_adjustment (progress, NULL);
718
719   return gtk_progress_build_string (progress, progress->adjustment->value,
720                                     gtk_progress_get_current_percentage (progress));
721 }
722
723 gchar *
724 gtk_progress_get_text_from_value (GtkProgress *progress,
725                                   gdouble      value)
726 {
727   g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
728
729   if (!progress->adjustment)
730     gtk_progress_set_adjustment (progress, NULL);
731
732   return gtk_progress_build_string (progress, value,
733                                     gtk_progress_get_percentage_from_value (progress, value));
734 }
735
736 void
737 gtk_progress_set_activity_mode (GtkProgress *progress,
738                                 gboolean     activity_mode)
739 {
740   g_return_if_fail (GTK_IS_PROGRESS (progress));
741
742   if (progress->activity_mode != (activity_mode != FALSE))
743     {
744       progress->activity_mode = (activity_mode != FALSE);
745
746       if (progress->activity_mode)
747         GTK_PROGRESS_GET_CLASS (progress)->act_mode_enter (progress);
748
749       if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (progress)))
750         gtk_widget_queue_resize (GTK_WIDGET (progress));
751
752       g_object_notify (G_OBJECT (progress), "activity_mode");
753     }
754 }