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 = 27 * outPack = gtk 28 * outFile = IconInfo 29 * strct = GtkIconInfo 30 * realStrct= 31 * ctorStrct= 32 * clss = IconInfo 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_icon_info_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ErrorG 48 * - glib.GException 49 * - cairo.Surface 50 * - gio.AsyncResultIF 51 * - gio.Cancellable 52 * - gdk.Pixbuf 53 * - gdk.RGBA 54 * - gdk.Window 55 * - gtk.IconTheme 56 * - gtk.Style 57 * - gtk.StyleContext 58 * - gtkc.paths 59 * - gtkc.Loader 60 * structWrap: 61 * - GAsyncResult* -> AsyncResultIF 62 * - GCancellable* -> Cancellable 63 * - GdkPixbuf* -> Pixbuf 64 * - GdkRGBA* -> RGBA 65 * - GdkWindow* -> Window 66 * - GtkIconInfo* -> IconInfo 67 * - GtkIconTheme* -> IconTheme 68 * - GtkStyle* -> Style 69 * - GtkStyleContext* -> StyleContext 70 * - cairo_surface_t* -> Surface 71 * module aliases: 72 * local aliases: 73 * overrides: 74 */ 75 76 module gtk.IconInfo; 77 78 public import gtkc.gtktypes; 79 80 private import gtkc.gtk; 81 private import glib.ConstructionException; 82 private import gobject.ObjectG; 83 84 private import gobject.Signals; 85 public import gtkc.gdktypes; 86 private import glib.Str; 87 private import glib.ErrorG; 88 private import glib.GException; 89 private import cairo.Surface; 90 private import gio.AsyncResultIF; 91 private import gio.Cancellable; 92 private import gdk.Pixbuf; 93 private import gdk.RGBA; 94 private import gdk.Window; 95 private import gtk.IconTheme; 96 private import gtk.Style; 97 private import gtk.StyleContext; 98 private import gtkc.paths; 99 private import gtkc.Loader; 100 101 102 103 /** 104 * GtkIconTheme provides a facility for looking up icons by name 105 * and size. The main reason for using a name rather than simply 106 * providing a filename is to allow different icons to be used 107 * depending on what icon theme is selected 108 * by the user. The operation of icon themes on Linux and Unix 109 * follows the Icon 110 * Theme Specification. There is a default icon theme, 111 * named hicolor where applications should install 112 * their icons, but more additional application themes can be 113 * installed as operating system vendors and users choose. 114 * 115 * Named icons are similar to the Themeable Stock Images(3) 116 * facility, and the distinction between the two may be a bit confusing. 117 * A few things to keep in mind: 118 * 119 * Stock images usually are used in conjunction with 120 * Stock Items(3), such as GTK_STOCK_OK or 121 * GTK_STOCK_OPEN. Named icons are easier to set up and therefore 122 * are more useful for new icons that an application wants to 123 * add, such as application icons or window icons. 124 * 125 * Stock images can only be loaded at the symbolic sizes defined 126 * by the GtkIconSize enumeration, or by custom sizes defined 127 * by gtk_icon_size_register(), while named icons are more flexible 128 * and any pixel size can be specified. 129 * 130 * Because stock images are closely tied to stock items, and thus 131 * to actions in the user interface, stock images may come in 132 * multiple variants for different widget states or writing 133 * directions. 134 * 135 * A good rule of thumb is that if there is a stock image for what 136 * you want to use, use it, otherwise use a named icon. It turns 137 * out that internally stock images are generally defined in 138 * terms of one or more named icons. (An example of the 139 * more than one case is icons that depend on writing direction; 140 * GTK_STOCK_GO_FORWARD uses the two themed icons 141 * "gtk-stock-go-forward-ltr" and "gtk-stock-go-forward-rtl".) 142 * 143 * In many cases, named themes are used indirectly, via GtkImage 144 * or stock items, rather than directly, but looking up icons 145 * directly is also simple. The GtkIconTheme object acts 146 * as a database of all the icons in the current theme. You 147 * can create new GtkIconTheme objects, but it's much more 148 * efficient to use the standard icon theme for the GdkScreen 149 * so that the icon information is shared with other people 150 * looking up icons. In the case where the default screen is 151 * being used, looking up an icon can be as simple as: 152 * 153 * $(DDOC_COMMENT example) 154 */ 155 public class IconInfo 156 { 157 158 /** the main Gtk struct */ 159 protected GtkIconInfo* gtkIconInfo; 160 161 162 /** Get the main Gtk struct */ 163 public GtkIconInfo* getIconInfoStruct() 164 { 165 return gtkIconInfo; 166 } 167 168 169 /** the main Gtk struct as a void* */ 170 protected void* getStruct() 171 { 172 return cast(void*)gtkIconInfo; 173 } 174 175 /** 176 * Sets our main struct and passes it to the parent class 177 */ 178 public this (GtkIconInfo* gtkIconInfo) 179 { 180 this.gtkIconInfo = gtkIconInfo; 181 } 182 183 ~this () 184 { 185 if ( Linker.isLoaded(LIBRARY.GTK) && gtkIconInfo !is null ) 186 { 187 gtk_icon_info_free(gtkIconInfo); 188 } 189 } 190 191 /** 192 */ 193 int[string] connectedSignals; 194 195 void delegate(IconInfo)[] onChangedListeners; 196 /** 197 * Emitted when the current icon theme is switched or GTK+ detects 198 * that a change has occurred in the contents of the current 199 * icon theme. 200 */ 201 void addOnChanged(void delegate(IconInfo) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 202 { 203 if ( !("changed" in connectedSignals) ) 204 { 205 Signals.connectData( 206 getStruct(), 207 "changed", 208 cast(GCallback)&callBackChanged, 209 cast(void*)this, 210 null, 211 connectFlags); 212 connectedSignals["changed"] = 1; 213 } 214 onChangedListeners ~= dlg; 215 } 216 extern(C) static void callBackChanged(GtkIconTheme* iconThemeStruct, IconInfo _iconInfo) 217 { 218 foreach ( void delegate(IconInfo) dlg ; _iconInfo.onChangedListeners ) 219 { 220 dlg(_iconInfo); 221 } 222 } 223 224 225 /** 226 * Warning 227 * gtk_icon_info_copy has been deprecated since version 3.8 and should not be used in newly-written code. Use g_object_ref() 228 * Make a copy of a GtkIconInfo. 229 * Since 2.4 230 * Returns: the new GtkIconInfo 231 */ 232 public IconInfo copy() 233 { 234 // GtkIconInfo * gtk_icon_info_copy (GtkIconInfo *icon_info); 235 auto p = gtk_icon_info_copy(gtkIconInfo); 236 237 if(p is null) 238 { 239 return null; 240 } 241 242 return ObjectG.getDObject!(IconInfo)(cast(GtkIconInfo*) p); 243 } 244 245 /** 246 * Warning 247 * gtk_icon_info_free has been deprecated since version 3.8 and should not be used in newly-written code. Use g_object_unref() 248 * Free a GtkIconInfo and associated information 249 * Since 2.4 250 */ 251 public void free() 252 { 253 // void gtk_icon_info_free (GtkIconInfo *icon_info); 254 gtk_icon_info_free(gtkIconInfo); 255 } 256 257 /** 258 * Creates a GtkIconInfo for a GdkPixbuf. 259 * Since 2.14 260 * Params: 261 * iconTheme = a GtkIconTheme 262 * pixbuf = the pixbuf to wrap in a GtkIconInfo 263 * Throws: ConstructionException GTK+ fails to create the object. 264 */ 265 public this (IconTheme iconTheme, Pixbuf pixbuf) 266 { 267 // GtkIconInfo * gtk_icon_info_new_for_pixbuf (GtkIconTheme *icon_theme, GdkPixbuf *pixbuf); 268 auto p = gtk_icon_info_new_for_pixbuf((iconTheme is null) ? null : iconTheme.getIconThemeStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 269 if(p is null) 270 { 271 throw new ConstructionException("null returned by gtk_icon_info_new_for_pixbuf((iconTheme is null) ? null : iconTheme.getIconThemeStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct())"); 272 } 273 this(cast(GtkIconInfo*) p); 274 } 275 276 /** 277 * Gets the base size for the icon. The base size 278 * is a size for the icon that was specified by 279 * the icon theme creator. This may be different 280 * than the actual size of image; an example of 281 * this is small emblem icons that can be attached 282 * to a larger icon. These icons will be given 283 * the same base size as the larger icons to which 284 * they are attached. 285 * Note that for scaled icons the base size does 286 * not include the base scale. 287 * Since 2.4 288 * Returns: the base size, or 0, if no base size is known for the icon. 289 */ 290 public int getBaseSize() 291 { 292 // gint gtk_icon_info_get_base_size (GtkIconInfo *icon_info); 293 return gtk_icon_info_get_base_size(gtkIconInfo); 294 } 295 296 /** 297 * Gets the base scale for the icon. The base scale is a scale for the 298 * icon that was specified by the icon theme creator. For instance an 299 * icon drawn for a high-dpi screen with window-scale 2 for a base 300 * size of 32 will be 64 pixels tall and have a base_scale of 2. 301 * Returns: the base scale. Since 3.10 302 */ 303 public int getBaseScale() 304 { 305 // gint gtk_icon_info_get_base_scale (GtkIconInfo *icon_info); 306 return gtk_icon_info_get_base_scale(gtkIconInfo); 307 } 308 309 /** 310 * Gets the filename for the icon. If the 311 * GTK_ICON_LOOKUP_USE_BUILTIN flag was passed 312 * to gtk_icon_theme_lookup_icon(), there may be 313 * no filename if a builtin icon is returned; in this 314 * case, you should use gtk_icon_info_get_builtin_pixbuf(). 315 * Since 2.4 316 * Returns: the filename for the icon, or NULL if gtk_icon_info_get_builtin_pixbuf() should be used instead. The return value is owned by GTK+ and should not be modified or freed. [type filename] 317 */ 318 public string getFilename() 319 { 320 // const gchar * gtk_icon_info_get_filename (GtkIconInfo *icon_info); 321 return Str.toString(gtk_icon_info_get_filename(gtkIconInfo)); 322 } 323 324 /** 325 * Gets the built-in image for this icon, if any. To allow 326 * GTK+ to use built in icon images, you must pass the 327 * GTK_ICON_LOOKUP_USE_BUILTIN to 328 * gtk_icon_theme_lookup_icon(). 329 * Since 2.4 330 * Returns: the built-in image pixbuf, or NULL. No extra reference is added to the returned pixbuf, so if you want to keep it around, you must use g_object_ref(). The returned image must not be modified. [transfer none] 331 */ 332 public Pixbuf getBuiltinPixbuf() 333 { 334 // GdkPixbuf * gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info); 335 auto p = gtk_icon_info_get_builtin_pixbuf(gtkIconInfo); 336 337 if(p is null) 338 { 339 return null; 340 } 341 342 import gtkc.gobject : g_object_ref; 343 g_object_ref(cast(GObject*)p); 344 345 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 346 } 347 348 /** 349 * Renders an icon previously looked up in an icon theme using 350 * gtk_icon_theme_lookup_icon(); the size will be based on the size 351 * passed to gtk_icon_theme_lookup_icon(). Note that the resulting 352 * pixbuf may not be exactly this size; an icon theme may have icons 353 * that differ slightly from their nominal sizes, and in addition GTK+ 354 * will avoid scaling icons that it considers sufficiently close to the 355 * requested size or for which the source image would have to be scaled 356 * up too far. (This maintains sharpness.). This behaviour can be changed 357 * by passing the GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining 358 * the GtkIconInfo. If this flag has been specified, the pixbuf 359 * returned by this function will be scaled to the exact size. 360 * Since 2.4 361 * Returns: the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon. [transfer full] 362 * Throws: GException on failure. 363 */ 364 public Pixbuf loadIcon() 365 { 366 // GdkPixbuf * gtk_icon_info_load_icon (GtkIconInfo *icon_info, GError **error); 367 GError* err = null; 368 369 auto p = gtk_icon_info_load_icon(gtkIconInfo, &err); 370 371 if (err !is null) 372 { 373 throw new GException( new ErrorG(err) ); 374 } 375 376 377 if(p is null) 378 { 379 return null; 380 } 381 382 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 383 } 384 385 /** 386 * Renders an icon previously looked up in an icon theme using 387 * gtk_icon_theme_lookup_icon(); the size will be based on the size 388 * passed to gtk_icon_theme_lookup_icon(). Note that the resulting 389 * surface may not be exactly this size; an icon theme may have icons 390 * that differ slightly from their nominal sizes, and in addition GTK+ 391 * will avoid scaling icons that it considers sufficiently close to the 392 * requested size or for which the source image would have to be scaled 393 * up too far. (This maintains sharpness.). This behaviour can be changed 394 * by passing the GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining 395 * the GtkIconInfo. If this flag has been specified, the pixbuf 396 * returned by this function will be scaled to the exact size. 397 * Params: 398 * forWindow = GdkWindow to optimize drawing for, or NULL. [allow-none] 399 * Returns: the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use cairo_surface_destroy() to release your reference to the icon. [transfer full] Since 3.10 400 * Throws: GException on failure. 401 */ 402 public Surface loadSurface(Window forWindow) 403 { 404 // cairo_surface_t * gtk_icon_info_load_surface (GtkIconInfo *icon_info, GdkWindow *for_window, GError **error); 405 GError* err = null; 406 407 auto p = gtk_icon_info_load_surface(gtkIconInfo, (forWindow is null) ? null : forWindow.getWindowStruct(), &err); 408 409 if (err !is null) 410 { 411 throw new GException( new ErrorG(err) ); 412 } 413 414 415 if(p is null) 416 { 417 return null; 418 } 419 420 return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p); 421 } 422 423 /** 424 * Asynchronously load, render and scale an icon previously looked up 425 * from the icon theme using gtk_icon_theme_lookup_icon(). 426 * For more details, see gtk_icon_info_load_icon() which is the synchronous 427 * version of this call. 428 * Params: 429 * cancellable = optional GCancellable object, 430 * NULL to ignore. [allow-none] 431 * callback = a GAsyncReadyCallback to call when the 432 * request is satisfied. [scope async] 433 * userData = the data to pass to callback function. [closure] 434 * Since 3.8 435 */ 436 public void loadIconAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 437 { 438 // void gtk_icon_info_load_icon_async (GtkIconInfo *icon_info, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 439 gtk_icon_info_load_icon_async(gtkIconInfo, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 440 } 441 442 /** 443 * Finishes an async icon load, see gtk_icon_info_load_icon_async(). 444 * Params: 445 * res = a GAsyncResult 446 * Returns: the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon. [transfer full] Since 3.8 447 * Throws: GException on failure. 448 */ 449 public Pixbuf loadIconFinish(AsyncResultIF res) 450 { 451 // GdkPixbuf * gtk_icon_info_load_icon_finish (GtkIconInfo *icon_info, GAsyncResult *res, GError **error); 452 GError* err = null; 453 454 auto p = gtk_icon_info_load_icon_finish(gtkIconInfo, (res is null) ? null : res.getAsyncResultTStruct(), &err); 455 456 if (err !is null) 457 { 458 throw new GException( new ErrorG(err) ); 459 } 460 461 462 if(p is null) 463 { 464 return null; 465 } 466 467 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 468 } 469 470 /** 471 * Loads an icon, modifying it to match the system colours for the foreground, 472 * success, warning and error colors provided. If the icon is not a symbolic 473 * one, the function will return the result from gtk_icon_info_load_icon(). 474 * This allows loading symbolic icons that will match the system theme. 475 * Unless you are implementing a widget, you will want to use 476 * g_themed_icon_new_with_default_fallbacks() to load the icon. 477 * As implementation details, the icon loaded needs to be of SVG type, 478 * contain the "symbolic" term as the last component of the icon name, 479 * and use the 'fg', 'success', 'warning' and 'error' CSS styles in the 480 * SVG file itself. 481 * See the Symbolic Icons spec 482 * for more information about symbolic icons. 483 * Params: 484 * fg = a GdkRGBA representing the foreground color of the icon 485 * successColor = a GdkRGBA representing the warning color 486 * of the icon or NULL to use the default color. [allow-none] 487 * warningColor = a GdkRGBA representing the warning color 488 * of the icon or NULL to use the default color. [allow-none] 489 * errorColor = a GdkRGBA representing the error color 490 * of the icon or NULL to use the default color (allow-none). [allow-none] 491 * wasSymbolic = a gboolean, returns whether the 492 * loaded icon was a symbolic one and whether the fg color was 493 * applied to it. [out][allow-none] 494 * error = location to store error information on failure, 495 * or NULL. [allow-none] 496 * Returns: a GdkPixbuf representing the loaded icon. [transfer full] Since 3.0 497 * Throws: GException on failure. 498 */ 499 public Pixbuf loadSymbolic(RGBA fg, RGBA successColor, RGBA warningColor, RGBA errorColor, out int wasSymbolic) 500 { 501 // GdkPixbuf * gtk_icon_info_load_symbolic (GtkIconInfo *icon_info, const GdkRGBA *fg, const GdkRGBA *success_color, const GdkRGBA *warning_color, const GdkRGBA *error_color, gboolean *was_symbolic, GError **error); 502 GError* err = null; 503 504 auto p = gtk_icon_info_load_symbolic(gtkIconInfo, (fg is null) ? null : fg.getRGBAStruct(), (successColor is null) ? null : successColor.getRGBAStruct(), (warningColor is null) ? null : warningColor.getRGBAStruct(), (errorColor is null) ? null : errorColor.getRGBAStruct(), &wasSymbolic, &err); 505 506 if (err !is null) 507 { 508 throw new GException( new ErrorG(err) ); 509 } 510 511 512 if(p is null) 513 { 514 return null; 515 } 516 517 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 518 } 519 520 /** 521 * Asynchronously load, render and scale a symbolic icon previously looked up 522 * from the icon theme using gtk_icon_theme_lookup_icon(). 523 * For more details, see gtk_icon_info_load_symbolic() which is the synchronous 524 * version of this call. 525 * Params: 526 * fg = a GdkRGBA representing the foreground color of the icon 527 * successColor = a GdkRGBA representing the warning color 528 * of the icon or NULL to use the default color. [allow-none] 529 * warningColor = a GdkRGBA representing the warning color 530 * of the icon or NULL to use the default color. [allow-none] 531 * errorColor = a GdkRGBA representing the error color 532 * of the icon or NULL to use the default color (allow-none). [allow-none] 533 * cancellable = optional GCancellable object, 534 * NULL to ignore. [allow-none] 535 * callback = a GAsyncReadyCallback to call when the 536 * request is satisfied. [scope async] 537 * userData = the data to pass to callback function. [closure] 538 * Since 3.8 539 */ 540 public void loadSymbolicAsync(RGBA fg, RGBA successColor, RGBA warningColor, RGBA errorColor, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 541 { 542 // void gtk_icon_info_load_symbolic_async (GtkIconInfo *icon_info, const GdkRGBA *fg, const GdkRGBA *success_color, const GdkRGBA *warning_color, const GdkRGBA *error_color, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 543 gtk_icon_info_load_symbolic_async(gtkIconInfo, (fg is null) ? null : fg.getRGBAStruct(), (successColor is null) ? null : successColor.getRGBAStruct(), (warningColor is null) ? null : warningColor.getRGBAStruct(), (errorColor is null) ? null : errorColor.getRGBAStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 544 } 545 546 /** 547 * Finishes an async icon load, see gtk_icon_info_load_symbolic_async(). 548 * Params: 549 * res = a GAsyncResult 550 * wasSymbolic = a gboolean, returns whether the 551 * loaded icon was a symbolic one and whether the fg color was 552 * applied to it. [out][allow-none] 553 * Returns: the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon. [transfer full] Since 3.8 554 * Throws: GException on failure. 555 */ 556 public Pixbuf loadSymbolicFinish(AsyncResultIF res, out int wasSymbolic) 557 { 558 // GdkPixbuf * gtk_icon_info_load_symbolic_finish (GtkIconInfo *icon_info, GAsyncResult *res, gboolean *was_symbolic, GError **error); 559 GError* err = null; 560 561 auto p = gtk_icon_info_load_symbolic_finish(gtkIconInfo, (res is null) ? null : res.getAsyncResultTStruct(), &wasSymbolic, &err); 562 563 if (err !is null) 564 { 565 throw new GException( new ErrorG(err) ); 566 } 567 568 569 if(p is null) 570 { 571 return null; 572 } 573 574 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 575 } 576 577 /** 578 * Warning 579 * gtk_icon_info_load_symbolic_for_style has been deprecated since version 3.0 and should not be used in newly-written code. Use gtk_icon_info_load_symbolic_for_context() instead 580 * Loads an icon, modifying it to match the system colours for the foreground, 581 * success, warning and error colors provided. If the icon is not a symbolic 582 * one, the function will return the result from gtk_icon_info_load_icon(). 583 * This allows loading symbolic icons that will match the system theme. 584 * See gtk_icon_info_load_symbolic() for more details. 585 * Params: 586 * style = a GtkStyle to take the colors from 587 * state = the widget state to use for colors 588 * wasSymbolic = a gboolean, returns whether the 589 * loaded icon was a symbolic one and whether the fg color was 590 * applied to it. [out][allow-none] 591 * Returns: a GdkPixbuf representing the loaded icon. [transfer full] Since 3.0 592 * Throws: GException on failure. 593 */ 594 public Pixbuf loadSymbolicForStyle(Style style, GtkStateType state, out int wasSymbolic) 595 { 596 // GdkPixbuf * gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info, GtkStyle *style, GtkStateType state, gboolean *was_symbolic, GError **error); 597 GError* err = null; 598 599 auto p = gtk_icon_info_load_symbolic_for_style(gtkIconInfo, (style is null) ? null : style.getStyleStruct(), state, &wasSymbolic, &err); 600 601 if (err !is null) 602 { 603 throw new GException( new ErrorG(err) ); 604 } 605 606 607 if(p is null) 608 { 609 return null; 610 } 611 612 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 613 } 614 615 /** 616 * Loads an icon, modifying it to match the system colors for the foreground, 617 * success, warning and error colors provided. If the icon is not a symbolic 618 * one, the function will return the result from gtk_icon_info_load_icon(). 619 * This function uses the regular foreground color and the symbolic colors 620 * with the names "success_color", "warning_color" and "error_color" from 621 * the context. 622 * This allows loading symbolic icons that will match the system theme. 623 * See gtk_icon_info_load_symbolic() for more details. 624 * Params: 625 * context = a GtkStyleContext 626 * wasSymbolic = a gboolean, returns whether the 627 * loaded icon was a symbolic one and whether the fg color was 628 * applied to it. [out][allow-none] 629 * Returns: a GdkPixbuf representing the loaded icon. [transfer full] Since 3.0 630 * Throws: GException on failure. 631 */ 632 public Pixbuf loadSymbolicForContext(StyleContext context, int* wasSymbolic) 633 { 634 // GdkPixbuf * gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info, GtkStyleContext *context, gboolean *was_symbolic, GError **error); 635 GError* err = null; 636 637 auto p = gtk_icon_info_load_symbolic_for_context(gtkIconInfo, (context is null) ? null : context.getStyleContextStruct(), wasSymbolic, &err); 638 639 if (err !is null) 640 { 641 throw new GException( new ErrorG(err) ); 642 } 643 644 645 if(p is null) 646 { 647 return null; 648 } 649 650 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 651 } 652 653 /** 654 * Asynchronously load, render and scale a symbolic icon previously looked up 655 * from the icon theme using gtk_icon_theme_lookup_icon(). 656 * For more details, see gtk_icon_info_load_symbolic_for_context() which is the synchronous 657 * version of this call. 658 * Params: 659 * context = a GtkStyleContext 660 * cancellable = optional GCancellable object, 661 * NULL to ignore. [allow-none] 662 * callback = a GAsyncReadyCallback to call when the 663 * request is satisfied. [scope async] 664 * userData = the data to pass to callback function. [closure] 665 * Since 3.8 666 */ 667 public void loadSymbolicForContextAsync(StyleContext context, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 668 { 669 // void gtk_icon_info_load_symbolic_for_context_async (GtkIconInfo *icon_info, GtkStyleContext *context, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 670 gtk_icon_info_load_symbolic_for_context_async(gtkIconInfo, (context is null) ? null : context.getStyleContextStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 671 } 672 673 /** 674 * Finishes an async icon load, see gtk_icon_info_load_symbolic_for_context_async(). 675 * Params: 676 * res = a GAsyncResult 677 * wasSymbolic = a gboolean, returns whether the 678 * loaded icon was a symbolic one and whether the fg color was 679 * applied to it. [out][allow-none] 680 * Returns: the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon. [transfer full] Since 3.8 681 * Throws: GException on failure. 682 */ 683 public Pixbuf loadSymbolicForContextFinish(AsyncResultIF res, out int wasSymbolic) 684 { 685 // GdkPixbuf * gtk_icon_info_load_symbolic_for_context_finish (GtkIconInfo *icon_info, GAsyncResult *res, gboolean *was_symbolic, GError **error); 686 GError* err = null; 687 688 auto p = gtk_icon_info_load_symbolic_for_context_finish(gtkIconInfo, (res is null) ? null : res.getAsyncResultTStruct(), &wasSymbolic, &err); 689 690 if (err !is null) 691 { 692 throw new GException( new ErrorG(err) ); 693 } 694 695 696 if(p is null) 697 { 698 return null; 699 } 700 701 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 702 } 703 704 /** 705 * Sets whether the coordinates returned by gtk_icon_info_get_embedded_rect() 706 * and gtk_icon_info_get_attach_points() should be returned in their 707 * original form as specified in the icon theme, instead of scaled 708 * appropriately for the pixbuf returned by gtk_icon_info_load_icon(). 709 * Raw coordinates are somewhat strange; they are specified to be with 710 * respect to the unscaled pixmap for PNG and XPM icons, but for SVG 711 * icons, they are in a 1000x1000 coordinate space that is scaled 712 * to the final size of the icon. You can determine if the icon is an SVG 713 * icon by using gtk_icon_info_get_filename(), and seeing if it is non-NULL 714 * and ends in '.svg'. 715 * This function is provided primarily to allow compatibility wrappers 716 * for older API's, and is not expected to be useful for applications. 717 * Since 2.4 718 * Params: 719 * rawCoordinates = whether the coordinates of embedded rectangles 720 * and attached points should be returned in their original 721 * (unscaled) form. 722 */ 723 public void setRawCoordinates(int rawCoordinates) 724 { 725 // void gtk_icon_info_set_raw_coordinates (GtkIconInfo *icon_info, gboolean raw_coordinates); 726 gtk_icon_info_set_raw_coordinates(gtkIconInfo, rawCoordinates); 727 } 728 729 /** 730 * Gets the coordinates of a rectangle within the icon 731 * that can be used for display of information such 732 * as a preview of the contents of a text file. 733 * See gtk_icon_info_set_raw_coordinates() for further 734 * information about the coordinate system. 735 * Since 2.4 736 * Params: 737 * rectangle = GdkRectangle in which to store embedded 738 * rectangle coordinates; coordinates are only stored 739 * when this function returns TRUE. [out] 740 * Returns: TRUE if the icon has an embedded rectangle 741 */ 742 public int getEmbeddedRect(out Rectangle rectangle) 743 { 744 // gboolean gtk_icon_info_get_embedded_rect (GtkIconInfo *icon_info, GdkRectangle *rectangle); 745 return gtk_icon_info_get_embedded_rect(gtkIconInfo, &rectangle); 746 } 747 748 /** 749 * Fetches the set of attach points for an icon. An attach point 750 * is a location in the icon that can be used as anchor points for attaching 751 * emblems or overlays to the icon. 752 * Since 2.4 753 * Params: 754 * points = location to store pointer to an array of points, or NULL 755 * free the array of points with g_free(). [allow-none][array length=n_points][out] 756 * Returns: TRUE if there are any attach points for the icon. 757 */ 758 public int getAttachPoints(out GdkPoint[] points) 759 { 760 // gboolean gtk_icon_info_get_attach_points (GtkIconInfo *icon_info, GdkPoint **points, gint *n_points); 761 GdkPoint* outpoints = null; 762 int nPoints; 763 764 auto p = gtk_icon_info_get_attach_points(gtkIconInfo, &outpoints, &nPoints); 765 766 points = outpoints[0 .. nPoints]; 767 return p; 768 } 769 770 /** 771 * Gets the display name for an icon. A display name is a 772 * string to be used in place of the icon name in a user 773 * visible context like a list of icons. 774 * Since 2.4 775 * Signal Details 776 * The "changed" signal 777 * void user_function (GtkIconTheme *icon_theme, 778 * gpointer user_data) : Run Last 779 * Emitted when the current icon theme is switched or GTK+ detects 780 * that a change has occurred in the contents of the current 781 * icon theme. 782 * Returns: the display name for the icon or NULL, if the icon doesn't have a specified display name. This value is owned icon_info and must not be modified or free. 783 */ 784 public string getDisplayName() 785 { 786 // const gchar * gtk_icon_info_get_display_name (GtkIconInfo *icon_info); 787 return Str.toString(gtk_icon_info_get_display_name(gtkIconInfo)); 788 } 789 }