Gtk.Plug


Gtk.Plug — Toplevel for embedding into other processes

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Bin
                    ╰── Gtk.Window
                        ╰── Gtk.Plug

See also:

Gtk.Socket


Functions:

Description:

Together with Gtk.Socket, GtkPlug 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 the ID of that widget’s window 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 communication between a Gtk.Socket and a GtkPlug follows 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 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:

construct()

construct (self, socket_id:int)

Finish the initialization of plug for a given Gtk.Socket identified bysocket_id. This function will generally only be used by classes deriving from Gtk.Plug.


construct_for_display()

construct_for_display (self, display:Gdk.Display, socket_id:int)

Finish the initialization of plug for a given Gtk.Socket identified bysocket_id which is currently displayed on display.This function will generally only be used by classes deriving from Gtk.Plug.

  • Since: 2.2

new()

new (socket_id:int) -> Gtk.Widget

Creates a new plug widget inside the Gtk.Socket identifiedby socket_id. If socket_id is 0, the plug is left “unplugged” andcan later be plugged into a Gtk.Socket by `Gtk.Socket:add_id()`.

  • Returns: the new Gtk.Plug widget.

new_for_display()

new_for_display (display:Gdk.Display, socket_id:int) -> Gtk.Widget

Create a new plug widget inside the Gtk.Socket identified by socket_id.

  • Returns: the new Gtk.Plug widget.

  • Since: 2.2


get_id()

get_id (self) -> int

Gets the window ID of a Gtk.Plug widget, which can thenbe used to embed this window inside another window, forinstance with `Gtk.Socket:add_id()`.

  • Returns: the window ID for the plug

get_embedded()

get_embedded (self) -> bool

Determines whether the plug is embedded in a socket.

  • Returns: True if the plug is embedded in a socket

  • Since: 2.14


get_socket_window()

get_socket_window (self) -> Gdk.Window

Retrieves the socket the plug is embedded in.

  • Returns: the window of the socket, or None.

  • Since: 2.14


Example:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import sys

def embed_event(widget):
    print("A plug has been embedded")

if len(sys.argv) == 2:
    socket_id = sys.argv[1]
    socket_id = int(socket_id)

plug = Gtk.Plug.new(socket_id)
plug.connect("embedded", embed_event)
plug.connect("destroy", Gtk.main_quit)

print("Plug ID:", plug.get_id())

entry = Gtk.Entry()
plug.add(entry)

plug.show_all()

Gtk.main()

results matching ""

    No results matching ""