# Gtk::Socket Class Reference
[Widgets, Container Widgets]

Container for widgets from other processes. More...

Inherits Gtk::Container.

Collaboration diagram for Gtk::Socket:
[legend]

List of all members.

## Public Member Functions

virtual | ~Socket ()
GtkSocket* | gobj ()
| Provides access to the underlying C GtkObject.
const GtkSocket* | gobj () const
| Provides access to the underlying C GtkObject.
| Socket ()
void | add_id (Gdk::NativeWindow window_id)
| Adds an XEMBED client, such as a Gtk::Plug, to the Gtk::Socket.
Gdk::NativeWindow | get_id () const
| Gets the window ID of a Gtk::Socket widget, which can then be used to create a client embedded inside the socket, for instance with Gtk::Plug::new().
Glib::RefPtr< Gdk::Window > | get_plug_window ()
| Retrieves the window of the plug.
Glib::RefPtr< const Gdk::Window > | get_plug_window () const
| Retrieves the window of the plug.
Glib::SignalProxy0< void > | signal_plug_added ()
Glib::SignalProxy0< bool > | signal_plug_removed ()

## Protected Member Functions

virtual void | on_plug_added ()
virtual bool | on_plug_removed ()

## Related Functions

(Note that these are not member functions.)
Gtk::Socket* | wrap (GtkSocket* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Container for widgets from other processes.

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 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 applications window.

The socket's window ID is obtained by using get_id(). Before using this function, the socket must have been realized, and for hence, have been added to its parent.

     Gtk::Socket socket;
     parent.add(socket);

     // The following call is only necessary if one of the ancestors of the
     // socket is not yet visible
     socket.realize();

     cout << "The ID of the sockets window is: " << socket.get_id() << endl;

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 examining the plug_window member of the GtkSocket structure returned by gobj(). If this field is non-NULL, then the plug has been successfully created inside of the socket.

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

The communication between a Gtk::Socket and a Gtk::Plug 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 gtkmm or vice versa.

## Constructor & Destructor Documentation

virtual Gtk::Socket::~Socket | ( |  | ) | `[virtual]`

Gtk::Socket::Socket | ( |  | ) |

## Member Function Documentation

void Gtk::Socket::add_id | ( | Gdk::NativeWindow | window_id | ) |

Adds an XEMBED client, such as a Gtk::Plug, to the Gtk::Socket.

The client may be in the same process or in a different process.

To embed a Gtk::Plug in a Gtk::Socket, you can either create the Gtk::Plug with <literal>gtk_plug_new (0)</literal>, call Gtk::Plug::get_id() to get the window ID of the plug, and then pass that to the add_id(), or you can call get_id() to get the window ID for the socket, and call Gtk::Plug::new() passing in that ID.

The Gtk::Socket must have already be added into a toplevel window before you can make this call.

Parameters:

  | window_id | The window ID of a client participating in the XEMBED protocol.

Gdk::NativeWindow Gtk::Socket::get_id | ( |  | ) | const

Gets the window ID of a Gtk::Socket widget, which can then be used to create a client embedded inside the socket, for instance with Gtk::Plug::new().

The Gtk::Socket must have already be added into a toplevel window before you can make this call.

Returns:
  The window ID for the socket.

Glib::RefPtr<const Gdk::Window> Gtk::Socket::get_plug_window | ( |  | ) | const

Retrieves the window of the plug.

Use this to check if the plug has been created inside of the socket.

Returns:
  The window of the plug if available, or `0`

Since gtkmm 2.14:

Glib::RefPtr<Gdk::Window> Gtk::Socket::get_plug_window | ( |  | ) |

Retrieves the window of the plug.

Use this to check if the plug has been created inside of the socket.

Returns:
  The window of the plug if available, or `0`

Since gtkmm 2.14:

const GtkSocket* Gtk::Socket::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Container.

GtkSocket* Gtk::Socket::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Container.

virtual void Gtk::Socket::on_plug_added | ( |  | ) | `[protected, virtual]`

virtual bool Gtk::Socket::on_plug_removed | ( |  | ) | `[protected, virtual]`

Glib::SignalProxy0< void > Gtk::Socket::signal_plug_added | ( |  | ) |

Prototype:
  `void on_my_plug_added()`

Glib::SignalProxy0< bool > Gtk::Socket::signal_plug_removed | ( |  | ) |

Prototype:
  `bool on_my_plug_removed()`

## Friends And Related Function Documentation

Gtk::Socket* wrap | ( | GtkSocket * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- gtkmm/socket.h