| 1 |
/* Copyright (C) 2014 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <giomm/permission.h> |
| 18 |
#include <gtkmm/button.h> |
| 19 |
_DEFS(gtkmm,gtk) |
| 20 |
_PINCLUDE(gtkmm/private/button_p.h) |
| 21 |
|
| 22 |
namespace Gtk |
| 23 |
{ |
| 24 |
|
| 25 |
/** A widget to unlock or lock privileged operations. |
| 26 |
* |
| 27 |
* LockButton is a widget that can be used in control panels or |
| 28 |
* preference dialogs to allow users to obtain and revoke authorizations |
| 29 |
* needed to operate the controls. The required authorization is represented |
| 30 |
* by a Gio::Permission object. Concrete implementations of Gio::Permission may use |
| 31 |
* PolicyKit or some other authorization framework. To obtain a PolicyKit-based |
| 32 |
* Gio::Permission, use polkit_permission_new(). |
| 33 |
* |
| 34 |
* If the user is not currently allowed to perform the action, but can obtain |
| 35 |
* the permission, the widget looks like this: |
| 36 |
* |
| 37 |
* @image html lockbutton1.png |
| 38 |
* |
| 39 |
* and the user can click the button to request the permission. Depending |
| 40 |
* on the platform, this may pop up an authentication dialog or ask the user |
| 41 |
* to authenticate in some other way. Once the user has obtained the permission, |
| 42 |
* the widget changes to this: |
| 43 |
* |
| 44 |
* @image html lockbutton2.png |
| 45 |
* |
| 46 |
* and the permission can be dropped again by clicking the button. If the user |
| 47 |
* is not able to obtain the permission at all, the widget looks like this: |
| 48 |
* |
| 49 |
* @image html lockbutton3.png |
| 50 |
* |
| 51 |
* If the user has the permission and cannot drop it, the button is hidden. |
| 52 |
* |
| 53 |
* The text (and tooltips) that are shown in the various cases can be adjusted |
| 54 |
* with the LockButton::property_text_lock(), LockButton::property_text_unlock(), |
| 55 |
* LockButton::property_tooltip_lock(), LockButton::property_tooltip_unlock() and |
| 56 |
* LockButton::property_tooltip_not_authorized() properties. |
| 57 |
* |
| 58 |
* @ingroup Widgets |
| 59 |
* @newin{3,14} |
| 60 |
*/ |
| 61 |
class GTKMM_API LockButton : public Button |
| 62 |
{ |
| 63 |
_CLASS_GTKOBJECT(LockButton, GtkLockButton, GTK_LOCK_BUTTON, Gtk::Button, GtkButton, , , GTKMM_API) |
| 64 |
public: |
| 65 |
|
| 66 |
/** Create a new lock button. |
| 67 |
*/ |
| 68 |
_CTOR_DEFAULT |
| 69 |
|
| 70 |
_WRAP_CTOR(LockButton(const Glib::RefPtr<const Gio::Permission>& permission), gtk_lock_button_new) |
| 71 |
|
| 72 |
|
| 73 |
_WRAP_METHOD(Glib::RefPtr<Gio::Permission> get_permission(), gtk_lock_button_get_permission, refreturn) |
| 74 |
_WRAP_METHOD(Glib::RefPtr<const Gio::Permission> get_permission() const, gtk_lock_button_get_permission, refreturn, constversion) |
| 75 |
_WRAP_METHOD(void set_permission(const Glib::RefPtr<const Gio::Permission>& permission), gtk_lock_button_set_permission) |
| 76 |
/** Unset permission. |
| 77 |
* See set_permission(). |
| 78 |
*/ |
| 79 |
void unset_permission(); |
| 80 |
|
| 81 |
_WRAP_PROPERTY("permission", Glib::RefPtr<Gio::Permission>) |
| 82 |
_WRAP_PROPERTY("text-lock", Glib::ustring) |
| 83 |
_WRAP_PROPERTY("text-unlock", Glib::ustring) |
| 84 |
_WRAP_PROPERTY("tooltip-lock", Glib::ustring) |
| 85 |
_WRAP_PROPERTY("tooltip-unlock", Glib::ustring) |
| 86 |
_WRAP_PROPERTY("tooltip-not-authorized", Glib::ustring) |
| 87 |
|
| 88 |
// Gtk::LockButton has no signals as of 3.2. |
| 89 |
}; |
| 90 |
|
| 91 |
} // namespace Gtk |