1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GtkProgressBar.html 27 * outPack = gtk 28 * outFile = ProgressBar 29 * strct = GtkProgressBar 30 * realStrct= 31 * ctorStrct= 32 * clss = ProgressBar 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_progress_bar_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gtk.Adjustment 49 * structWrap: 50 * - GtkAdjustment* -> Adjustment 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module gtk.ProgressBar; 57 58 public import gtkc.gtktypes; 59 60 private import gtkc.gtk; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 65 private import glib.Str; 66 private import gtk.Adjustment; 67 68 69 70 private import gtk.Progress; 71 72 /** 73 * Description 74 * The GtkProgressBar is typically used to display the progress of a long 75 * running operation. It provides a visual clue that processing 76 * is underway. The GtkProgressBar can be used in two different 77 * modes: percentage mode and activity mode. 78 * When an application can determine how much work needs to take place 79 * (e.g. read a fixed number of bytes from a file) and can monitor its 80 * progress, it can use the GtkProgressBar in percentage mode and the user 81 * sees a growing bar indicating the percentage of the work that has 82 * been completed. In this mode, the application is required to call 83 * gtk_progress_bar_set_fraction() periodically to update the progress bar. 84 * When an application has no accurate way of knowing the amount of work 85 * to do, it can use the GtkProgressBar in activity mode, which shows activity 86 * by a block moving back and forth within the progress area. In this mode, 87 * the application is required to call gtk_progress_bar_pulse() perodically 88 * to update the progress bar. 89 * There is quite a bit of flexibility provided to control the appearance 90 * of the GtkProgressBar. Functions are provided to control the 91 * orientation of the bar, optional text can be displayed along with 92 * the bar, and the step size used in activity mode can be set. 93 * Note 94 * The GtkProgressBar/GtkProgress API in GTK 1.2 was bloated, needlessly complex 95 * and hard to use properly. Therefore GtkProgress has been deprecated 96 * completely and the GtkProgressBar API has been reduced to the following 10 97 * functions: gtk_progress_bar_new(), gtk_progress_bar_pulse(), 98 * gtk_progress_bar_set_text(), gtk_progress_bar_set_fraction(), 99 * gtk_progress_bar_set_pulse_step(), gtk_progress_bar_set_orientation(), 100 * gtk_progress_bar_get_text(), gtk_progress_bar_get_fraction(), 101 * gtk_progress_bar_get_pulse_step(), gtk_progress_bar_get_orientation(). 102 * These have been grouped at the beginning of this section, followed by 103 * a large chunk of deprecated 1.2 compatibility functions. 104 */ 105 public class ProgressBar : Progress 106 { 107 108 /** the main Gtk struct */ 109 protected GtkProgressBar* gtkProgressBar; 110 111 112 public GtkProgressBar* getProgressBarStruct() 113 { 114 return gtkProgressBar; 115 } 116 117 118 /** the main Gtk struct as a void* */ 119 protected override void* getStruct() 120 { 121 return cast(void*)gtkProgressBar; 122 } 123 124 /** 125 * Sets our main struct and passes it to the parent class 126 */ 127 public this (GtkProgressBar* gtkProgressBar) 128 { 129 super(cast(GtkProgress*)gtkProgressBar); 130 this.gtkProgressBar = gtkProgressBar; 131 } 132 133 protected override void setStruct(GObject* obj) 134 { 135 super.setStruct(obj); 136 gtkProgressBar = cast(GtkProgressBar*)obj; 137 } 138 139 /** 140 */ 141 142 /** 143 * Creates a new GtkProgressBar. 144 * Creates a new GtkProgressBar. 145 * Throws: ConstructionException GTK+ fails to create the object. 146 */ 147 public this () 148 { 149 // GtkWidget * gtk_progress_bar_new (void); 150 auto p = gtk_progress_bar_new(); 151 if(p is null) 152 { 153 throw new ConstructionException("null returned by gtk_progress_bar_new()"); 154 } 155 this(cast(GtkProgressBar*) p); 156 } 157 158 /** 159 * Indicates that some progress is made, but you don't know how much. 160 * Causes the progress bar to enter "activity mode," where a block 161 * bounces back and forth. Each call to gtk_progress_bar_pulse() 162 * causes the block to move by a little bit (the amount of movement 163 * per pulse is determined by gtk_progress_bar_set_pulse_step()). 164 */ 165 public void pulse() 166 { 167 // void gtk_progress_bar_pulse (GtkProgressBar *pbar); 168 gtk_progress_bar_pulse(gtkProgressBar); 169 } 170 171 /** 172 * Causes the given text to appear superimposed on the progress bar. 173 * Params: 174 * text = a UTF-8 string, or NULL. [allow-none] 175 */ 176 public void setText(string text) 177 { 178 // void gtk_progress_bar_set_text (GtkProgressBar *pbar, const gchar *text); 179 gtk_progress_bar_set_text(gtkProgressBar, Str.toStringz(text)); 180 } 181 182 /** 183 * Causes the progress bar to "fill in" the given fraction 184 * of the bar. The fraction should be between 0.0 and 1.0, 185 * inclusive. 186 * Params: 187 * fraction = fraction of the task that's been completed 188 */ 189 public void setFraction(double fraction) 190 { 191 // void gtk_progress_bar_set_fraction (GtkProgressBar *pbar, gdouble fraction); 192 gtk_progress_bar_set_fraction(gtkProgressBar, fraction); 193 } 194 195 /** 196 * Sets the fraction of total progress bar length to move the 197 * bouncing block for each call to gtk_progress_bar_pulse(). 198 * Params: 199 * fraction = fraction between 0.0 and 1.0 200 */ 201 public void setPulseStep(double fraction) 202 { 203 // void gtk_progress_bar_set_pulse_step (GtkProgressBar *pbar, gdouble fraction); 204 gtk_progress_bar_set_pulse_step(gtkProgressBar, fraction); 205 } 206 207 /** 208 * Causes the progress bar to switch to a different orientation 209 * (left-to-right, right-to-left, top-to-bottom, or bottom-to-top). 210 * Params: 211 * orientation = orientation of the progress bar 212 */ 213 public void setOrientation(GtkProgressBarOrientation orientation) 214 { 215 // void gtk_progress_bar_set_orientation (GtkProgressBar *pbar, GtkProgressBarOrientation orientation); 216 gtk_progress_bar_set_orientation(gtkProgressBar, orientation); 217 } 218 219 /** 220 * Sets the mode used to ellipsize (add an ellipsis: "...") the text 221 * if there is not enough space to render the entire string. 222 * Since 2.6 223 * Params: 224 * mode = a PangoEllipsizeMode 225 */ 226 public void setEllipsize(PangoEllipsizeMode mode) 227 { 228 // void gtk_progress_bar_set_ellipsize (GtkProgressBar *pbar, PangoEllipsizeMode mode); 229 gtk_progress_bar_set_ellipsize(gtkProgressBar, mode); 230 } 231 232 /** 233 * Retrieves the text displayed superimposed on the progress bar, 234 * if any, otherwise NULL. The return value is a reference 235 * to the text, not a copy of it, so will become invalid 236 * if you change the text in the progress bar. 237 * Returns: text, or NULL; this string is owned by the widget and should not be modified or freed. 238 */ 239 public string getText() 240 { 241 // const gchar * gtk_progress_bar_get_text (GtkProgressBar *pbar); 242 return Str.toString(gtk_progress_bar_get_text(gtkProgressBar)); 243 } 244 245 /** 246 * Returns the current fraction of the task that's been completed. 247 * Returns: a fraction from 0.0 to 1.0 248 */ 249 public double getFraction() 250 { 251 // gdouble gtk_progress_bar_get_fraction (GtkProgressBar *pbar); 252 return gtk_progress_bar_get_fraction(gtkProgressBar); 253 } 254 255 /** 256 * Retrieves the pulse step set with gtk_progress_bar_set_pulse_step() 257 * Returns: a fraction from 0.0 to 1.0 258 */ 259 public double getPulseStep() 260 { 261 // gdouble gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar); 262 return gtk_progress_bar_get_pulse_step(gtkProgressBar); 263 } 264 265 /** 266 * Retrieves the current progress bar orientation. 267 * Returns: orientation of the progress bar 268 */ 269 public GtkProgressBarOrientation getOrientation() 270 { 271 // GtkProgressBarOrientation gtk_progress_bar_get_orientation (GtkProgressBar *pbar); 272 return gtk_progress_bar_get_orientation(gtkProgressBar); 273 } 274 275 /** 276 * Returns the ellipsizing position of the progressbar. 277 * See gtk_progress_bar_set_ellipsize(). 278 * Since 2.6 279 * Returns: PangoEllipsizeMode 280 */ 281 public PangoEllipsizeMode getEllipsize() 282 { 283 // PangoEllipsizeMode gtk_progress_bar_get_ellipsize (GtkProgressBar *pbar); 284 return gtk_progress_bar_get_ellipsize(gtkProgressBar); 285 } 286 287 /** 288 * Warning 289 * gtk_progress_bar_new_with_adjustment is deprecated and should not be used in newly-written code. 290 * Creates a new GtkProgressBar with an associated GtkAdjustment. 291 * Params: 292 * adjustment = . [allow-none] 293 * Throws: ConstructionException GTK+ fails to create the object. 294 */ 295 public this (Adjustment adjustment) 296 { 297 // GtkWidget * gtk_progress_bar_new_with_adjustment (GtkAdjustment *adjustment); 298 auto p = gtk_progress_bar_new_with_adjustment((adjustment is null) ? null : adjustment.getAdjustmentStruct()); 299 if(p is null) 300 { 301 throw new ConstructionException("null returned by gtk_progress_bar_new_with_adjustment((adjustment is null) ? null : adjustment.getAdjustmentStruct())"); 302 } 303 this(cast(GtkProgressBar*) p); 304 } 305 306 /** 307 * Warning 308 * gtk_progress_bar_set_bar_style is deprecated and should not be used in newly-written code. 309 * Sets the style of the GtkProgressBar. The default style is 310 * GTK_PROGRESS_CONTINUOUS. 311 * Params: 312 * style = a GtkProgressBarStyle value indicating the desired style. 313 */ 314 public void setBarStyle(GtkProgressBarStyle style) 315 { 316 // void gtk_progress_bar_set_bar_style (GtkProgressBar *pbar, GtkProgressBarStyle style); 317 gtk_progress_bar_set_bar_style(gtkProgressBar, style); 318 } 319 320 /** 321 * Warning 322 * gtk_progress_bar_set_discrete_blocks is deprecated and should not be used in newly-written code. 323 * Sets the number of blocks that the progress bar is divided into 324 * when the style is GTK_PROGRESS_DISCRETE. 325 * Params: 326 * blocks = number of individual blocks making up the bar. 327 */ 328 public void setDiscreteBlocks(uint blocks) 329 { 330 // void gtk_progress_bar_set_discrete_blocks (GtkProgressBar *pbar, guint blocks); 331 gtk_progress_bar_set_discrete_blocks(gtkProgressBar, blocks); 332 } 333 334 /** 335 * Warning 336 * gtk_progress_bar_set_activity_step is deprecated and should not be used in newly-written code. 337 * Sets the step value used when the progress bar is in activity 338 * mode. The step is the amount by which the progress is incremented 339 * each iteration. 340 * Params: 341 * step = the amount which the progress is incremented in activity 342 * mode. 343 */ 344 public void setActivityStep(uint step) 345 { 346 // void gtk_progress_bar_set_activity_step (GtkProgressBar *pbar, guint step); 347 gtk_progress_bar_set_activity_step(gtkProgressBar, step); 348 } 349 350 /** 351 * Warning 352 * gtk_progress_bar_set_activity_blocks is deprecated and should not be used in newly-written code. 353 * Sets the number of blocks used when the progress bar is in activity 354 * mode. Larger numbers make the visible block smaller. 355 * Params: 356 * blocks = number of blocks which can fit within the progress bar area. 357 */ 358 public void setActivityBlocks(uint blocks) 359 { 360 // void gtk_progress_bar_set_activity_blocks (GtkProgressBar *pbar, guint blocks); 361 gtk_progress_bar_set_activity_blocks(gtkProgressBar, blocks); 362 } 363 364 /** 365 * Warning 366 * gtk_progress_bar_update is deprecated and should not be used in newly-written code. 367 * This function is deprecated. Please use gtk_progress_set_value() or 368 * gtk_progress_set_percentage() instead. 369 * Params: 370 * percentage = the new percent complete value. 371 */ 372 public void update(double percentage) 373 { 374 // void gtk_progress_bar_update (GtkProgressBar *pbar, gdouble percentage); 375 gtk_progress_bar_update(gtkProgressBar, percentage); 376 } 377 }