gtk-0.11.0: Binding to the Gtk+ graphical user interface library.ContentsIndex
Graphics.UI.Gtk.General.Selection
Portabilityportable (depends on GHC)
Stabilityprovisional
Maintainergtk2hs-users@lists.sourceforge.net
Contents
Types
Constants
Constructors
Methods
Signals
Description
Functions for handling inter-process communication via selections.
Synopsis
type InfoId = CUInt
data Atom
type TargetTag = Atom
type SelectionTag = Atom
type SelectionTypeTag = Atom
data TargetList
type SelectionDataM a = ReaderT (Ptr ()) IO a
data TargetFlags
= TargetSameApp
| TargetSameWidget
| TargetOtherApp
| TargetOtherWidget
targetString :: TargetTag
selectionTypeAtom :: SelectionTypeTag
selectionTypeInteger :: SelectionTypeTag
selectionTypeString :: SelectionTypeTag
atomNew :: String -> IO Atom
targetListNew :: IO TargetList
targetListAdd :: TargetList -> TargetTag -> [TargetFlags] -> InfoId -> IO ()
targetListAddTextTargets :: TargetList -> InfoId -> IO ()
targetListAddImageTargets :: TargetList -> InfoId -> Bool -> IO ()
targetListAddUriTargets :: TargetList -> InfoId -> IO ()
targetListAddRichTextTargets :: TextBufferClass tb => TargetList -> InfoId -> Bool -> tb -> IO ()
targetListRemove :: TargetList -> TargetTag -> IO ()
selectionAddTarget :: WidgetClass widget => widget -> SelectionTag -> TargetTag -> InfoId -> IO ()
selectionClearTargets :: WidgetClass widget => widget -> SelectionTag -> IO ()
selectionOwnerSet :: WidgetClass widget => Maybe widget -> SelectionTag -> TimeStamp -> IO Bool
selectionOwnerSetForDisplay :: WidgetClass widget => Display -> Maybe widget -> SelectionTag -> TimeStamp -> IO Bool
selectionRemoveAll :: WidgetClass widget => widget -> IO ()
selectionDataSet :: (Integral a, Storable a) => SelectionTypeTag -> [a] -> SelectionDataM ()
selectionDataGet :: (Integral a, Storable a) => SelectionTypeTag -> SelectionDataM (Maybe [a])
selectionDataIsValid :: SelectionDataM Bool
selectionDataSetText :: String -> SelectionDataM Bool
selectionDataGetText :: SelectionDataM (Maybe String)
selectionDataSetPixbuf :: Pixbuf -> SelectionDataM Bool
selectionDataGetPixbuf :: SelectionDataM (Maybe Pixbuf)
selectionDataSetURIs :: [String] -> SelectionDataM Bool
selectionDataGetURIs :: SelectionDataM (Maybe [String])
selectionDataTargetsIncludeImage :: Bool -> SelectionDataM Bool
selectionDataGetTarget :: SelectionDataM TargetTag
selectionDataSetTarget :: TargetTag -> SelectionDataM ()
selectionDataGetTargets :: SelectionDataM [TargetTag]
selectionDataTargetsIncludeText :: SelectionDataM Bool
selectionDataTargetsIncludeUri :: SelectionDataM Bool
selectionDataTargetsIncludeRichText :: TextBufferClass tb => tb -> SelectionDataM Bool
selectionGet :: WidgetClass self => Signal self (InfoId -> TimeStamp -> SelectionDataM ())
selectionReceived :: WidgetClass self => Signal self (TimeStamp -> SelectionDataM ())
Types
type InfoId = CUInt
A number that the application can use to differentiate between different data types or application states.
data Atom
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 Graphics.UI.Gtk.Gdk.DrawWindow.DrawWindow (using PropertyTag), Graphics.UI.Gtk.Clipboard.Clipboard or Graphics.UI.Gtk.General.Drag (SelectionId and TargetId).
show/hide Instances
type TargetTag = Atom
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 = Atom
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 = Atom
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
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 a
A monad providing access to selection data.
data TargetFlags

The TargetFlags enumeration is used to specify constraints on an entry in a Graphics.UI.Gtk.Gdk.Selection.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.
Constructors
TargetSameApp
TargetSameWidget
TargetOtherApp
TargetOtherWidget
show/hide Instances
Constants
targetString :: TargetTag
If this target is provided by a selection, then the data is a string.
selectionTypeAtom :: SelectionTypeTag
The type indicating that the associated data is itself a (list of) Graphics.UI.Gtk.General.Selection.Atoms.
selectionTypeInteger :: SelectionTypeTag
The type indicating that the associated data consists of integers.
selectionTypeString :: SelectionTypeTag
The type indicating that the associated data is a string without further information on its encoding.
Constructors
atomNew :: String -> IO Atom
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.
targetListNew :: IO TargetList
Create a new, empty TargetList.
Methods
targetListAdd :: TargetList -> TargetTag -> [TargetFlags] -> InfoId -> IO ()

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 ()

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 ()

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 Graphics.UI.Gtk.Pixbuf.Pixbuf.

  • Since Gtk 2.6.
targetListAddUriTargets :: TargetList -> InfoId -> IO ()

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 ()

Append all rich text targets registered with Graphics.UI.Gtk.TextBuffer.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 ()
Remove a target from a target list.
selectionAddTarget :: WidgetClass widget => widget -> SelectionTag -> TargetTag -> InfoId -> IO ()
Appends a specified target to the list of supported targets for a given widget and selection.
selectionClearTargets :: WidgetClass widget => widget -> SelectionTag -> IO ()
Remove all targets registered for the given selection for the widget.
selectionOwnerSet :: WidgetClass widget => Maybe widget -> SelectionTag -> TimeStamp -> IO Bool
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 Bool
Set the ownership of a given selection and display.
selectionRemoveAll :: WidgetClass widget => widget -> IO ()
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 ()
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.
selectionDataGet :: (Integral a, Storable a) => SelectionTypeTag -> SelectionDataM (Maybe [a])
Retreives the data in the SelectionDataM monad. The returned array must have elements of the size that were used to set this data. If the size or the type tag does not match, Nothing is returned.
selectionDataIsValid :: SelectionDataM Bool

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 Bool

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)
Gets the contents of the selection data as a string.
selectionDataSetPixbuf :: Pixbuf -> SelectionDataM Bool

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)

Gets the contents of the selection data as a Pixbuf.

  • Since Gtk 2.6.
selectionDataSetURIs :: [String] -> SelectionDataM Bool

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])

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.
selectionDataTargetsIncludeImage
:: Boolwhether 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 TargetTag
Retrieve the currently set TargetTag in the selection.
selectionDataSetTarget :: TargetTag -> SelectionDataM ()
Set the selection to the given TargetTag.
selectionDataGetTargets :: SelectionDataM [TargetTag]
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 Bool
Given a SelectionDataM holding a list of targets, determines if any of the targets in targets can be used to provide text.
selectionDataTargetsIncludeUri :: SelectionDataM Bool

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 Bool

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 ())
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 ())
Pass the supplied selection data to the application. The application is expected to read the data using selectionDataGet or one of its derivatives.
Produced by Haddock version 2.4.2