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 glib.ConstructionException;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import gtkc.gio;
33 public  import gtkc.giotypes;
34 
35 
36 /**
37  * #GThemedIcon is an implementation of #GIcon that supports icon themes.
38  * #GThemedIcon contains a list of all of the icons present in an icon
39  * theme, so that icons can be looked up quickly. #GThemedIcon does
40  * not provide actual pixmaps for icons, just the icon names.
41  * Ideally something like gtk_icon_theme_choose_icon() should be used to
42  * resolve the list of names so that fallback icons work nicely with
43  * themes that inherit other themes.
44  */
45 public class ThemedIcon : ObjectG, IconIF
46 {
47 	/** the main Gtk struct */
48 	protected GThemedIcon* gThemedIcon;
49 
50 	/** Get the main Gtk struct */
51 	public GThemedIcon* getThemedIconStruct()
52 	{
53 		return gThemedIcon;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)gThemedIcon;
60 	}
61 
62 	protected override void setStruct(GObject* obj)
63 	{
64 		gThemedIcon = cast(GThemedIcon*)obj;
65 		super.setStruct(obj);
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GThemedIcon* gThemedIcon, bool ownedRef = false)
72 	{
73 		this.gThemedIcon = gThemedIcon;
74 		super(cast(GObject*)gThemedIcon, ownedRef);
75 	}
76 
77 	// add the Icon capabilities
78 	mixin IconT!(GThemedIcon);
79 
80 	/**
81 	 */
82 
83 	public static GType getType()
84 	{
85 		return g_themed_icon_get_type();
86 	}
87 
88 	/**
89 	 * Creates a new themed icon for @iconnames.
90 	 *
91 	 * Params:
92 	 *     iconnames = an array of strings containing icon names.
93 	 *     len = the length of the @iconnames array, or -1 if @iconnames is
94 	 *         %NULL-terminated
95 	 *
96 	 * Return: 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 	 * Return: 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 	 * Return: 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 }