Maintainer | gtk2hs-users@lists.sourceforge.net |
---|---|
Stability | provisional |
Portability | portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell98 |
Completion functionality for Entry
- Module available since Gtk+ version 2.4
- data EntryCompletion
- class GObjectClass o => EntryCompletionClass o
- castToEntryCompletion :: GObjectClass obj => obj -> EntryCompletion
- gTypeEntryCompletion :: GType
- toEntryCompletion :: EntryCompletionClass o => o -> EntryCompletion
- entryCompletionNew :: IO EntryCompletion
- entryCompletionGetEntry :: EntryCompletion -> IO (Maybe Entry)
- entryCompletionSetModel :: TreeModelClass model => EntryCompletion -> Maybe model -> IO ()
- entryCompletionGetModel :: EntryCompletion -> IO (Maybe TreeModel)
- entryCompletionSetTextModel :: (TreeModelClass (model string), TypedTreeModelClass model, GlibString string) => EntryCompletion -> model string -> IO ()
- entryCompletionSetMatchFunc :: GlibString string => EntryCompletion -> (string -> TreeIter -> IO Bool) -> IO ()
- entryCompletionSetMinimumKeyLength :: EntryCompletion -> Int -> IO ()
- entryCompletionGetMinimumKeyLength :: EntryCompletion -> IO Int
- entryCompletionComplete :: EntryCompletion -> IO ()
- entryCompletionInsertActionText :: GlibString string => EntryCompletion -> Int -> string -> IO ()
- entryCompletionInsertActionMarkup :: GlibString string => EntryCompletion -> Int -> string -> IO ()
- entryCompletionDeleteAction :: EntryCompletion -> Int -> IO ()
- entryCompletionSetTextColumn :: GlibString string => EntryCompletion -> ColumnId row string -> IO ()
- entryCompletionInsertPrefix :: EntryCompletion -> IO ()
- entryCompletionGetTextColumn :: GlibString string => EntryCompletion -> IO (ColumnId row string)
- entryCompletionSetInlineCompletion :: EntryCompletion -> Bool -> IO ()
- entryCompletionGetInlineCompletion :: EntryCompletion -> IO Bool
- entryCompletionSetPopupCompletion :: EntryCompletion -> Bool -> IO ()
- entryCompletionGetPopupCompletion :: EntryCompletion -> IO Bool
- entryCompletionSetPopupSetWidth :: EntryCompletion -> Bool -> IO ()
- entryCompletionGetPopupSetWidth :: EntryCompletion -> IO Bool
- entryCompletionSetPopupSingleMatch :: EntryCompletion -> Bool -> IO ()
- entryCompletionGetPopupSingleMatch :: EntryCompletion -> IO Bool
- entryCompletionModel :: TreeModelClass model => ReadWriteAttr EntryCompletion (Maybe TreeModel) (Maybe model)
- entryCompletionMinimumKeyLength :: Attr EntryCompletion Int
- entryCompletionTextColumn :: GlibString string => Attr EntryCompletion (ColumnId row string)
- entryCompletionInlineCompletion :: Attr EntryCompletion Bool
- entryCompletionPopupCompletion :: Attr EntryCompletion Bool
- entryCompletionPopupSetWidth :: Attr EntryCompletion Bool
- entryCompletionPopupSingleMatch :: Attr EntryCompletion Bool
- insertPrefix :: (EntryCompletionClass self, GlibString string) => Signal self (string -> IO Bool)
- completionActionActivated :: EntryCompletionClass self => Signal self (Int -> IO ())
- matchSelected :: EntryCompletionClass self => Signal self (TreeModel -> TreeIter -> IO Bool)
- onInsertPrefix :: (EntryCompletionClass self, GlibString string) => self -> (string -> IO Bool) -> IO (ConnectId self)
- afterInsertPrefix :: (EntryCompletionClass self, GlibString string) => self -> (string -> IO Bool) -> IO (ConnectId self)
- onActionActivated :: EntryCompletionClass self => self -> (Int -> IO ()) -> IO (ConnectId self)
- afterActionActivated :: EntryCompletionClass self => self -> (Int -> IO ()) -> IO (ConnectId self)
Detail
EntryCompletion
is an auxiliary object to be used in conjunction with
Entry
to provide the completion functionality. It implements the
CellLayout
interface, to allow the user to add extra cells to the
TreeView
with completion matches.
"Completion functionality" means that when the user modifies the
text in the entry, EntryCompletion
checks which rows in the model
match the current content of the entry, and displays a list of
matches. By default, the matching is done by comparing the entry
text case-insensitively against the text in a model (see
entryCompletionSetTextModel
), but this can
be overridden with a custom match function (see
entryCompletionSetMatchFunc
).
When the user selects a completion, the content of the entry is updated.
By default, the content of the entry is replaced by the text column of the
model, but this can be overridden by connecting to the matchSelected
signal and updating the entry in the signal handler. Note that you should
return True
from the signal handler to suppress the default behaviour.
To add completion functionality to an entry, use
entrySetCompletion
.
In addition to regular completion matches, which will be inserted into
the entry when they are selected, EntryCompletion
also allows to display
"actions" in the popup window. Their appearance is similar to menu items,
to differentiate them clearly from completion strings. When an action is
selected, the completionActionActivated
signal is emitted.
Class Hierarchy
| GObject
| +----EntryCompletion
Types
data EntryCompletion Source
castToEntryCompletion :: GObjectClass obj => obj -> EntryCompletion Source
toEntryCompletion :: EntryCompletionClass o => o -> EntryCompletion Source
Constructors
entryCompletionNew :: IO EntryCompletion Source
Creates a new EntryCompletion
object.
Methods
entryCompletionGetEntry Source
:: EntryCompletion | |
-> IO (Maybe Entry) | returns the entry |
Gets the entry completion
has been attached to.
entryCompletionSetModel Source
:: TreeModelClass model | |
=> EntryCompletion | |
-> Maybe model |
|
-> IO () |
Sets the model for a EntryCompletion
. If completion
already has a
model set, it will remove it before setting the new model. If model is
Nothing
, then it will unset the model.
entryCompletionGetModel Source
:: EntryCompletion | |
-> IO (Maybe TreeModel) | returns A |
Returns the model the EntryCompletion
is using as data source. Returns
Nothing
if the model is unset.
entryCompletionSetTextModel Source
:: (TreeModelClass (model string), TypedTreeModelClass model, GlibString string) | |
=> EntryCompletion | completion |
-> model string | the model containing |
-> IO () |
Convenience function for setting up the most used case of this code: a
completion list with just strings. This function will set up completion
to
have a list displaying all (and just) strings in the completion list, and to
get those strings from model
. This functions creates and adds a
CellRendererText
which retrieves its content from the given model.
entryCompletionSetMatchFunc :: GlibString string => EntryCompletion -> (string -> TreeIter -> IO Bool) -> IO () Source
Sets the match function for completion
to be func
. The match function
is used to determine if a row should or should not be in the completion
list.
- The passed-in function decides whether the row indicated by the
TreeIter
matches a given key, and should be displayed as a possible completion for key. Note that the key is normalized and case-folded. Normalization will standardizing such issues as whether a character with an accent is represented as a base character and combining accent or as a single precomposed character. If this is not appropriate you can extract the original text from the entry.
entryCompletionSetMinimumKeyLength Source
:: EntryCompletion | |
-> Int |
|
-> IO () |
Requires the length of the search key for completion
to be at least
length
. This is useful for long lists, where completing using a small key
takes a lot of time and will come up with meaningless results anyway (ie, a
too large dataset).
entryCompletionGetMinimumKeyLength Source
:: EntryCompletion | |
-> IO Int | returns The currently used minimum key length. |
Returns the minimum key length as set for completion
.
entryCompletionComplete :: EntryCompletion -> IO () Source
Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key. The completion list view will be updated accordingly.
entryCompletionInsertActionText Source
:: GlibString string | |
=> EntryCompletion | |
-> Int |
|
-> string |
|
-> IO () |
Inserts an action in completion
's action item list at position index
with text text
. If you want the action item to have markup, use
entryCompletionInsertActionMarkup
.
entryCompletionInsertActionMarkup Source
:: GlibString string | |
=> EntryCompletion | |
-> Int |
|
-> string |
|
-> IO () |
Inserts an action in completion
's action item list at position index
with markup markup
.
entryCompletionDeleteAction Source
:: EntryCompletion | |
-> Int |
|
-> IO () |
Deletes the action at index
from completion
's action list.
entryCompletionSetTextColumn Source
:: GlibString string | |
=> EntryCompletion | |
-> ColumnId row string |
|
-> IO () |
Convenience function for setting up the most used case of this code: a
completion list with just strings. This function will set up completion
to
have a list displaying all (and just) strings in the completion list, and to
get those strings from column
in the model of completion
.
This functions creates and adds a CellRendererText
for the selected
column.
entryCompletionInsertPrefix :: EntryCompletion -> IO () Source
Requests a prefix insertion.
- Available since Gtk+ version 2.6
entryCompletionGetTextColumn Source
:: GlibString string | |
=> EntryCompletion | |
-> IO (ColumnId row string) | returns the column containing the strings |
Returns the column in the model of the completion to get strings from.
- Available since Gtk+ version 2.6
entryCompletionSetInlineCompletion Source
:: EntryCompletion | |
-> Bool |
|
-> IO () |
Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
- Available since Gtk+ version 2.6
entryCompletionGetInlineCompletion Source
:: EntryCompletion | |
-> IO Bool | returns |
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
- Available since Gtk+ version 2.6
entryCompletionSetPopupCompletion Source
:: EntryCompletion | |
-> Bool |
|
-> IO () |
Sets whether the completions should be presented in a popup window.
- Available since Gtk+ version 2.6
entryCompletionGetPopupCompletion Source
:: EntryCompletion | |
-> IO Bool | returns |
Returns whether the completions should be presented in a popup window.
- Available since Gtk+ version 2.6
entryCompletionSetPopupSetWidth Source
:: EntryCompletion | |
-> Bool |
|
-> IO () |
Sets whether the completion popup window will be resized to be the same width as the entry.
- Available since Gtk+ version 2.8
entryCompletionGetPopupSetWidth Source
:: EntryCompletion | |
-> IO Bool | returns |
Returns whether the completion popup window will be resized to the width of the entry.
- Available since Gtk+ version 2.8
entryCompletionSetPopupSingleMatch Source
:: EntryCompletion | |
-> Bool |
|
-> IO () |
Sets whether the completion popup window will appear even if there is
only a single match. You may want to set this to False
if you are using
inline completion.
- Available since Gtk+ version 2.8
entryCompletionGetPopupSingleMatch Source
:: EntryCompletion | |
-> IO Bool | returns |
Returns whether the completion popup window will appear even if there is only a single match.
- Available since Gtk+ version 2.8
Attributes
entryCompletionModel :: TreeModelClass model => ReadWriteAttr EntryCompletion (Maybe TreeModel) (Maybe model) Source
The model to find matches in.
entryCompletionMinimumKeyLength :: Attr EntryCompletion Int Source
Minimum length of the search key in order to look up matches.
Allowed values: >= 0
Default value: 1
entryCompletionTextColumn :: GlibString string => Attr EntryCompletion (ColumnId row string) Source
The column of the model containing the strings.
Default value: invalidColumnId
entryCompletionInlineCompletion :: Attr EntryCompletion Bool Source
Determines whether the common prefix of the possible completions should be inserted automatically in the entry. Note that this requires text-column to be set, even if you are using a custom match function.
Default value: False
entryCompletionPopupCompletion :: Attr EntryCompletion Bool Source
Determines whether the possible completions should be shown in a popup window.
Default value: True
entryCompletionPopupSetWidth :: Attr EntryCompletion Bool Source
Determines whether the completions popup window will be resized to the width of the entry.
Default value: True
entryCompletionPopupSingleMatch :: Attr EntryCompletion Bool Source
Determines whether the completions popup window will shown for a single
possible completion. You probably want to set this to False
if you are
using inline completion.
Default value: True
Signals
insertPrefix :: (EntryCompletionClass self, GlibString string) => Signal self (string -> IO Bool) Source
Gets emitted when the inline autocompletion is triggered. The default behaviour is to make the entry display the whole prefix and select the newly inserted part.
Applications may connect to this signal in order to insert only a smaller
part of the prefix
into the entry - e.g. the entry used in the
FileChooser
inserts only the part of the prefix up to the next '/'.
- Available since Gtk+ version 2.6
completionActionActivated :: EntryCompletionClass self => Signal self (Int -> IO ()) Source
Gets emitted when an action is activated.
matchSelected :: EntryCompletionClass self => Signal self (TreeModel -> TreeIter -> IO Bool) Source
Gets emitted when a match from the list is selected. The default
behaviour is to replace the contents of the entry with the contents of the
text column in the row pointed to by iter
.
Deprecated
onInsertPrefix :: (EntryCompletionClass self, GlibString string) => self -> (string -> IO Bool) -> IO (ConnectId self) Source
Gets emitted when the inline autocompletion is triggered. The default behaviour is to make the entry display the whole prefix and select the newly inserted part.
Applications may connect to this signal in order to insert only a smaller
part of the prefix
into the entry - e.g. the entry used in the
FileChooser
inserts only the part of the prefix up to the next '/'.
afterInsertPrefix :: (EntryCompletionClass self, GlibString string) => self -> (string -> IO Bool) -> IO (ConnectId self) Source
Gets emitted when the inline autocompletion is triggered. The default behaviour is to make the entry display the whole prefix and select the newly inserted part.
Applications may connect to this signal in order to insert only a smaller
part of the prefix
into the entry - e.g. the entry used in the
FileChooser
inserts only the part of the prefix up to the next '/'.
onActionActivated :: EntryCompletionClass self => self -> (Int -> IO ()) -> IO (ConnectId self) Source
Gets emitted when an action is activated.
afterActionActivated :: EntryCompletionClass self => self -> (Int -> IO ()) -> IO (ConnectId self) Source
Gets emitted when an action is activated.