| 1 |
/* Copyright (C) 1998-2002 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <gtkmm/container.h> |
| 18 |
#include <gdkmm/types.h> |
| 19 |
#include <gtk/gtkx.h> //Necessary for the X11 Window type. |
| 20 |
_DEFS(gtkmm,gtk) |
| 21 |
_PINCLUDE(gtkmm/private/container_p.h) |
| 22 |
|
| 23 |
//This file is used only on systems with the X11 backend. |
| 24 |
_INCLUDE_IN_WRAP_INIT(gdkmmconfig.h)dnl // If GDKMM_X11_BACKEND_ENABLED is defined, it's defined here. |
| 25 |
_GMMPROC_WRAP_CONDITIONALLY(ifdef GDKMM_X11_BACKEND_ENABLED) |
| 26 |
|
| 27 |
namespace Gtk |
| 28 |
{ |
| 29 |
|
| 30 |
//Note that Window is the (awfully named) type from the X11 header. |
| 31 |
//gtkx.h (needed to get GtkPlug and GtkSocket) pulls this in, |
| 32 |
//assuming that you will be careful when doing so. |
| 33 |
|
| 34 |
/** Container for widgets from other processes. |
| 35 |
* Together with Gtk::Plug, Gtk::Socket provides the ability to embed |
| 36 |
* widgets from one process into another process in a fashion that is |
| 37 |
* transparent to the user. One process creates a Gtk::Socket widget and, |
| 38 |
* passes the that widget's window ID to the other process, which then |
| 39 |
* creates a Gtk::Plug with that window ID. Any widgets contained in the |
| 40 |
* Gtk::Plug then will appear inside the first applications window. |
| 41 |
* |
| 42 |
* The socket's window ID is obtained by using get_id(). Before using this |
| 43 |
* function, the socket must have been realized, and for hence, have been |
| 44 |
* added to its parent. |
| 45 |
* |
| 46 |
* @code |
| 47 |
* Gtk::Socket socket; |
| 48 |
* parent.add(socket); |
| 49 |
* |
| 50 |
* // The following call is only necessary if one of the ancestors of the |
| 51 |
* // socket is not yet visible |
| 52 |
* socket.realize(); |
| 53 |
* |
| 54 |
* cout << "The ID of the sockets window is: " << socket.get_id() << endl; |
| 55 |
* |
| 56 |
* @endcode |
| 57 |
* |
| 58 |
* Note that if you pass the window ID of the socket to another process that |
| 59 |
* will create a plug in the socket, you must make sure that the socket |
| 60 |
* widget is not destroyed until that plug is created. Violating this rule |
| 61 |
* will cause unpredictable consequences, the most likely consequence being |
| 62 |
* that the plug will appear as a separate toplevel window. You can check if |
| 63 |
* the plug has been created by examining the plug_window member of the |
| 64 |
* GtkSocket structure returned by gobj(). If this field is non-NULL, then |
| 65 |
* the plug has been successfully created inside of the socket. |
| 66 |
* |
| 67 |
* When gtkmm is notified that the embedded window has been destroyed, then |
| 68 |
* it will destroy the socket as well. You should always, therefore, be |
| 69 |
* prepared for your sockets to be destroyed at any time when the main event |
| 70 |
* loop is running. |
| 71 |
* |
| 72 |
* The communication between a Gtk::Socket and a Gtk::Plug follows the |
| 73 |
* XEmbed protocol. This protocol has also been implemented in other |
| 74 |
* toolkits, e.g. Qt, allowing the same level of integration when embedding |
| 75 |
* a Qt widget in gtkmm or vice versa. |
| 76 |
* |
| 77 |
* @ingroup Widgets |
| 78 |
* @ingroup Containers |
| 79 |
*/ |
| 80 |
class GTKMM_API Socket : public Container |
| 81 |
{ |
| 82 |
_CLASS_GTKOBJECT(Socket, GtkSocket, GTK_SOCKET, Gtk::Container, GtkContainer, , , GTKMM_API) |
| 83 |
public: |
| 84 |
_CTOR_DEFAULT |
| 85 |
|
| 86 |
#m4 _CONVERSION(`Window', `::Window', `($3)') |
| 87 |
#m4 _CONVERSION(`::Window', `Window', `($3)') |
| 88 |
_WRAP_METHOD(void add_id(::Window window_id), gtk_socket_add_id) |
| 89 |
_WRAP_METHOD(::Window get_id() const, gtk_socket_get_id) |
| 90 |
|
| 91 |
_WRAP_METHOD(Glib::RefPtr<Gdk::Window> get_plug_window(), gtk_socket_get_plug_window, refreturn) |
| 92 |
_WRAP_METHOD(Glib::RefPtr<const Gdk::Window> get_plug_window() const, gtk_socket_get_plug_window, refreturn, constversion) |
| 93 |
|
| 94 |
_WRAP_SIGNAL(void plug_added(), "plug_added") |
| 95 |
_WRAP_SIGNAL(bool plug_removed(), "plug_removed") |
| 96 |
}; |
| 97 |
|
| 98 |
} // namespace Gtk |