gi-handy-1.0.2: libhandy bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Handy.Objects.SearchBar

Description

A toolbar to integrate a search entry with.

HdySearchBar 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 [methodsearchBar.handle_event] for example code. Common shortcuts such as <kbd>Ctrl</kbd>+<kbd>F</kbd> 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 [methodsearchBar.connect_entry]. The following example shows you how to create a more complex search entry.

HdySearchBar is very similar to SearchBar, the main difference being that it allows the search entry to fill all the available space. This allows you to control your search entry's width with a [classclamp].

CSS nodes

HdySearchBar has a single CSS node with name searchbar.

Since: 1.0

Synopsis

Exported types

newtype SearchBar Source #

Memory-managed wrapper type.

Constructors

SearchBar (ManagedPtr SearchBar) 

Instances

Instances details
Eq SearchBar Source # 
Instance details

Defined in GI.Handy.Objects.SearchBar

GObject SearchBar Source # 
Instance details

Defined in GI.Handy.Objects.SearchBar

ManagedPtrNewtype SearchBar Source # 
Instance details

Defined in GI.Handy.Objects.SearchBar

Methods

toManagedPtr :: SearchBar -> ManagedPtr SearchBar

TypedObject SearchBar Source # 
Instance details

Defined in GI.Handy.Objects.SearchBar

Methods

glibType :: IO GType

HasParentTypes SearchBar Source # 
Instance details

Defined in GI.Handy.Objects.SearchBar

IsGValue (Maybe SearchBar) Source #

Convert SearchBar to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Handy.Objects.SearchBar

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe SearchBar -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe SearchBar)

type ParentTypes SearchBar Source # 
Instance details

Defined in GI.Handy.Objects.SearchBar

type ParentTypes SearchBar = '[Bin, Container, Widget, Object, ImplementorIface, Buildable]

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

Methods

Click to display all available methods, including inherited ones

Expand

Methods

activate, add, addAccelerator, addChild, addDeviceEvents, addEvents, addMnemonicLabel, addTickCallback, bindProperty, bindPropertyFull, canActivateAccel, checkResize, childFocus, childGetProperty, childNotify, childNotifyByPspec, childSetProperty, childType, classPath, computeExpand, connectEntry, constructChild, createPangoContext, createPangoLayout, customFinished, customTagEnd, customTagStart, destroy, destroyed, deviceIsShadowed, dragBegin, dragBeginWithCoordinates, dragCheckThreshold, dragDestAddImageTargets, dragDestAddTextTargets, dragDestAddUriTargets, dragDestFindTarget, dragDestGetTargetList, dragDestGetTrackMotion, dragDestSet, dragDestSetProxy, dragDestSetTargetList, dragDestSetTrackMotion, dragDestUnset, dragGetData, dragHighlight, dragSourceAddImageTargets, dragSourceAddTextTargets, dragSourceAddUriTargets, dragSourceGetTargetList, dragSourceSet, dragSourceSetIconGicon, dragSourceSetIconName, dragSourceSetIconPixbuf, dragSourceSetIconStock, dragSourceSetTargetList, dragSourceUnset, dragUnhighlight, draw, ensureStyle, errorBell, event, forall, forceFloating, foreach, freezeChildNotify, freezeNotify, getv, grabAdd, grabDefault, grabFocus, grabRemove, handleEvent, hasDefault, hasFocus, hasGrab, hasRcStyle, hasScreen, hasVisibleFocus, hide, hideOnDelete, inDestruction, initTemplate, inputShapeCombineRegion, insertActionGroup, intersect, isAncestor, isComposited, isDrawable, isFloating, isFocus, isSensitive, isToplevel, isVisible, keynavFailed, listAccelClosures, listActionPrefixes, listMnemonicLabels, map, mnemonicActivate, modifyBase, modifyBg, modifyCursor, modifyFg, modifyFont, modifyStyle, modifyText, notify, notifyByPspec, overrideBackgroundColor, overrideColor, overrideCursor, overrideFont, overrideSymbolicColor, parserFinished, path, propagateDraw, queueAllocate, queueComputeExpand, queueDraw, queueDrawArea, queueDrawRegion, queueResize, queueResizeNoRedraw, realize, ref, refSink, regionIntersect, registerWindow, remove, removeAccelerator, removeMnemonicLabel, removeTickCallback, renderIcon, renderIconPixbuf, reparent, resetRcStyles, resetStyle, resizeChildren, runDispose, sendExpose, sendFocusChange, shapeCombineRegion, show, showAll, showNow, sizeAllocate, sizeAllocateWithBaseline, sizeRequest, stealData, stealQdata, styleAttach, styleGetProperty, thawChildNotify, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unregisterWindow, unsetFocusChain, unsetStateFlags, watchClosure.

Getters

