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 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * GtkLockButton is a widget that can be used in control panels or
39  * preference dialogs to allow users to obtain and revoke authorizations
40  * needed to operate the controls. The required authorization is represented
41  * by a #GPermission object. Concrete implementations of #GPermission may use
42  * PolicyKit or some other authorization framework. To obtain a PolicyKit-based
43  * #GPermission, use polkit_permission_new().
44  * 
45  * If the user is not currently allowed to perform the action, but can obtain
46  * the permission, the widget looks like this:
47  * 
48  * ![](lockbutton-locked.png)
49  * 
50  * and the user can click the button to request the permission. Depending
51  * on the platform, this may pop up an authentication dialog or ask the user
52  * to authenticate in some other way. Once the user has obtained the permission,
53  * the widget changes to this:
54  * 
55  * ![](lockbutton-unlocked.png)
56  * 
57  * and the permission can be dropped again by clicking the button. If the user
58  * is not able to obtain the permission at all, the widget looks like this:
59  * 
60  * ![](lockbutton-sorry.png)
61  * 
62  * If the user has the permission and cannot drop it, the button is hidden.
63  * 
64  * The text (and tooltips) that are shown in the various cases can be adjusted
65  * with the #GtkLockButton:text-lock, #GtkLockButton:text-unlock,
66  * #GtkLockButton:tooltip-lock, #GtkLockButton:tooltip-unlock and
67  * #GtkLockButton:tooltip-not-authorized properties.
68  */
69 public class LockButton : Button
70 {
71 	/** the main Gtk struct */
72 	protected GtkLockButton* gtkLockButton;
73 
74 	/** Get the main Gtk struct */
75 	public GtkLockButton* getLockButtonStruct(bool transferOwnership = false)
76 	{
77 		if (transferOwnership)
78 			ownedRef = false;
79 		return gtkLockButton;
80 	}
81 
82 	/** the main Gtk struct as a void* */
83 	protected override void* getStruct()
84 	{
85 		return cast(void*)gtkLockButton;
86 	}
87 
88 	protected override void setStruct(GObject* obj)
89 	{
90 		gtkLockButton = cast(GtkLockButton*)obj;
91 		super.setStruct(obj);
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 	 * Since: 3.2
119 	 *
120 	 * Throws: ConstructionException GTK+ fails to create the object.
121 	 */
122 	public this(Permission permission)
123 	{
124 		auto p = gtk_lock_button_new((permission is null) ? null : permission.getPermissionStruct());
125 
126 		if(p is null)
127 		{
128 			throw new ConstructionException("null returned by new");
129 		}
130 
131 		this(cast(GtkLockButton*) p);
132 	}
133 
134 	/**
135 	 * Obtains the #GPermission object that controls @button.
136 	 *
137 	 * Returns: the #GPermission of @button
138 	 *
139 	 * Since: 3.2
140 	 */
141 	public Permission getPermission()
142 	{
143 		auto p = gtk_lock_button_get_permission(gtkLockButton);
144 
145 		if(p is null)
146 		{
147 			return null;
148 		}
149 
150 		return ObjectG.getDObject!(Permission)(cast(GPermission*) p);
151 	}
152 
153 	/**
154 	 * Sets the #GPermission object that controls @button.
155 	 *
156 	 * Params:
157 	 *     permission = a #GPermission object, or %NULL
158 	 *
159 	 * Since: 3.2
160 	 */
161 	public void setPermission(Permission permission)
162 	{
163 		gtk_lock_button_set_permission(gtkLockButton, (permission is null) ? null : permission.getPermissionStruct());
164 	}
165 }