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.IOModule;
26 
27 private import gio.IOModuleScope;
28 private import glib.ConstructionException;
29 private import glib.ListG;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import gobject.TypeModule;
33 private import gobject.TypePluginIF;
34 private import gobject.TypePluginT;
35 private import gtkc.gio;
36 public  import gtkc.giotypes;
37 
38 
39 /**
40  * Provides an interface and default functions for loading and unloading
41  * modules. This is used internally to make GIO extensible, but can also
42  * be used by others to implement module loading.
43  */
44 public class IOModule : TypeModule
45 {
46 	/** the main Gtk struct */
47 	protected GIOModule* gIOModule;
48 
49 	/** Get the main Gtk struct */
50 	public GIOModule* getIOModuleStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gIOModule;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gIOModule;
61 	}
62 
63 	protected override void setStruct(GObject* obj)
64 	{
65 		gIOModule = cast(GIOModule*)obj;
66 		super.setStruct(obj);
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GIOModule* gIOModule, bool ownedRef = false)
73 	{
74 		this.gIOModule = gIOModule;
75 		super(cast(GTypeModule*)gIOModule, ownedRef);
76 	}
77 
78 
79 	/** */
80 	public static GType getType()
81 	{
82 		return g_io_module_get_type();
83 	}
84 
85 	/**
86 	 * Creates a new GIOModule that will load the specific
87 	 * shared library when in use.
88 	 *
89 	 * Params:
90 	 *     filename = filename of the shared library module.
91 	 *
92 	 * Returns: a #GIOModule from given @filename,
93 	 *     or %NULL on error.
94 	 *
95 	 * Throws: ConstructionException GTK+ fails to create the object.
96 	 */
97 	public this(string filename)
98 	{
99 		auto p = g_io_module_new(Str.toStringz(filename));
100 		
101 		if(p is null)
102 		{
103 			throw new ConstructionException("null returned by new");
104 		}
105 		
106 		this(cast(GIOModule*) p, true);
107 	}
108 
109 	/**
110 	 * Loads all the modules in the specified directory.
111 	 *
112 	 * If don't require all modules to be initialized (and thus registering
113 	 * all gtypes) then you can use g_io_modules_scan_all_in_directory()
114 	 * which allows delayed/lazy loading of modules.
115 	 *
116 	 * Params:
117 	 *     dirname = pathname for a directory containing modules
118 	 *         to load.
119 	 *
120 	 * Returns: a list of #GIOModules loaded
121 	 *     from the directory,
122 	 *     All the modules are loaded into memory, if you want to
123 	 *     unload them (enabling on-demand loading) you must call
124 	 *     g_type_module_unuse() on all the modules. Free the list
125 	 *     with g_list_free().
126 	 */
127 	public static ListG loadAllInDirectory(string dirname)
128 	{
129 		auto p = g_io_modules_load_all_in_directory(Str.toStringz(dirname));
130 		
131 		if(p is null)
132 		{
133 			return null;
134 		}
135 		
136 		return new ListG(cast(GList*) p, true);
137 	}
138 
139 	/**
140 	 * Loads all the modules in the specified directory.
141 	 *
142 	 * If don't require all modules to be initialized (and thus registering
143 	 * all gtypes) then you can use g_io_modules_scan_all_in_directory()
144 	 * which allows delayed/lazy loading of modules.
145 	 *
146 	 * Params:
147 	 *     dirname = pathname for a directory containing modules
148 	 *         to load.
149 	 *     scop = a scope to use when scanning the modules.
150 	 *
151 	 * Returns: a list of #GIOModules loaded
152 	 *     from the directory,
153 	 *     All the modules are loaded into memory, if you want to
154 	 *     unload them (enabling on-demand loading) you must call
155 	 *     g_type_module_unuse() on all the modules. Free the list
156 	 *     with g_list_free().
157 	 *
158 	 * Since: 2.30
159 	 */
160 	public static ListG loadAllInDirectoryWithScope(string dirname, IOModuleScope scop)
161 	{
162 		auto p = g_io_modules_load_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct());
163 		
164 		if(p is null)
165 		{
166 			return null;
167 		}
168 		
169 		return new ListG(cast(GList*) p, true);
170 	}
171 
172 	/**
173 	 * Scans all the modules in the specified directory, ensuring that
174 	 * any extension point implemented by a module is registered.
175 	 *
176 	 * This may not actually load and initialize all the types in each
177 	 * module, some modules may be lazily loaded and initialized when
178 	 * an extension point it implementes is used with e.g.
179 	 * g_io_extension_point_get_extensions() or
180 	 * g_io_extension_point_get_extension_by_name().
181 	 *
182 	 * If you need to guarantee that all types are loaded in all the modules,
183 	 * use g_io_modules_load_all_in_directory().
184 	 *
185 	 * Params:
186 	 *     dirname = pathname for a directory containing modules
187 	 *         to scan.
188 	 *
189 	 * Since: 2.24
190 	 */
191 	public static void scanAllInDirectory(string dirname)
192 	{
193 		g_io_modules_scan_all_in_directory(Str.toStringz(dirname));
194 	}
195 
196 	/**
197 	 * Scans all the modules in the specified directory, ensuring that
198 	 * any extension point implemented by a module is registered.
199 	 *
200 	 * This may not actually load and initialize all the types in each
201 	 * module, some modules may be lazily loaded and initialized when
202 	 * an extension point it implementes is used with e.g.
203 	 * g_io_extension_point_get_extensions() or
204 	 * g_io_extension_point_get_extension_by_name().
205 	 *
206 	 * If you need to guarantee that all types are loaded in all the modules,
207 	 * use g_io_modules_load_all_in_directory().
208 	 *
209 	 * Params:
210 	 *     dirname = pathname for a directory containing modules
211 	 *         to scan.
212 	 *     scop = a scope to use when scanning the modules
213 	 *
214 	 * Since: 2.30
215 	 */
216 	public static void scanAllInDirectoryWithScope(string dirname, IOModuleScope scop)
217 	{
218 		g_io_modules_scan_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct());
219 	}
220 }