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.Plug; 26 27 private import gdk.Display; 28 private import gdk.Window : GdkWin = Window; 29 private import glib.ConstructionException; 30 private import gobject.ObjectG; 31 private import gobject.Signals; 32 private import gtk.Widget; 33 private import gtk.Window; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 public import gtkc.gtktypes; 37 private import std.algorithm; 38 39 40 /** 41 * Together with #GtkSocket, #GtkPlug provides the ability to embed 42 * widgets from one process into another process in a fashion that is 43 * transparent to the user. One process creates a #GtkSocket widget 44 * and passes the ID of that widget’s window to the other process, 45 * which then creates a #GtkPlug with that window ID. Any widgets 46 * contained in the #GtkPlug then will appear inside the first 47 * application’s window. 48 * 49 * The communication between a #GtkSocket and a #GtkPlug follows the 50 * [XEmbed Protocol](http://www.freedesktop.org/Standards/xembed-spec). 51 * This protocol has also been implemented in other toolkits, e.g. Qt, 52 * allowing the same level of integration when embedding a Qt widget 53 * in GTK+ or vice versa. 54 * 55 * The #GtkPlug and #GtkSocket widgets are only available when GTK+ 56 * is compiled for the X11 platform and %GDK_WINDOWING_X11 is defined. 57 * They can only be used on a #GdkX11Display. To use #GtkPlug and 58 * #GtkSocket, you need to include the `gtk/gtkx.h` header. 59 */ 60 public class Plug : Window 61 { 62 /** the main Gtk struct */ 63 protected GtkPlug* gtkPlug; 64 65 /** Get the main Gtk struct */ 66 public GtkPlug* getPlugStruct(bool transferOwnership = false) 67 { 68 if (transferOwnership) 69 ownedRef = false; 70 return gtkPlug; 71 } 72 73 /** the main Gtk struct as a void* */ 74 protected override void* getStruct() 75 { 76 return cast(void*)gtkPlug; 77 } 78 79 /** 80 * Sets our main struct and passes it to the parent class. 81 */ 82 public this (GtkPlug* gtkPlug, bool ownedRef = false) 83 { 84 this.gtkPlug = gtkPlug; 85 super(cast(GtkWindow*)gtkPlug, ownedRef); 86 } 87 88 89 /** */ 90 public static GType getType() 91 { 92 return gtk_plug_get_type(); 93 } 94 95 /** 96 * Creates a new plug widget inside the #GtkSocket identified 97 * by @socket_id. If @socket_id is 0, the plug is left “unplugged” and 98 * can later be plugged into a #GtkSocket by gtk_socket_add_id(). 99 * 100 * Params: 101 * socketId = the window ID of the socket, or 0. 102 * 103 * Returns: the new #GtkPlug widget. 104 * 105 * Throws: ConstructionException GTK+ fails to create the object. 106 */ 107 public this(ulong socketId) 108 { 109 auto p = gtk_plug_new(socketId); 110 111 if(p is null) 112 { 113 throw new ConstructionException("null returned by new"); 114 } 115 116 this(cast(GtkPlug*) p); 117 } 118 119 /** 120 * Create a new plug widget inside the #GtkSocket identified by socket_id. 121 * 122 * Params: 123 * display = the #GdkDisplay on which @socket_id is displayed 124 * socketId = the XID of the socket’s window. 125 * 126 * Returns: the new #GtkPlug widget. 127 * 128 * Since: 2.2 129 * 130 * Throws: ConstructionException GTK+ fails to create the object. 131 */ 132 public this(Display display, ulong socketId) 133 { 134 auto p = gtk_plug_new_for_display((display is null) ? null : display.getDisplayStruct(), socketId); 135 136 if(p is null) 137 { 138 throw new ConstructionException("null returned by new_for_display"); 139 } 140 141 this(cast(GtkPlug*) p); 142 } 143 144 /** 145 * Finish the initialization of @plug for a given #GtkSocket identified by 146 * @socket_id. This function will generally only be used by classes deriving from #GtkPlug. 147 * 148 * Params: 149 * socketId = the XID of the socket’s window. 150 */ 151 public void construct(ulong socketId) 152 { 153 gtk_plug_construct(gtkPlug, socketId); 154 } 155 156 /** 157 * Finish the initialization of @plug for a given #GtkSocket identified by 158 * @socket_id which is currently displayed on @display. 159 * This function will generally only be used by classes deriving from #GtkPlug. 160 * 161 * Params: 162 * display = the #GdkDisplay associated with @socket_id’s 163 * #GtkSocket. 164 * socketId = the XID of the socket’s window. 165 * 166 * Since: 2.2 167 */ 168 public void constructForDisplay(Display display, ulong socketId) 169 { 170 gtk_plug_construct_for_display(gtkPlug, (display is null) ? null : display.getDisplayStruct(), socketId); 171 } 172 173 /** 174 * Determines whether the plug is embedded in a socket. 175 * 176 * Returns: %TRUE if the plug is embedded in a socket 177 * 178 * Since: 2.14 179 */ 180 public bool getEmbedded() 181 { 182 return gtk_plug_get_embedded(gtkPlug) != 0; 183 } 184 185 /** 186 * Gets the window ID of a #GtkPlug widget, which can then 187 * be used to embed this window inside another window, for 188 * instance with gtk_socket_add_id(). 189 * 190 * Returns: the window ID for the plug 191 */ 192 public ulong getId() 193 { 194 return gtk_plug_get_id(gtkPlug); 195 } 196 197 /** 198 * Retrieves the socket the plug is embedded in. 199 * 200 * Returns: the window of the socket, or %NULL 201 * 202 * Since: 2.14 203 */ 204 public GdkWin getSocketWindow() 205 { 206 auto p = gtk_plug_get_socket_window(gtkPlug); 207 208 if(p is null) 209 { 210 return null; 211 } 212 213 return ObjectG.getDObject!(GdkWin)(cast(GdkWindow*) p); 214 } 215 216 /** 217 * Gets emitted when the plug becomes embedded in a socket. 218 */ 219 gulong addOnEmbedded(void delegate(Plug) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 220 { 221 return Signals.connect(this, "embedded", dlg, connectFlags ^ ConnectFlags.SWAPPED); 222 } 223 }