getAccessible, getActionGroup, getAllocatedBaseline, getAllocatedHeight, getAllocatedSize, getAllocatedWidth, getAllocation, getAncestor, getAppPaintable, getBorderWidth, getCanDefault, getCanFocus, getChild, getChildRequisition, getChildVisible, getChildren, getClip, getClipboard, getCompositeName, getData, getDeviceEnabled, getDeviceEvents, getDirection, getDisplay, getDoubleBuffered, getEvents, getFocusChain, getFocusChild, getFocusHadjustment, getFocusOnClick, getFocusVadjustment, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHasWindow, getHexpand, getHexpandSet, getInternalChild, getMapped, getMarginBottom, getMarginEnd, getMarginLeft, getMarginRight, getMarginStart, getMarginTop, getModifierMask, getModifierStyle, getName, getNoShowAll, getOpacity, getPangoContext, getParent, getParentWindow, getPath, getPathForChild, getPointer, getPreferredHeight, getPreferredHeightAndBaselineForWidth, getPreferredHeightForWidth, getPreferredSize, getPreferredWidth, getPreferredWidthForHeight, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRequisition, getResizeMode, getRootWindow, getScaleFactor, getScreen, getSearchMode, getSensitive, getSettings, getShowCloseButton, getSizeRequest, getState, getStateFlags, getStyle, getStyleContext, getSupportMultidevice, getTemplateChild, getTooltipMarkup, getTooltipText, getTooltipWindow, getToplevel, getValign, getValignWithBaseline, getVexpand, getVexpandSet, getVisible, getVisual, getWindow.

Setters

setAccelPath, setAllocation, setAppPaintable, setBorderWidth, setBuildableProperty, setCanDefault, setCanFocus, setChildVisible, setClip, setCompositeName, setData, setDataFull, setDeviceEnabled, setDeviceEvents, setDirection, setDoubleBuffered, setEvents, setFocusChain, setFocusChild, setFocusHadjustment, setFocusOnClick, setFocusVadjustment, setFontMap, setFontOptions, setHalign, setHasTooltip, setHasWindow, setHexpand, setHexpandSet, setMapped, setMarginBottom, setMarginEnd, setMarginLeft, setMarginRight, setMarginStart, setMarginTop, setName, setNoShowAll, setOpacity, setParent, setParentWindow, setProperty, setRealized, setReallocateRedraws, setReceivesDefault, setRedrawOnAllocate, setResizeMode, setSearchMode, setSensitive, setShowCloseButton, setSizeRequest, setState, setStateFlags, setStyle, setSupportMultidevice, setTooltipMarkup, setTooltipText, setTooltipWindow, setValign, setVexpand, setVexpandSet, setVisible, setVisual, setWindow.

connectEntry

searchBarConnectEntry Source #

Arguments

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

self: a search bar

-> b

entry: an entry

-> m () 

Sets 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: 1.0

getSearchMode

searchBarGetSearchMode Source #

Arguments

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

self: a search bar

-> m Bool

Returns: whether search mode is toggled on

Gets whether the search mode is on.

Since: 1.0

getShowCloseButton

searchBarGetShowCloseButton Source #

Arguments

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

self: a search bar

-> m Bool

Returns: whether the close button is shown

Gets whether the close button is shown.

Since: 1.0

handleEvent

searchBarHandleEvent Source #

Arguments

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

self: a search bar

-> Event

event: a [structgdk.Event] containing key press events

-> m Bool

Returns: GDK_EVENT_STOP if the key press event resulted in text being entered in the search entry (and revealing the search bar if necessary), GDK_EVENT_PROPAGATE otherwise.

Handles key press events.

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 GDK_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 [methodsearchBar.connect_entry], 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)
{
  HdySearchBar *bar = HDY_SEARCH_BAR (user_data);
  return hdy_search_bar_handle_event (self, event);
}

static void
create_toplevel (void)
{
  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  GtkWindow *search_bar = hdy_search_bar_new ();

  // Add more widgets to the window...

  g_signal_connect (window,
                   "key-press-event",
                    G_CALLBACK (on_key_press_event),
                    search_bar);
}

Since: 1.0

new

searchBarNew Source #

Arguments

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

Returns: the newly created HdySearchBar

Creates a new `HdySearchBar.

You will need to tell it about which widget is going to be your text entry using [methodsearchBar.connect_entry].

Since: 1.0

setSearchMode

searchBarSetSearchMode Source #

Arguments

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

self: a search bar

-> Bool

searchMode: the new state of the search mode

-> m () 

Switches the search mode on or off.

Since: 1.0

setShowCloseButton

searchBarSetShowCloseButton Source #

Arguments

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

self: a search bar

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

Since: 1.0

Properties

searchModeEnabled

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

Since: 1.0

constructSearchBarSearchModeEnabled :: (IsSearchBar o, MonadIO m) => Bool -> m (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 toolbar.

Since: 1.0

constructSearchBarShowCloseButton :: (IsSearchBar o, MonadIO m) => Bool -> m (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 ]