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.IOModuleScope;
26 
27 private import gio.c.functions;
28 public  import gio.c.types;
29 private import glib.ConstructionException;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 public  import gtkc.giotypes;
33 private import gtkd.Loader;
34 
35 
36 /**
37  * Represents a scope for loading IO modules. A scope can be used for blocking
38  * duplicate modules, or blocking a module you don't want to load.
39  * 
40  * The scope can be used with g_io_modules_load_all_in_directory_with_scope()
41  * or g_io_modules_scan_all_in_directory_with_scope().
42  *
43  * Since: 2.30
44  */
45 public class IOModuleScope
46 {
47 	/** the main Gtk struct */
48 	protected GIOModuleScope* gIOModuleScope;
49 	protected bool ownedRef;
50 
51 	/** Get the main Gtk struct */
52 	public GIOModuleScope* getIOModuleScopeStruct(bool transferOwnership = false)
53 	{
54 		if (transferOwnership)
55 			ownedRef = false;
56 		return gIOModuleScope;
57 	}
58 
59 	/** the main Gtk struct as a void* */
60 	protected void* getStruct()
61 	{
62 		return cast(void*)gIOModuleScope;
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GIOModuleScope* gIOModuleScope, bool ownedRef = false)
69 	{
70 		this.gIOModuleScope = gIOModuleScope;
71 		this.ownedRef = ownedRef;
72 	}
73 
74 	~this ()
75 	{
76 		if ( Linker.isLoaded(LIBRARY_GIO) && ownedRef )
77 			g_io_module_scope_free(gIOModuleScope);
78 	}
79 
80 
81 	/**
82 	 * Block modules with the given @basename from being loaded when
83 	 * this scope is used with g_io_modules_scan_all_in_directory_with_scope()
84 	 * or g_io_modules_load_all_in_directory_with_scope().
85 	 *
86 	 * Params:
87 	 *     basename = the basename to block
88 	 *
89 	 * Since: 2.30
90 	 */
91 	public void block(string basename)
92 	{
93 		g_io_module_scope_block(gIOModuleScope, Str.toStringz(basename));
94 	}
95 
96 	/**
97 	 * Free a module scope.
98 	 *
99 	 * Since: 2.30
100 	 */
101 	public void free()
102 	{
103 		g_io_module_scope_free(gIOModuleScope);
104 		ownedRef = false;
105 	}
106 
107 	/**
108 	 * Create a new scope for loading of IO modules. A scope can be used for
109 	 * blocking duplicate modules, or blocking a module you don't want to load.
110 	 *
111 	 * Specify the %G_IO_MODULE_SCOPE_BLOCK_DUPLICATES flag to block modules
112 	 * which have the same base name as a module that has already been seen
113 	 * in this scope.
114 	 *
115 	 * Params:
116 	 *     flags = flags for the new scope
117 	 *
118 	 * Returns: the new module scope
119 	 *
120 	 * Since: 2.30
121 	 *
122 	 * Throws: ConstructionException GTK+ fails to create the object.
123 	 */
124 	public this(GIOModuleScopeFlags flags)
125 	{
126 		auto p = g_io_module_scope_new(flags);
127 
128 		if(p is null)
129 		{
130 			throw new ConstructionException("null returned by new");
131 		}
132 
133 		this(cast(GIOModuleScope*) p);
134 	}
135 }