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  * Conversion parameters:
26  * inFile  = GIOModule.html
27  * outPack = gio
28  * outFile = IOModule
29  * strct   = GIOModule
30  * realStrct=
31  * ctorStrct=
32  * clss    = IOModule
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_io_module_
41  * 	- g_io_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ListG
49  * structWrap:
50  * 	- GList* -> ListG
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gio.IOModule;
57 
58 public  import gtkc.giotypes;
59 
60 private import gtkc.gio;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 
65 private import glib.Str;
66 private import glib.ListG;
67 
68 
69 
70 private import gobject.TypeModule;
71 
72 /**
73  * Description
74  * Provides an interface and default functions for loading and unloading
75  * modules. This is used internally to make GIO extensible, but can also
76  * be used by others to implement module loading.
77  */
78 public class IOModule : TypeModule
79 {
80 	
81 	/** the main Gtk struct */
82 	protected GIOModule* gIOModule;
83 	
84 	
85 	public GIOModule* getIOModuleStruct()
86 	{
87 		return gIOModule;
88 	}
89 	
90 	
91 	/** the main Gtk struct as a void* */
92 	protected override void* getStruct()
93 	{
94 		return cast(void*)gIOModule;
95 	}
96 	
97 	/**
98 	 * Sets our main struct and passes it to the parent class
99 	 */
100 	public this (GIOModule* gIOModule)
101 	{
102 		super(cast(GTypeModule*)gIOModule);
103 		this.gIOModule = gIOModule;
104 	}
105 	
106 	protected override void setStruct(GObject* obj)
107 	{
108 		super.setStruct(obj);
109 		gIOModule = cast(GIOModule*)obj;
110 	}
111 	
112 	/**
113 	 */
114 	
115 	/**
116 	 * Creates a new GIOModule that will load the specific
117 	 * shared library when in use.
118 	 * Params:
119 	 * filename = filename of the shared library module.
120 	 * Throws: ConstructionException GTK+ fails to create the object.
121 	 */
122 	public this (string filename)
123 	{
124 		// GIOModule * g_io_module_new (const gchar *filename);
125 		auto p = g_io_module_new(Str.toStringz(filename));
126 		if(p is null)
127 		{
128 			throw new ConstructionException("null returned by g_io_module_new(Str.toStringz(filename))");
129 		}
130 		this(cast(GIOModule*) p);
131 	}
132 	
133 	/**
134 	 * Loads all the modules in the specified directory.
135 	 * If don't require all modules to be initialized (and thus registering
136 	 * all gtypes) then you can use g_io_modules_scan_all_in_directory()
137 	 * which allows delayed/lazy loading of modules.
138 	 * Params:
139 	 * dirname = pathname for a directory containing modules to load.
140 	 * Returns: a list of GIOModules loaded from the directory, All the modules are loaded into memory, if you want to unload them (enabling on-demand loading) you must call g_type_module_unuse() on all the modules. Free the list with g_list_free(). [element-type GIOModule][transfer full]
141 	 */
142 	public static ListG modulesLoadAllInDirectory(string dirname)
143 	{
144 		// GList * g_io_modules_load_all_in_directory (const gchar *dirname);
145 		auto p = g_io_modules_load_all_in_directory(Str.toStringz(dirname));
146 		
147 		if(p is null)
148 		{
149 			return null;
150 		}
151 		
152 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
153 	}
154 	
155 	/**
156 	 * Scans all the modules in the specified directory, ensuring that
157 	 * any extension point implemented by a module is registered.
158 	 * This may not actually load and initialize all the types in each
159 	 * module, some modules may be lazily loaded and initialized when
160 	 * an extension point it implementes is used with e.g.
161 	 * g_io_extension_point_get_extensions() or
162 	 * g_io_extension_point_get_extension_by_name().
163 	 * If you need to guarantee that all types are loaded in all the modules,
164 	 * use g_io_modules_load_all_in_directory().
165 	 * Since 2.24
166 	 * Params:
167 	 * dirname = pathname for a directory containing modules to scan.
168 	 */
169 	public static void modulesScanAllInDirectory(string dirname)
170 	{
171 		// void g_io_modules_scan_all_in_directory (const char *dirname);
172 		g_io_modules_scan_all_in_directory(Str.toStringz(dirname));
173 	}
174 	
175 	/**
176 	 * Required API for GIO modules to implement.
177 	 * This function is ran after the module has been loaded into GIO,
178 	 * to initialize the module.
179 	 */
180 	public void load()
181 	{
182 		// void g_io_module_load (GIOModule *module);
183 		g_io_module_load(gIOModule);
184 	}
185 	
186 	/**
187 	 * Required API for GIO modules to implement.
188 	 * This function is ran when the module is being unloaded from GIO,
189 	 * to finalize the module.
190 	 */
191 	public void unload()
192 	{
193 		// void g_io_module_unload (GIOModule *module);
194 		g_io_module_unload(gIOModule);
195 	}
196 	
197 	/**
198 	 * Optional API for GIO modules to implement.
199 	 * Should return a list of all the extension points that may be
200 	 * implemented in this module.
201 	 * This method will not be called in normal use, however it may be
202 	 * called when probing existing modules and recording which extension
203 	 * points that this modle is used for. This means we won't have to
204 	 * load and initialze this module unless its needed.
205 	 * If this function is not implemented by the module the module will
206 	 * always be loaded, initialized and then unloaded on application startup
207 	 * so that it can register its extension points during init.
208 	 * Note that a module need not actually implement all the extension points
209 	 * that g_io_module_query returns, since the exact list of extension may
210 	 * depend on runtime issues. However all extension points actually implemented
211 	 * must be returned by g_io_module_query() (if defined).
212 	 * When installing a module that implements g_io_module_query you must
213 	 * run gio-querymodules in order to build the cache files required for
214 	 * lazy loading.
215 	 * Since 2.24
216 	 * Returns: A NULL-terminated array of strings, listing the supported extension points of the module. The array must be suitable for freeing with g_strfreev(). [transfer full]
217 	 */
218 	public static string[] query()
219 	{
220 		// char ** g_io_module_query (void);
221 		return Str.toStringArray(g_io_module_query());
222 	}
223 }