gtk3-0.12.5.6: Binding to the Gtk+ graphical user interface library.

Portabilityportable (depends on GHC)
Stabilityprovisional
Maintainergtk2hs-users@lists.sourceforge.net
Safe HaskellNone

Graphics.UI.Gtk.General.Selection

Contents

Description

Functions for handling inter-process communication via selections.

Synopsis

Types

type InfoId = CUIntSource

A number that the application can use to differentiate between different data types or application states.

data Atom Source

An atom is an index into a global string table. It is possible to associate binary data with each entry. This facility is used for inter-application data exchange such as properties of DrawWindow (using PropertyTag), Clipboard or Drag (SelectionId and TargetId).

Instances

type TargetTag = AtomSource

A tag that uniquely identifies a target. A target describes the format of the underlying data source, for instance, it might be a string. A single selection may support multiple targets: suppose a new target is created for the Haskell data type Double. In this case, the value of the floating point number could also be offered as a string.

type SelectionTag = AtomSource

A tag that uniquely identifies a selection. A selection denotes the exchange mechanism that is being used, for instance, the clipboard is the most common exchange mechanism. For drag and drop applications, a new selection tag is usually created for each different kind of data that is being exchanged.

type SelectionTypeTag = AtomSource

A tag that defines the encoding of the binary data. For instance, a string might be encoded as UTF-8 or in a different locale. Each encoding would use the same TargetTag but a different SelectionTypeTag.

data TargetList Source

A TargetList contains information about all possible formats (represented as TargetTag) that a widget can create or receive in form of a selection.

type SelectionDataM a = ReaderT (Ptr ()) IO aSource

A monad providing access to selection data.

data TargetFlags Source

The TargetFlags enumeration is used to specify constraints on an entry in a TargetList. These flags are only used for drag and drop.

  • If the TargetSameApp flag is set, the target will only be selected for drags within a single application.
  • If the TargetSameWidget flag is set, the target will only be selected for drags within a single widget.

Instances

Bounded TargetFlags 
Enum TargetFlags

Is the text written from left to right or the exotic way?

Eq TargetFlags 
Show TargetFlags 
Flags TargetFlags 

Constants

targetString :: TargetTagSource

If this target is provided by a selection, then the data is a string.

selectionTypeAtom :: SelectionTypeTagSource

The type indicating that the associated data is itself a (list of) Atoms.

selectionTypeInteger :: SelectionTypeTagSource

The type indicating that the associated data consists of integers.

selectionTypeString :: SelectionTypeTagSource

The type indicating that the associated data is a string without further information on its encoding.

Constructors

atomNew :: String -> IO AtomSource

Create a new TargetTag, SelectionTag, SelectionTypeTag or PropertyTag. Note that creating two target tags with the same name will create the same tag, in particular, the tag will be the same across different applications. Note that the name of an Atom can be printed by show though comparing the atom is merely an integer comparison.

Methods

targetListAdd :: TargetList -> TargetTag -> [TargetFlags] -> InfoId -> IO ()Source

Append another target to the given TargetList.

  • Note that the TargetFlags are only used for drag and drop, not in normal selection handling.

targetListAddTextTargets :: TargetList -> InfoId -> IO ()Source

Append all text targets supported by the selection mechanism to the target list. All targets are added with the same InfoId.

  • Since Gtk 2.6.

targetListAddImageTargets :: TargetList -> InfoId -> Bool -> IO ()Source

Append all image targets supported by the selection mechanism to the target list. All targets are added with the same InfoId. If the boolean flag is set, only targets will be added which Gtk+ knows how to convert into a Pixbuf.

  • Since Gtk 2.6.

targetListAddUriTargets :: TargetList -> InfoId -> IO ()Source

Append all URI (universal resource indicator, fomerly URL) targets supported by the selection mechanism to the target list. All targets are added with the same InfoId.

  • Since Gtk 2.6.

targetListAddRichTextTargets :: TextBufferClass tb => TargetList -> InfoId -> Bool -> tb -> IO ()Source

Append all rich text targets registered with textBufferRegisterSerializeFormat to the target list. All targets are added with the same InfoId. If the boolean flag is True then deserializable rich text formats will be added, serializable formats otherwise.

  • Since Gtk 2.10.

targetListRemove :: TargetList -> TargetTag -> IO ()Source

Remove a target from a target list.

