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