2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkSocket.html
51 private import gtk
.gtktypes
;
53 private import lib
.gtk
;
58 * Together with GtkPlug, GtkSocket provides the ability
59 * to embed widgets from one process into another process
60 * in a fashion that is transparent to the user. One
61 * process creates a GtkSocket widget and, passes the
62 * that widget's window ID to the other process,
63 * which then creates a GtkPlug with that window ID.
64 * Any widgets contained in the GtkPlug then will appear
65 * inside the first applications window.
66 * The socket's window ID is obtained by using
67 * gtk_socket_get_id(). Before using this function,
68 * the socket must have been realized, and for hence,
69 * have been added to its parent.
70 * Example1.Obtaining the window ID of a socket.
71 * GtkWidget *socket = gtk_socket_new ();
72 * gtk_widget_show (socket);
73 * gtk_container_add (GTK_CONTAINER (parent), socket);
74 * /+* The following call is only necessary if one of
75 * * the ancestors of the socket is not yet visible.
77 * gtk_widget_realize (socket);
78 * g_print ("The ID of the sockets window is %x\n",
79 * gtk_socket_get_id (socket));
80 * Note that if you pass the window ID of the socket to another
81 * process that will create a plug in the socket, you
82 * must make sure that the socket widget is not destroyed
83 * until that plug is created. Violating this rule will
84 * cause unpredictable consequences, the most likely
85 * consequence being that the plug will appear as a
86 * separate toplevel window. You can check if the plug
87 * has been created by examining the
88 * plug_window field of the
89 * GtkSocket structure. If this field is non-NULL,
90 * then the plug has been successfully created inside
92 * When GTK+ is notified that the embedded window has been
93 * destroyed, then it will destroy the socket as well. You
94 * should always, therefore, be prepared for your sockets
95 * to be destroyed at any time when the main event loop
97 * The communication between a GtkSocket and a GtkPlug follows the
99 * protocol. This protocol has also been implemented in other toolkits, e.g.
100 * Qt, allowing the same level of integration
101 * when embedding a Qt widget in GTK or vice versa.
102 * A socket can also be used to swallow arbitrary
103 * pre-existing top-level windows using gtk_socket_steal(),
104 * though the integration when this is done will not be as close
105 * as between a GtkPlug and a GtkSocket.
107 * The GtkPlug and GtkSocket widgets are currently not available
108 * on all platforms supported by GTK+.
110 private import gtk
.Container
;
111 public class Socket
: Container
114 /** the main Gtk struct */
115 protected GtkSocket
* gtkSocket
;
118 public GtkSocket
* getSocketStruct()
124 /** the main Gtk struct as a void* */
125 protected void* getStruct()
127 return cast(void*)gtkSocket
;
131 * Sets our main struct and passes it to the parent class
133 public this (GtkSocket
* gtkSocket
)
135 super(cast(GtkContainer
*)gtkSocket
);
136 this.gtkSocket
= gtkSocket
;
142 // imports for the signal processing
143 private import gobject
.Signals
;
144 private import gdk
.gdktypes
;
145 int[char[]] connectedSignals
;
147 void delegate(Socket
)[] onPlugAddedListeners
;
148 void addOnPlugAdded(void delegate(Socket
) dlg
)
150 if ( !("plug-added" in connectedSignals
) )
155 cast(GCallback
)&callBackPlugAdded
,
158 cast(ConnectFlags
)0);
159 connectedSignals
["plug-added"] = 1;
161 onPlugAddedListeners
~= dlg
;
163 extern(C
) static void callBackPlugAdded(GtkSocket
* socketStruct
, Socket socket
)
165 bit consumed
= false;
167 foreach ( void delegate(Socket
) dlg
; socket
.onPlugAddedListeners
)
175 gboolean
delegate(Socket
)[] onPlugRemovedListeners
;
176 void addOnPlugRemoved(gboolean
delegate(Socket
) dlg
)
178 if ( !("plug-removed" in connectedSignals
) )
183 cast(GCallback
)&callBackPlugRemoved
,
186 cast(ConnectFlags
)0);
187 connectedSignals
["plug-removed"] = 1;
189 onPlugRemovedListeners
~= dlg
;
191 extern(C
) static void callBackPlugRemoved(GtkSocket
* socketStruct
, Socket socket
)
193 bit consumed
= false;
195 foreach ( gboolean
delegate(Socket
) dlg
; socket
.onPlugRemovedListeners
)
206 * Create a new empty GtkSocket.
212 // GtkWidget* gtk_socket_new (void);
213 this(cast(GtkSocket
*)gtk_socket_new() );
218 * gtk_socket_steal is deprecated and should not be used in newly-written code.
219 * Reparents a pre-existing toplevel window into a GtkSocket. This is
220 * meant to embed clients that do not know about embedding into a
221 * GtkSocket, however doing so is inherently unreliable, and using
222 * this function is not recommended.
223 * The GtkSocket must have already be added into a toplevel window
224 * before you can make this call.
228 * the window ID of an existing toplevel window.
230 public void steal(GdkNativeWindow wid
)
232 // void gtk_socket_steal (GtkSocket *socket_, GdkNativeWindow wid);
233 gtk_socket_steal(gtkSocket
, wid
);
237 * Adds an XEMBED client, such as a GtkPlug, to the GtkSocket. The
238 * client may be in the same process or in a different process.
239 * To embed a GtkPlug in a GtkSocket, you can either create the
240 * GtkPlug with gtk_plug_new (0), call
241 * gtk_plug_get_id() to get the window ID of the plug, and then pass that to the
242 * gtk_socket_add_id(), or you can call gtk_socket_get_id() to get the
243 * window ID for the socket, and call gtk_plug_new() passing in that
245 * The GtkSocket must have already be added into a toplevel window
246 * before you can make this call.
250 * the window ID of a client participating in the XEMBED protocol.
252 public void addId(GdkNativeWindow windowId
)
254 // void gtk_socket_add_id (GtkSocket *socket_, GdkNativeWindow window_id);
255 gtk_socket_add_id(gtkSocket
, windowId
);
259 * Gets the window ID of a GtkSocket widget, which can then
260 * be used to create a client embedded inside the socket, for
261 * instance with gtk_plug_new().
262 * The GtkSocket must have already be added into a toplevel window
263 * before you can make this call.
267 * the window ID for the socket
269 * The "plug-added" signal
270 * void user_function (GtkSocket *socket,
271 * gpointer user_data) : Run last
272 * This signal is emitted when a client is successfully
273 * added to the socket.
275 * the object which received the signal.
277 * user data set when the signal handler was connected.
279 public GdkNativeWindow
getId()
281 // GdkNativeWindow gtk_socket_get_id (GtkSocket *socket_);
282 return gtk_socket_get_id(gtkSocket
);