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 auto retStr = g_io_module_query(); 141 142 scope(exit) Str.freeStringArray(retStr); 143 return Str.toStringArray(retStr); 144 } 145 146 /** 147 * Required API for GIO modules to implement. 148 * 149 * This function is run after the module has been loaded into GIO, 150 * to initialize the module. Typically, this function will call 151 * g_io_extension_point_implement(). 152 */ 153 public void load() 154 { 155 g_io_module_load(gIOModule); 156 } 157 158 /** 159 * Required API for GIO modules to implement. 160 * 161 * This function is run when the module is being unloaded from GIO, 162 * to finalize the module. 163 */ 164 public void unload() 165 { 166 g_io_module_unload(gIOModule); 167 } 168 169 /** 170 * Loads all the modules in the specified directory. 171 * 172 * If don't require all modules to be initialized (and thus registering 173 * all gtypes) then you can use g_io_modules_scan_all_in_directory() 174 * which allows delayed/lazy loading of modules. 175 * 176 * Params: 177 * dirname = pathname for a directory containing modules 178 * to load. 179 * 180 * Return: a list of #GIOModules loaded 181 * from the directory, 182 * All the modules are loaded into memory, if you want to 183 * unload them (enabling on-demand loading) you must call 184 * g_type_module_unuse() on all the modules. Free the list 185 * with g_list_free(). 186 */ 187 public static ListG loadAllInDirectory(string dirname) 188 { 189 auto p = g_io_modules_load_all_in_directory(Str.toStringz(dirname)); 190 191 if(p is null) 192 { 193 return null; 194 } 195 196 return new ListG(cast(GList*) p, true); 197 } 198 199 /** 200 * Loads all the modules in the specified directory. 201 * 202 * If don't require all modules to be initialized (and thus registering 203 * all gtypes) then you can use g_io_modules_scan_all_in_directory() 204 * which allows delayed/lazy loading of modules. 205 * 206 * Params: 207 * dirname = pathname for a directory containing modules 208 * to load. 209 * scop = a scope to use when scanning the modules. 210 * 211 * Return: a list of #GIOModules loaded 212 * from the directory, 213 * All the modules are loaded into memory, if you want to 214 * unload them (enabling on-demand loading) you must call 215 * g_type_module_unuse() on all the modules. Free the list 216 * with g_list_free(). 217 * 218 * Since: 2.30 219 */ 220 public static ListG loadAllInDirectoryWithScope(string dirname, IOModuleScope scop) 221 { 222 auto p = g_io_modules_load_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct()); 223 224 if(p is null) 225 { 226 return null; 227 } 228 229 return new ListG(cast(GList*) p, true); 230 } 231 232 /** 233 * Scans all the modules in the specified directory, ensuring that 234 * any extension point implemented by a module is registered. 235 * 236 * This may not actually load and initialize all the types in each 237 * module, some modules may be lazily loaded and initialized when 238 * an extension point it implementes is used with e.g. 239 * g_io_extension_point_get_extensions() or 240 * g_io_extension_point_get_extension_by_name(). 241 * 242 * If you need to guarantee that all types are loaded in all the modules, 243 * use g_io_modules_load_all_in_directory(). 244 * 245 * Params: 246 * dirname = pathname for a directory containing modules 247 * to scan. 248 * 249 * Since: 2.24 250 */ 251 public static void scanAllInDirectory(string dirname) 252 { 253 g_io_modules_scan_all_in_directory(Str.toStringz(dirname)); 254 } 255 256 /** 257 * Scans all the modules in the specified directory, ensuring that 258 * any extension point implemented by a module is registered. 259 * 260 * This may not actually load and initialize all the types in each 261 * module, some modules may be lazily loaded and initialized when 262 * an extension point it implementes is used with e.g. 263 * g_io_extension_point_get_extensions() or 264 * g_io_extension_point_get_extension_by_name(). 265 * 266 * If you need to guarantee that all types are loaded in all the modules, 267 * use g_io_modules_load_all_in_directory(). 268 * 269 * Params: 270 * dirname = pathname for a directory containing modules 271 * to scan. 272 * scop = a scope to use when scanning the modules 273 * 274 * Since: 2.30 275 */ 276 public static void scanAllInDirectoryWithScope(string dirname, IOModuleScope scop) 277 { 278 g_io_modules_scan_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct()); 279 } 280 }