gi-gtk-3.0.11: Gtk bindings

CopyrightWill Thompson, Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.Socket

Contents

Description

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.

Synopsis

Exported types

Methods

addId

data SocketAddIdMethodInfo Source #

Instances

((~) * signature (CULong -> m ()), MonadIO m, IsSocket a) => MethodInfo * SocketAddIdMethodInfo a signature Source # 

Methods

overloadedMethod :: MethodProxy SocketAddIdMethodInfo a -> signature -> s #

socketAddId Source #

Arguments

:: (HasCallStack, MonadIO m, IsSocket a) 
=> a

socket_: a Socket

-> CULong

window: the Window of a client participating in the XEMBED protocol.

-> 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 #

Instances

((~) * signature (m CULong), MonadIO m, IsSocket a) => MethodInfo * SocketGetIdMethodInfo a signature Source # 

Methods

overloadedMethod :: MethodProxy SocketGetIdMethodInfo a -> signature -> s #

socketGetId Source #

Arguments

:: (HasCallStack, MonadIO m, IsSocket a) 
=> a

socket_: a Socket.

-> m CULong

Returns: the window ID for the socket

Gets the window ID of a Socket widget, which can then be used to create a client embedded inside the socket, for instance with plugNew.

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

getPlugWindow

socketGetPlugWindow Source #

Arguments

:: (HasCallStack, MonadIO m, IsSocket a) 
=> a

socket_: a Socket.

-> m (Maybe Window)

Returns: the window of the plug if available, or Nothing

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

Since: 2.14

new

socketNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Socket

Returns: the new Socket.

Create a new empty Socket.

Signals

plugAdded

type C_SocketPlugAddedCallback = Ptr () -> Ptr () -> IO () Source #

plugRemoved