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