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 gtkc.gtk;
33 public  import gtkc.gtktypes;
34 
35 
36 /**
37  * GtkLockButton is a widget that can be used in control panels or
38  * preference dialogs to allow users to obtain and revoke authorizations
39  * needed to operate the controls. The required authorization is represented
40  * by a #GPermission object. Concrete implementations of #GPermission may use
41  * PolicyKit or some other authorization framework. To obtain a PolicyKit-based
42  * #GPermission, use polkit_permission_new().
43  * 
44  * If the user is not currently allowed to perform the action, but can obtain
45  * the permission, the widget looks like this:
46  * 
47  * ![](lockbutton-locked.png)
48  * 
49  * and the user can click the button to request the permission. Depending
50  * on the platform, this may pop up an authentication dialog or ask the user
51  * to authenticate in some other way. Once the user has obtained the permission,
52  * the widget changes to this:
53  * 
54  * ![](lockbutton-unlocked.png)
55  * 
56  * and the permission can be dropped again by clicking the button. If the user
57  * is not able to obtain the permission at all, the widget looks like this:
58  * 
59  * ![](lockbutton-sorry.png)
60  * 
61  * If the user has the permission and cannot drop it, the button is hidden.
62  * 
63  * The text (and tooltips) that are shown in the various cases can be adjusted
64  * with the #GtkLockButton:text-lock, #GtkLockButton:text-unlock,
65  * #GtkLockButton:tooltip-lock, #GtkLockButton:tooltip-unlock and
66  * #GtkLockButton:tooltip-not-authorized properties.
67  */
68 public class LockButton : Button
69 {
70 	/** the main Gtk struct */
71 	protected GtkLockButton* gtkLockButton;
72 
73 	/** Get the main Gtk struct */
74 	public GtkLockButton* getLockButtonStruct()
75 	{
76 		return gtkLockButton;
77 	}
78 
79 	/** the main Gtk struct as a void* */
80 	protected override void* getStruct()
81 	{
82 		return cast(void*)gtkLockButton;
83 	}
84 
85 	protected override void setStruct(GObject* obj)
86 	{
87 		gtkLockButton = cast(GtkLockButton*)obj;
88 		super.setStruct(obj);
89 	}
90 
91 	/**
92 	 * Sets our main struct and passes it to the parent class.
93 	 */
94 	public this (GtkLockButton* gtkLockButton, bool ownedRef = false)
95 	{
96 		this.gtkLockButton = gtkLockButton;
97 		super(cast(GtkButton*)gtkLockButton, ownedRef);
98 	}
99 
100 	/**
101 	 */
102 
103 	public static GType getType()
104 	{
105 		return gtk_lock_button_get_type();
106 	}
107 
108 	/**
109 	 * Creates a new lock button which reflects the @permission.
110 	 *
111 	 * Params:
112 	 *     permission = a #GPermission
113 	 *
114 	 * Return: a new #GtkLockButton
115 	 *
116 	 * Since: 3.2
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 	 * Return: the #GPermission of @button
136 	 *
137 	 * Since: 3.2
138 	 */
139 	public Permission getPermission()
140 	{
141 		auto p = gtk_lock_button_get_permission(gtkLockButton);
142 		
143 		if(p is null)
144 		{
145 			return null;
146 		}
147 		
148 		return ObjectG.getDObject!(Permission)(cast(GPermission*) p);
149 	}
150 
151 	/**
152 	 * Sets the #GPermission object that controls @button.
153 	 *
154 	 * Params:
155 	 *     permission = a #GPermission object, or %NULL
156 	 *
157 	 * Since: 3.2
158 	 */
159 	public void setPermission(Permission permission)
160 	{
161 		gtk_lock_button_set_permission(gtkLockButton, (permission is null) ? null : permission.getPermissionStruct());
162 	}
163 }