1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Container for widgets from other processes
7 <!-- ##### SECTION Long_Description ##### -->
9 Together with #GtkPlug, #GtkSocket provides the ability
10 to embed widgets from one process into another process
11 in a fashion that is transparent to the user. One
12 process creates a #GtkSocket widget and, passes the
13 that widget's window ID to the other process,
14 which then creates a #GtkPlug with that window ID.
15 Any widgets contained in the #GtkPlug then will appear
16 inside the first applications window.
20 The socket's window ID is obtained by using
21 gtk_socket_get_id(). Before using this function,
22 the socket must have been realized, and for hence,
23 have been added to its parent.
26 <title>Obtaining the window ID of a socket.</title>
28 GtkWidget *socket = gtk_socket_new (<!-- -->);
29 gtk_widget_show (socket);
30 gtk_container_add (GTK_CONTAINER (parent), socket);
32 /* The following call is only necessary if one of
33 * the ancestors of the socket is not yet visible.
35 gtk_widget_realize (socket);
36 g_print ("The ID of the sockets window is %#x\n",
37 gtk_socket_get_id (socket));
43 Note that if you pass the window ID of the socket to another
44 process that will create a plug in the socket, you
45 must make sure that the socket widget is not destroyed
46 until that plug is created. Violating this rule will
47 cause unpredictable consequences, the most likely
48 consequence being that the plug will appear as a
49 separate toplevel window. You can check if the plug
50 has been created by examining the
51 <structfield>plug_window</structfield> field of the
52 #GtkSocket structure. If this field is non-%NULL,
53 then the plug has been successfully created inside
58 When GTK+ is notified that the embedded window has been
59 destroyed, then it will destroy the socket as well. You
60 should always, therefore, be prepared for your sockets
61 to be destroyed at any time when the main event loop
66 The communication between a #GtkSocket and a #GtkPlug follows the
67 <ulink url="http://www.freedesktop.org/standards/xembed-spec">XEmbed</ulink>
68 protocol. This protocol has also been implemented in other toolkits, e.g.
69 <application>Qt</application>, allowing the same level of integration
70 when embedding a <application>Qt</application> widget in GTK or vice versa.</para>
73 A socket can also be used to swallow arbitrary
74 pre-existing top-level windows using gtk_socket_steal(),
75 though the integration when this is done will not be as close
76 as between a #GtkPlug and a #GtkSocket.</para>
80 The #GtkPlug and #GtkSocket widgets are currently not available
81 on all platforms supported by GTK+.
85 <!-- ##### SECTION See_Also ##### -->
91 <listitem><para>the widget that plugs into a #GtkSocket.</para></listitem>
95 <term><ulink url="http://www.freedesktop.org/standards/xembed-spec">XEmbed</ulink></term>
96 <listitem><para>the XEmbed Protocol Specification.</para></listitem>
102 <!-- ##### SECTION Stability_Level ##### -->
105 <!-- ##### STRUCT GtkSocket ##### -->
107 The #GtkSocket structure contains the <structfield>plug_window</structfield>
108 field. (This field should be considered read-only. It should
109 never be set by an application.)
113 <!-- ##### SIGNAL GtkSocket::plug-added ##### -->
115 This signal is emitted when a client is successfully
119 @socket: the object which received the signal.
120 <!-- # Unused Parameters # -->
121 @socket_: the object which received the signal.
123 <!-- ##### SIGNAL GtkSocket::plug-removed ##### -->
125 This signal is emitted when a client is removed from the socket. The
126 default action is to destroy the #GtkSocket widget, so if you want to
127 reuse it you must add a signal handler that returns %TRUE.
130 @socket: the object which received the signal.
132 <!-- # Unused Parameters # -->
133 @socket_: the object which received the signal.
135 <!-- ##### FUNCTION gtk_socket_new ##### -->
142 <!-- ##### FUNCTION gtk_socket_steal ##### -->
146 @socket_: a #GtkSocket.
150 <!-- ##### FUNCTION gtk_socket_add_id ##### -->
159 <!-- ##### FUNCTION gtk_socket_get_id ##### -->