Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
GtkPopover is a bubble-like context window, primarily meant to
provide context-dependent information or options. Popovers are
attached to a widget, passed at construction time on popoverNew
,
or updated afterwards through popoverSetRelativeTo
, by
default they will point to the whole widget area, although this
behavior can be changed through popoverSetPointingTo
.
The position of a popover relative to the widget it is attached to
can also be changed through popoverSetPosition
.
By default, Popover
performs a GTK+ grab, in order to ensure
input events get redirected to it while it is shown, and also so
the popover is dismissed in the expected situations (clicks outside
the popover, or the Esc key being pressed). If no such modal behavior
is desired on a popover, popoverSetModal
may be called on it
to tweak its behavior.
GtkPopover as menu replacement
GtkPopover is often used to replace menus. To facilitate this, it
supports being populated from a MenuModel
, using
popoverNewFromModel
. In addition to all the regular menu
model features, this function supports rendering sections in the
model in a more compact form, as a row of icon buttons instead of
menu items.
To use this rendering, set the ”display-hint” attribute of the section to ”horizontal-buttons” and set the icons of your items with the ”verb-icon” attribute.
<section> <attribute name="display-hint">horizontal-buttons</attribute> <item> <attribute name="label">Cut</attribute> <attribute name="action">app.cut</attribute> <attribute name="verb-icon">edit-cut-symbolic</attribute> </item> <item> <attribute name="label">Copy</attribute> <attribute name="action">app.copy</attribute> <attribute name="verb-icon">edit-copy-symbolic</attribute> </item> <item> <attribute name="label">Paste</attribute> <attribute name="action">app.paste</attribute> <attribute name="verb-icon">edit-paste-symbolic</attribute> </item> </section>
CSS nodes
GtkPopover has a single css node called popover. It always gets the
.background style class and it gets the .menu style class if it is
menu-like (e.g. PopoverMenu
or created using popoverNewFromModel
.
Particular uses of GtkPopover, such as touch selection popups
or magnifiers in Entry
or TextView
get style classes
like .touch-selection or .magnifier to differentiate from
plain popovers.
Since: 3.12
Synopsis
- newtype Popover = Popover (ManagedPtr Popover)
- class (GObject o, IsDescendantOf Popover o) => IsPopover o
- toPopover :: (MonadIO m, IsPopover o) => o -> m Popover
- noPopover :: Maybe Popover
- popoverBindModel :: (HasCallStack, MonadIO m, IsPopover a, IsMenuModel b) => a -> Maybe b -> Maybe Text -> m ()
- popoverGetConstrainTo :: (HasCallStack, MonadIO m, IsPopover a) => a -> m PopoverConstraint
- popoverGetDefaultWidget :: (HasCallStack, MonadIO m, IsPopover a) => a -> m (Maybe Widget)
- popoverGetModal :: (HasCallStack, MonadIO m, IsPopover a) => a -> m Bool
- popoverGetPointingTo :: (HasCallStack, MonadIO m, IsPopover a) => a -> m (Bool, Rectangle)
- popoverGetPosition :: (HasCallStack, MonadIO m, IsPopover a) => a -> m PositionType
- popoverGetRelativeTo :: (HasCallStack, MonadIO m, IsPopover a) => a -> m Widget
- popoverGetTransitionsEnabled :: (HasCallStack, MonadIO m, IsPopover a) => a -> m Bool
- popoverNew :: (HasCallStack, MonadIO m, IsWidget a) => Maybe a -> m Popover
- popoverNewFromModel :: (HasCallStack, MonadIO m, IsWidget a, IsMenuModel b) => Maybe a -> b -> m Popover
- popoverPopdown :: (HasCallStack, MonadIO m, IsPopover a) => a -> m ()
- popoverPopup :: (HasCallStack, MonadIO m, IsPopover a) => a -> m ()
- popoverSetConstrainTo :: (HasCallStack, MonadIO m, IsPopover a) => a -> PopoverConstraint -> m ()
- popoverSetDefaultWidget :: (HasCallStack, MonadIO m, IsPopover a, IsWidget b) => a -> Maybe b -> m ()
- popoverSetModal :: (HasCallStack, MonadIO m, IsPopover a) => a -> Bool -> m ()
- popoverSetPointingTo :: (HasCallStack, MonadIO m, IsPopover a) => a -> Rectangle -> m ()
- popoverSetPosition :: (HasCallStack, MonadIO m, IsPopover a) => a -> PositionType -> m ()
- popoverSetRelativeTo :: (HasCallStack, MonadIO m, IsPopover a, IsWidget b) => a -> Maybe b -> m ()
- popoverSetTransitionsEnabled :: (HasCallStack, MonadIO m, IsPopover a) => a -> Bool -> m ()
- constructPopoverConstrainTo :: IsPopover o => PopoverConstraint -> IO (GValueConstruct o)
- getPopoverConstrainTo :: (MonadIO m, IsPopover o) => o -> m PopoverConstraint
- setPopoverConstrainTo :: (MonadIO m, IsPopover o) => o -> PopoverConstraint -> m ()
- constructPopoverModal :: IsPopover o => Bool -> IO (GValueConstruct o)
- getPopoverModal :: (MonadIO m, IsPopover o) => o -> m Bool
- setPopoverModal :: (MonadIO m, IsPopover o) => o -> Bool -> m ()
- constructPopoverPointingTo :: IsPopover o => Rectangle -> IO (GValueConstruct o)
- getPopoverPointingTo :: (MonadIO m, IsPopover o) => o -> m (Maybe Rectangle)
- setPopoverPointingTo :: (MonadIO m, IsPopover o) => o -> Rectangle -> m ()
- constructPopoverPosition :: IsPopover o => PositionType -> IO (GValueConstruct o)
- getPopoverPosition :: (MonadIO m, IsPopover o) => o -> m PositionType
- setPopoverPosition :: (MonadIO m, IsPopover o) => o -> PositionType -> m ()
- clearPopoverRelativeTo :: (MonadIO m, IsPopover o) => o -> m ()
- constructPopoverRelativeTo :: (IsPopover o, IsWidget a) => a -> IO (GValueConstruct o)
- getPopoverRelativeTo :: (MonadIO m, IsPopover o) => o -> m Widget
- setPopoverRelativeTo :: (MonadIO m, IsPopover o, IsWidget a) => o -> a -> m ()
- constructPopoverTransitionsEnabled :: IsPopover o => Bool -> IO (GValueConstruct o)
- getPopoverTransitionsEnabled :: (MonadIO m, IsPopover o) => o -> m Bool
- setPopoverTransitionsEnabled :: (MonadIO m, IsPopover o) => o -> Bool -> m ()
- type C_PopoverClosedCallback = Ptr () -> Ptr () -> IO ()
- type PopoverClosedCallback = IO ()
- afterPopoverClosed :: (IsPopover a, MonadIO m) => a -> PopoverClosedCallback -> m SignalHandlerId
- genClosure_PopoverClosed :: MonadIO m => PopoverClosedCallback -> m (GClosure C_PopoverClosedCallback)
- mk_PopoverClosedCallback :: C_PopoverClosedCallback -> IO (FunPtr C_PopoverClosedCallback)
- noPopoverClosedCallback :: Maybe PopoverClosedCallback
- onPopoverClosed :: (IsPopover a, MonadIO m) => a -> PopoverClosedCallback -> m SignalHandlerId
- wrap_PopoverClosedCallback :: PopoverClosedCallback -> C_PopoverClosedCallback
Exported types
Memory-managed wrapper type.
Instances
GObject Popover Source # | |
Defined in GI.Gtk.Objects.Popover gobjectType :: IO GType # | |
HasParentTypes Popover Source # | |
Defined in GI.Gtk.Objects.Popover | |
type ParentTypes Popover Source # | |
Defined in GI.Gtk.Objects.Popover type ParentTypes Popover = Bin ': (Container ': (Widget ': (Object ': (ImplementorIface ': (Buildable ': ([] :: [Type])))))) |
class (GObject o, IsDescendantOf Popover o) => IsPopover o Source #
Instances
(GObject o, IsDescendantOf Popover o) => IsPopover o Source # | |
Defined in GI.Gtk.Objects.Popover |
Methods
bindModel
:: (HasCallStack, MonadIO m, IsPopover a, IsMenuModel b) | |
=> a |
|
-> Maybe b |
|
-> Maybe Text |
|
-> m () |
Establishes a binding between a Popover
and a MenuModel
.
The contents of popover
are removed and then refilled with menu items
according to model
. When model
changes, popover
is updated.
Calling this function twice on popover
with different model
will
cause the first binding to be replaced with a binding to the new
model. If model
is Nothing
then any previous binding is undone and
all children are removed.
If actionNamespace
is non-Nothing
then the effect is as if all
actions mentioned in the model
have their names prefixed with the
namespace, plus a dot. For example, if the action “quit” is
mentioned and actionNamespace
is “app” then the effective action
name is “app.quit”.
This function uses Actionable
to define the action name and
target values on the created menu items. If you want to use an
action group other than “app” and “win”, or if you want to use a
MenuShell
outside of a ApplicationWindow
, then you will need
to attach your own action group to the widget hierarchy using
widgetInsertActionGroup
. As an example, if you created a
group with a “quit” action and inserted it with the name “mygroup”
then you would use the action name “mygroup.quit” in your
MenuModel
.
Since: 3.12
getConstrainTo
popoverGetConstrainTo Source #
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> m PopoverConstraint | Returns: the constraint for placing this popover. |
Returns the constraint for placing this popover.
See popoverSetConstrainTo
.
Since: 3.20
getDefaultWidget
popoverGetDefaultWidget Source #
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> m (Maybe Widget) | Returns: the default widget,
or |
Gets the widget that should be set as the default while the popover is shown.
Since: 3.18
getModal
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> m Bool | Returns: |
Returns whether the popover is modal, see gtk_popover_set_modal to see the implications of this.
Since: 3.12
getPointingTo
getPosition
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> m PositionType | Returns: The preferred position. |
Returns the preferred position of popover
.
getRelativeTo
Returns the widget popover
is currently attached to
Since: 3.12
getTransitionsEnabled
popoverGetTransitionsEnabled Source #
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> m Bool | Returns: |
Deprecated: (Since version 3.22)You can show or hide the popover without transitions using widgetShow
and widgetHide
while popoverPopup
and popoverPopdown
will use transitions.
Returns whether show/hide transitions are enabled on this popover.
Since: 3.16
new
:: (HasCallStack, MonadIO m, IsWidget a) | |
=> Maybe a |
|
-> m Popover | Returns: a new |
Creates a new popover to point to relativeTo
Since: 3.12
newFromModel
:: (HasCallStack, MonadIO m, IsWidget a, IsMenuModel b) | |
=> Maybe a |
|
-> b |
|
-> m Popover | Returns: the new |
Creates a Popover
and populates it according to
model
. The popover is pointed to the relativeTo
widget.
The created buttons are connected to actions found in the
ApplicationWindow
to which the popover belongs - typically
by means of being attached to a widget that is contained within
the GtkApplicationWindows
widget hierarchy.
Actions can also be added using widgetInsertActionGroup
on the menus attach widget or on any of its parent widgets.
Since: 3.12
popdown
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> m () |
Pops popover
down.This is different than a widgetHide
call
in that it shows the popover with a transition. If you want to hide
the popover without a transition, use widgetHide
.
Since: 3.22
popup
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> m () |
Pops popover
up. This is different than a widgetShow
call
in that it shows the popover with a transition. If you want to show
the popover without a transition, use widgetShow
.
Since: 3.22
setConstrainTo
popoverSetConstrainTo Source #
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> PopoverConstraint |
|
-> m () |
Sets a constraint for positioning this popover.
Note that not all platforms support placing popovers freely, and may already impose constraints.
Since: 3.20
setDefaultWidget
popoverSetDefaultWidget Source #
:: (HasCallStack, MonadIO m, IsPopover a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the widget that should be set as default widget while
the popover is shown (see windowSetDefault
). Popover
remembers the previous default widget and reestablishes it
when the popover is dismissed.
Since: 3.18
setModal
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether popover
is modal, a modal popover will grab all input
within the toplevel and grab the keyboard focus on it when being
displayed. Clicking outside the popover area or pressing Esc will
dismiss the popover and ungrab input.
Since: 3.12
setPointingTo
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> Rectangle |
|
-> m () |
Sets the rectangle that popover
will point to, in the
coordinate space of the widget popover
is attached to,
see popoverSetRelativeTo
.
Since: 3.12
setPosition
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> PositionType |
|
-> m () |
Sets the preferred position for popover
to appear. If the popover
is currently visible, it will be immediately updated.
This preference will be respected where possible, although
on lack of space (eg. if close to the window edges), the
Popover
may choose to appear on the opposite side
Since: 3.12
setRelativeTo
:: (HasCallStack, MonadIO m, IsPopover a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets a new widget to be attached to popover
. If popover
is
visible, the position will be updated.
Note: the ownership of popovers is always given to their relativeTo
widget, so if relativeTo
is set to Nothing
on an attached popover
, it
will be detached from its previous widget, and consequently destroyed
unless extra references are kept.
Since: 3.12
setTransitionsEnabled
popoverSetTransitionsEnabled Source #
:: (HasCallStack, MonadIO m, IsPopover a) | |
=> a |
|
-> Bool |
|
-> m () |
Deprecated: (Since version 3.22)You can show or hide the popover without transitions using widgetShow
and widgetHide
while popoverPopup
and popoverPopdown
will use transitions.
Sets whether show/hide transitions are enabled on this popover
Since: 3.16
Properties
constrainTo
Sets a constraint for the popover position.
Since: 3.20
constructPopoverConstrainTo :: IsPopover o => PopoverConstraint -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “constrain-to
” property. This is rarely needed directly, but it is used by new
.
getPopoverConstrainTo :: (MonadIO m, IsPopover o) => o -> m PopoverConstraint Source #
Get the value of the “constrain-to
” property.
When overloading is enabled, this is equivalent to
get
popover #constrainTo
setPopoverConstrainTo :: (MonadIO m, IsPopover o) => o -> PopoverConstraint -> m () Source #
Set the value of the “constrain-to
” property.
When overloading is enabled, this is equivalent to
set
popover [ #constrainTo:=
value ]
modal
Sets whether the popover is modal (so other elements in the window do not receive input while the popover is visible).
Since: 3.12
constructPopoverModal :: IsPopover o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “modal
” property. This is rarely needed directly, but it is used by new
.
getPopoverModal :: (MonadIO m, IsPopover o) => o -> m Bool Source #
Get the value of the “modal
” property.
When overloading is enabled, this is equivalent to
get
popover #modal
setPopoverModal :: (MonadIO m, IsPopover o) => o -> Bool -> m () Source #
Set the value of the “modal
” property.
When overloading is enabled, this is equivalent to
set
popover [ #modal:=
value ]
pointingTo
Marks a specific rectangle to be pointed.
Since: 3.12
constructPopoverPointingTo :: IsPopover o => Rectangle -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “pointing-to
” property. This is rarely needed directly, but it is used by new
.
getPopoverPointingTo :: (MonadIO m, IsPopover o) => o -> m (Maybe Rectangle) Source #
Get the value of the “pointing-to
” property.
When overloading is enabled, this is equivalent to
get
popover #pointingTo
setPopoverPointingTo :: (MonadIO m, IsPopover o) => o -> Rectangle -> m () Source #
Set the value of the “pointing-to
” property.
When overloading is enabled, this is equivalent to
set
popover [ #pointingTo:=
value ]
position
Sets the preferred position of the popover.
Since: 3.12
constructPopoverPosition :: IsPopover o => PositionType -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “position
” property. This is rarely needed directly, but it is used by new
.
getPopoverPosition :: (MonadIO m, IsPopover o) => o -> m PositionType Source #
Get the value of the “position
” property.
When overloading is enabled, this is equivalent to
get
popover #position
setPopoverPosition :: (MonadIO m, IsPopover o) => o -> PositionType -> m () Source #
Set the value of the “position
” property.
When overloading is enabled, this is equivalent to
set
popover [ #position:=
value ]
relativeTo
Sets the attached widget.
Since: 3.12
clearPopoverRelativeTo :: (MonadIO m, IsPopover o) => o -> m () Source #
Set the value of the “relative-to
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#relativeTo
constructPopoverRelativeTo :: (IsPopover o, IsWidget a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “relative-to
” property. This is rarely needed directly, but it is used by new
.
getPopoverRelativeTo :: (MonadIO m, IsPopover o) => o -> m Widget Source #
Get the value of the “relative-to
” property.
When overloading is enabled, this is equivalent to
get
popover #relativeTo
setPopoverRelativeTo :: (MonadIO m, IsPopover o, IsWidget a) => o -> a -> m () Source #
Set the value of the “relative-to
” property.
When overloading is enabled, this is equivalent to
set
popover [ #relativeTo:=
value ]
transitionsEnabled
Whether show/hide transitions are enabled for this popover.
Since: 3.16
constructPopoverTransitionsEnabled :: IsPopover o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “transitions-enabled
” property. This is rarely needed directly, but it is used by new
.
getPopoverTransitionsEnabled :: (MonadIO m, IsPopover o) => o -> m Bool Source #
Get the value of the “transitions-enabled
” property.
When overloading is enabled, this is equivalent to
get
popover #transitionsEnabled
setPopoverTransitionsEnabled :: (MonadIO m, IsPopover o) => o -> Bool -> m () Source #
Set the value of the “transitions-enabled
” property.
When overloading is enabled, this is equivalent to
set
popover [ #transitionsEnabled:=
value ]
Signals
closed
type C_PopoverClosedCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type PopoverClosedCallback = IO () Source #
This signal is emitted when the popover is dismissed either through API or user interaction.
Since: 3.12
afterPopoverClosed :: (IsPopover a, MonadIO m) => a -> PopoverClosedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “closed
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
popover #closed callback
genClosure_PopoverClosed :: MonadIO m => PopoverClosedCallback -> m (GClosure C_PopoverClosedCallback) Source #
Wrap the callback into a GClosure
.
mk_PopoverClosedCallback :: C_PopoverClosedCallback -> IO (FunPtr C_PopoverClosedCallback) Source #
Generate a function pointer callable from C code, from a C_PopoverClosedCallback
.
noPopoverClosedCallback :: Maybe PopoverClosedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
PopoverClosedCallback
onPopoverClosed :: (IsPopover a, MonadIO m) => a -> PopoverClosedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “closed
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
popover #closed callback