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