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