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 /** 66 * Sets our main struct and passes it to the parent class. 67 */ 68 public this (GThemedIcon* gThemedIcon, bool ownedRef = false) 69 { 70 this.gThemedIcon = gThemedIcon; 71 super(cast(GObject*)gThemedIcon, ownedRef); 72 } 73 74 // add the Icon capabilities 75 mixin IconT!(GThemedIcon); 76 77 78 /** */ 79 public static GType getType() 80 { 81 return g_themed_icon_get_type(); 82 } 83 84 /** 85 * Creates a new themed icon for @iconnames. 86 * 87 * Params: 88 * iconnames = an array of strings containing icon names. 89 * 90 * Returns: a new #GThemedIcon 91 * 92 * Throws: ConstructionException GTK+ fails to create the object. 93 */ 94 public this(string[] iconnames) 95 { 96 auto p = g_themed_icon_new_from_names(Str.toStringzArray(iconnames), cast(int)iconnames.length); 97 98 if(p is null) 99 { 100 throw new ConstructionException("null returned by new_from_names"); 101 } 102 103 this(cast(GThemedIcon*) p, true); 104 } 105 106 /** 107 * Creates a new themed icon for @iconname, and all the names 108 * that can be created by shortening @iconname at '-' characters. 109 * 110 * In the following example, @icon1 and @icon2 are equivalent: 111 * |[<!-- language="C" --> 112 * const char *names[] = { 113 * "gnome-dev-cdrom-audio", 114 * "gnome-dev-cdrom", 115 * "gnome-dev", 116 * "gnome" 117 * }; 118 * 119 * icon1 = g_themed_icon_new_from_names (names, 4); 120 * icon2 = g_themed_icon_new_with_default_fallbacks ("gnome-dev-cdrom-audio"); 121 * ]| 122 * 123 * Params: 124 * iconname = a string containing an icon name 125 * 126 * Returns: a new #GThemedIcon. 127 * 128 * Throws: ConstructionException GTK+ fails to create the object. 129 */ 130 public this(string iconname) 131 { 132 auto p = g_themed_icon_new_with_default_fallbacks(Str.toStringz(iconname)); 133 134 if(p is null) 135 { 136 throw new ConstructionException("null returned by new_with_default_fallbacks"); 137 } 138 139 this(cast(GThemedIcon*) p, true); 140 } 141 142 /** 143 * Append a name to the list of icons from within @icon. 144 * 145 * Note that doing so invalidates the hash computed by prior calls 146 * to g_icon_hash(). 147 * 148 * Params: 149 * iconname = name of icon to append to list of icons from within @icon. 150 */ 151 public void appendName(string iconname) 152 { 153 g_themed_icon_append_name(gThemedIcon, Str.toStringz(iconname)); 154 } 155 156 /** 157 * Gets the names of icons from within @icon. 158 * 159 * Returns: a list of icon names. 160 */ 161 public string[] getNames() 162 { 163 return Str.toStringArray(g_themed_icon_get_names(gThemedIcon)); 164 } 165 166 /** 167 * Prepend a name to the list of icons from within @icon. 168 * 169 * Note that doing so invalidates the hash computed by prior calls 170 * to g_icon_hash(). 171 * 172 * Params: 173 * iconname = name of icon to prepend to list of icons from within @icon. 174 * 175 * Since: 2.18 176 */ 177 public void prependName(string iconname) 178 { 179 g_themed_icon_prepend_name(gThemedIcon, Str.toStringz(iconname)); 180 } 181 }