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 	public static GType getType()
103 	{
104 		return gtk_lock_button_get_type();
105 	}
106 
107 	/**
108 	 * Creates a new lock button which reflects the @permission.
109 	 *
110 	 * Params:
111 	 *     permission = a #GPermission
112 	 *
113 	 * Returns: a new #GtkLockButton
114 	 *
115 	 * Since: 3.2
116 	 *
117 	 * Throws: ConstructionException GTK+ fails to create the object.
118 	 */
119 	public this(Permission permission)
120 	{
121 		auto p = gtk_lock_button_new((permission is null) ? null : permission.getPermissionStruct());
122 		
123 		if(p is null)
124 		{
125 			throw new ConstructionException("null returned by new");
126 		}
127 		
128 		this(cast(GtkLockButton*) p);
129 	}
130 
131 	/**
132 	 * Obtains the #GPermission object that controls @button.
133 	 *
134 	 * Returns: the #GPermission of @button
135 	 *
136 	 * Since: 3.2
137 	 */
138 	public Permission getPermission()
139 	{
140 		auto p = gtk_lock_button_get_permission(gtkLockButton);
141 		
142 		if(p is null)
143 		{
144 			return null;
145 		}
146 		
147 		return ObjectG.getDObject!(Permission)(cast(GPermission*) p);
148 	}
149 
150 	/**
151 	 * Sets the #GPermission object that controls @button.
152 	 *
153 	 * Params:
154 	 *     permission = a #GPermission object, or %NULL
155 	 *
156 	 * Since: 3.2
157 	 */
158 	public void setPermission(Permission permission)
159 	{
160 		gtk_lock_button_set_permission(gtkLockButton, (permission is null) ? null : permission.getPermissionStruct());
161 	}
162 }