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