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_modules_ 42 * omit structs: 43 * omit prefixes: 44 * - g_io_module_scope_ 45 * omit code: 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - glib.ListG 50 * - gio.IOModuleScope 51 * structWrap: 52 * - GIOModuleScope* -> IOModuleScope 53 * - GList* -> ListG 54 * module aliases: 55 * local aliases: 56 * overrides: 57 */ 58 59 module gio.IOModule; 60 61 public import gtkc.giotypes; 62 63 private import gtkc.gio; 64 private import glib.ConstructionException; 65 private import gobject.ObjectG; 66 67 68 private import glib.Str; 69 private import glib.ListG; 70 private import gio.IOModuleScope; 71 72 73 74 private import gobject.TypeModule; 75 76 /** 77 * Provides an interface and default functions for loading and unloading 78 * modules. This is used internally to make GIO extensible, but can also 79 * be used by others to implement module loading. 80 */ 81 public class IOModule : TypeModule 82 { 83 84 /** the main Gtk struct */ 85 protected GIOModule* gIOModule; 86 87 88 public GIOModule* getIOModuleStruct() 89 { 90 return gIOModule; 91 } 92 93 94 /** the main Gtk struct as a void* */ 95 protected override void* getStruct() 96 { 97 return cast(void*)gIOModule; 98 } 99 100 /** 101 * Sets our main struct and passes it to the parent class 102 */ 103 public this (GIOModule* gIOModule) 104 { 105 super(cast(GTypeModule*)gIOModule); 106 this.gIOModule = gIOModule; 107 } 108 109 protected override void setStruct(GObject* obj) 110 { 111 super.setStruct(obj); 112 gIOModule = cast(GIOModule*)obj; 113 } 114 115 /** 116 */ 117 118 /** 119 * Creates a new GIOModule that will load the specific 120 * shared library when in use. 121 * Params: 122 * filename = filename of the shared library module. 123 * Throws: ConstructionException GTK+ fails to create the object. 124 */ 125 public this (string filename) 126 { 127 // GIOModule * g_io_module_new (const gchar *filename); 128 auto p = g_io_module_new(Str.toStringz(filename)); 129 if(p is null) 130 { 131 throw new ConstructionException("null returned by g_io_module_new(Str.toStringz(filename))"); 132 } 133 this(cast(GIOModule*) p); 134 } 135 136 /** 137 * Loads all the modules in the specified directory. 138 * If don't require all modules to be initialized (and thus registering 139 * all gtypes) then you can use g_io_modules_scan_all_in_directory() 140 * which allows delayed/lazy loading of modules. 141 * Params: 142 * dirname = pathname for a directory containing modules to load. 143 * 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] 144 */ 145 public static ListG loadAllInDirectory(string dirname) 146 { 147 // GList * g_io_modules_load_all_in_directory (const gchar *dirname); 148 auto p = g_io_modules_load_all_in_directory(Str.toStringz(dirname)); 149 150 if(p is null) 151 { 152 return null; 153 } 154 155 return ObjectG.getDObject!(ListG)(cast(GList*) p); 156 } 157 158 /** 159 * Loads all the modules in the specified directory. 160 * If don't require all modules to be initialized (and thus registering 161 * all gtypes) then you can use g_io_modules_scan_all_in_directory() 162 * which allows delayed/lazy loading of modules. 163 * Since 2.30 164 * Params: 165 * dirname = pathname for a directory containing modules to load. 166 * 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] 167 */ 168 public static ListG loadAllInDirectoryWithScope(string dirname, IOModuleScope scop) 169 { 170 // GList * g_io_modules_load_all_in_directory_with_scope (const gchar *dirname, GIOModuleScope *scope); 171 auto p = g_io_modules_load_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct()); 172 173 if(p is null) 174 { 175 return null; 176 } 177 178 return ObjectG.getDObject!(ListG)(cast(GList*) p); 179 } 180 181 /** 182 * Scans all the modules in the specified directory, ensuring that 183 * any extension point implemented by a module is registered. 184 * This may not actually load and initialize all the types in each 185 * module, some modules may be lazily loaded and initialized when 186 * an extension point it implementes is used with e.g. 187 * g_io_extension_point_get_extensions() or 188 * g_io_extension_point_get_extension_by_name(). 189 * If you need to guarantee that all types are loaded in all the modules, 190 * use g_io_modules_load_all_in_directory(). 191 * Since 2.24 192 * Params: 193 * dirname = pathname for a directory containing modules to scan. 194 */ 195 public static void scanAllInDirectory(string dirname) 196 { 197 // void g_io_modules_scan_all_in_directory (const char *dirname); 198 g_io_modules_scan_all_in_directory(Str.toStringz(dirname)); 199 } 200 201 /** 202 * Scans all the modules in the specified directory, ensuring that 203 * any extension point implemented by a module is registered. 204 * This may not actually load and initialize all the types in each 205 * module, some modules may be lazily loaded and initialized when 206 * an extension point it implementes is used with e.g. 207 * g_io_extension_point_get_extensions() or 208 * g_io_extension_point_get_extension_by_name(). 209 * If you need to guarantee that all types are loaded in all the modules, 210 * use g_io_modules_load_all_in_directory(). 211 * Since 2.30 212 * Params: 213 * dirname = pathname for a directory containing modules to scan. 214 */ 215 public static void scanAllInDirectoryWithScope(string dirname, IOModuleScope scop) 216 { 217 // void g_io_modules_scan_all_in_directory_with_scope (const gchar *dirname, GIOModuleScope *scope); 218 g_io_modules_scan_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct()); 219 } 220 221 /** 222 * Required API for GIO modules to implement. 223 * This function is ran after the module has been loaded into GIO, 224 * to initialize the module. 225 */ 226 public void load() 227 { 228 // void g_io_module_load (GIOModule *module); 229 g_io_module_load(gIOModule); 230 } 231 232 /** 233 * Required API for GIO modules to implement. 234 * This function is ran when the module is being unloaded from GIO, 235 * to finalize the module. 236 */ 237 public void unload() 238 { 239 // void g_io_module_unload (GIOModule *module); 240 g_io_module_unload(gIOModule); 241 } 242 243 /** 244 * Optional API for GIO modules to implement. 245 * Should return a list of all the extension points that may be 246 * implemented in this module. 247 * This method will not be called in normal use, however it may be 248 * called when probing existing modules and recording which extension 249 * points that this model is used for. This means we won't have to 250 * load and initialze this module unless its needed. 251 * If this function is not implemented by the module the module will 252 * always be loaded, initialized and then unloaded on application startup 253 * so that it can register its extension points during init. 254 * Note that a module need not actually implement all the extension points 255 * that g_io_module_query returns, since the exact list of extension may 256 * depend on runtime issues. However all extension points actually implemented 257 * must be returned by g_io_module_query() (if defined). 258 * When installing a module that implements g_io_module_query you must 259 * run gio-querymodules in order to build the cache files required for 260 * lazy loading. 261 * Since 2.24 262 * 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] 263 */ 264 public static string[] query() 265 { 266 // char ** g_io_module_query (void); 267 return Str.toStringArray(g_io_module_query()); 268 } 269 }