Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
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 plugRemoved 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.
Synopsis
- newtype Socket = Socket (ManagedPtr Socket)
- class (GObject o, IsDescendantOf Socket o) => IsSocket o
- toSocket :: (MonadIO m, IsSocket o) => o -> m Socket
- socketAddId :: (HasCallStack, MonadIO m, IsSocket a) => a -> CULong -> m ()
- socketGetId :: (HasCallStack, MonadIO m, IsSocket a) => a -> m CULong
- 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 ()
- afterSocketPlugAdded :: (IsSocket a, MonadIO m) => a -> SocketPlugAddedCallback -> m SignalHandlerId
- genClosure_SocketPlugAdded :: MonadIO m => SocketPlugAddedCallback -> m (GClosure C_SocketPlugAddedCallback)
- mk_SocketPlugAddedCallback :: C_SocketPlugAddedCallback -> IO (FunPtr C_SocketPlugAddedCallback)
- noSocketPlugAddedCallback :: Maybe SocketPlugAddedCallback
- onSocketPlugAdded :: (IsSocket a, MonadIO m) => a -> SocketPlugAddedCallback -> m SignalHandlerId
- wrap_SocketPlugAddedCallback :: SocketPlugAddedCallback -> C_SocketPlugAddedCallback
- type C_SocketPlugRemovedCallback = Ptr () -> Ptr () -> IO CInt
- type SocketPlugRemovedCallback = IO Bool
- afterSocketPlugRemoved :: (IsSocket a, MonadIO m) => a -> SocketPlugRemovedCallback -> m SignalHandlerId
- genClosure_SocketPlugRemoved :: MonadIO m => SocketPlugRemovedCallback -> m (GClosure C_SocketPlugRemovedCallback)
- mk_SocketPlugRemovedCallback :: C_SocketPlugRemovedCallback -> IO (FunPtr C_SocketPlugRemovedCallback)
- noSocketPlugRemovedCallback :: Maybe SocketPlugRemovedCallback
- onSocketPlugRemoved :: (IsSocket a, MonadIO m) => a -> SocketPlugRemovedCallback -> m SignalHandlerId
- wrap_SocketPlugRemovedCallback :: SocketPlugRemovedCallback -> C_SocketPlugRemovedCallback
Exported types
Memory-managed wrapper type.
Instances
Eq Socket Source # | |
GObject Socket Source # | |
Defined in GI.Gtk.Objects.Socket | |
ManagedPtrNewtype Socket Source # | |
Defined in GI.Gtk.Objects.Socket toManagedPtr :: Socket -> ManagedPtr Socket | |
TypedObject Socket Source # | |
Defined in GI.Gtk.Objects.Socket | |
HasParentTypes Socket Source # | |
Defined in GI.Gtk.Objects.Socket | |
IsGValue (Maybe Socket) Source # | Convert |
Defined in GI.Gtk.Objects.Socket gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Socket -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Socket) | |
type ParentTypes Socket Source # | |
class (GObject o, IsDescendantOf Socket o) => IsSocket o Source #
Instances
(GObject o, IsDescendantOf Socket o) => IsSocket o Source # | |
Defined in GI.Gtk.Objects.Socket |
Methods
Click to display all available methods, including inherited ones
Methods
activate, add, addAccelerator, addChild, addDeviceEvents, addEvents, addId, addMnemonicLabel, addTickCallback, bindProperty, bindPropertyFull, canActivateAccel, checkResize, childFocus, childGetProperty, childNotify, childNotifyByPspec, childSetProperty, childType, classPath, computeExpand, constructChild, createPangoContext, createPangoLayout, customFinished, customTagEnd, customTagStart, destroy, destroyed, deviceIsShadowed, dragBegin, dragBeginWithCoordinates, dragCheckThreshold, dragDestAddImageTargets, dragDestAddTextTargets, dragDestAddUriTargets, dragDestFindTarget, dragDestGetTargetList, dragDestGetTrackMotion, dragDestSet, dragDestSetProxy, dragDestSetTargetList, dragDestSetTrackMotion, dragDestUnset, dragGetData, dragHighlight, dragSourceAddImageTargets, dragSourceAddTextTargets, dragSourceAddUriTargets, dragSourceGetTargetList, dragSourceSet, dragSourceSetIconGicon, dragSourceSetIconName, dragSourceSetIconPixbuf, dragSourceSetIconStock, dragSourceSetTargetList, dragSourceUnset, dragUnhighlight, draw, ensureStyle, errorBell, event, forall, forceFloating, foreach, freezeChildNotify, freezeNotify, getv, grabAdd, grabDefault, grabFocus, grabRemove, hasDefault, hasFocus, hasGrab, hasRcStyle, hasScreen, hasVisibleFocus, hide, hideOnDelete, inDestruction, initTemplate, inputShapeCombineRegion, insertActionGroup, intersect, isAncestor, isComposited, isDrawable, isFloating, isFocus, isSensitive, isToplevel, isVisible, keynavFailed, listAccelClosures, listActionPrefixes, listMnemonicLabels, map, mnemonicActivate, modifyBase, modifyBg, modifyCursor, modifyFg, modifyFont, modifyStyle, modifyText, notify, notifyByPspec, overrideBackgroundColor, overrideColor, overrideCursor, overrideFont, overrideSymbolicColor, parserFinished, path, propagateDraw, queueAllocate, queueComputeExpand, queueDraw, queueDrawArea, queueDrawRegion, queueResize, queueResizeNoRedraw, realize, ref, refSink, regionIntersect, registerWindow, remove, removeAccelerator, removeMnemonicLabel, removeTickCallback, renderIcon, renderIconPixbuf, reparent, resetRcStyles, resetStyle, resizeChildren, runDispose, sendExpose, sendFocusChange, shapeCombineRegion, show, showAll, showNow, sizeAllocate, sizeAllocateWithBaseline, sizeRequest, stealData, stealQdata, styleAttach, styleGetProperty, thawChildNotify, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unregisterWindow, unsetFocusChain, unsetStateFlags, watchClosure.
Getters
getAccessible, getActionGroup, getAllocatedBaseline, getAllocatedHeight, getAllocatedSize, getAllocatedWidth, getAllocation, getAncestor, getAppPaintable, getBorderWidth, getCanDefault, getCanFocus, getChildRequisition, getChildVisible, getChildren, getClip, getClipboard, getCompositeName, getData, getDeviceEnabled, getDeviceEvents, getDirection, getDisplay, getDoubleBuffered, getEvents, getFocusChain, getFocusChild, getFocusHadjustment, getFocusOnClick, getFocusVadjustment, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHasWindow, getHexpand, getHexpandSet, getId, getInternalChild, getMapped, getMarginBottom, getMarginEnd, getMarginLeft, getMarginRight, getMarginStart, getMarginTop, getModifierMask, getModifierStyle, getName, getNoShowAll, getOpacity, getPangoContext, getParent, getParentWindow, getPath, getPathForChild, getPlugWindow, getPointer, getPreferredHeight, getPreferredHeightAndBaselineForWidth, getPreferredHeightForWidth, getPreferredSize, getPreferredWidth, getPreferredWidthForHeight, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRequisition, getResizeMode, getRootWindow, getScaleFactor, getScreen, getSensitive, getSettings, getSizeRequest, getState, getStateFlags, getStyle, getStyleContext, getSupportMultidevice, getTemplateChild, getTooltipMarkup, getTooltipText, getTooltipWindow, getToplevel, getValign, getValignWithBaseline, getVexpand, getVexpandSet, getVisible, getVisual, getWindow.
Setters
setAccelPath, setAllocation, setAppPaintable, setBorderWidth, setBuildableProperty, setCanDefault, setCanFocus, setChildVisible, setClip, setCompositeName, setData, setDataFull, setDeviceEnabled, setDeviceEvents, setDirection, setDoubleBuffered, setEvents, setFocusChain, setFocusChild, setFocusHadjustment, setFocusOnClick, setFocusVadjustment, setFontMap, setFontOptions, setHalign, setHasTooltip, setHasWindow, setHexpand, setHexpandSet, setMapped, setMarginBottom, setMarginEnd, setMarginLeft, setMarginRight, setMarginStart, setMarginTop, setName, setNoShowAll, setOpacity, setParent, setParentWindow, setProperty, setRealized, setReallocateRedraws, setReceivesDefault, setRedrawOnAllocate, setResizeMode, setSensitive, setSizeRequest, setState, setStateFlags, setStyle, setSupportMultidevice, setTooltipMarkup, setTooltipText, setTooltipWindow, setValign, setVexpand, setVexpandSet, setVisible, setVisual, setWindow.
addId
:: (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
:: (HasCallStack, MonadIO m, IsSocket a) | |
=> a |
|
-> m CULong | Returns: the window ID for the socket |
getPlugWindow
:: (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 C_SocketPlugAddedCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type SocketPlugAddedCallback = IO () Source #
This signal is emitted when a client is successfully added to the socket.
afterSocketPlugAdded :: (IsSocket a, MonadIO m) => a -> SocketPlugAddedCallback -> m SignalHandlerId Source #
Connect a signal handler for the plugAdded signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
socket #plugAdded callback
genClosure_SocketPlugAdded :: MonadIO m => SocketPlugAddedCallback -> m (GClosure C_SocketPlugAddedCallback) Source #
Wrap the callback into a GClosure
.
mk_SocketPlugAddedCallback :: C_SocketPlugAddedCallback -> IO (FunPtr C_SocketPlugAddedCallback) Source #
Generate a function pointer callable from C code, from a C_SocketPlugAddedCallback
.
noSocketPlugAddedCallback :: Maybe SocketPlugAddedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SocketPlugAddedCallback
onSocketPlugAdded :: (IsSocket a, MonadIO m) => a -> SocketPlugAddedCallback -> m SignalHandlerId Source #
Connect a signal handler for the plugAdded signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
socket #plugAdded callback
wrap_SocketPlugAddedCallback :: SocketPlugAddedCallback -> C_SocketPlugAddedCallback Source #
Wrap a SocketPlugAddedCallback
into a C_SocketPlugAddedCallback
.
plugRemoved
type C_SocketPlugRemovedCallback = Ptr () -> Ptr () -> IO CInt Source #
Type for the callback on the (unwrapped) C side.
afterSocketPlugRemoved :: (IsSocket a, MonadIO m) => a -> SocketPlugRemovedCallback -> m SignalHandlerId Source #
Connect a signal handler for the plugRemoved signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
socket #plugRemoved callback
genClosure_SocketPlugRemoved :: MonadIO m => SocketPlugRemovedCallback -> m (GClosure C_SocketPlugRemovedCallback) Source #
Wrap the callback into a GClosure
.
mk_SocketPlugRemovedCallback :: C_SocketPlugRemovedCallback -> IO (FunPtr C_SocketPlugRemovedCallback) Source #
Generate a function pointer callable from C code, from a C_SocketPlugRemovedCallback
.
noSocketPlugRemovedCallback :: Maybe SocketPlugRemovedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
SocketPlugRemovedCallback
onSocketPlugRemoved :: (IsSocket a, MonadIO m) => a -> SocketPlugRemovedCallback -> m SignalHandlerId Source #
Connect a signal handler for the plugRemoved signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
socket #plugRemoved callback