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