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