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