selectionAddTarget :: WidgetClass widget => widget -> SelectionTag -> TargetTag -> InfoId -> IO ()Source

Appends a specified target to the list of supported targets for a given widget and selection.

selectionClearTargets :: WidgetClass widget => widget -> SelectionTag -> IO ()Source

Remove all targets registered for the given selection for the widget.

selectionOwnerSet :: WidgetClass widget => Maybe widget -> SelectionTag -> TimeStamp -> IO BoolSource

Claims ownership of a given selection for a particular widget, or, if widget is Nothing, release ownership of the selection.

selectionOwnerSetForDisplay :: WidgetClass widget => Display -> Maybe widget -> SelectionTag -> TimeStamp -> IO BoolSource

Set the ownership of a given selection and display.

selectionRemoveAll :: WidgetClass widget => widget -> IO ()Source

Removes all handlers and unsets ownership of all selections for a widget. Called when widget is being destroyed. This function will not generally be called by applications.

selectionDataSet :: (Integral a, Storable a) => SelectionTypeTag -> [a] -> SelectionDataM ()Source

Stores new data in the SelectionDataM monad. The stored data may only be an array of integer types that are no larger than 32 bits.

selectionDataIsValid :: SelectionDataM BoolSource

Check if the currently stored data is valid.

  • If this function returns False, no data is set in this selection and selectionDataGet will return Nothing no matter what type is requested.

selectionDataSetText :: String -> SelectionDataM BoolSource

Sets the contents of the selection from a string. The string is converted to the form determined by the allowed targets of the selection.

  • Returns True if setting the text was successful.

selectionDataGetText :: SelectionDataM (Maybe String)Source

Gets the contents of the selection data as a string.

selectionDataSetPixbuf :: Pixbuf -> SelectionDataM BoolSource

Sets the contents of the selection from a Pixbuf. The pixbuf is converted to the form determined by the allowed targets of the selection.

  • Returns True if setting the Pixbuf was successful. Since Gtk 2.6.

selectionDataGetPixbuf :: SelectionDataM (Maybe Pixbuf)Source

Gets the contents of the selection data as a Pixbuf.

  • Since Gtk 2.6.

selectionDataSetURIs :: [String] -> SelectionDataM BoolSource

Sets the contents of the selection from a list of URIs. The string is converted to the form determined by the possible targets of the selection.

  • Returns True if setting the URIs was successful. Since Gtk 2.6.

selectionDataGetURIs :: SelectionDataM (Maybe [String])Source

Gets the contents of the selection data as list of URIs. Returns Nothing if the selection did not contain any URIs.

  • Since Gtk 2.6.

selectionDataTargetsIncludeImageSource

Arguments

:: Bool

whether to accept only targets for which GTK+ knows how to convert a pixbuf into the format

-> SelectionDataM Bool 

Given a SelectionDataM holding a list of targets, determines if any of the targets in targets can be used to provide a Pixbuf.

  • Since Gtk 2.6

selectionDataGetTarget :: SelectionDataM TargetTagSource

Retrieve the currently set TargetTag in the selection.

selectionDataGetTargets :: SelectionDataM [TargetTag]Source

Queries the content type of the selection data as a list of targets. Whenever the application is asked whether certain targets are acceptable, it is handed a selection that contains a list of TargetTags as payload. A similar result could be achieved using 'selectionDataGet selectionTypeAtom'.

selectionDataTargetsIncludeText :: SelectionDataM BoolSource

Given a SelectionDataM holding a list of targets, determines if any of the targets in targets can be used to provide text.

selectionDataTargetsIncludeUri :: SelectionDataM BoolSource

Given a SelectionDataM holding a list of targets, determines if any of the targets in targets can be used to provide URIs.

  • Since Gtk 2.10

selectionDataTargetsIncludeRichText :: TextBufferClass tb => tb -> SelectionDataM BoolSource

Given a SelectionDataM holding a list of targets, check if, well, dunno really. FIXME: what does the TextBuffer do?

  • Since Gtk 2.10

Signals

selectionGet :: WidgetClass self => Signal self (InfoId -> TimeStamp -> SelectionDataM ())Source

Emitted in order to ask the application for selection data. Within the handler the function selectionDataSet or one of its derivatives should be called.

selectionReceived :: WidgetClass self => Signal self (TimeStamp -> SelectionDataM ())Source

Pass the supplied selection data to the application. The application is expected to read the data using selectionDataGet or one of its derivatives.