Gio::Permission Class Reference

An object representing the permission to perform a certain action. More...

`#include <giomm/permission.h>`

Inheritance diagram for Gio::Permission:
[legend]

## Public Member Functions

| Permission (Permission&& src) noexcept
Permission& | operator= (Permission&& src) noexcept
| ~Permission () noexcept override
GPermission* | gobj ()
| Provides access to the underlying C GObject. More...
const GPermission* | gobj () const
| Provides access to the underlying C GObject. More...
GPermission* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
bool | acquire (const Glib::RefPtr< Cancellable >& cancellable)
| Attempts to acquire the permission represented by permission. More...
bool | acquire ()
| A acquire() convenience overload. More...
void | acquire_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Attempts to acquire the permission represented by permission. More...
void | acquire_async (const SlotAsyncReady& slot)
| A acquire_async() convenience overload. More...
bool | acquire_finish (const Glib::RefPtr< AsyncResult >& result)
| Collects the result of attempting to acquire the permission represented by permission. More...
bool | release (const Glib::RefPtr< Cancellable >& cancellable)
| Attempts to release the permission represented by permission. More...
bool | release ()
| A release() convenience overload. More...
void | release_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Attempts to release the permission represented by permission. More...
void | release_async (const SlotAsyncReady& slot)
| A release_async() convenience overload. More...
bool | release_finish (const Glib::RefPtr< AsyncResult >& result)
| Collects the result of attempting to release the permission represented by permission. More...
bool | get_allowed () const
| Gets the value of the 'allowed' property. More...
bool | get_can_acquire () const
| Gets the value of the 'can-acquire' property. More...
bool | get_can_release () const
| Gets the value of the 'can-release' property. More...
Glib::PropertyProxy_ReadOnly< bool > | property_allowed () const
| `true` if the caller currently has permission to perform the action that permission represents the permission to perform. More...
Glib::PropertyProxy_ReadOnly< bool > | property_can_acquire () const
| `true` if it is generally possible to acquire the permission by calling g_permission_acquire(). More...
Glib::PropertyProxy_ReadOnly< bool > | property_can_release () const
| `true` if it is generally possible to release the permission by calling g_permission_release(). More...
Public Member Functions inherited from Glib::Object
| Object (const Object&)=delete
Object& | operator= (const Object&)=delete
| Object (Object&& src) noexcept
Object& | operator= (Object&& src) noexcept
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase&)=delete
ObjectBase& | operator= (const ObjectBase&)=delete
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | connect_property_changed (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Member Functions

| Permission ()
virtual bool | acquire_vfunc (const Glib::RefPtr< Cancellable >& cancellable)
virtual void | acquire_async_vfunc (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
virtual bool | acquire_finish_vfunc (const Glib::RefPtr< AsyncResult >& result)
virtual bool | release_vfunc (const Glib::RefPtr< Cancellable >& cancellable)
virtual void | release_async_vfunc (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
virtual bool | release_finish_vfunc (const Glib::RefPtr< AsyncResult >& result)
void | impl_update (bool allowed, bool can_acquire, bool can_release)
| This function is called by the Permission implementation to update the properties of the permission. More...
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
| ~Object () noexcept override
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
| ObjectBase (ObjectBase&& src) noexcept
ObjectBase& | operator= (ObjectBase&& src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject* castitem)
void | initialize_move (GObject* castitem, Glib::ObjectBase* previous_wrapper)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gio::Permission > | wrap (GPermission* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject* object, bool take_copy=false)

## Additional Inherited Members

Public Types inherited from Glib::Object
using | DestroyNotify = void(*)(gpointer data)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## Detailed Description

An object representing the permission to perform a certain action.

A Permission represents the status of the caller's permission to perform a certain action.

You can query if the action is currently allowed and if it is possible to acquire the permission so that the action will be allowed in the future.

There is also an API to actually acquire the permission and one to release it.

As an example, a Permission might represent the ability for the user to write to a Settings object. This Permission object could then be used to decide if it is appropriate to show a "Click here to unlock" button in a dialog and to provide the mechanism to invoke when that button is clicked.

Since glibmm 2.42:

## Constructor & Destructor Documentation

## Permission() [1/2]

Gio::Permission::Permission | ( | Permission&& | src | ) |

noexcept

## ~Permission()

Gio::Permission::~Permission | ( |  | ) |

override noexcept

## Permission() [2/2]

Gio::Permission::Permission | ( |  | ) |

protected

## Member Function Documentation

## acquire() [1/2]

bool Gio::Permission::acquire | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Attempts to acquire the permission represented by permission.

The precise method by which this happens depends on the permission and the underlying authentication mechanism. A simple example is that a dialog may appear asking the user to enter their password.

You should check with g_permission_get_can_acquire() before calling this function.

If the permission is acquired then `true` is returned. Otherwise, `false` is returned and error is set appropriately.

This call is blocking, likely for a very long time (in the case that user interaction is required). See g_permission_acquire_async() for the non-blocking version.

Since glibmm 2.26:

Parameters

  cancellable | A Cancellable, or `nullptr`.

Returns
  `true` if the permission was successfully acquired.

## acquire() [2/2]

bool Gio::Permission::acquire | ( |  | ) |

A acquire() convenience overload.

## acquire_async() [1/2]

void Gio::Permission::acquire_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Attempts to acquire the permission represented by permission.

This is the first half of the asynchronous version of g_permission_acquire().

Since glibmm 2.26:

Parameters

  cancellable | A Cancellable, or `nullptr`.
  slot | The SlotAsyncReady to call when done.

## acquire_async() [2/2]

void Gio::Permission::acquire_async | ( | const SlotAsyncReady& | slot | ) |

A acquire_async() convenience overload.

## acquire_async_vfunc()

virtual void Gio::Permission::acquire_async_vfunc | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

protected virtual

## acquire_finish()

bool Gio::Permission::acquire_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Collects the result of attempting to acquire the permission represented by permission.

This is the second half of the asynchronous version of g_permission_acquire().

Since glibmm 2.26:

Parameters

  result | The AsyncResult given to the SlotAsyncReady.

Returns
  `true` if the permission was successfully acquired.

## acquire_finish_vfunc()

virtual bool Gio::Permission::acquire_finish_vfunc | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

protected virtual

Exceptions

  Glib::Error. |

## acquire_vfunc()

virtual bool Gio::Permission::acquire_vfunc | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

protected virtual

Exceptions

  Glib::Error. |

## get_allowed()

bool Gio::Permission::get_allowed | ( |  | ) | const

Gets the value of the 'allowed' property.

This property is `true` if the caller currently has permission to perform the action that permission represents the permission to perform.

Since glibmm 2.26:

Returns
  The value of the 'allowed' property.

## get_can_acquire()

bool Gio::Permission::get_can_acquire | ( |  | ) | const

Gets the value of the 'can-acquire' property.

This property is `true` if it is generally possible to acquire the permission by calling g_permission_acquire().

Since glibmm 2.26:

Returns
  The value of the 'can-acquire' property.

## get_can_release()

bool Gio::Permission::get_can_release | ( |  | ) | const

Gets the value of the 'can-release' property.

This property is `true` if it is generally possible to release the permission by calling g_permission_release().

Since glibmm 2.26:

Returns
  The value of the 'can-release' property.

## get_type()

static GType Gio::Permission::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

## gobj() [1/2]

GPermission* Gio::Permission::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

## gobj() [2/2]

const GPermission* Gio::Permission::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

## gobj_copy()

GPermission* Gio::Permission::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## impl_update()

void Gio::Permission::impl_update | ( | bool | allowed,
|  | bool | can_acquire,
|  | bool | can_release
| ) |  |

protected

This function is called by the Permission implementation to update the properties of the permission.

You should never call this function except from a Permission implementation.

GObject notify signals are generated, as appropriate.

Since glibmm 2.26:

Parameters

  allowed | The new value for the 'allowed' property.
  can_acquire | The new value for the 'can-acquire' property.
  can_release | The new value for the 'can-release' property.

## operator=()

Permission& Gio::Permission::operator= | ( | Permission&& | src | ) |

noexcept

## property_allowed()

Glib::PropertyProxy_ReadOnly< bool > Gio::Permission::property_allowed | ( |  | ) | const

`true` if the caller currently has permission to perform the action that permission represents the permission to perform.

Default value: `false`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## property_can_acquire()

Glib::PropertyProxy_ReadOnly< bool > Gio::Permission::property_can_acquire | ( |  | ) | const

`true` if it is generally possible to acquire the permission by calling g_permission_acquire().

Default value: `false`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## property_can_release()

Glib::PropertyProxy_ReadOnly< bool > Gio::Permission::property_can_release | ( |  | ) | const

`true` if it is generally possible to release the permission by calling g_permission_release().

Default value: `false`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## release() [1/2]

bool Gio::Permission::release | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Attempts to release the permission represented by permission.

The precise method by which this happens depends on the permission and the underlying authentication mechanism. In most cases the permission will be dropped immediately without further action.

You should check with g_permission_get_can_release() before calling this function.

If the permission is released then `true` is returned. Otherwise, `false` is returned and error is set appropriately.

This call is blocking, likely for a very long time (in the case that user interaction is required). See g_permission_release_async() for the non-blocking version.

Since glibmm 2.26:

Parameters

  cancellable | A Cancellable, or `nullptr`.

Returns
  `true` if the permission was successfully released.

## release() [2/2]

bool Gio::Permission::release | ( |  | ) |

A release() convenience overload.

## release_async() [1/2]

void Gio::Permission::release_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Attempts to release the permission represented by permission.

This is the first half of the asynchronous version of g_permission_release().

Since glibmm 2.26:

Parameters

  cancellable | A Cancellable, or `nullptr`.
  slot | The SlotAsyncReady to call when done.

## release_async() [2/2]

void Gio::Permission::release_async | ( | const SlotAsyncReady& | slot | ) |

A release_async() convenience overload.

## release_async_vfunc()

virtual void Gio::Permission::release_async_vfunc | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

protected virtual

## release_finish()

bool Gio::Permission::release_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Collects the result of attempting to release the permission represented by permission.

This is the second half of the asynchronous version of g_permission_release().

Since glibmm 2.26:

Parameters

  result | The AsyncResult given to the SlotAsyncReady.

Returns
  `true` if the permission was successfully released.

## release_finish_vfunc()

virtual bool Gio::Permission::release_finish_vfunc | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

protected virtual

Exceptions

  Glib::Error. |

## release_vfunc()

virtual bool Gio::Permission::release_vfunc | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

protected virtual

Exceptions

  Glib::Error. |

## Friends And Related Function Documentation

## wrap()

Glib::RefPtr< Gio::Permission > wrap | ( | GPermission * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.