Gtk.Socket¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)
- Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class |
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Style Properties¶
- Inherited:
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
This signal is emitted when a client is successfully added to the socket. |
|
This signal is emitted when a client is removed from the socket. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
container |
r |
Class Details¶
- class Gtk.Socket(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Together with
Gtk.Plug,Gtk.Socketprovides the ability to embed widgets from one process into another process in a fashion that is transparent to the user. One process creates aGtk.Socketwidget and passes that widget’s window ID to the other process, which then creates aGtk.Plugwith that window ID. Any widgets contained in theGtk.Plugthen will appear inside the first application’s window.The socket’s window ID is obtained by using
Gtk.Socket.get_id(). Before using this function, the socket must have been realized, and for hence, have been added to its parent.- Obtaining the window ID of a socket.
GtkWidget *socket = gtk_socket_new (); gtk_widget_show (socket); gtk_container_add (GTK_CONTAINER (parent), socket); // The following call is only necessary if one of // the ancestors of the socket is not yet visible. gtk_widget_realize (socket); g_print ("The ID of the sockets window is %#x\n", gtk_socket_get_id (socket));
Note that if you pass the window ID of the socket to another process that will create a plug in the socket, you must make sure that the socket widget is not destroyed until that plug is created. Violating this rule will cause unpredictable consequences, the most likely consequence being that the plug will appear as a separate toplevel window. You can check if the plug has been created by using
Gtk.Socket.get_plug_window(). If it returns a non-Nonevalue, then the plug has been successfully created inside of the socket.When GTK+ is notified that the embedded window has been destroyed, then it will destroy the socket as well. You should always, therefore, be prepared for your sockets to be destroyed at any time when the main event loop is running. To prevent this from happening, you can connect to the
Gtk.Socket::plug-removedsignal.The communication between a
Gtk.Socketand aGtk.Plugfollows the XEmbed Protocol. This protocol has also been implemented in other toolkits, e.g. Qt, allowing the same level of integration when embedding a Qt widget in GTK or vice versa.The
Gtk.PlugandGtk.Socketwidgets are only available when GTK+ is compiled for the X11 platform and %GDK_WINDOWING_X11 is defined. They can only be used on a #GdkX11Display. To useGtk.PlugandGtk.Socket, you need to include thegtk/gtkx.hheader.- classmethod new()[source]¶
- Returns:
the new
Gtk.Socket.- Return type:
Create a new empty
Gtk.Socket.
- add_id(window)[source]¶
- Parameters:
window (
int) – the Window of a client participating in the XEMBED protocol.
Adds an XEMBED client, such as a
Gtk.Plug, to theGtk.Socket. The client may be in the same process or in a different process.To embed a
Gtk.Plugin aGtk.Socket, you can either create theGtk.Plugwithgtk_plug_new (0), callGtk.Plug.get_id() to get the window ID of the plug, and then pass that to theGtk.Socket.add_id(), or you can callGtk.Socket.get_id() to get the window ID for the socket, and callGtk.Plug.new() passing in that ID.The
Gtk.Socketmust have already be added into a toplevel window before you can make this call.
- get_id()[source]¶
- Returns:
the window ID for the socket
- Return type:
Gets the window ID of a
Gtk.Socketwidget, which can then be used to create a client embedded inside the socket, for instance withGtk.Plug.new().The
Gtk.Socketmust have already be added into a toplevel window before you can make this call.
- get_plug_window()[source]¶
- Returns:
the window of the plug if available, or
None- Return type:
Gdk.WindoworNone
Retrieves the window of the plug. Use this to check if the plug has been created inside of the socket.
New in version 2.14.
- do_plug_added() virtual¶
Signal Details¶
- Gtk.Socket.signals.plug_added(socket)¶
- Signal Name:
plug-added- Flags:
- Parameters:
socket (
Gtk.Socket) – The object which received the signal
This signal is emitted when a client is successfully added to the socket.
- Gtk.Socket.signals.plug_removed(socket)¶
- Signal Name:
plug-removed- Flags:
- Parameters:
socket (
Gtk.Socket) – The object which received the signal- Returns:
Trueto stop other handlers from being invoked.- Return type:
This signal is emitted when a client is removed from the socket. The default action is to destroy the
Gtk.Socketwidget, so if you want to reuse it you must add a signal handler that returnsTrue.