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.FileAttributeInfoList;
26 
27 private import gio.c.functions;
28 public  import gio.c.types;
29 private import glib.ConstructionException;
30 private import glib.Str;
31 private import glib.c.functions;
32 private import gobject.ObjectG;
33 public  import gtkc.giotypes;
34 private import gtkd.Loader;
35 
36 
37 /**
38  * Acts as a lightweight registry for possible valid file attributes.
39  * The registry stores Key-Value pair formats as #GFileAttributeInfos.
40  */
41 public final class FileAttributeInfoList
42 {
43 	/** the main Gtk struct */
44 	protected GFileAttributeInfoList* gFileAttributeInfoList;
45 	protected bool ownedRef;
46 
47 	/** Get the main Gtk struct */
48 	public GFileAttributeInfoList* getFileAttributeInfoListStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gFileAttributeInfoList;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected void* getStruct()
57 	{
58 		return cast(void*)gFileAttributeInfoList;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GFileAttributeInfoList* gFileAttributeInfoList, bool ownedRef = false)
65 	{
66 		this.gFileAttributeInfoList = gFileAttributeInfoList;
67 		this.ownedRef = ownedRef;
68 	}
69 
70 	~this ()
71 	{
72 		if ( Linker.isLoaded(LIBRARY_GIO) && ownedRef )
73 			g_file_attribute_info_list_unref(gFileAttributeInfoList);
74 	}
75 
76 
77 	/**
78 	 * an array of #GFileAttributeInfos.
79 	 */
80 	public @property GFileAttributeInfo[] infos()
81 	{
82 		return gFileAttributeInfoList.infos[0..gFileAttributeInfoList.nInfos];
83 	}
84 
85 	/** Ditto */
86 	public @property void infos(GFileAttributeInfo[] value)
87 	{
88 		gFileAttributeInfoList.infos = value.ptr;
89 		gFileAttributeInfoList.nInfos = cast(int)value.length;
90 	}
91 
92 
93 	/** */
94 	public static GType getType()
95 	{
96 		return g_file_attribute_info_list_get_type();
97 	}
98 
99 	/**
100 	 * Creates a new file attribute info list.
101 	 *
102 	 * Returns: a #GFileAttributeInfoList.
103 	 *
104 	 * Throws: ConstructionException GTK+ fails to create the object.
105 	 */
106 	public this()
107 	{
108 		auto p = g_file_attribute_info_list_new();
109 
110 		if(p is null)
111 		{
112 			throw new ConstructionException("null returned by new");
113 		}
114 
115 		this(cast(GFileAttributeInfoList*) p);
116 	}
117 
118 	/**
119 	 * Adds a new attribute with @name to the @list, setting
120 	 * its @type and @flags.
121 	 *
122 	 * Params:
123 	 *     name = the name of the attribute to add.
124 	 *     type = the #GFileAttributeType for the attribute.
125 	 *     flags = #GFileAttributeInfoFlags for the attribute.
126 	 */
127 	public void add(string name, GFileAttributeType type, GFileAttributeInfoFlags flags)
128 	{
129 		g_file_attribute_info_list_add(gFileAttributeInfoList, Str.toStringz(name), type, flags);
130 	}
131 
132 	/**
133 	 * Makes a duplicate of a file attribute info list.
134 	 *
135 	 * Returns: a copy of the given @list.
136 	 */
137 	public FileAttributeInfoList dup()
138 	{
139 		auto p = g_file_attribute_info_list_dup(gFileAttributeInfoList);
140 
141 		if(p is null)
142 		{
143 			return null;
144 		}
145 
146 		return ObjectG.getDObject!(FileAttributeInfoList)(cast(GFileAttributeInfoList*) p, true);
147 	}
148 
149 	/**
150 	 * Gets the file attribute with the name @name from @list.
151 	 *
152 	 * Params:
153 	 *     name = the name of the attribute to lookup.
154 	 *
155 	 * Returns: a #GFileAttributeInfo for the @name, or %NULL if an
156 	 *     attribute isn't found.
157 	 */
158 	public GFileAttributeInfo* lookup(string name)
159 	{
160 		return g_file_attribute_info_list_lookup(gFileAttributeInfoList, Str.toStringz(name));
161 	}
162 
163 	/**
164 	 * References a file attribute info list.
165 	 *
166 	 * Returns: #GFileAttributeInfoList or %NULL on error.
167 	 */
168 	public FileAttributeInfoList doref()
169 	{
170 		auto p = g_file_attribute_info_list_ref(gFileAttributeInfoList);
171 
172 		if(p is null)
173 		{
174 			return null;
175 		}
176 
177 		return ObjectG.getDObject!(FileAttributeInfoList)(cast(GFileAttributeInfoList*) p, true);
178 	}
179 
180 	/**
181 	 * Removes a reference from the given @list. If the reference count
182 	 * falls to zero, the @list is deleted.
183 	 */
184 	public void unref()
185 	{
186 		g_file_attribute_info_list_unref(gFileAttributeInfoList);
187 	}
188 }