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 to load. 178 * 179 * Return: a list of #GIOModules loaded 180 * from the directory, 181 * All the modules are loaded into memory, if you want to 182 * unload them (enabling on-demand loading) you must call 183 * g_type_module_unuse() on all the modules. Free the list 184 * with g_list_free(). 185 */ 186 public static ListG loadAllInDirectory(string dirname) 187 { 188 auto p = g_io_modules_load_all_in_directory(Str.toStringz(dirname)); 189 190 if(p is null) 191 { 192 return null; 193 } 194 195 return new ListG(cast(GList*) p, true); 196 } 197 198 /** 199 * Loads all the modules in the specified directory. 200 * 201 * If don't require all modules to be initialized (and thus registering 202 * all gtypes) then you can use g_io_modules_scan_all_in_directory() 203 * which allows delayed/lazy loading of modules. 204 * 205 * Params: 206 * dirname = pathname for a directory containing modules to load. 207 * scop = a scope to use when scanning the modules. 208 * 209 * Return: a list of #GIOModules loaded 210 * from the directory, 211 * All the modules are loaded into memory, if you want to 212 * unload them (enabling on-demand loading) you must call 213 * g_type_module_unuse() on all the modules. Free the list 214 * with g_list_free(). 215 * 216 * Since: 2.30 217 */ 218 public static ListG loadAllInDirectoryWithScope(string dirname, IOModuleScope scop) 219 { 220 auto p = g_io_modules_load_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct()); 221 222 if(p is null) 223 { 224 return null; 225 } 226 227 return new ListG(cast(GList*) p, true); 228 } 229 230 /** 231 * Scans all the modules in the specified directory, ensuring that 232 * any extension point implemented by a module is registered. 233 * 234 * This may not actually load and initialize all the types in each 235 * module, some modules may be lazily loaded and initialized when 236 * an extension point it implementes is used with e.g. 237 * g_io_extension_point_get_extensions() or 238 * g_io_extension_point_get_extension_by_name(). 239 * 240 * If you need to guarantee that all types are loaded in all the modules, 241 * use g_io_modules_load_all_in_directory(). 242 * 243 * Params: 244 * dirname = pathname for a directory containing modules to scan. 245 * 246 * Since: 2.24 247 */ 248 public static void scanAllInDirectory(string dirname) 249 { 250 g_io_modules_scan_all_in_directory(Str.toStringz(dirname)); 251 } 252 253 /** 254 * Scans all the modules in the specified directory, ensuring that 255 * any extension point implemented by a module is registered. 256 * 257 * This may not actually load and initialize all the types in each 258 * module, some modules may be lazily loaded and initialized when 259 * an extension point it implementes is used with e.g. 260 * g_io_extension_point_get_extensions() or 261 * g_io_extension_point_get_extension_by_name(). 262 * 263 * If you need to guarantee that all types are loaded in all the modules, 264 * use g_io_modules_load_all_in_directory(). 265 * 266 * Params: 267 * dirname = pathname for a directory containing modules to scan. 268 * scop = a scope to use when scanning the modules 269 * 270 * Since: 2.30 271 */ 272 public static void scanAllInDirectoryWithScope(string dirname, IOModuleScope scop) 273 { 274 g_io_modules_scan_all_in_directory_with_scope(Str.toStringz(dirname), (scop is null) ? null : scop.getIOModuleScopeStruct()); 275 } 276 }