]> Pileus Git - ~andy/gtk/blob - gtk/gtkprogressbar.h
define __GTK_H_INSIDE__ around including all other headers.
[~andy/gtk] / gtk / gtkprogressbar.h
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 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_PROGRESS_BAR_H__
32 #define __GTK_PROGRESS_BAR_H__
33
34
35 #include <gdk/gdk.h>
36 #include <gtk/gtkprogress.h>
37
38
39 G_BEGIN_DECLS
40
41 #define GTK_TYPE_PROGRESS_BAR            (gtk_progress_bar_get_type ())
42 #define GTK_PROGRESS_BAR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PROGRESS_BAR, GtkProgressBar))
43 #define GTK_PROGRESS_BAR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PROGRESS_BAR, GtkProgressBarClass))
44 #define GTK_IS_PROGRESS_BAR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PROGRESS_BAR))
45 #define GTK_IS_PROGRESS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PROGRESS_BAR))
46 #define GTK_PROGRESS_BAR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PROGRESS_BAR, GtkProgressBarClass))
47
48
49 typedef struct _GtkProgressBar       GtkProgressBar;
50 typedef struct _GtkProgressBarClass  GtkProgressBarClass;
51
52 typedef enum
53 {
54   GTK_PROGRESS_CONTINUOUS,
55   GTK_PROGRESS_DISCRETE
56 } GtkProgressBarStyle;
57
58 typedef enum
59 {
60   GTK_PROGRESS_LEFT_TO_RIGHT,
61   GTK_PROGRESS_RIGHT_TO_LEFT,
62   GTK_PROGRESS_BOTTOM_TO_TOP,
63   GTK_PROGRESS_TOP_TO_BOTTOM
64 } GtkProgressBarOrientation;
65
66 struct _GtkProgressBar
67 {
68   GtkProgress progress;
69
70   GtkProgressBarStyle bar_style;
71   GtkProgressBarOrientation orientation;
72
73   guint blocks;
74   gint  in_block;
75
76   gint  activity_pos;
77   guint activity_step;
78   guint activity_blocks;
79
80   gdouble pulse_fraction;
81   
82   guint activity_dir : 1;
83   guint ellipsize : 3;
84   guint dirty : 1;
85 };
86
87 struct _GtkProgressBarClass
88 {
89   GtkProgressClass parent_class;
90
91   /* Padding for future expansion */
92   void (*_gtk_reserved1) (void);
93   void (*_gtk_reserved2) (void);
94   void (*_gtk_reserved3) (void);
95   void (*_gtk_reserved4) (void);
96 };
97
98
99 GType      gtk_progress_bar_get_type             (void) G_GNUC_CONST;
100 GtkWidget* gtk_progress_bar_new                  (void);
101
102 /*
103  * GtkProgress/GtkProgressBar had serious problems in GTK 1.2.
104  * 
105  *  - Only 3 or 4 functions are really needed for 95% of progress  
106  *    interfaces; GtkProgress[Bar] had about 25 functions, and 
107  *    didn't even include these 3 or 4.
108  *  - In activity mode, the API involves setting the adjustment 
109  *    to any random value, just to have the side effect of 
110  *    calling the progress bar update function - the adjustment
111  *    is totally ignored in activity mode
112  *  - You set the activity step as a pixel value, which means to 
113  *    set the activity step you basically need to connect to 
114  *    size_allocate
115  *  - There are ctree_set_expander_style()-functions, to randomly 
116  *    change look-and-feel for no good reason
117  *  - The split between GtkProgress and GtkProgressBar makes no sense 
118  *    to me whatsoever.
119  *  
120  * This was a big wart on GTK and made people waste lots of time,
121  * both learning and using the interface.
122  * 
123  * So, I have added what I feel is the correct API, and marked all the
124  * rest deprecated. However, the changes are 100% backward-compatible and
125  * should break no existing code.
126  *
127  * The following 9 functions are the new programming interface. 
128  */
129 void       gtk_progress_bar_pulse                (GtkProgressBar *pbar);
130 void       gtk_progress_bar_set_text             (GtkProgressBar *pbar,
131                                                   const gchar    *text);
132 void       gtk_progress_bar_set_fraction         (GtkProgressBar *pbar,
133                                                   gdouble         fraction);
134
135 void       gtk_progress_bar_set_pulse_step       (GtkProgressBar *pbar,
136                                                   gdouble         fraction);
137 void       gtk_progress_bar_set_orientation      (GtkProgressBar *pbar,
138                                                   GtkProgressBarOrientation orientation);
139
140 G_CONST_RETURN gchar* gtk_progress_bar_get_text       (GtkProgressBar *pbar);
141 gdouble               gtk_progress_bar_get_fraction   (GtkProgressBar *pbar);
142 gdouble               gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar);
143
144 GtkProgressBarOrientation gtk_progress_bar_get_orientation (GtkProgressBar *pbar);
145 void               gtk_progress_bar_set_ellipsize (GtkProgressBar     *pbar,
146                                                    PangoEllipsizeMode  mode);
147 PangoEllipsizeMode gtk_progress_bar_get_ellipsize (GtkProgressBar     *pbar);
148
149
150 #ifndef GTK_DISABLE_DEPRECATED
151
152 /* Everything below here is deprecated */
153 GtkWidget* gtk_progress_bar_new_with_adjustment  (GtkAdjustment  *adjustment);
154 void       gtk_progress_bar_set_bar_style        (GtkProgressBar *pbar,
155                                                   GtkProgressBarStyle style);
156 void       gtk_progress_bar_set_discrete_blocks  (GtkProgressBar *pbar,
157                                                   guint           blocks);
158 /* set_activity_step() is not only deprecated, it doesn't even work.
159  * (Of course, it wasn't usable anyway, you had to set it from a size_allocate
160  * handler or something)
161  */
162 void       gtk_progress_bar_set_activity_step    (GtkProgressBar *pbar,
163                                                   guint           step);
164 void       gtk_progress_bar_set_activity_blocks  (GtkProgressBar *pbar,
165                                                   guint           blocks);
166 void       gtk_progress_bar_update               (GtkProgressBar *pbar,
167                                                   gdouble         percentage);
168
169 #endif /* GTK_DISABLE_DEPRECATED */
170
171 G_END_DECLS
172
173 #endif /* __GTK_PROGRESS_BAR_H__ */