1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.IconPaintable; 26 27 private import gdk.PaintableIF; 28 private import gdk.PaintableT; 29 private import gio.FileIF; 30 private import glib.ConstructionException; 31 private import glib.Str; 32 private import glib.c.functions; 33 private import gobject.ObjectG; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 37 38 /** 39 * Contains information found when looking up an icon in `GtkIconTheme`. 40 * 41 * `GtkIconPaintable` implements `GdkPaintable`. 42 */ 43 public class IconPaintable : ObjectG, PaintableIF 44 { 45 /** the main Gtk struct */ 46 protected GtkIconPaintable* gtkIconPaintable; 47 48 /** Get the main Gtk struct */ 49 public GtkIconPaintable* getIconPaintableStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return gtkIconPaintable; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)gtkIconPaintable; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (GtkIconPaintable* gtkIconPaintable, bool ownedRef = false) 66 { 67 this.gtkIconPaintable = gtkIconPaintable; 68 super(cast(GObject*)gtkIconPaintable, ownedRef); 69 } 70 71 // add the Paintable capabilities 72 mixin PaintableT!(GtkIconPaintable); 73 74 75 /** */ 76 public static GType getType() 77 { 78 return gtk_icon_paintable_get_type(); 79 } 80 81 /** 82 * Creates a `GtkIconPaintable` for a file with a given size and scale. 83 * 84 * The icon can then be rendered by using it as a `GdkPaintable`. 85 * 86 * Params: 87 * file = a `GFile` 88 * size = desired icon size 89 * scale = the desired scale 90 * 91 * Returns: a `GtkIconPaintable` containing 92 * for the icon. Unref with g_object_unref() 93 * 94 * Throws: ConstructionException GTK+ fails to create the object. 95 */ 96 public this(FileIF file, int size, int scale) 97 { 98 auto __p = gtk_icon_paintable_new_for_file((file is null) ? null : file.getFileStruct(), size, scale); 99 100 if(__p is null) 101 { 102 throw new ConstructionException("null returned by new_for_file"); 103 } 104 105 this(cast(GtkIconPaintable*) __p, true); 106 } 107 108 /** 109 * Gets the `GFile` that was used to load the icon. 110 * 111 * Returns %NULL if the icon was not loaded from a file. 112 * 113 * Returns: the #GFile for the icon, or %NULL. 114 * Free with g_object_unref(). 115 */ 116 public FileIF getFile() 117 { 118 auto __p = gtk_icon_paintable_get_file(gtkIconPaintable); 119 120 if(__p is null) 121 { 122 return null; 123 } 124 125 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 126 } 127 128 /** 129 * Get the icon name being used for this icon. 130 * 131 * When an icon looked up in the icon theme was not available, the 132 * icon theme may use fallback icons - either those specified to 133 * gtk_icon_theme_lookup_icon() or the always-available 134 * "image-missing". The icon chosen is returned by this function. 135 * 136 * If the icon was created without an icon theme, this function 137 * returns %NULL. 138 * 139 * Returns: the themed icon-name for the 140 * icon, or %NULL if its not a themed icon. 141 */ 142 public string getIconName() 143 { 144 return Str.toString(gtk_icon_paintable_get_icon_name(gtkIconPaintable)); 145 } 146 147 /** 148 * Checks if the icon is symbolic or not. 149 * 150 * This currently uses only the file name and not the file contents 151 * for determining this. This behaviour may change in the future. 152 * 153 * Note that to render a symbolic `GtkIconPaintable` properly (with 154 * recoloring), you have to set its icon name on a `GtkImage`. 155 * 156 * Returns: %TRUE if the icon is symbolic, %FALSE otherwise 157 */ 158 public bool isSymbolic() 159 { 160 return gtk_icon_paintable_is_symbolic(gtkIconPaintable) != 0; 161 } 162 }