Skip to content

Gtk.LockButton

class — extends Button, Accessible, Actionable, Buildable, ConstraintTarget

:::warning Deprecated since 4.10 This API is deprecated. :::

GtkLockButton is a widget to obtain and revoke authorizations needed to operate the controls.

<picture> <source srcset="lockbutton-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkLockButton" src="lockbutton.png"> </picture>

It is typically used in preference dialogs or control panels.

The required authorization is represented by a GPermission object. Concrete implementations of GPermission may use PolicyKit or some other authorization framework. To obtain a PolicyKit-based GPermission, use polkit_permission_new().

If the user is not currently allowed to perform the action, but can obtain the permission, the widget looks like this:

<picture> <source srcset="lockbutton-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An locked GtkLockButton" src="lockbutton.png"> </picture>

and the user can click the button to request the permission. Depending on the platform, this may pop up an authentication dialog or ask the user to authenticate in some other way. Once the user has obtained the permission, the widget changes to this:

<picture> <source srcset="lockbutton-unlocked-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An unlocked GtkLockButton" src="lockbutton-unlocked.png"> </picture>

and the permission can be dropped again by clicking the button. If the user is not able to obtain the permission at all, the widget looks like this:

<picture> <source srcset="lockbutton-sorry-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An unobtainable GtkLockButton" src="lockbutton-sorry.png"> </picture>

If the user has the permission and cannot drop it, the button is hidden.

The text (and tooltips) that are shown in the various cases can be adjusted with the LockButton.text-lock, LockButton.text-unlock, LockButton.tooltip-lock, LockButton.tooltip-unlock and LockButton.tooltip-not-authorized properties.

Constructors

new

@classmethod
def new(cls, permission: Gio.Permission | None = ...) -> Widget

:::warning Deprecated since 4.10 This API is deprecated. :::

Creates a new lock button which reflects the permission.

Parameters:

  • permission — a GPermission

Methods

get_permission

def get_permission(self) -> Gio.Permission | None

:::warning Deprecated since 4.10 This API is deprecated. :::

Obtains the GPermission object that controls button.

set_permission

def set_permission(self, permission: Gio.Permission | None = ...) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets the GPermission object that controls button.

Parameters:

  • permission — a GPermission object

Properties

permission

permission: Gio.Permission  # read/write

:::warning Deprecated since 4.10 This API is deprecated. :::

The `GPermission object controlling this button.

text_lock

text_lock: str  # read/write

:::warning Deprecated since 4.10 This API is deprecated. :::

The text to display when prompting the user to lock.

text_unlock

text_unlock: str  # read/write

:::warning Deprecated since 4.10 This API is deprecated. :::

The text to display when prompting the user to unlock.

tooltip_lock

tooltip_lock: str  # read/write

:::warning Deprecated since 4.10 This API is deprecated. :::

The tooltip to display when prompting the user to lock.

tooltip_not_authorized

tooltip_not_authorized: str  # read/write

:::warning Deprecated since 4.10 This API is deprecated. :::

The tooltip to display when the user cannot obtain authorization.

tooltip_unlock

tooltip_unlock: str  # read/write

:::warning Deprecated since 4.10 This API is deprecated. :::

The tooltip to display when prompting the user to unlock.