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