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