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(bool transferOwnership = false)
75 	{
76 		if (transferOwnership)
77 			ownedRef = false;
78 		return gtkLockButton;
79 	}
80 
81 	/** the main Gtk struct as a void* */
82 	protected override void* getStruct()
83 	{
84 		return cast(void*)gtkLockButton;
85 	}
86 
87 	protected override void setStruct(GObject* obj)
88 	{
89 		gtkLockButton = cast(GtkLockButton*)obj;
90 		super.setStruct(obj);
91 	}
92 
93 	/**
94 	 * Sets our main struct and passes it to the parent class.
95 	 */
96 	public this (GtkLockButton* gtkLockButton, bool ownedRef = false)
97 	{
98 		this.gtkLockButton = gtkLockButton;
99 		super(cast(GtkButton*)gtkLockButton, ownedRef);
100 	}
101 
102 
103 	/** */
104 	public static GType getType()
105 	{
106 		return gtk_lock_button_get_type();
107 	}
108 
109 	/**
110 	 * Creates a new lock button which reflects the @permission.
111 	 *
112 	 * Params:
113 	 *     permission = a #GPermission
114 	 *
115 	 * Returns: a new #GtkLockButton
116 	 *
117 	 * Since: 3.2
118 	 *
119 	 * Throws: ConstructionException GTK+ fails to create the object.
120 	 */
121 	public this(Permission permission)
122 	{
123 		auto p = gtk_lock_button_new((permission is null) ? null : permission.getPermissionStruct());
124 		
125 		if(p is null)
126 		{
127 			throw new ConstructionException("null returned by new");
128 		}
129 		
130 		this(cast(GtkLockButton*) p);
131 	}
132 
133 	/**
134 	 * Obtains the #GPermission object that controls @button.
135 	 *
136 	 * Returns: the #GPermission of @button
137 	 *
138 	 * Since: 3.2
139 	 */
140 	public Permission getPermission()
141 	{
142 		auto p = gtk_lock_button_get_permission(gtkLockButton);
143 		
144 		if(p is null)
145 		{
146 			return null;
147 		}
148 		
149 		return ObjectG.getDObject!(Permission)(cast(GPermission*) p);
150 	}
151 
152 	/**
153 	 * Sets the #GPermission object that controls @button.
154 	 *
155 	 * Params:
156 	 *     permission = a #GPermission object, or %NULL
157 	 *
158 	 * Since: 3.2
159 	 */
160 	public void setPermission(Permission permission)
161 	{
162 		gtk_lock_button_set_permission(gtkLockButton, (permission is null) ? null : permission.getPermissionStruct());
163 	}
164 }