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