Gdk.PopupLayout

Fields

None

Methods

class

new (anchor_rect, rect_anchor, surface_anchor)

copy ()

equal (other)

get_anchor_hints ()

get_anchor_rect ()

get_offset ()

get_rect_anchor ()

get_shadow_width ()

get_surface_anchor ()

ref ()

set_anchor_hints (anchor_hints)

set_anchor_rect (anchor_rect)

set_offset (dx, dy)

set_rect_anchor (anchor)

set_shadow_width (left, right, top, bottom)

set_surface_anchor (anchor)

unref ()

Details

class Gdk.PopupLayout

The GdkPopupLayout struct contains information that is necessary position a [iface`Gdk`.Popup] relative to its parent.

The positioning requires a negotiation with the windowing system, since it depends on external constraints, such as the position of the parent surface, and the screen dimensions.

The basic ingredients are a rectangle on the parent surface, and the anchor on both that rectangle and the popup. The anchors specify a side or corner to place next to each other.

Popup anchors

For cases where placing the anchors next to each other would make the popup extend offscreen, the layout includes some hints for how to resolve this problem. The hints may suggest to flip the anchor position to the other side, or to ‘slide’ the popup along a side, or to resize it.

Flipping popups

Sliding popups

These hints may be combined.

Ultimatively, it is up to the windowing system to determine the position and size of the popup. You can learn about the result by calling [method`Gdk`.Popup.get_position_x], [method`Gdk`.Popup.get_position_y], [method`Gdk`.Popup.get_rect_anchor] and [method`Gdk`.Popup.get_surface_anchor] after the popup has been presented. This can be used to adjust the rendering. For example, GtkPopover changes its arrow position accordingly. But you have to be careful avoid changing the size of the popover, or it has to be presented again.

classmethod new(anchor_rect, rect_anchor, surface_anchor)[source]
Parameters:
  • anchor_rect (Gdk.Rectangle) – the anchor GdkRectangle to align surface with

  • rect_anchor (Gdk.Gravity) – the point on anchor_rect to align with surface's anchor point

  • surface_anchor (Gdk.Gravity) – the point on surface to align with rect's anchor point

Returns:

newly created instance of GdkPopupLayout

Return type:

Gdk.PopupLayout

Create a popup layout description.

Used together with [method`Gdk`.Popup.present] to describe how a popup surface should be placed and behave on-screen.

anchor_rect is relative to the top-left corner of the surface’s parent. rect_anchor and surface_anchor determine anchor points on anchor_rect and surface to pin together.

The position of anchor_rect's anchor point can optionally be offset using [method`Gdk`.PopupLayout.set_offset], which is equivalent to offsetting the position of surface.

copy()[source]
Returns:

a copy of self.

Return type:

Gdk.PopupLayout

Makes a copy of self.

equal(other)[source]
Parameters:

other (Gdk.PopupLayout) – another GdkPopupLayout

Returns:

True if self and other have identical layout properties, otherwise False.

Return type:

bool

Check whether self and other has identical layout properties.

get_anchor_hints()[source]
Returns:

the GdkAnchorHints

Return type:

Gdk.AnchorHints

Get the GdkAnchorHints.

get_anchor_rect()[source]
Returns:

The anchor rectangle

Return type:

Gdk.Rectangle

Get the anchor rectangle.

get_offset()[source]
Returns:

dx:

return location for the delta X coordinate

dy:

return location for the delta Y coordinate

Return type:

(dx: int, dy: int)

Retrieves the offset for the anchor rectangle.

get_rect_anchor()[source]
Returns:

the anchor on the anchor rectangle.

Return type:

Gdk.Gravity

Returns the anchor position on the anchor rectangle.

get_shadow_width()[source]
Returns:

left:

return location for the left shadow width

right:

return location for the right shadow width

top:

return location for the top shadow width

bottom:

return location for the bottom shadow width

Return type:

(left: int, right: int, top: int, bottom: int)

Obtains the shadow widths of this layout.

New in version 4.2.

get_surface_anchor()[source]
Returns:

the anchor on the popup surface.

Return type:

Gdk.Gravity

Returns the anchor position on the popup surface.

ref()[source]
Returns:

the same self

Return type:

Gdk.PopupLayout

Increases the reference count of value.

set_anchor_hints(anchor_hints)[source]
Parameters:

anchor_hints (Gdk.AnchorHints) – the new GdkAnchorHints

Set new anchor hints.

The set anchor_hints determines how surface will be moved if the anchor points cause it to move off-screen. For example, Gdk.AnchorHints.FLIP_X will replace Gdk.Gravity.NORTH_WEST with Gdk.Gravity.NORTH_EAST and vice versa if surface extends beyond the left or right edges of the monitor.

set_anchor_rect(anchor_rect)[source]
Parameters:

anchor_rect (Gdk.Rectangle) – the new anchor rectangle

Set the anchor rectangle.

set_offset(dx, dy)[source]
Parameters:
  • dx (int) – x delta to offset the anchor rectangle with

  • dy (int) – y delta to offset the anchor rectangle with

Offset the position of the anchor rectangle with the given delta.

set_rect_anchor(anchor)[source]
Parameters:

anchor (Gdk.Gravity) – the new rect anchor

Set the anchor on the anchor rectangle.

set_shadow_width(left, right, top, bottom)[source]
Parameters:
  • left (int) – width of the left part of the shadow

  • right (int) – width of the right part of the shadow

  • top (int) – height of the top part of the shadow

  • bottom (int) – height of the bottom part of the shadow

Sets the shadow width of the popup.

The shadow width corresponds to the part of the computed surface size that would consist of the shadow margin surrounding the window, would there be any.

New in version 4.2.

set_surface_anchor(anchor)[source]
Parameters:

anchor (Gdk.Gravity) – the new popup surface anchor

Set the anchor on the popup surface.

unref()[source]

Decreases the reference count of value.