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 * Conversion parameters: 26 * inFile = GtkPlug.html 27 * outPack = gtk 28 * outFile = Plug 29 * strct = GtkPlug 30 * realStrct= 31 * ctorStrct= 32 * clss = Plug 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_plug_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - gdk.Display 48 * structWrap: 49 * - GdkDisplay* -> Display 50 * module aliases: 51 * local aliases: 52 * overrides: 53 */ 54 55 module gtk.Plug; 56 57 public import gtkc.gtktypes; 58 59 private import gtkc.gtk; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 private import gobject.Signals; 64 public import gtkc.gdktypes; 65 66 private import gdk.Display; 67 68 69 70 private import gtk.Window; 71 72 /** 73 * Description 74 * Together with GtkSocket, GtkPlug provides the ability 75 * to embed widgets from one process into another process 76 * in a fashion that is transparent to the user. One 77 * process creates a GtkSocket widget and passes the 78 * ID of that widget's window to the other process, 79 * which then creates a GtkPlug with that window ID. 80 * Any widgets contained in the GtkPlug then will appear 81 * inside the first application's window. 82 * Note 83 * The GtkPlug and GtkSocket widgets are currently not available 84 * on all platforms supported by GTK+. 85 */ 86 public class Plug : Window 87 { 88 89 /** the main Gtk struct */ 90 protected GtkPlug* gtkPlug; 91 92 93 public GtkPlug* getPlugStruct() 94 { 95 return gtkPlug; 96 } 97 98 99 /** the main Gtk struct as a void* */ 100 protected override void* getStruct() 101 { 102 return cast(void*)gtkPlug; 103 } 104 105 /** 106 * Sets our main struct and passes it to the parent class 107 */ 108 public this (GtkPlug* gtkPlug) 109 { 110 super(cast(GtkWindow*)gtkPlug); 111 this.gtkPlug = gtkPlug; 112 } 113 114 protected override void setStruct(GObject* obj) 115 { 116 super.setStruct(obj); 117 gtkPlug = cast(GtkPlug*)obj; 118 } 119 120 /** 121 */ 122 int[string] connectedSignals; 123 124 void delegate(Plug)[] onEmbeddedListeners; 125 /** 126 * Gets emitted when the plug becomes embedded in a socket. 127 * See Also 128 * GtkSocket 129 */ 130 void addOnEmbedded(void delegate(Plug) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 131 { 132 if ( !("embedded" in connectedSignals) ) 133 { 134 Signals.connectData( 135 getStruct(), 136 "embedded", 137 cast(GCallback)&callBackEmbedded, 138 cast(void*)this, 139 null, 140 connectFlags); 141 connectedSignals["embedded"] = 1; 142 } 143 onEmbeddedListeners ~= dlg; 144 } 145 extern(C) static void callBackEmbedded(GtkPlug* plugStruct, Plug _plug) 146 { 147 foreach ( void delegate(Plug) dlg ; _plug.onEmbeddedListeners ) 148 { 149 dlg(_plug); 150 } 151 } 152 153 154 /** 155 * Finish the initialization of plug for a given GtkSocket identified by 156 * socket_id. This function will generally only be used by classes deriving from GtkPlug. 157 * Params: 158 * socketId = the XID of the socket's window. 159 */ 160 public void construct(GdkNativeWindow socketId) 161 { 162 // void gtk_plug_construct (GtkPlug *plug, GdkNativeWindow socket_id); 163 gtk_plug_construct(gtkPlug, socketId); 164 } 165 166 /** 167 * Finish the initialization of plug for a given GtkSocket identified by 168 * socket_id which is currently displayed on display. 169 * This function will generally only be used by classes deriving from GtkPlug. 170 * Since 2.2 171 * Params: 172 * display = the GdkDisplay associated with socket_id's 173 * GtkSocket. 174 * socketId = the XID of the socket's window. 175 */ 176 public void constructForDisplay(Display display, GdkNativeWindow socketId) 177 { 178 // void gtk_plug_construct_for_display (GtkPlug *plug, GdkDisplay *display, GdkNativeWindow socket_id); 179 gtk_plug_construct_for_display(gtkPlug, (display is null) ? null : display.getDisplayStruct(), socketId); 180 } 181 182 /** 183 * Creates a new plug widget inside the GtkSocket identified 184 * by socket_id. If socket_id is 0, the plug is left "unplugged" and 185 * can later be plugged into a GtkSocket by gtk_socket_add_id(). 186 * Params: 187 * socketId = the window ID of the socket, or 0. 188 * Throws: ConstructionException GTK+ fails to create the object. 189 */ 190 public this (GdkNativeWindow socketId) 191 { 192 // GtkWidget * gtk_plug_new (GdkNativeWindow socket_id); 193 auto p = gtk_plug_new(socketId); 194 if(p is null) 195 { 196 throw new ConstructionException("null returned by gtk_plug_new(socketId)"); 197 } 198 this(cast(GtkPlug*) p); 199 } 200 201 /** 202 * Create a new plug widget inside the GtkSocket identified by socket_id. 203 * Since 2.2 204 * Params: 205 * display = the GdkDisplay on which socket_id is displayed 206 * socketId = the XID of the socket's window. 207 * Throws: ConstructionException GTK+ fails to create the object. 208 */ 209 public this (Display display, GdkNativeWindow socketId) 210 { 211 // GtkWidget * gtk_plug_new_for_display (GdkDisplay *display, GdkNativeWindow socket_id); 212 auto p = gtk_plug_new_for_display((display is null) ? null : display.getDisplayStruct(), socketId); 213 if(p is null) 214 { 215 throw new ConstructionException("null returned by gtk_plug_new_for_display((display is null) ? null : display.getDisplayStruct(), socketId)"); 216 } 217 this(cast(GtkPlug*) p); 218 } 219 220 /** 221 * Gets the window ID of a GtkPlug widget, which can then 222 * be used to embed this window inside another window, for 223 * instance with gtk_socket_add_id(). 224 * Returns: the window ID for the plug 225 */ 226 public GdkNativeWindow getId() 227 { 228 // GdkNativeWindow gtk_plug_get_id (GtkPlug *plug); 229 return gtk_plug_get_id(gtkPlug); 230 } 231 232 /** 233 * Determines whether the plug is embedded in a socket. 234 * Since 2.14 235 * Returns: TRUE if the plug is embedded in a socket 236 */ 237 public int getEmbedded() 238 { 239 // gboolean gtk_plug_get_embedded (GtkPlug *plug); 240 return gtk_plug_get_embedded(gtkPlug); 241 } 242 243 /** 244 * Retrieves the socket the plug is embedded in. 245 * Since 2.14 246 * Returns: the window of the socket, or NULL. [transfer none] 247 */ 248 public GdkWindow* getSocketWindow() 249 { 250 // GdkWindow * gtk_plug_get_socket_window (GtkPlug *plug); 251 return gtk_plug_get_socket_window(gtkPlug); 252 } 253 }