gi-gtk-4.0.1: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.SearchBar

Description

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, the search bar must be told of a widget to capture key events from through searchBarSetKeyCaptureWidget. This widget will typically be the top-level window, or a parent container of the search bar. 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

plain code

searchbar
╰── revealer
    ╰── box
         ├── [child]
         ╰── [button.close]

GtkSearchBar has a main CSS node with name searchbar. It has a child node with name revealer that contains a node with name box. The box node contains both the CSS node of the child widget as well as an optional button node which gets the .close style class applied.

Creating a search bar

A simple example

Synopsis

Exported types

newtype SearchBar Source #

Memory-managed wrapper type.

Instances

Instances details
Eq SearchBar Source # 
Instance details

Defined in GI.Gtk.Objects.SearchBar

IsGValue SearchBar Source #

Convert SearchBar to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.SearchBar

GObject SearchBar Source # 
Instance details

Defined in GI.Gtk.Objects.SearchBar

Methods

gobjectType :: IO GType #

HasParentTypes SearchBar Source # 
Instance details

Defined in GI.Gtk.Objects.SearchBar

type ParentTypes SearchBar Source # 
Instance details

Defined in GI.Gtk.Objects.SearchBar

class (GObject o, IsDescendantOf SearchBar o) => IsSearchBar o Source #

Type class for types which can be safely cast to SearchBar, for instance with toSearchBar.

Instances

Instances details
(GObject o, IsDescendantOf SearchBar o) => IsSearchBar o Source # 
Instance details

Defined in GI.Gtk.Objects.SearchBar

toSearchBar :: (MonadIO m, IsSearchBar o) => o -> m SearchBar Source #

Cast to SearchBar, for types for which this is known to be safe. For general casts, use castTo.

noSearchBar :: Maybe SearchBar Source #

A convenience alias for Nothing :: Maybe SearchBar.

Methods

Overloaded methods

connectEntry

searchBarConnectEntry Source #

Arguments

:: (HasCallStack, MonadIO m, IsSearchBar a, IsEditable b) 
=> a

bar: a SearchBar

-> b

entry: a Editable

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

getKeyCaptureWidget

searchBarGetKeyCaptureWidget Source #

Arguments

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

bar: a SearchBar

-> m Widget

Returns: The key capture widget.

Gets the widget that bar is capturing key events from.

getSearchMode

searchBarGetSearchMode Source #

Arguments

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

bar: a SearchBar

-> m Bool

Returns: whether search mode is toggled on

Returns whether the search mode is on or off.

getShowCloseButton

searchBarGetShowCloseButton Source #

Arguments

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

bar: a SearchBar

-> m Bool

Returns: whether the close button is shown

Returns whether the close button is shown.

new

searchBarNew Source #

Arguments

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

Returns: a new SearchBar

Creates a SearchBar. You will need to tell it about which widget is going to be your text entry using searchBarConnectEntry.

setKeyCaptureWidget

searchBarSetKeyCaptureWidget Source #

Arguments

:: (HasCallStack, MonadIO m, IsSearchBar a, IsWidget b) 
=> a

bar: a SearchBar

-> Maybe b

widget: a Widget

-> m () 

Sets widget as the widget that bar will capture key events from.

If key events are handled by the search bar, the bar will be shown, and the entry populated with the entered text.

setSearchMode

searchBarSetSearchMode Source #

Arguments

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

bar: a SearchBar

-> Bool

searchMode: the new state of the search mode

-> m () 

Switches the search mode on or off.

setShowCloseButton

searchBarSetShowCloseButton Source #

Arguments

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

bar: a SearchBar

-> Bool

visible: whether the close button will be shown or not

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

Properties

searchModeEnabled

Whether the search mode is on and the search bar shown.

See searchBarSetSearchMode for details.

constructSearchBarSearchModeEnabled :: IsSearchBar o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “search-mode-enabled” property. This is rarely needed directly, but it is used by new.

getSearchBarSearchModeEnabled :: (MonadIO m, IsSearchBar o) => o -> m Bool Source #

Get the value of the “search-mode-enabled” property. When overloading is enabled, this is equivalent to

get searchBar #searchModeEnabled

setSearchBarSearchModeEnabled :: (MonadIO m, IsSearchBar o) => o -> Bool -> m () Source #

Set the value of the “search-mode-enabled” property. When overloading is enabled, this is equivalent to

set searchBar [ #searchModeEnabled := value ]

showCloseButton

Whether to show the close button in the search bar.

constructSearchBarShowCloseButton :: IsSearchBar o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “show-close-button” property. This is rarely needed directly, but it is used by new.

getSearchBarShowCloseButton :: (MonadIO m, IsSearchBar o) => o -> m Bool Source #

Get the value of the “show-close-button” property. When overloading is enabled, this is equivalent to

get searchBar #showCloseButton

setSearchBarShowCloseButton :: (MonadIO m, IsSearchBar o) => o -> Bool -> m () Source #

Set the value of the “show-close-button” property. When overloading is enabled, this is equivalent to

set searchBar [ #showCloseButton := value ]