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