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 gtk.BuilderCScope; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtk.BuilderScopeIF; 31 private import gtk.BuilderScopeT; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 35 36 /** 37 * A `GtkBuilderScope` implementation for the C language. 38 * 39 * `GtkBuilderCScope` instances use symbols explicitly added to @builder 40 * with prior calls to [method@Gtk.BuilderCScope.add_callback_symbol]. 41 * If developers want to do that, they are encouraged to create their 42 * own scopes for that purpose. 43 * 44 * In the case that symbols are not explicitly added; GTK will uses 45 * `GModule`’s introspective features (by opening the module %NULL) to 46 * look at the application’s symbol table. From here it tries to match 47 * the signal function names given in the interface description with 48 * symbols in the application. 49 * 50 * Note that unless [method@Gtk.BuilderCScope.add_callback_symbol] is 51 * called for all signal callbacks which are referenced by the loaded XML, 52 * this functionality will require that `GModule` be supported on the platform. 53 */ 54 public class BuilderCScope : ObjectG, BuilderScopeIF 55 { 56 /** the main Gtk struct */ 57 protected GtkBuilderCScope* gtkBuilderCScope; 58 59 /** Get the main Gtk struct */ 60 public GtkBuilderCScope* getBuilderCScopeStruct(bool transferOwnership = false) 61 { 62 if (transferOwnership) 63 ownedRef = false; 64 return gtkBuilderCScope; 65 } 66 67 /** the main Gtk struct as a void* */ 68 protected override void* getStruct() 69 { 70 return cast(void*)gtkBuilderCScope; 71 } 72 73 /** 74 * Sets our main struct and passes it to the parent class. 75 */ 76 public this (GtkBuilderCScope* gtkBuilderCScope, bool ownedRef = false) 77 { 78 this.gtkBuilderCScope = gtkBuilderCScope; 79 super(cast(GObject*)gtkBuilderCScope, ownedRef); 80 } 81 82 // add the BuilderScope capabilities 83 mixin BuilderScopeT!(GtkBuilderCScope); 84 85 86 /** */ 87 public static GType getType() 88 { 89 return gtk_builder_cscope_get_type(); 90 } 91 92 /** 93 * Creates a new `GtkBuilderCScope` object to use with future 94 * `GtkBuilder` instances. 95 * 96 * Calling this function is only necessary if you want to add 97 * custom callbacks via [method@Gtk.BuilderCScope.add_callback_symbol]. 98 * 99 * Returns: a new `GtkBuilderCScope` 100 * 101 * Throws: ConstructionException GTK+ fails to create the object. 102 */ 103 public this() 104 { 105 auto __p = gtk_builder_cscope_new(); 106 107 if(__p is null) 108 { 109 throw new ConstructionException("null returned by new"); 110 } 111 112 this(cast(GtkBuilderCScope*) __p, true); 113 } 114 115 /** 116 * Adds the @callback_symbol to the scope of @builder under the 117 * given @callback_name. 118 * 119 * Using this function overrides the behavior of 120 * [method@Gtk.Builder.create_closure] for any callback symbols that 121 * are added. Using this method allows for better encapsulation as it 122 * does not require that callback symbols be declared in the global 123 * namespace. 124 * 125 * Params: 126 * callbackName = The name of the callback, as expected in the XML 127 * callbackSymbol = The callback pointer 128 */ 129 public void addCallbackSymbol(string callbackName, GCallback callbackSymbol) 130 { 131 gtk_builder_cscope_add_callback_symbol(gtkBuilderCScope, Str.toStringz(callbackName), callbackSymbol); 132 } 133 134 /** 135 * Fetches a symbol previously added with 136 * gtk_builder_cscope_add_callback_symbol(). 137 * 138 * Params: 139 * callbackName = The name of the callback 140 * 141 * Returns: The callback symbol 142 * in @builder for @callback_name, or %NULL 143 */ 144 public GCallback lookupCallbackSymbol(string callbackName) 145 { 146 return gtk_builder_cscope_lookup_callback_symbol(gtkBuilderCScope, Str.toStringz(callbackName)); 147 } 148 }