Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
SearchBar
is a container made to have a search entry (possibly
with additional connex widgets, such as drop-down menus, or buttons)
built-in. The search bar would appear when a search is started through
typing on the keyboard, or the application’s search mode is toggled on.
For keyboard presses to start a search, events will need to be
forwarded from the top-level window that contains the search bar.
See searchBarHandleEvent
for example code. Common shortcuts
such as Ctrl+F should be handled as an application action, or through
the menu items.
You will also need to tell the search bar about which entry you
are using as your search entry using searchBarConnectEntry
.
The following example shows you how to create a more complex search
entry.
CSS nodes
GtkSearchBar has a single CSS node with name searchbar.
Creating a search bar
- newtype SearchBar = SearchBar (ManagedPtr SearchBar)
- class GObject o => IsSearchBar o
- toSearchBar :: IsSearchBar o => o -> IO SearchBar
- noSearchBar :: Maybe SearchBar
- data SearchBarConnectEntryMethodInfo
- searchBarConnectEntry :: (HasCallStack, MonadIO m, IsSearchBar a, IsEntry b) => a -> b -> m ()
- data SearchBarGetSearchModeMethodInfo
- searchBarGetSearchMode :: (HasCallStack, MonadIO m, IsSearchBar a) => a -> m Bool
- data SearchBarGetShowCloseButtonMethodInfo
- searchBarGetShowCloseButton :: (HasCallStack, MonadIO m, IsSearchBar a) => a -> m Bool
- data SearchBarHandleEventMethodInfo
- searchBarHandleEvent :: (HasCallStack, MonadIO m, IsSearchBar a) => a -> Event -> m Bool
- searchBarNew :: (HasCallStack, MonadIO m) => m SearchBar
- data SearchBarSetSearchModeMethodInfo
- searchBarSetSearchMode :: (HasCallStack, MonadIO m, IsSearchBar a) => a -> Bool -> m ()
- data SearchBarSetShowCloseButtonMethodInfo
- searchBarSetShowCloseButton :: (HasCallStack, MonadIO m, IsSearchBar a) => a -> Bool -> m ()
- data SearchBarSearchModeEnabledPropertyInfo
- constructSearchBarSearchModeEnabled :: IsSearchBar o => Bool -> IO (GValueConstruct o)
- getSearchBarSearchModeEnabled :: (MonadIO m, IsSearchBar o) => o -> m Bool
- searchBarSearchModeEnabled :: AttrLabelProxy "searchModeEnabled"
- setSearchBarSearchModeEnabled :: (MonadIO m, IsSearchBar o) => o -> Bool -> m ()
- data SearchBarShowCloseButtonPropertyInfo
- constructSearchBarShowCloseButton :: IsSearchBar o => Bool -> IO (GValueConstruct o)
- getSearchBarShowCloseButton :: (MonadIO m, IsSearchBar o) => o -> m Bool
- searchBarShowCloseButton :: AttrLabelProxy "showCloseButton"
- setSearchBarShowCloseButton :: (MonadIO m, IsSearchBar o) => o -> Bool -> m ()
Exported types
GObject SearchBar Source # | |
IsImplementorIface SearchBar Source # | |
IsObject SearchBar Source # | |
IsWidget SearchBar Source # | |
IsContainer SearchBar Source # | |
IsBin SearchBar Source # | |
IsBuildable SearchBar Source # | |
IsSearchBar SearchBar Source # | |
((~) * info (ResolveSearchBarMethod t SearchBar), MethodInfo * info SearchBar p) => IsLabel t (SearchBar -> p) Source # | |
((~) * info (ResolveSearchBarMethod t SearchBar), MethodInfo * info SearchBar p) => IsLabelProxy t (SearchBar -> p) Source # | |
HasAttributeList * SearchBar Source # | |
type AttributeList SearchBar Source # | |
type SignalList SearchBar Source # | |
class GObject o => IsSearchBar o Source #
toSearchBar :: IsSearchBar o => o -> IO SearchBar Source #
Methods
connectEntry
data SearchBarConnectEntryMethodInfo Source #
((~) * signature (b -> m ()), MonadIO m, IsSearchBar a, IsEntry b) => MethodInfo * SearchBarConnectEntryMethodInfo a signature Source # | |
searchBarConnectEntry Source #
:: (HasCallStack, MonadIO m, IsSearchBar a, IsEntry b) | |
=> a |
|
-> b |
|
-> m () |
Connects the Entry
widget passed as the one to be used in
this search bar. The entry should be a descendant of the search bar.
This is only required if the entry isn’t the direct child of the
search bar (as in our main example).
Since: 3.10
getSearchMode
data SearchBarGetSearchModeMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsSearchBar a) => MethodInfo * SearchBarGetSearchModeMethodInfo a signature Source # | |
searchBarGetSearchMode Source #
:: (HasCallStack, MonadIO m, IsSearchBar a) | |
=> a |
|
-> m Bool | Returns: whether search mode is toggled on |
Returns whether the search mode is on or off.
Since: 3.10
getShowCloseButton
data SearchBarGetShowCloseButtonMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsSearchBar a) => MethodInfo * SearchBarGetShowCloseButtonMethodInfo a signature Source # | |
searchBarGetShowCloseButton Source #
:: (HasCallStack, MonadIO m, IsSearchBar a) | |
=> a |
|
-> m Bool | Returns: whether the close button is shown |
Returns whether the close button is shown.
Since: 3.10
handleEvent
data SearchBarHandleEventMethodInfo Source #
((~) * signature (Event -> m Bool), MonadIO m, IsSearchBar a) => MethodInfo * SearchBarHandleEventMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsSearchBar a) | |
=> a |
|
-> Event |
|
-> m Bool | Returns: |
This function should be called when the top-level window which contains the search bar received a key event.
If the key event is handled by the search bar, the bar will
be shown, the entry populated with the entered text and EVENT_STOP
will be returned. The caller should ensure that events are
not propagated further.
If no entry has been connected to the search bar, using
searchBarConnectEntry
, this function will return
immediately with a warning.
Showing the search bar on key presses
C code
static gboolean on_key_press_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { GtkSearchBar *bar = GTK_SEARCH_BAR (user_data); return gtk_search_bar_handle_event (bar, event); } g_signal_connect (window, "key-press-event", G_CALLBACK (on_key_press_event), search_bar);
Since: 3.10
new
:: (HasCallStack, MonadIO m) | |
=> m SearchBar | Returns: a new |
Creates a SearchBar
. You will need to tell it about
which widget is going to be your text entry using
searchBarConnectEntry
.
Since: 3.10
setSearchMode
data SearchBarSetSearchModeMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsSearchBar a) => MethodInfo * SearchBarSetSearchModeMethodInfo a signature Source # | |
searchBarSetSearchMode Source #
:: (HasCallStack, MonadIO m, IsSearchBar a) | |
=> a |
|
-> Bool |
|
-> m () |
Switches the search mode on or off.
Since: 3.10
setShowCloseButton
data SearchBarSetShowCloseButtonMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsSearchBar a) => MethodInfo * SearchBarSetShowCloseButtonMethodInfo a signature Source # | |
searchBarSetShowCloseButton Source #
:: (HasCallStack, MonadIO m, IsSearchBar a) | |
=> a |
|
-> Bool |
|
-> m () |
Shows or hides the close button. Applications that already have a “search” toggle button should not show a close button in their search bar, as it duplicates the role of the toggle button.
Since: 3.10
Properties
searchModeEnabled
data SearchBarSearchModeEnabledPropertyInfo Source #
constructSearchBarSearchModeEnabled :: IsSearchBar o => Bool -> IO (GValueConstruct o) Source #
getSearchBarSearchModeEnabled :: (MonadIO m, IsSearchBar o) => o -> m Bool Source #
searchBarSearchModeEnabled :: AttrLabelProxy "searchModeEnabled" Source #
setSearchBarSearchModeEnabled :: (MonadIO m, IsSearchBar o) => o -> Bool -> m () Source #
showCloseButton
data SearchBarShowCloseButtonPropertyInfo Source #
constructSearchBarShowCloseButton :: IsSearchBar o => Bool -> IO (GValueConstruct o) Source #
getSearchBarShowCloseButton :: (MonadIO m, IsSearchBar o) => o -> m Bool Source #
searchBarShowCloseButton :: AttrLabelProxy "showCloseButton" Source #
setSearchBarShowCloseButton :: (MonadIO m, IsSearchBar o) => o -> Bool -> m () Source #