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 gio.ThemedIcon; 26 27 private import gio.IconIF; 28 private import gio.IconT; 29 private import gio.c.functions; 30 public import gio.c.types; 31 private import glib.ConstructionException; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 public import gtkc.giotypes; 35 36 37 /** 38 * #GThemedIcon is an implementation of #GIcon that supports icon themes. 39 * #GThemedIcon contains a list of all of the icons present in an icon 40 * theme, so that icons can be looked up quickly. #GThemedIcon does 41 * not provide actual pixmaps for icons, just the icon names. 42 * Ideally something like gtk_icon_theme_choose_icon() should be used to 43 * resolve the list of names so that fallback icons work nicely with 44 * themes that inherit other themes. 45 */ 46 public class ThemedIcon : ObjectG, IconIF 47 { 48 /** the main Gtk struct */ 49 protected GThemedIcon* gThemedIcon; 50 51 /** Get the main Gtk struct */ 52 public GThemedIcon* getThemedIconStruct(bool transferOwnership = false) 53 { 54 if (transferOwnership) 55 ownedRef = false; 56 return gThemedIcon; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected override void* getStruct() 61 { 62 return cast(void*)gThemedIcon; 63 } 64 65 protected override void setStruct(GObject* obj) 66 { 67 gThemedIcon = cast(GThemedIcon*)obj; 68 super.setStruct(obj); 69 } 70 71 /** 72 * Sets our main struct and passes it to the parent class. 73 */ 74 public this (GThemedIcon* gThemedIcon, bool ownedRef = false) 75 { 76 this.gThemedIcon = gThemedIcon; 77 super(cast(GObject*)gThemedIcon, ownedRef); 78 } 79 80 // add the Icon capabilities 81 mixin IconT!(GThemedIcon); 82 83 84 /** */ 85 public static GType getType() 86 { 87 return g_themed_icon_get_type(); 88 } 89 90 /** 91 * Creates a new themed icon for @iconnames. 92 * 93 * Params: 94 * iconnames = an array of strings containing icon names. 95 * 96 * Returns: a new #GThemedIcon 97 * 98 * Throws: ConstructionException GTK+ fails to create the object. 99 */ 100 public this(string[] iconnames) 101 { 102 auto p = g_themed_icon_new_from_names(Str.toStringzArray(iconnames), cast(int)iconnames.length); 103 104 if(p is null) 105 { 106 throw new ConstructionException("null returned by new_from_names"); 107 } 108 109 this(cast(GThemedIcon*) p, true); 110 } 111 112 /** 113 * Creates a new themed icon for @iconname, and all the names 114 * that can be created by shortening @iconname at '-' characters. 115 * 116 * In the following example, @icon1 and @icon2 are equivalent: 117 * |[<!-- language="C" --> 118 * const char *names[] = { 119 * "gnome-dev-cdrom-audio", 120 * "gnome-dev-cdrom", 121 * "gnome-dev", 122 * "gnome" 123 * }; 124 * 125 * icon1 = g_themed_icon_new_from_names (names, 4); 126 * icon2 = g_themed_icon_new_with_default_fallbacks ("gnome-dev-cdrom-audio"); 127 * ]| 128 * 129 * Params: 130 * iconname = a string containing an icon name 131 * 132 * Returns: a new #GThemedIcon. 133 * 134 * Throws: ConstructionException GTK+ fails to create the object. 135 */ 136 public this(string iconname) 137 { 138 auto p = g_themed_icon_new_with_default_fallbacks(Str.toStringz(iconname)); 139 140 if(p is null) 141 { 142 throw new ConstructionException("null returned by new_with_default_fallbacks"); 143 } 144 145 this(cast(GThemedIcon*) p, true); 146 } 147 148 /** 149 * Append a name to the list of icons from within @icon. 150 * 151 * Note that doing so invalidates the hash computed by prior calls 152 * to g_icon_hash(). 153 * 154 * Params: 155 * iconname = name of icon to append to list of icons from within @icon. 156 */ 157 public void appendName(string iconname) 158 { 159 g_themed_icon_append_name(gThemedIcon, Str.toStringz(iconname)); 160 } 161 162 /** 163 * Gets the names of icons from within @icon. 164 * 165 * Returns: a list of icon names. 166 */ 167 public string[] getNames() 168 { 169 return Str.toStringArray(g_themed_icon_get_names(gThemedIcon)); 170 } 171 172 /** 173 * Prepend a name to the list of icons from within @icon. 174 * 175 * Note that doing so invalidates the hash computed by prior calls 176 * to g_icon_hash(). 177 * 178 * Params: 179 * iconname = name of icon to prepend to list of icons from within @icon. 180 * 181 * Since: 2.18 182 */ 183 public void prependName(string iconname) 184 { 185 g_themed_icon_prepend_name(gThemedIcon, Str.toStringz(iconname)); 186 } 187 }