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 * Return: 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 * Optional API for GIO modules to implement. 109 * 110 * Should return a list of all the extension points that may be 111 * implemented in this module. 112 * 113 * This method will not be called in normal use, however it may be 114 * called when probing existing modules and recording which extension 115 * points that this model is used for. This means we won't have to 116 * load and initialize this module unless its needed. 117 * 118 * If this function is not implemented by the module the module will 119 * always be loaded, initialized and then unloaded on application 120 * startup so that it can register its extension points during init. 121 * 122 * Note that a module need not actually implement all the extension 123 * points that g_io_module_query() returns, since the exact list of 124 * extension may depend on runtime issues. However all extension 125 * points actually implemented must be returned by g_io_module_query() 126 * (if defined). 127 * 128 * When installing a module that implements g_io_module_query() you must 129 * run gio-querymodules in order to build the cache files required for 130 * lazy loading. 131 * 132 * Return: A %NULL-terminated array of strings, 133 * listing the supported extension points of the module. The array 134 * must be suitable for freeing with g_strfreev(). 135 * 136 * Since: 2.24 137 */ 138 public static string[] query() 139 { 140 return Str.toStringArray(g_io_module_query()); 141 } 142 143 /** 144 * Required API for GIO modules to implement. 145 * 146 * This function is run after the module has been loaded into GIO, 147 * to initialize the module. Typically, this function will call 148 * g_io_extension_point_implement(). 149 */ 150 public void load() 151 { 152 g_io_module_load(gIOModule); 153 } 154 155 /** 156 * Required API for GIO modules to implement. 157 * 158 * This function is run when the module is being unloaded from GIO, 159 * to finalize the module. 160 */ 161 public void unload() 162 { 163 g_io_module_unload(gIOModule); 164 } 165 166 /** 167 * Loads all the modules in the specified directory. 168 * 169 * If don't require all modules to be initialized (and thus registering 170 * all gtypes) then you can use g_io_modules_scan_all_in_directory() 171 * which allows delayed/lazy loading of modules. 172 * 173 * Params: 174 * dirname = pathname for a directory containing modules to load. 175 * 176 * Return: a list of #GIOModules loaded 177 * from the directory, 178 * All the modules are loaded into memory, if you want to 179 * unload them (enabling on-demand loading) you must call 180 * g_type_module_unuse() on all the modules. Free the list 181 * with g_list_free(). 182 */ 183 public static ListG loadAllInDirectory(string dirname) 184 { 185 auto p = g_io_modules_load_all_in_directory(Str.toStringz(dirname)); 186 187 if(p is null) 188 { 189 return null; 190 } 191 192 return new ListG(cast(GList*) p); 193 } 194 195 /** 196 * Loads all the modules in the specified directory. 197 * 198 * If don't require all modules to be initialized (and thus registering 199 * all gtypes) then you can use g_io_modules_scan_all_in_directory() 200 * which allows delayed/lazy loading of modules. 201 * 202 * Params: 203 * dirname = pathname for a directory containing modules to load. 204 * scop = a scope to use when scanning the modules. 205 * 206 * Return: a list of #GIOModules loaded 207 * from the directory, 208 * All the modules are loaded into memory, if you want to 209 * unload them (enabling on-demand loading) you must call 210 * g_type_module_unuse() on all the modules. Free the list 211 * with g_list_free(). 212 * 213 * Since: 2.30 214 */ 215 public static ListG loadAllInDirectoryWithScope(string dirname, IOModuleScope scop) 216 { 217 auto p = g_io_modules_load_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct()); 218 219 if(p is null) 220 { 221 return null; 222 } 223 224 return new ListG(cast(GList*) p); 225 } 226 227 /** 228 * Scans all the modules in the specified directory, ensuring that 229 * any extension point implemented by a module is registered. 230 * 231 * This may not actually load and initialize all the types in each 232 * module, some modules may be lazily loaded and initialized when 233 * an extension point it implementes is used with e.g. 234 * g_io_extension_point_get_extensions() or 235 * g_io_extension_point_get_extension_by_name(). 236 * 237 * If you need to guarantee that all types are loaded in all the modules, 238 * use g_io_modules_load_all_in_directory(). 239 * 240 * Params: 241 * dirname = pathname for a directory containing modules to scan. 242 * 243 * Since: 2.24 244 */ 245 public static void scanAllInDirectory(string dirname) 246 { 247 g_io_modules_scan_all_in_directory(Str.toStringz(dirname)); 248 } 249 250 /** 251 * Scans all the modules in the specified directory, ensuring that 252 * any extension point implemented by a module is registered. 253 * 254 * This may not actually load and initialize all the types in each 255 * module, some modules may be lazily loaded and initialized when 256 * an extension point it implementes is used with e.g. 257 * g_io_extension_point_get_extensions() or 258 * g_io_extension_point_get_extension_by_name(). 259 * 260 * If you need to guarantee that all types are loaded in all the modules, 261 * use g_io_modules_load_all_in_directory(). 262 * 263 * Params: 264 * dirname = pathname for a directory containing modules to scan. 265 * scop = a scope to use when scanning the modules 266 * 267 * Since: 2.30 268 */ 269 public static void scanAllInDirectoryWithScope(string dirname, IOModuleScope scop) 270 { 271 g_io_modules_scan_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct()); 272 } 273 }