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