Gtk.Socket


Gtk.Socket — Container for widgets from other processes

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Socket

See also:

Gtk.Plug, XEmbed Protocol


Functions:


Signals:

  • “plug-added” (socket_, user_data)

Description:

Together with GtkPlug, Gtk.Socket provides the ability to embed widgets from one process into another process in a fashion that is transparent to the user. One process creates a Gtk.Socket widget and passes that widget’s window ID to the other process, which then creates a Gtk.Plug with that window ID. Any widgets contained in the Gtk.Plug then 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.
    socket = Gtk.Socket()
    print("Socket ID:", socket.get_id())

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-None value, 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-removed signal.

The communication between a Gtk.Socket and a GtkPlug follows the [XEmbed Protocol](http://www.freedesktop.org/Standards/xembed-spec\).

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 GtkPlug and Gtk.Socket widgets 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 use Gtk.Plug and Gtk.Socket, you need to include the gtk/gtkx.h header.


Function Details:

new()

new () -> Gtk.Widget

Create a new empty Gtk.Socket.

  • Returns: the new Gtk.Socket.

add_id()

add_id (self, window:int)

Adds an XEMBED client, such as a Gtk.Plug, to the Gtk.Socket. Theclient may be in the same process or in a different process. To embed a Gtk.Plug in a Gtk.Socket, you can either create theGtk.Plug with Gtk.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 call Gtk.Socket:get_id() to get thewindow ID for the socket, and call `Gtk.Plug:new()passing in thatID. TheGtk.Socket` must have already be added into a toplevel window before you can make this call.


get_id()

get_id (self) -> int

Gets the window ID of a Gtk.Socket widget, which can thenbe used to create a client embedded inside the socket, forinstance with `Gtk.Plug:new(). TheGtk.Socket` must have already be added into a toplevel window before you can make this call.

  • Returns: the window ID for the socket

get_plug_window()

get_plug_window (self) -> Gdk.Window

Retrieves the window of the plug. Use this to check if the plug hasbeen created inside of the socket.

  • Returns: the window of the plug if available, or None.

  • Since: 2.14


results matching ""

    No results matching ""