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 
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 	/**
64 	 * Sets our main struct and passes it to the parent class.
65 	 */
66 	public this (GIOModule* gIOModule, bool ownedRef = false)
67 	{
68 		this.gIOModule = gIOModule;
69 		super(cast(GTypeModule*)gIOModule, ownedRef);
70 	}
71 
72 
73 	/** */
74 	public static GType getType()
75 	{
76 		return g_io_module_get_type();
77 	}
78 
79 	/**
80 	 * Creates a new GIOModule that will load the specific
81 	 * shared library when in use.
82 	 *
83 	 * Params:
84 	 *     filename = filename of the shared library module.
85 	 *
86 	 * Returns: a #GIOModule from given @filename,
87 	 *     or %NULL on error.
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this(string filename)
92 	{
93 		auto __p = g_io_module_new(Str.toStringz(filename));
94 
95 		if(__p is null)
96 		{
97 			throw new ConstructionException("null returned by new");
98 		}
99 
100 		this(cast(GIOModule*) __p, true);
101 	}
102 
103 	/**
104 	 * Loads all the modules in the specified directory.
105 	 *
106 	 * If don't require all modules to be initialized (and thus registering
107 	 * all gtypes) then you can use g_io_modules_scan_all_in_directory()
108 	 * which allows delayed/lazy loading of modules.
109 	 *
110 	 * Params:
111 	 *     dirname = pathname for a directory containing modules
112 	 *         to load.
113 	 *
114 	 * Returns: a list of #GIOModules loaded
115 	 *     from the directory,
116 	 *     All the modules are loaded into memory, if you want to
117 	 *     unload them (enabling on-demand loading) you must call
118 	 *     g_type_module_unuse() on all the modules. Free the list
119 	 *     with g_list_free().
120 	 */
121 	public static ListG loadAllInDirectory(string dirname)
122 	{
123 		auto __p = g_io_modules_load_all_in_directory(Str.toStringz(dirname));
124 
125 		if(__p is null)
126 		{
127 			return null;
128 		}
129 
130 		return new ListG(cast(GList*) __p, true);
131 	}
132 
133 	/**
134 	 * Loads all the modules in the specified directory.
135 	 *
136 	 * If don't require all modules to be initialized (and thus registering
137 	 * all gtypes) then you can use g_io_modules_scan_all_in_directory()
138 	 * which allows delayed/lazy loading of modules.
139 	 *
140 	 * Params:
141 	 *     dirname = pathname for a directory containing modules
142 	 *         to load.
143 	 *     scope_ = a scope to use when scanning the modules.
144 	 *
145 	 * Returns: a list of #GIOModules loaded
146 	 *     from the directory,
147 	 *     All the modules are loaded into memory, if you want to
148 	 *     unload them (enabling on-demand loading) you must call
149 	 *     g_type_module_unuse() on all the modules. Free the list
150 	 *     with g_list_free().
151 	 *
152 	 * Since: 2.30
153 	 */
154 	public static ListG loadAllInDirectoryWithScope(string dirname, IOModuleScope scope_)
155 	{
156 		auto __p = g_io_modules_load_all_in_directory_with_scope(Str.toStringz(dirname), (scope_ is null) ? null : scope_.getIOModuleScopeStruct());
157 
158 		if(__p is null)
159 		{
160 			return null;
161 		}
162 
163 		return new ListG(cast(GList*) __p, true);
164 	}
165 
166 	/**
167 	 * Scans all the modules in the specified directory, ensuring that
168 	 * any extension point implemented by a module is registered.
169 	 *
170 	 * This may not actually load and initialize all the types in each
171 	 * module, some modules may be lazily loaded and initialized when
172 	 * an extension point it implements is used with e.g.
173 	 * g_io_extension_point_get_extensions() or
174 	 * g_io_extension_point_get_extension_by_name().
175 	 *
176 	 * If you need to guarantee that all types are loaded in all the modules,
177 	 * use g_io_modules_load_all_in_directory().
178 	 *
179 	 * Params:
180 	 *     dirname = pathname for a directory containing modules
181 	 *         to scan.
182 	 *
183 	 * Since: 2.24
184 	 */
185 	public static void scanAllInDirectory(string dirname)
186 	{
187 		g_io_modules_scan_all_in_directory(Str.toStringz(dirname));
188 	}
189 
190 	/**
191 	 * Scans all the modules in the specified directory, ensuring that
192 	 * any extension point implemented by a module is registered.
193 	 *
194 	 * This may not actually load and initialize all the types in each
195 	 * module, some modules may be lazily loaded and initialized when
196 	 * an extension point it implements is used with e.g.
197 	 * g_io_extension_point_get_extensions() or
198 	 * g_io_extension_point_get_extension_by_name().
199 	 *
200 	 * If you need to guarantee that all types are loaded in all the modules,
201 	 * use g_io_modules_load_all_in_directory().
202 	 *
203 	 * Params:
204 	 *     dirname = pathname for a directory containing modules
205 	 *         to scan.
206 	 *     scope_ = a scope to use when scanning the modules
207 	 *
208 	 * Since: 2.30
209 	 */
210 	public static void scanAllInDirectoryWithScope(string dirname, IOModuleScope scope_)
211 	{
212 		g_io_modules_scan_all_in_directory_with_scope(Str.toStringz(dirname), (scope_ is null) ? null : scope_.getIOModuleScopeStruct());
213 	}
214 }