[Contents] [Back] [Prev] [Up] [Next] [Forward]

# Package Gtk.Socket

Note that this package is currently not supported under Win32 systems.

Together with Gtk_Plug, 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 the XID of that widget's window to the other process, which then creates a Gtk_Plug window with that XID. Any widgets contained in the Gtk_Plug then will appear inside the first applications window.

The XID of the socket's window is obtained by using the XWindow function provided in this package. Before using this macro, the socket must have been realized, and for hence, have been added to its parent.

Note that if you pass the XID 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 examining the plug_window field of the Gtk_Socket structure. If this field is non-NULL, then the plug has been succesfully created inside of the socket.

When GtkAda 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.

A socket can also be used to swallow arbitrary pre-existing top-level windows using Steal, though the integration when this is done will not be as close as between a Gtk_Plug and a Gtk_Socket. All you need in that case is the X11 window identifier for the external process.

Note that it is recommended that the external window be first hidden before being swallowed, so that Gtk.Socket works with most window managers. If you start with visible windows, some window managers will not be able to correctly merge the two windows (Enlightenment for instance).

- Gtk.Socket Widget Hierarchy
- Gtk.Socket Subprograms
- Gtk.Socket Example

## Widget Hierarchy

    Gtk_Object                    (see section Package Gtk.Object)
       \___ Gtk_Widget            (see section Package Gtk.Widget)
          \___ Gtk_Container      (see section Package Gtk.Container)
             \___ Gtk_Socket      (see section Package Gtk.Socket)

## Subprograms

    procedure Gtk_New
      (Widget             : out    Gtk_Socket);
| Create a new empty GtkSocket.
    procedure Steal
      (Socket             : access Gtk_Socket_Record;
       Wid                : in     Guint32);
| Reparent a pre-existing toplevel window into a Gtk_Socket. Wid is the XID of an existing toplevel window.
    function Get_Plug_Window
      (Socket             : access Gtk_Socket_Record)
       return Gdk.Window.Gdk_Window;
| Return the id of the embedded window.
    function Get_XWindow
      (Window             :        Gdk.Window.Gdk_Window)
       return Guint32;
| Return the X window associated with a Gdk_Window, 0 under Win32.

## Example

     Obtaining the XID of a socket

     with Gtk.Socket;
     use Gtk.Socket;

     Socket : Gtk_Socket;

     Gtk_New (Socket);
     Show (Socket);
     Add (Parent, Socket);

     --  The following call is only necessary if one of
     --  the ancestors of the socket is not yet visible.

     Realize (Socket);
     Put_Line ("The XID of the sockets window is" &
               Guint32'Image (Get_XWindow (Get_Window (Socket))));

[Contents] [Back] [Prev] [Up] [Next] [Forward]