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.IconSource; 26 27 private import gdkpixbuf.Pixbuf; 28 private import glib.ConstructionException; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gtkc.Loader; 32 private import gtkc.gtk; 33 public import gtkc.gtktypes; 34 private import gtkc.paths; 35 36 37 public class IconSource 38 { 39 /** the main Gtk struct */ 40 protected GtkIconSource* gtkIconSource; 41 42 /** Get the main Gtk struct */ 43 public GtkIconSource* getIconSourceStruct() 44 { 45 return gtkIconSource; 46 } 47 48 /** the main Gtk struct as a void* */ 49 protected void* getStruct() 50 { 51 return cast(void*)gtkIconSource; 52 } 53 54 /** 55 * Sets our main struct and passes it to the parent class. 56 */ 57 public this (GtkIconSource* gtkIconSource) 58 { 59 this.gtkIconSource = gtkIconSource; 60 } 61 62 ~this () 63 { 64 if ( Linker.isLoaded(LIBRARY.GTK) && gtkIconSource !is null ) 65 { 66 gtk_icon_source_free(gtkIconSource); 67 } 68 } 69 70 /** 71 */ 72 73 public static GType getType() 74 { 75 return gtk_icon_source_get_type(); 76 } 77 78 /** 79 * Creates a new #GtkIconSource. A #GtkIconSource contains a #GdkPixbuf (or 80 * image filename) that serves as the base image for one or more of the 81 * icons in a #GtkIconSet, along with a specification for which icons in the 82 * icon set will be based on that pixbuf or image file. An icon set contains 83 * a set of icons that represent “the same” logical concept in different states, 84 * different global text directions, and different sizes. 85 * 86 * So for example a web browser’s “Back to Previous Page” icon might 87 * point in a different direction in Hebrew and in English; it might 88 * look different when insensitive; and it might change size depending 89 * on toolbar mode (small/large icons). So a single icon set would 90 * contain all those variants of the icon. #GtkIconSet contains a list 91 * of #GtkIconSource from which it can derive specific icon variants in 92 * the set. 93 * 94 * In the simplest case, #GtkIconSet contains one source pixbuf from 95 * which it derives all variants. The convenience function 96 * gtk_icon_set_new_from_pixbuf() handles this case; if you only have 97 * one source pixbuf, just use that function. 98 * 99 * If you want to use a different base pixbuf for different icon 100 * variants, you create multiple icon sources, mark which variants 101 * they’ll be used to create, and add them to the icon set with 102 * gtk_icon_set_add_source(). 103 * 104 * By default, the icon source has all parameters wildcarded. That is, 105 * the icon source will be used as the base icon for any desired text 106 * direction, widget state, or icon size. 107 * 108 * Deprecated: Use #GtkIconTheme instead. 109 * 110 * Return: a new #GtkIconSource 111 * 112 * Throws: ConstructionException GTK+ fails to create the object. 113 */ 114 public this() 115 { 116 auto p = gtk_icon_source_new(); 117 118 if(p is null) 119 { 120 throw new ConstructionException("null returned by new"); 121 } 122 123 this(cast(GtkIconSource*) p); 124 } 125 126 /** 127 * Creates a copy of @source; mostly useful for language bindings. 128 * 129 * Deprecated: Use #GtkIconTheme instead. 130 * 131 * Return: a new #GtkIconSource 132 */ 133 public IconSource copy() 134 { 135 auto p = gtk_icon_source_copy(gtkIconSource); 136 137 if(p is null) 138 { 139 return null; 140 } 141 142 return ObjectG.getDObject!(IconSource)(cast(GtkIconSource*) p); 143 } 144 145 /** 146 * Frees a dynamically-allocated icon source, along with its 147 * filename, size, and pixbuf fields if those are not %NULL. 148 * 149 * Deprecated: Use #GtkIconTheme instead. 150 */ 151 public void free() 152 { 153 gtk_icon_source_free(gtkIconSource); 154 } 155 156 /** 157 * Obtains the text direction this icon source applies to. The return 158 * value is only useful/meaningful if the text direction is not 159 * wildcarded. 160 * 161 * Deprecated: Use #GtkIconTheme instead. 162 * 163 * Return: text direction this source matches 164 */ 165 public GtkTextDirection getDirection() 166 { 167 return gtk_icon_source_get_direction(gtkIconSource); 168 } 169 170 /** 171 * Gets the value set by gtk_icon_source_set_direction_wildcarded(). 172 * 173 * Deprecated: Use #GtkIconTheme instead. 174 * 175 * Return: %TRUE if this icon source is a base for any text direction variant 176 */ 177 public bool getDirectionWildcarded() 178 { 179 return gtk_icon_source_get_direction_wildcarded(gtkIconSource) != 0; 180 } 181 182 /** 183 * Retrieves the source filename, or %NULL if none is set. The 184 * filename is not a copy, and should not be modified or expected to 185 * persist beyond the lifetime of the icon source. 186 * 187 * Deprecated: Use #GtkIconTheme instead. 188 * 189 * Return: image filename. This string must not 190 * be modified or freed. 191 */ 192 public string getFilename() 193 { 194 return Str.toString(gtk_icon_source_get_filename(gtkIconSource)); 195 } 196 197 /** 198 * Retrieves the source icon name, or %NULL if none is set. The 199 * icon_name is not a copy, and should not be modified or expected to 200 * persist beyond the lifetime of the icon source. 201 * 202 * Deprecated: Use #GtkIconTheme instead. 203 * 204 * Return: icon name. This string must not be modified or freed. 205 */ 206 public string getIconName() 207 { 208 return Str.toString(gtk_icon_source_get_icon_name(gtkIconSource)); 209 } 210 211 /** 212 * Retrieves the source pixbuf, or %NULL if none is set. 213 * In addition, if a filename source is in use, this 214 * function in some cases will return the pixbuf from 215 * loaded from the filename. This is, for example, true 216 * for the GtkIconSource passed to the #GtkStyle render_icon() 217 * virtual function. The reference count on the pixbuf is 218 * not incremented. 219 * 220 * Deprecated: Use #GtkIconTheme instead. 221 * 222 * Return: source pixbuf 223 */ 224 public Pixbuf getPixbuf() 225 { 226 auto p = gtk_icon_source_get_pixbuf(gtkIconSource); 227 228 if(p is null) 229 { 230 return null; 231 } 232 233 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 234 } 235 236 /** 237 * Obtains the icon size this source applies to. The return value 238 * is only useful/meaningful if the icon size is not wildcarded. 239 * 240 * Deprecated: Use #GtkIconTheme instead. 241 * 242 * Return: icon size this source matches. 243 */ 244 public GtkIconSize getSize() 245 { 246 return gtk_icon_source_get_size(gtkIconSource); 247 } 248 249 /** 250 * Gets the value set by gtk_icon_source_set_size_wildcarded(). 251 * 252 * Deprecated: Use #GtkIconTheme instead. 253 * 254 * Return: %TRUE if this icon source is a base for any icon size variant 255 */ 256 public bool getSizeWildcarded() 257 { 258 return gtk_icon_source_get_size_wildcarded(gtkIconSource) != 0; 259 } 260 261 /** 262 * Obtains the widget state this icon source applies to. The return 263 * value is only useful/meaningful if the widget state is not 264 * wildcarded. 265 * 266 * Deprecated: Use #GtkIconTheme instead. 267 * 268 * Return: widget state this source matches 269 */ 270 public GtkStateType getState() 271 { 272 return gtk_icon_source_get_state(gtkIconSource); 273 } 274 275 /** 276 * Gets the value set by gtk_icon_source_set_state_wildcarded(). 277 * 278 * Deprecated: Use #GtkIconTheme instead. 279 * 280 * Return: %TRUE if this icon source is a base for any widget state variant 281 */ 282 public bool getStateWildcarded() 283 { 284 return gtk_icon_source_get_state_wildcarded(gtkIconSource) != 0; 285 } 286 287 /** 288 * Sets the text direction this icon source is intended to be used 289 * with. 290 * 291 * Setting the text direction on an icon source makes no difference 292 * if the text direction is wildcarded. Therefore, you should usually 293 * call gtk_icon_source_set_direction_wildcarded() to un-wildcard it 294 * in addition to calling this function. 295 * 296 * Deprecated: Use #GtkIconTheme instead. 297 * 298 * Params: 299 * direction = text direction this source applies to 300 */ 301 public void setDirection(GtkTextDirection direction) 302 { 303 gtk_icon_source_set_direction(gtkIconSource, direction); 304 } 305 306 /** 307 * If the text direction is wildcarded, this source can be used 308 * as the base image for an icon in any #GtkTextDirection. 309 * If the text direction is not wildcarded, then the 310 * text direction the icon source applies to should be set 311 * with gtk_icon_source_set_direction(), and the icon source 312 * will only be used with that text direction. 313 * 314 * #GtkIconSet prefers non-wildcarded sources (exact matches) over 315 * wildcarded sources, and will use an exact match when possible. 316 * 317 * Deprecated: Use #GtkIconTheme instead. 318 * 319 * Params: 320 * setting = %TRUE to wildcard the text direction 321 */ 322 public void setDirectionWildcarded(bool setting) 323 { 324 gtk_icon_source_set_direction_wildcarded(gtkIconSource, setting); 325 } 326 327 /** 328 * Sets the name of an image file to use as a base image when creating 329 * icon variants for #GtkIconSet. The filename must be absolute. 330 * 331 * Deprecated: Use #GtkIconTheme instead. 332 * 333 * Params: 334 * filename = image file to use 335 */ 336 public void setFilename(string filename) 337 { 338 gtk_icon_source_set_filename(gtkIconSource, Str.toStringz(filename)); 339 } 340 341 /** 342 * Sets the name of an icon to look up in the current icon theme 343 * to use as a base image when creating icon variants for #GtkIconSet. 344 * 345 * Deprecated: Use #GtkIconTheme instead. 346 * 347 * Params: 348 * iconName = name of icon to use 349 */ 350 public void setIconName(string iconName) 351 { 352 gtk_icon_source_set_icon_name(gtkIconSource, Str.toStringz(iconName)); 353 } 354 355 /** 356 * Sets a pixbuf to use as a base image when creating icon variants 357 * for #GtkIconSet. 358 * 359 * Deprecated: Use #GtkIconTheme instead. 360 * 361 * Params: 362 * pixbuf = pixbuf to use as a source 363 */ 364 public void setPixbuf(Pixbuf pixbuf) 365 { 366 gtk_icon_source_set_pixbuf(gtkIconSource, (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 367 } 368 369 /** 370 * Sets the icon size this icon source is intended to be used 371 * with. 372 * 373 * Setting the icon size on an icon source makes no difference 374 * if the size is wildcarded. Therefore, you should usually 375 * call gtk_icon_source_set_size_wildcarded() to un-wildcard it 376 * in addition to calling this function. 377 * 378 * Deprecated: Use #GtkIconTheme instead. 379 * 380 * Params: 381 * size = icon size this source applies to 382 */ 383 public void setSize(GtkIconSize size) 384 { 385 gtk_icon_source_set_size(gtkIconSource, size); 386 } 387 388 /** 389 * If the icon size is wildcarded, this source can be used as the base 390 * image for an icon of any size. If the size is not wildcarded, then 391 * the size the source applies to should be set with 392 * gtk_icon_source_set_size() and the icon source will only be used 393 * with that specific size. 394 * 395 * #GtkIconSet prefers non-wildcarded sources (exact matches) over 396 * wildcarded sources, and will use an exact match when possible. 397 * 398 * #GtkIconSet will normally scale wildcarded source images to produce 399 * an appropriate icon at a given size, but will not change the size 400 * of source images that match exactly. 401 * 402 * Deprecated: Use #GtkIconTheme instead. 403 * 404 * Params: 405 * setting = %TRUE to wildcard the widget state 406 */ 407 public void setSizeWildcarded(bool setting) 408 { 409 gtk_icon_source_set_size_wildcarded(gtkIconSource, setting); 410 } 411 412 /** 413 * Sets the widget state this icon source is intended to be used 414 * with. 415 * 416 * Setting the widget state on an icon source makes no difference 417 * if the state is wildcarded. Therefore, you should usually 418 * call gtk_icon_source_set_state_wildcarded() to un-wildcard it 419 * in addition to calling this function. 420 * 421 * Deprecated: Use #GtkIconTheme instead. 422 * 423 * Params: 424 * state = widget state this source applies to 425 */ 426 public void setState(GtkStateType state) 427 { 428 gtk_icon_source_set_state(gtkIconSource, state); 429 } 430 431 /** 432 * If the widget state is wildcarded, this source can be used as the 433 * base image for an icon in any #GtkStateType. If the widget state 434 * is not wildcarded, then the state the source applies to should be 435 * set with gtk_icon_source_set_state() and the icon source will 436 * only be used with that specific state. 437 * 438 * #GtkIconSet prefers non-wildcarded sources (exact matches) over 439 * wildcarded sources, and will use an exact match when possible. 440 * 441 * #GtkIconSet will normally transform wildcarded source images to 442 * produce an appropriate icon for a given state, for example 443 * lightening an image on prelight, but will not modify source images 444 * that match exactly. 445 * 446 * Deprecated: Use #GtkIconTheme instead. 447 * 448 * Params: 449 * setting = %TRUE to wildcard the widget state 450 */ 451 public void setStateWildcarded(bool setting) 452 { 453 gtk_icon_source_set_state_wildcarded(gtkIconSource, setting); 454 } 455 }