1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.LockButton;
26 
27 private import gio.Permission;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import gtk.Button;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 
35 
36 /**
37  * `GtkLockButton` is a widget to obtain and revoke authorizations
38  * needed to operate the controls.
39  * 
40  * ![An example GtkLockButton](lock-button.png)
41  * 
42  * It is typically used in preference dialogs or control panels.
43  * 
44  * The required authorization is represented by a `GPermission` object.
45  * Concrete implementations of `GPermission` may use PolicyKit or some
46  * other authorization framework. To obtain a PolicyKit-based
47  * `GPermission`, use `polkit_permission_new()`.
48  * 
49  * If the user is not currently allowed to perform the action, but can
50  * obtain the permission, the widget looks like this:
51  * 
52  * ![](lockbutton-locked.png)
53  * 
54  * and the user can click the button to request the permission. Depending
55  * on the platform, this may pop up an authentication dialog or ask the user
56  * to authenticate in some other way. Once the user has obtained the permission,
57  * the widget changes to this:
58  * 
59  * ![](lockbutton-unlocked.png)
60  * 
61  * and the permission can be dropped again by clicking the button. If the user
62  * is not able to obtain the permission at all, the widget looks like this:
63  * 
64  * ![](lockbutton-sorry.png)
65  * 
66  * If the user has the permission and cannot drop it, the button is hidden.
67  * 
68  * The text (and tooltips) that are shown in the various cases can be adjusted
69  * with the [property@Gtk.LockButton:text-lock],
70  * [property@Gtk.LockButton:text-unlock],
71  * [property@Gtk.LockButton:tooltip-lock],
72  * [property@Gtk.LockButton:tooltip-unlock] and
73  * [property@Gtk.LockButton:tooltip-not-authorized] properties.
74  */
75 public class LockButton : Button
76 {
77 	/** the main Gtk struct */
78 	protected GtkLockButton* gtkLockButton;
79 
80 	/** Get the main Gtk struct */
81 	public GtkLockButton* getLockButtonStruct(bool transferOwnership = false)
82 	{
83 		if (transferOwnership)
84 			ownedRef = false;
85 		return gtkLockButton;
86 	}
87 
88 	/** the main Gtk struct as a void* */
89 	protected override void* getStruct()
90 	{
91 		return cast(void*)gtkLockButton;
92 	}
93 
94 	/**
95 	 * Sets our main struct and passes it to the parent class.
96 	 */
97 	public this (GtkLockButton* gtkLockButton, bool ownedRef = false)
98 	{
99 		this.gtkLockButton = gtkLockButton;
100 		super(cast(GtkButton*)gtkLockButton, ownedRef);
101 	}
102 
103 
104 	/** */
105 	public static GType getType()
106 	{
107 		return gtk_lock_button_get_type();
108 	}
109 
110 	/**
111 	 * Creates a new lock button which reflects the @permission.
112 	 *
113 	 * Params:
114 	 *     permission = a `GPermission`
115 	 *
116 	 * Returns: a new `GtkLockButton`
117 	 *
118 	 * Throws: ConstructionException GTK+ fails to create the object.
119 	 */
120 	public this(Permission permission)
121 	{
122 		auto __p = gtk_lock_button_new((permission is null) ? null : permission.getPermissionStruct());
123 
124 		if(__p is null)
125 		{
126 			throw new ConstructionException("null returned by new");
127 		}
128 
129 		this(cast(GtkLockButton*) __p);
130 	}
131 
132 	/**
133 	 * Obtains the `GPermission` object that controls @button.
134 	 *
135 	 * Returns: the `GPermission` of @button
136 	 */
137 	public Permission getPermission()
138 	{
139 		auto __p = gtk_lock_button_get_permission(gtkLockButton);
140 
141 		if(__p is null)
142 		{
143 			return null;
144 		}
145 
146 		return ObjectG.getDObject!(Permission)(cast(GPermission*) __p);
147 	}
148 
149 	/**
150 	 * Sets the `GPermission` object that controls @button.
151 	 *
152 	 * Params:
153 	 *     permission = a `GPermission` object, or %NULL
154 	 */
155 	public void setPermission(Permission permission)
156 	{
157 		gtk_lock_button_set_permission(gtkLockButton, (permission is null) ? null : permission.getPermissionStruct());
158 	}
159 }