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 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 343 } 344 345 /** 346 * Renders an icon previously looked up in an icon theme using 347 * gtk_icon_theme_lookup_icon(); the size will be based on the size 348 * passed to gtk_icon_theme_lookup_icon(). Note that the resulting 349 * pixbuf may not be exactly this size; an icon theme may have icons 350 * that differ slightly from their nominal sizes, and in addition GTK+ 351 * will avoid scaling icons that it considers sufficiently close to the 352 * requested size or for which the source image would have to be scaled 353 * up too far. (This maintains sharpness.). This behaviour can be changed 354 * by passing the GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining 355 * the GtkIconInfo. If this flag has been specified, the pixbuf 356 * returned by this function will be scaled to the exact size. 357 * Since 2.4 358 * 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] 359 * Throws: GException on failure. 360 */ 361 public Pixbuf loadIcon() 362 { 363 // GdkPixbuf * gtk_icon_info_load_icon (GtkIconInfo *icon_info, GError **error); 364 GError* err = null; 365 366 auto p = gtk_icon_info_load_icon(gtkIconInfo, &err); 367 368 if (err !is null) 369 { 370 throw new GException( new ErrorG(err) ); 371 } 372 373 374 if(p is null) 375 { 376 return null; 377 } 378 379 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 380 } 381 382 /** 383 * Renders an icon previously looked up in an icon theme using 384 * gtk_icon_theme_lookup_icon(); the size will be based on the size 385 * passed to gtk_icon_theme_lookup_icon(). Note that the resulting 386 * surface may not be exactly this size; an icon theme may have icons 387 * that differ slightly from their nominal sizes, and in addition GTK+ 388 * will avoid scaling icons that it considers sufficiently close to the 389 * requested size or for which the source image would have to be scaled 390 * up too far. (This maintains sharpness.). This behaviour can be changed 391 * by passing the GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining 392 * the GtkIconInfo. If this flag has been specified, the pixbuf 393 * returned by this function will be scaled to the exact size. 394 * Params: 395 * forWindow = GdkWindow to optimize drawing for, or NULL. [allow-none] 396 * 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 397 * Throws: GException on failure. 398 */ 399 public Surface loadSurface(Window forWindow) 400 { 401 // cairo_surface_t * gtk_icon_info_load_surface (GtkIconInfo *icon_info, GdkWindow *for_window, GError **error); 402 GError* err = null; 403 404 auto p = gtk_icon_info_load_surface(gtkIconInfo, (forWindow is null) ? null : forWindow.getWindowStruct(), &err); 405 406 if (err !is null) 407 { 408 throw new GException( new ErrorG(err) ); 409 } 410 411 412 if(p is null) 413 { 414 return null; 415 } 416 417 return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p); 418 } 419 420 /** 421 * Asynchronously load, render and scale an icon previously looked up 422 * from the icon theme using gtk_icon_theme_lookup_icon(). 423 * For more details, see gtk_icon_info_load_icon() which is the synchronous 424 * version of this call. 425 * Params: 426 * cancellable = optional GCancellable object, 427 * NULL to ignore. [allow-none] 428 * callback = a GAsyncReadyCallback to call when the 429 * request is satisfied. [scope async] 430 * userData = the data to pass to callback function. [closure] 431 * Since 3.8 432 */ 433 public void loadIconAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 434 { 435 // void gtk_icon_info_load_icon_async (GtkIconInfo *icon_info, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 436 gtk_icon_info_load_icon_async(gtkIconInfo, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 437 } 438 439 /** 440 * Finishes an async icon load, see gtk_icon_info_load_icon_async(). 441 * Params: 442 * res = a GAsyncResult 443 * 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 444 * Throws: GException on failure. 445 */ 446 public Pixbuf loadIconFinish(AsyncResultIF res) 447 { 448 // GdkPixbuf * gtk_icon_info_load_icon_finish (GtkIconInfo *icon_info, GAsyncResult *res, GError **error); 449 GError* err = null; 450 451 auto p = gtk_icon_info_load_icon_finish(gtkIconInfo, (res is null) ? null : res.getAsyncResultTStruct(), &err); 452 453 if (err !is null) 454 { 455 throw new GException( new ErrorG(err) ); 456 } 457 458 459 if(p is null) 460 { 461 return null; 462 } 463 464 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 465 } 466 467 /** 468 * Loads an icon, modifying it to match the system colours for the foreground, 469 * success, warning and error colors provided. If the icon is not a symbolic 470 * one, the function will return the result from gtk_icon_info_load_icon(). 471 * This allows loading symbolic icons that will match the system theme. 472 * Unless you are implementing a widget, you will want to use 473 * g_themed_icon_new_with_default_fallbacks() to load the icon. 474 * As implementation details, the icon loaded needs to be of SVG type, 475 * contain the "symbolic" term as the last component of the icon name, 476 * and use the 'fg', 'success', 'warning' and 'error' CSS styles in the 477 * SVG file itself. 478 * See the Symbolic Icons spec 479 * for more information about symbolic icons. 480 * Params: 481 * fg = a GdkRGBA representing the foreground color of the icon 482 * successColor = a GdkRGBA representing the warning color 483 * of the icon or NULL to use the default color. [allow-none] 484 * warningColor = a GdkRGBA representing the warning color 485 * of the icon or NULL to use the default color. [allow-none] 486 * errorColor = a GdkRGBA representing the error color 487 * of the icon or NULL to use the default color (allow-none). [allow-none] 488 * wasSymbolic = a gboolean, returns whether the 489 * loaded icon was a symbolic one and whether the fg color was 490 * applied to it. [out][allow-none] 491 * error = location to store error information on failure, 492 * or NULL. [allow-none] 493 * Returns: a GdkPixbuf representing the loaded icon. [transfer full] Since 3.0 494 * Throws: GException on failure. 495 */ 496 public Pixbuf loadSymbolic(RGBA fg, RGBA successColor, RGBA warningColor, RGBA errorColor, out int wasSymbolic) 497 { 498 // 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); 499 GError* err = null; 500 501 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); 502 503 if (err !is null) 504 { 505 throw new GException( new ErrorG(err) ); 506 } 507 508 509 if(p is null) 510 { 511 return null; 512 } 513 514 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 515 } 516 517 /** 518 * Asynchronously load, render and scale a symbolic icon previously looked up 519 * from the icon theme using gtk_icon_theme_lookup_icon(). 520 * For more details, see gtk_icon_info_load_symbolic() which is the synchronous 521 * version of this call. 522 * Params: 523 * fg = a GdkRGBA representing the foreground color of the icon 524 * successColor = a GdkRGBA representing the warning color 525 * of the icon or NULL to use the default color. [allow-none] 526 * warningColor = a GdkRGBA representing the warning color 527 * of the icon or NULL to use the default color. [allow-none] 528 * errorColor = a GdkRGBA representing the error color 529 * of the icon or NULL to use the default color (allow-none). [allow-none] 530 * cancellable = optional GCancellable object, 531 * NULL to ignore. [allow-none] 532 * callback = a GAsyncReadyCallback to call when the 533 * request is satisfied. [scope async] 534 * userData = the data to pass to callback function. [closure] 535 * Since 3.8 536 */ 537 public void loadSymbolicAsync(RGBA fg, RGBA successColor, RGBA warningColor, RGBA errorColor, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 538 { 539 // 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); 540 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); 541 } 542 543 /** 544 * Finishes an async icon load, see gtk_icon_info_load_symbolic_async(). 545 * Params: 546 * res = a GAsyncResult 547 * wasSymbolic = a gboolean, returns whether the 548 * loaded icon was a symbolic one and whether the fg color was 549 * applied to it. [out][allow-none] 550 * 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 551 * Throws: GException on failure. 552 */ 553 public Pixbuf loadSymbolicFinish(AsyncResultIF res, out int wasSymbolic) 554 { 555 // GdkPixbuf * gtk_icon_info_load_symbolic_finish (GtkIconInfo *icon_info, GAsyncResult *res, gboolean *was_symbolic, GError **error); 556 GError* err = null; 557 558 auto p = gtk_icon_info_load_symbolic_finish(gtkIconInfo, (res is null) ? null : res.getAsyncResultTStruct(), &wasSymbolic, &err); 559 560 if (err !is null) 561 { 562 throw new GException( new ErrorG(err) ); 563 } 564 565 566 if(p is null) 567 { 568 return null; 569 } 570 571 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 572 } 573 574 /** 575 * Warning 576 * 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 577 * Loads an icon, modifying it to match the system colours for the foreground, 578 * success, warning and error colors provided. If the icon is not a symbolic 579 * one, the function will return the result from gtk_icon_info_load_icon(). 580 * This allows loading symbolic icons that will match the system theme. 581 * See gtk_icon_info_load_symbolic() for more details. 582 * Params: 583 * style = a GtkStyle to take the colors from 584 * state = the widget state to use for colors 585 * wasSymbolic = a gboolean, returns whether the 586 * loaded icon was a symbolic one and whether the fg color was 587 * applied to it. [out][allow-none] 588 * Returns: a GdkPixbuf representing the loaded icon. [transfer full] Since 3.0 589 * Throws: GException on failure. 590 */ 591 public Pixbuf loadSymbolicForStyle(Style style, GtkStateType state, out int wasSymbolic) 592 { 593 // GdkPixbuf * gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info, GtkStyle *style, GtkStateType state, gboolean *was_symbolic, GError **error); 594 GError* err = null; 595 596 auto p = gtk_icon_info_load_symbolic_for_style(gtkIconInfo, (style is null) ? null : style.getStyleStruct(), state, &wasSymbolic, &err); 597 598 if (err !is null) 599 { 600 throw new GException( new ErrorG(err) ); 601 } 602 603 604 if(p is null) 605 { 606 return null; 607 } 608 609 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 610 } 611 612 /** 613 * Loads an icon, modifying it to match the system colors for the foreground, 614 * success, warning and error colors provided. If the icon is not a symbolic 615 * one, the function will return the result from gtk_icon_info_load_icon(). 616 * This function uses the regular foreground color and the symbolic colors 617 * with the names "success_color", "warning_color" and "error_color" from 618 * the context. 619 * This allows loading symbolic icons that will match the system theme. 620 * See gtk_icon_info_load_symbolic() for more details. 621 * Params: 622 * context = a GtkStyleContext 623 * wasSymbolic = a gboolean, returns whether the 624 * loaded icon was a symbolic one and whether the fg color was 625 * applied to it. [out][allow-none] 626 * Returns: a GdkPixbuf representing the loaded icon. [transfer full] Since 3.0 627 * Throws: GException on failure. 628 */ 629 public Pixbuf loadSymbolicForContext(StyleContext context, int* wasSymbolic) 630 { 631 // GdkPixbuf * gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info, GtkStyleContext *context, gboolean *was_symbolic, GError **error); 632 GError* err = null; 633 634 auto p = gtk_icon_info_load_symbolic_for_context(gtkIconInfo, (context is null) ? null : context.getStyleContextStruct(), wasSymbolic, &err); 635 636 if (err !is null) 637 { 638 throw new GException( new ErrorG(err) ); 639 } 640 641 642 if(p is null) 643 { 644 return null; 645 } 646 647 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 648 } 649 650 /** 651 * Asynchronously load, render and scale a symbolic icon previously looked up 652 * from the icon theme using gtk_icon_theme_lookup_icon(). 653 * For more details, see gtk_icon_info_load_symbolic_for_context() which is the synchronous 654 * version of this call. 655 * Params: 656 * context = a GtkStyleContext 657 * cancellable = optional GCancellable object, 658 * NULL to ignore. [allow-none] 659 * callback = a GAsyncReadyCallback to call when the 660 * request is satisfied. [scope async] 661 * userData = the data to pass to callback function. [closure] 662 * Since 3.8 663 */ 664 public void loadSymbolicForContextAsync(StyleContext context, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 665 { 666 // void gtk_icon_info_load_symbolic_for_context_async (GtkIconInfo *icon_info, GtkStyleContext *context, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 667 gtk_icon_info_load_symbolic_for_context_async(gtkIconInfo, (context is null) ? null : context.getStyleContextStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 668 } 669 670 /** 671 * Finishes an async icon load, see gtk_icon_info_load_symbolic_for_context_async(). 672 * Params: 673 * res = a GAsyncResult 674 * wasSymbolic = a gboolean, returns whether the 675 * loaded icon was a symbolic one and whether the fg color was 676 * applied to it. [out][allow-none] 677 * 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 678 * Throws: GException on failure. 679 */ 680 public Pixbuf loadSymbolicForContextFinish(AsyncResultIF res, out int wasSymbolic) 681 { 682 // GdkPixbuf * gtk_icon_info_load_symbolic_for_context_finish (GtkIconInfo *icon_info, GAsyncResult *res, gboolean *was_symbolic, GError **error); 683 GError* err = null; 684 685 auto p = gtk_icon_info_load_symbolic_for_context_finish(gtkIconInfo, (res is null) ? null : res.getAsyncResultTStruct(), &wasSymbolic, &err); 686 687 if (err !is null) 688 { 689 throw new GException( new ErrorG(err) ); 690 } 691 692 693 if(p is null) 694 { 695 return null; 696 } 697 698 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 699 } 700 701 /** 702 * Sets whether the coordinates returned by gtk_icon_info_get_embedded_rect() 703 * and gtk_icon_info_get_attach_points() should be returned in their 704 * original form as specified in the icon theme, instead of scaled 705 * appropriately for the pixbuf returned by gtk_icon_info_load_icon(). 706 * Raw coordinates are somewhat strange; they are specified to be with 707 * respect to the unscaled pixmap for PNG and XPM icons, but for SVG 708 * icons, they are in a 1000x1000 coordinate space that is scaled 709 * to the final size of the icon. You can determine if the icon is an SVG 710 * icon by using gtk_icon_info_get_filename(), and seeing if it is non-NULL 711 * and ends in '.svg'. 712 * This function is provided primarily to allow compatibility wrappers 713 * for older API's, and is not expected to be useful for applications. 714 * Since 2.4 715 * Params: 716 * rawCoordinates = whether the coordinates of embedded rectangles 717 * and attached points should be returned in their original 718 * (unscaled) form. 719 */ 720 public void setRawCoordinates(int rawCoordinates) 721 { 722 // void gtk_icon_info_set_raw_coordinates (GtkIconInfo *icon_info, gboolean raw_coordinates); 723 gtk_icon_info_set_raw_coordinates(gtkIconInfo, rawCoordinates); 724 } 725 726 /** 727 * Gets the coordinates of a rectangle within the icon 728 * that can be used for display of information such 729 * as a preview of the contents of a text file. 730 * See gtk_icon_info_set_raw_coordinates() for further 731 * information about the coordinate system. 732 * Since 2.4 733 * Params: 734 * rectangle = GdkRectangle in which to store embedded 735 * rectangle coordinates; coordinates are only stored 736 * when this function returns TRUE. [out] 737 * Returns: TRUE if the icon has an embedded rectangle 738 */ 739 public int getEmbeddedRect(out Rectangle rectangle) 740 { 741 // gboolean gtk_icon_info_get_embedded_rect (GtkIconInfo *icon_info, GdkRectangle *rectangle); 742 return gtk_icon_info_get_embedded_rect(gtkIconInfo, &rectangle); 743 } 744 745 /** 746 * Fetches the set of attach points for an icon. An attach point 747 * is a location in the icon that can be used as anchor points for attaching 748 * emblems or overlays to the icon. 749 * Since 2.4 750 * Params: 751 * points = location to store pointer to an array of points, or NULL 752 * free the array of points with g_free(). [allow-none][array length=n_points][out] 753 * Returns: TRUE if there are any attach points for the icon. 754 */ 755 public int getAttachPoints(out GdkPoint[] points) 756 { 757 // gboolean gtk_icon_info_get_attach_points (GtkIconInfo *icon_info, GdkPoint **points, gint *n_points); 758 GdkPoint* outpoints = null; 759 int nPoints; 760 761 auto p = gtk_icon_info_get_attach_points(gtkIconInfo, &outpoints, &nPoints); 762 763 points = outpoints[0 .. nPoints]; 764 return p; 765 } 766 767 /** 768 * Gets the display name for an icon. A display name is a 769 * string to be used in place of the icon name in a user 770 * visible context like a list of icons. 771 * Since 2.4 772 * Signal Details 773 * The "changed" signal 774 * void user_function (GtkIconTheme *icon_theme, 775 * gpointer user_data) : Run Last 776 * Emitted when the current icon theme is switched or GTK+ detects 777 * that a change has occurred in the contents of the current 778 * icon theme. 779 * 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. 780 */ 781 public string getDisplayName() 782 { 783 // const gchar * gtk_icon_info_get_display_name (GtkIconInfo *icon_info); 784 return Str.toString(gtk_icon_info_get_display_name(gtkIconInfo)); 785 } 786 }