Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
Together with Plug
, 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 Socket
widget
and passes that widget’s window ID to the other process, which then
creates a Plug
with that window ID. Any widgets contained in the
Plug
then will appear inside the first application’s window.
The socket’s window ID is obtained by using socketGetId
.
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.
C code
GtkWidget *socket = gtk_socket_new (); gtk_widget_show (socket); gtk_container_add (GTK_CONTAINER (parent), socket); // The following call is only necessary if one of // the ancestors of the socket is not yet visible. gtk_widget_realize (socket); g_print ("The ID of the sockets window is %#x\n", gtk_socket_get_id (socket));
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 socketGetPlugWindow
.
If it returns a non-Nothing
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 Socket
::plug-removed
signal.
The communication between a Socket
and a 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 GTK or vice versa.
The Plug
and 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 Plug
and
Socket
, you need to include the gtk/gtkx.h
header.
- newtype Socket = Socket (ManagedPtr Socket)
- class GObject o => IsSocket o
- toSocket :: IsSocket o => o -> IO Socket
- noSocket :: Maybe Socket
- data SocketAddIdMethodInfo
- socketAddId :: (HasCallStack, MonadIO m, IsSocket a) => a -> CULong -> m ()
- data SocketGetIdMethodInfo
- socketGetId :: (HasCallStack, MonadIO m, IsSocket a) => a -> m CULong
- data SocketGetPlugWindowMethodInfo
- socketGetPlugWindow :: (HasCallStack, MonadIO m, IsSocket a) => a -> m (Maybe Window)
- socketNew :: (HasCallStack, MonadIO m) => m Socket
- type C_SocketPlugAddedCallback = Ptr () -> Ptr () -> IO ()
- type SocketPlugAddedCallback = IO ()
- data SocketPlugAddedSignalInfo
- afterSocketPlugAdded :: (GObject a, MonadIO m) => a -> SocketPlugAddedCallback -> m SignalHandlerId
- genClosure_SocketPlugAdded :: SocketPlugAddedCallback -> IO Closure
- mk_SocketPlugAddedCallback :: C_SocketPlugAddedCallback -> IO (FunPtr C_SocketPlugAddedCallback)
- noSocketPlugAddedCallback :: Maybe SocketPlugAddedCallback
- onSocketPlugAdded :: (GObject a, MonadIO m) => a -> SocketPlugAddedCallback -> m SignalHandlerId
- wrap_SocketPlugAddedCallback :: SocketPlugAddedCallback -> Ptr () -> Ptr () -> IO ()
- type C_SocketPlugRemovedCallback = Ptr () -> Ptr () -> IO CInt
- type SocketPlugRemovedCallback = IO Bool
- data SocketPlugRemovedSignalInfo
- afterSocketPlugRemoved :: (GObject a, MonadIO m) => a -> SocketPlugRemovedCallback -> m SignalHandlerId
- genClosure_SocketPlugRemoved :: SocketPlugRemovedCallback -> IO Closure
- mk_SocketPlugRemovedCallback :: C_SocketPlugRemovedCallback -> IO (FunPtr C_SocketPlugRemovedCallback)
- noSocketPlugRemovedCallback :: Maybe SocketPlugRemovedCallback
- onSocketPlugRemoved :: (GObject a, MonadIO m) => a -> SocketPlugRemovedCallback -> m SignalHandlerId
- wrap_SocketPlugRemovedCallback :: SocketPlugRemovedCallback -> Ptr () -> Ptr () -> IO CInt
Exported types
GObject Socket Source # | |
IsImplementorIface Socket Source # | |
IsObject Socket Source # | |
IsWidget Socket Source # | |
IsContainer Socket Source # | |
IsBuildable Socket Source # | |
IsSocket Socket Source # | |
((~) * info (ResolveSocketMethod t Socket), MethodInfo * info Socket p) => IsLabel t (Socket -> p) Source # | |
((~) * info (ResolveSocketMethod t Socket), MethodInfo * info Socket p) => IsLabelProxy t (Socket -> p) Source # | |
HasAttributeList * Socket Source # | |
type AttributeList Socket Source # | |
type SignalList Socket Source # | |
Methods
addId
data SocketAddIdMethodInfo Source #
((~) * signature (CULong -> m ()), MonadIO m, IsSocket a) => MethodInfo * SocketAddIdMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsSocket a) | |
=> a |
|
-> CULong |
|
-> m () |
Adds an XEMBED client, such as a Plug
, to the Socket
. The
client may be in the same process or in a different process.
To embed a Plug
in a Socket
, you can either create the
Plug
with gtk_plug_new (0)
, call
plugGetId
to get the window ID of the plug, and then pass that to the
socketAddId
, or you can call socketGetId
to get the
window ID for the socket, and call plugNew
passing in that
ID.
The Socket
must have already be added into a toplevel window
before you can make this call.
getId
data SocketGetIdMethodInfo Source #
((~) * signature (m CULong), MonadIO m, IsSocket a) => MethodInfo * SocketGetIdMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsSocket a) | |
=> a |
|
-> m CULong | Returns: the window ID for the socket |
getPlugWindow
data SocketGetPlugWindowMethodInfo Source #
((~) * signature (m (Maybe Window)), MonadIO m, IsSocket a) => MethodInfo * SocketGetPlugWindowMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsSocket a) | |
=> a |
|
-> m (Maybe Window) | Returns: the window of the plug if
available, or |
Retrieves the window of the plug. Use this to check if the plug has been created inside of the socket.
Since: 2.14
new
:: (HasCallStack, MonadIO m) | |
=> m Socket | Returns: the new |
Create a new empty Socket
.
Signals
plugAdded
type SocketPlugAddedCallback = IO () Source #
afterSocketPlugAdded :: (GObject a, MonadIO m) => a -> SocketPlugAddedCallback -> m SignalHandlerId Source #
mk_SocketPlugAddedCallback :: C_SocketPlugAddedCallback -> IO (FunPtr C_SocketPlugAddedCallback) Source #
onSocketPlugAdded :: (GObject a, MonadIO m) => a -> SocketPlugAddedCallback -> m SignalHandlerId Source #
wrap_SocketPlugAddedCallback :: SocketPlugAddedCallback -> Ptr () -> Ptr () -> IO () Source #
plugRemoved
type SocketPlugRemovedCallback = IO Bool Source #
afterSocketPlugRemoved :: (GObject a, MonadIO m) => a -> SocketPlugRemovedCallback -> m SignalHandlerId Source #
mk_SocketPlugRemovedCallback :: C_SocketPlugRemovedCallback -> IO (FunPtr C_SocketPlugRemovedCallback) Source #
onSocketPlugRemoved :: (GObject a, MonadIO m) => a -> SocketPlugRemovedCallback -> m SignalHandlerId Source #
wrap_SocketPlugRemovedCallback :: SocketPlugRemovedCallback -> Ptr () -> Ptr () -> IO CInt Source #