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