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