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 module gtk.ProgressBar; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtk.OrientableIF; 31 private import gtk.OrientableT; 32 private import gtk.Widget; 33 private import gtkc.gtk; 34 public import gtkc.gtktypes; 35 36 37 /** 38 * The #GtkProgressBar is typically used to display the progress of a long 39 * running operation. It provides a visual clue that processing is underway. 40 * The GtkProgressBar can be used in two different modes: percentage mode 41 * and activity mode. 42 * 43 * When an application can determine how much work needs to take place 44 * (e.g. read a fixed number of bytes from a file) and can monitor its 45 * progress, it can use the GtkProgressBar in percentage mode and the 46 * user sees a growing bar indicating the percentage of the work that 47 * has been completed. In this mode, the application is required to call 48 * gtk_progress_bar_set_fraction() periodically to update the progress bar. 49 * 50 * When an application has no accurate way of knowing the amount of work 51 * to do, it can use the #GtkProgressBar in activity mode, which shows 52 * activity by a block moving back and forth within the progress area. In 53 * this mode, the application is required to call gtk_progress_bar_pulse() 54 * periodically to update the progress bar. 55 * 56 * There is quite a bit of flexibility provided to control the appearance 57 * of the #GtkProgressBar. Functions are provided to control the orientation 58 * of the bar, optional text can be displayed along with the bar, and the 59 * step size used in activity mode can be set. 60 * 61 * # CSS nodes 62 * 63 * |[<!-- language="plain" --> 64 * progressbar[.osd] 65 * ╰── trough[.empty][.full] 66 * ├── [text] 67 * ╰── progress[.pulse] 68 * ]| 69 * 70 * GtkProgressBar has a main CSS node with name progressbar and subnodes with 71 * names text, trough and progress. The text subnode is only present if text 72 * is shown. The progress subnode has the style class .pulse when in activity 73 * mode. It gets the style classes .left, .right, .top or .bottom added when 74 * the progress 'touches' the corresponding end of the GtkProgressBar. 75 * The .osd class on the progressbar node is for use in overlays like the one 76 * epiphany has for page loading progress. 77 */ 78 public class ProgressBar : Widget, OrientableIF 79 { 80 /** the main Gtk struct */ 81 protected GtkProgressBar* gtkProgressBar; 82 83 /** Get the main Gtk struct */ 84 public GtkProgressBar* getProgressBarStruct() 85 { 86 return gtkProgressBar; 87 } 88 89 /** the main Gtk struct as a void* */ 90 protected override void* getStruct() 91 { 92 return cast(void*)gtkProgressBar; 93 } 94 95 protected override void setStruct(GObject* obj) 96 { 97 gtkProgressBar = cast(GtkProgressBar*)obj; 98 super.setStruct(obj); 99 } 100 101 /** 102 * Sets our main struct and passes it to the parent class. 103 */ 104 public this (GtkProgressBar* gtkProgressBar, bool ownedRef = false) 105 { 106 this.gtkProgressBar = gtkProgressBar; 107 super(cast(GtkWidget*)gtkProgressBar, ownedRef); 108 } 109 110 // add the Orientable capabilities 111 mixin OrientableT!(GtkProgressBar); 112 113 114 /** */ 115 public static GType getType() 116 { 117 return gtk_progress_bar_get_type(); 118 } 119 120 /** 121 * Creates a new #GtkProgressBar. 122 * 123 * Return: a #GtkProgressBar. 124 * 125 * Throws: ConstructionException GTK+ fails to create the object. 126 */ 127 public this() 128 { 129 auto p = gtk_progress_bar_new(); 130 131 if(p is null) 132 { 133 throw new ConstructionException("null returned by new"); 134 } 135 136 this(cast(GtkProgressBar*) p); 137 } 138 139 /** 140 * Returns the ellipsizing position of the progress bar. 141 * See gtk_progress_bar_set_ellipsize(). 142 * 143 * Return: #PangoEllipsizeMode 144 * 145 * Since: 2.6 146 */ 147 public PangoEllipsizeMode getEllipsize() 148 { 149 return gtk_progress_bar_get_ellipsize(gtkProgressBar); 150 } 151 152 /** 153 * Returns the current fraction of the task that’s been completed. 154 * 155 * Return: a fraction from 0.0 to 1.0 156 */ 157 public double getFraction() 158 { 159 return gtk_progress_bar_get_fraction(gtkProgressBar); 160 } 161 162 /** 163 * Gets the value set by gtk_progress_bar_set_inverted(). 164 * 165 * Return: %TRUE if the progress bar is inverted 166 */ 167 public bool getInverted() 168 { 169 return gtk_progress_bar_get_inverted(gtkProgressBar) != 0; 170 } 171 172 /** 173 * Retrieves the pulse step set with gtk_progress_bar_set_pulse_step(). 174 * 175 * Return: a fraction from 0.0 to 1.0 176 */ 177 public double getPulseStep() 178 { 179 return gtk_progress_bar_get_pulse_step(gtkProgressBar); 180 } 181 182 /** 183 * Gets the value of the #GtkProgressBar:show-text property. 184 * See gtk_progress_bar_set_show_text(). 185 * 186 * Return: %TRUE if text is shown in the progress bar 187 * 188 * Since: 3.0 189 */ 190 public bool getShowText() 191 { 192 return gtk_progress_bar_get_show_text(gtkProgressBar) != 0; 193 } 194 195 /** 196 * Retrieves the text that is displayed with the progress bar, 197 * if any, otherwise %NULL. The return value is a reference 198 * to the text, not a copy of it, so will become invalid 199 * if you change the text in the progress bar. 200 * 201 * Return: text, or %NULL; this string is owned by the widget 202 * and should not be modified or freed. 203 */ 204 public string getText() 205 { 206 return Str.toString(gtk_progress_bar_get_text(gtkProgressBar)); 207 } 208 209 /** 210 * Indicates that some progress has been made, but you don’t know how much. 211 * Causes the progress bar to enter “activity mode,” where a block 212 * bounces back and forth. Each call to gtk_progress_bar_pulse() 213 * causes the block to move by a little bit (the amount of movement 214 * per pulse is determined by gtk_progress_bar_set_pulse_step()). 215 */ 216 public void pulse() 217 { 218 gtk_progress_bar_pulse(gtkProgressBar); 219 } 220 221 /** 222 * Sets the mode used to ellipsize (add an ellipsis: "...") the 223 * text if there is not enough space to render the entire string. 224 * 225 * Params: 226 * mode = a #PangoEllipsizeMode 227 * 228 * Since: 2.6 229 */ 230 public void setEllipsize(PangoEllipsizeMode mode) 231 { 232 gtk_progress_bar_set_ellipsize(gtkProgressBar, mode); 233 } 234 235 /** 236 * Causes the progress bar to “fill in” the given fraction 237 * of the bar. The fraction should be between 0.0 and 1.0, 238 * inclusive. 239 * 240 * Params: 241 * fraction = fraction of the task that’s been completed 242 */ 243 public void setFraction(double fraction) 244 { 245 gtk_progress_bar_set_fraction(gtkProgressBar, fraction); 246 } 247 248 /** 249 * Progress bars normally grow from top to bottom or left to right. 250 * Inverted progress bars grow in the opposite direction. 251 * 252 * Params: 253 * inverted = %TRUE to invert the progress bar 254 */ 255 public void setInverted(bool inverted) 256 { 257 gtk_progress_bar_set_inverted(gtkProgressBar, inverted); 258 } 259 260 /** 261 * Sets the fraction of total progress bar length to move the 262 * bouncing block for each call to gtk_progress_bar_pulse(). 263 * 264 * Params: 265 * fraction = fraction between 0.0 and 1.0 266 */ 267 public void setPulseStep(double fraction) 268 { 269 gtk_progress_bar_set_pulse_step(gtkProgressBar, fraction); 270 } 271 272 /** 273 * Sets whether the progress bar will show text next to the bar. 274 * The shown text is either the value of the #GtkProgressBar:text 275 * property or, if that is %NULL, the #GtkProgressBar:fraction value, 276 * as a percentage. 277 * 278 * To make a progress bar that is styled and sized suitably for containing 279 * text (even if the actual text is blank), set #GtkProgressBar:show-text to 280 * %TRUE and #GtkProgressBar:text to the empty string (not %NULL). 281 * 282 * Params: 283 * showText = whether to show superimposed text 284 * 285 * Since: 3.0 286 */ 287 public void setShowText(bool showText) 288 { 289 gtk_progress_bar_set_show_text(gtkProgressBar, showText); 290 } 291 292 /** 293 * Causes the given @text to appear next to the progress bar. 294 * 295 * If @text is %NULL and #GtkProgressBar:show-text is %TRUE, the current 296 * value of #GtkProgressBar:fraction will be displayed as a percentage. 297 * 298 * If @text is non-%NULL and #GtkProgressBar:show-text is %TRUE, the text 299 * will be displayed. In this case, it will not display the progress 300 * percentage. If @text is the empty string, the progress bar will still 301 * be styled and sized suitably for containing text, as long as 302 * #GtkProgressBar:show-text is %TRUE. 303 * 304 * Params: 305 * text = a UTF-8 string, or %NULL 306 */ 307 public void setText(string text) 308 { 309 gtk_progress_bar_set_text(gtkProgressBar, Str.toStringz(text)); 310 } 311 }