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.PasswordEntry; 26 27 private import gio.MenuModel; 28 private import glib.ConstructionException; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.EditableIF; 32 private import gtk.EditableT; 33 private import gtk.Widget; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 private import std.algorithm; 37 38 39 /** 40 * `GtkPasswordEntry` is an entry that has been tailored for entering secrets. 41 * 42 * ![An example GtkPasswordEntry](password-entry.png) 43 * 44 * It does not show its contents in clear text, does not allow to copy it 45 * to the clipboard, and it shows a warning when Caps Lock is engaged. If 46 * the underlying platform allows it, `GtkPasswordEntry` will also place 47 * the text in a non-pageable memory area, to avoid it being written out 48 * to disk by the operating system. 49 * 50 * Optionally, it can offer a way to reveal the contents in clear text. 51 * 52 * `GtkPasswordEntry` provides only minimal API and should be used with 53 * the [iface@Gtk.Editable] API. 54 * 55 * # CSS Nodes 56 * 57 * ``` 58 * entry.password 59 * ╰── text 60 * ├── image.caps-lock-indicator 61 * ┊ 62 * ``` 63 * 64 * `GtkPasswordEntry` has a single CSS node with name entry that carries 65 * a .passwordstyle class. The text Css node below it has a child with 66 * name image and style class .caps-lock-indicator for the Caps Lock 67 * icon, and possibly other children. 68 * 69 * # Accessibility 70 * 71 * `GtkPasswordEntry` uses the %GTK_ACCESSIBLE_ROLE_TEXT_BOX role. 72 */ 73 public class PasswordEntry : Widget, EditableIF 74 { 75 /** the main Gtk struct */ 76 protected GtkPasswordEntry* gtkPasswordEntry; 77 78 /** Get the main Gtk struct */ 79 public GtkPasswordEntry* getPasswordEntryStruct(bool transferOwnership = false) 80 { 81 if (transferOwnership) 82 ownedRef = false; 83 return gtkPasswordEntry; 84 } 85 86 /** the main Gtk struct as a void* */ 87 protected override void* getStruct() 88 { 89 return cast(void*)gtkPasswordEntry; 90 } 91 92 /** 93 * Sets our main struct and passes it to the parent class. 94 */ 95 public this (GtkPasswordEntry* gtkPasswordEntry, bool ownedRef = false) 96 { 97 this.gtkPasswordEntry = gtkPasswordEntry; 98 super(cast(GtkWidget*)gtkPasswordEntry, ownedRef); 99 } 100 101 // add the Editable capabilities 102 mixin EditableT!(GtkPasswordEntry); 103 104 105 /** */ 106 public static GType getType() 107 { 108 return gtk_password_entry_get_type(); 109 } 110 111 /** 112 * Creates a `GtkPasswordEntry`. 113 * 114 * Returns: a new `GtkPasswordEntry` 115 * 116 * Throws: ConstructionException GTK+ fails to create the object. 117 */ 118 public this() 119 { 120 auto __p = gtk_password_entry_new(); 121 122 if(__p is null) 123 { 124 throw new ConstructionException("null returned by new"); 125 } 126 127 this(cast(GtkPasswordEntry*) __p); 128 } 129 130 /** 131 * Gets the menu model set with gtk_password_entry_set_extra_menu(). 132 * 133 * Returns: (nullable): the menu model 134 */ 135 public MenuModel getExtraMenu() 136 { 137 auto __p = gtk_password_entry_get_extra_menu(gtkPasswordEntry); 138 139 if(__p is null) 140 { 141 return null; 142 } 143 144 return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) __p); 145 } 146 147 /** 148 * Returns whether the entry is showing an icon to 149 * reveal the contents. 150 * 151 * Returns: %TRUE if an icon is shown 152 */ 153 public bool getShowPeekIcon() 154 { 155 return gtk_password_entry_get_show_peek_icon(gtkPasswordEntry) != 0; 156 } 157 158 /** 159 * Sets a menu model to add when constructing 160 * the context menu for @entry. 161 * 162 * Params: 163 * model = a `GMenuModel` 164 */ 165 public void setExtraMenu(MenuModel model) 166 { 167 gtk_password_entry_set_extra_menu(gtkPasswordEntry, (model is null) ? null : model.getMenuModelStruct()); 168 } 169 170 /** 171 * Sets whether the entry should have a clickable icon 172 * to reveal the contents. 173 * 174 * Setting this to %FALSE also hides the text again. 175 * 176 * Params: 177 * showPeekIcon = whether to show the peek icon 178 */ 179 public void setShowPeekIcon(bool showPeekIcon) 180 { 181 gtk_password_entry_set_show_peek_icon(gtkPasswordEntry, showPeekIcon); 182 } 183 184 /** 185 * Emitted when the entry is activated. 186 * 187 * The keybindings for this signal are all forms of the Enter key. 188 */ 189 gulong addOnActivate(void delegate(PasswordEntry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 190 { 191 return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 192 } 193 }