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 = IconFactory 29 * strct = GtkIconFactory 30 * realStrct= 31 * ctorStrct= 32 * clss = IconFactory 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_icon_factory_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gtk.IconSet 48 * structWrap: 49 * - GtkIconFactory* -> IconFactory 50 * - GtkIconSet* -> IconSet 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module gtk.IconFactory; 57 58 public import gtkc.gtktypes; 59 60 private import gtkc.gtk; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 65 private import glib.Str; 66 private import gtk.IconSet; 67 68 69 70 private import gobject.ObjectG; 71 72 /** 73 * Description 74 * Browse the available stock icons in the list of stock IDs found here. You can also use 75 * the gtk-demo application for this purpose. 76 * An icon factory manages a collection of GtkIconSet; a GtkIconSet manages a 77 * set of variants of a particular icon (i.e. a GtkIconSet contains variants for 78 * different sizes and widget states). Icons in an icon factory are named by a 79 * stock ID, which is a simple string identifying the icon. Each GtkStyle has a 80 * list of GtkIconFactory derived from the current theme; those icon factories 81 * are consulted first when searching for an icon. If the theme doesn't set a 82 * particular icon, GTK+ looks for the icon in a list of default icon factories, 83 * maintained by gtk_icon_factory_add_default() and 84 * gtk_icon_factory_remove_default(). Applications with icons should add a default 85 * icon factory with their icons, which will allow themes to override the icons 86 * for the application. 87 * To display an icon, always use gtk_style_lookup_icon_set() on the widget that 88 * will display the icon, or the convenience function 89 * gtk_widget_render_icon(). These functions take the theme into account when 90 * looking up the icon to use for a given stock ID. 91 * GtkIconFactory as GtkBuildable 92 * GtkIconFactory supports a custom <sources> element, which 93 * can contain multiple <source> elements. 94 * The following attributes are allowed: 95 * stock-id 96 * The stock id of the source, a string. 97 * This attribute is mandatory 98 * filename 99 * The filename of the source, a string. 100 * This attribute is optional 101 * icon-name 102 * The icon name for the source, a string. 103 * This attribute is optional. 104 * size 105 * Size of the icon, a GtkIconSize enum value. 106 * This attribute is optional. 107 * direction 108 * Direction of the source, a GtkTextDirection enum value. 109 * This attribute is optional. 110 * state 111 * State of the source, a GtkStateType enum value. 112 * This attribute is optional. 113 * $(DDOC_COMMENT example) 114 */ 115 public class IconFactory : ObjectG 116 { 117 118 /** the main Gtk struct */ 119 protected GtkIconFactory* gtkIconFactory; 120 121 122 public GtkIconFactory* getIconFactoryStruct() 123 { 124 return gtkIconFactory; 125 } 126 127 128 /** the main Gtk struct as a void* */ 129 protected override void* getStruct() 130 { 131 return cast(void*)gtkIconFactory; 132 } 133 134 /** 135 * Sets our main struct and passes it to the parent class 136 */ 137 public this (GtkIconFactory* gtkIconFactory) 138 { 139 super(cast(GObject*)gtkIconFactory); 140 this.gtkIconFactory = gtkIconFactory; 141 } 142 143 protected override void setStruct(GObject* obj) 144 { 145 super.setStruct(obj); 146 gtkIconFactory = cast(GtkIconFactory*)obj; 147 } 148 149 /** 150 */ 151 152 /** 153 * Adds the given icon_set to the icon factory, under the name 154 * stock_id. stock_id should be namespaced for your application, 155 * e.g. "myapp-whatever-icon". Normally applications create a 156 * GtkIconFactory, then add it to the list of default factories with 157 * gtk_icon_factory_add_default(). Then they pass the stock_id to 158 * widgets such as GtkImage to display the icon. Themes can provide 159 * an icon with the same name (such as "myapp-whatever-icon") to 160 * override your application's default icons. If an icon already 161 * existed in factory for stock_id, it is unreferenced and replaced 162 * with the new icon_set. 163 * Params: 164 * stockId = icon name 165 * iconSet = icon set 166 */ 167 public void add(string stockId, IconSet iconSet) 168 { 169 // void gtk_icon_factory_add (GtkIconFactory *factory, const gchar *stock_id, GtkIconSet *icon_set); 170 gtk_icon_factory_add(gtkIconFactory, Str.toStringz(stockId), (iconSet is null) ? null : iconSet.getIconSetStruct()); 171 } 172 173 /** 174 * Adds an icon factory to the list of icon factories searched by 175 * gtk_style_lookup_icon_set(). This means that, for example, 176 * gtk_image_new_from_stock() will be able to find icons in factory. 177 * There will normally be an icon factory added for each library or 178 * application that comes with icons. The default icon factories 179 * can be overridden by themes. 180 */ 181 public void addDefault() 182 { 183 // void gtk_icon_factory_add_default (GtkIconFactory *factory); 184 gtk_icon_factory_add_default(gtkIconFactory); 185 } 186 187 /** 188 * Looks up stock_id in the icon factory, returning an icon set 189 * if found, otherwise NULL. For display to the user, you should 190 * use gtk_style_lookup_icon_set() on the GtkStyle for the 191 * widget that will display the icon, instead of using this 192 * function directly, so that themes are taken into account. 193 * Params: 194 * stockId = an icon name 195 * Returns: icon set of stock_id. 196 */ 197 public IconSet lookup(string stockId) 198 { 199 // GtkIconSet* gtk_icon_factory_lookup (GtkIconFactory *factory, const gchar *stock_id); 200 auto p = gtk_icon_factory_lookup(gtkIconFactory, Str.toStringz(stockId)); 201 202 if(p is null) 203 { 204 return null; 205 } 206 207 return ObjectG.getDObject!(IconSet)(cast(GtkIconSet*) p); 208 } 209 210 /** 211 * Looks for an icon in the list of default icon factories. For 212 * display to the user, you should use gtk_style_lookup_icon_set() on 213 * the GtkStyle for the widget that will display the icon, instead of 214 * using this function directly, so that themes are taken into 215 * account. 216 * Params: 217 * stockId = an icon name 218 * Returns: a GtkIconSet, or NULL 219 */ 220 public static IconSet lookupDefault(string stockId) 221 { 222 // GtkIconSet* gtk_icon_factory_lookup_default (const gchar *stock_id); 223 auto p = gtk_icon_factory_lookup_default(Str.toStringz(stockId)); 224 225 if(p is null) 226 { 227 return null; 228 } 229 230 return ObjectG.getDObject!(IconSet)(cast(GtkIconSet*) p); 231 } 232 233 /** 234 * Creates a new GtkIconFactory. An icon factory manages a collection 235 * of GtkIconSets; a GtkIconSet manages a set of variants of a 236 * particular icon (i.e. a GtkIconSet contains variants for different 237 * sizes and widget states). Icons in an icon factory are named by a 238 * stock ID, which is a simple string identifying the icon. Each 239 * GtkStyle has a list of GtkIconFactorys derived from the current 240 * theme; those icon factories are consulted first when searching for 241 * an icon. If the theme doesn't set a particular icon, GTK+ looks for 242 * the icon in a list of default icon factories, maintained by 243 * gtk_icon_factory_add_default() and 244 * gtk_icon_factory_remove_default(). Applications with icons should 245 * add a default icon factory with their icons, which will allow 246 * themes to override the icons for the application. 247 * Throws: ConstructionException GTK+ fails to create the object. 248 */ 249 public this () 250 { 251 // GtkIconFactory* gtk_icon_factory_new (void); 252 auto p = gtk_icon_factory_new(); 253 if(p is null) 254 { 255 throw new ConstructionException("null returned by gtk_icon_factory_new()"); 256 } 257 this(cast(GtkIconFactory*) p); 258 } 259 260 /** 261 * Removes an icon factory from the list of default icon 262 * factories. Not normally used; you might use it for a library that 263 * can be unloaded or shut down. 264 */ 265 public void removeDefault() 266 { 267 // void gtk_icon_factory_remove_default (GtkIconFactory *factory); 268 gtk_icon_factory_remove_default(gtkIconFactory); 269 } 270 }