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.EditableLabel;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.EditableIF;
31 private import gtk.EditableT;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 
36 
37 /**
38  * A `GtkEditableLabel` is a label that allows users to
39  * edit the text by switching to an “edit mode”.
40  * 
41  * ![An example GtkEditableLabel](editable-label.png)
42  * 
43  * `GtkEditableLabel` does not have API of its own, but it
44  * implements the [iface@Gtk.Editable] interface.
45  * 
46  * The default bindings for activating the edit mode is
47  * to click or press the Enter key. The default bindings
48  * for leaving the edit mode are the Enter key (to save
49  * the results) or the Escape key (to cancel the editing).
50  * 
51  * # CSS nodes
52  * 
53  * ```
54  * editablelabel[.editing]
55  * ╰── stack
56  * ├── label
57  * ╰── text
58  * ```
59  * 
60  * `GtkEditableLabel` has a main node with the name editablelabel.
61  * When the entry is in editing mode, it gets the .editing style
62  * class.
63  * 
64  * For all the subnodes added to the text node in various situations,
65  * see [class@Gtk.Text].
66  */
67 public class EditableLabel : Widget, EditableIF
68 {
69 	/** the main Gtk struct */
70 	protected GtkEditableLabel* gtkEditableLabel;
71 
72 	/** Get the main Gtk struct */
73 	public GtkEditableLabel* getEditableLabelStruct(bool transferOwnership = false)
74 	{
75 		if (transferOwnership)
76 			ownedRef = false;
77 		return gtkEditableLabel;
78 	}
79 
80 	/** the main Gtk struct as a void* */
81 	protected override void* getStruct()
82 	{
83 		return cast(void*)gtkEditableLabel;
84 	}
85 
86 	/**
87 	 * Sets our main struct and passes it to the parent class.
88 	 */
89 	public this (GtkEditableLabel* gtkEditableLabel, bool ownedRef = false)
90 	{
91 		this.gtkEditableLabel = gtkEditableLabel;
92 		super(cast(GtkWidget*)gtkEditableLabel, ownedRef);
93 	}
94 
95 	// add the Editable capabilities
96 	mixin EditableT!(GtkEditableLabel);
97 
98 
99 	/** */
100 	public static GType getType()
101 	{
102 		return gtk_editable_label_get_type();
103 	}
104 
105 	/**
106 	 * Creates a new `GtkEditableLabel` widget.
107 	 *
108 	 * Params:
109 	 *     str = the text for the label
110 	 *
111 	 * Returns: the new `GtkEditableLabel`
112 	 *
113 	 * Throws: ConstructionException GTK+ fails to create the object.
114 	 */
115 	public this(string str)
116 	{
117 		auto __p = gtk_editable_label_new(Str.toStringz(str));
118 
119 		if(__p is null)
120 		{
121 			throw new ConstructionException("null returned by new");
122 		}
123 
124 		this(cast(GtkEditableLabel*) __p);
125 	}
126 
127 	/**
128 	 * Returns whether the label is currently in “editing mode”.
129 	 *
130 	 * Returns: %TRUE if @self is currently in editing mode
131 	 */
132 	public bool getEditing()
133 	{
134 		return gtk_editable_label_get_editing(gtkEditableLabel) != 0;
135 	}
136 
137 	/**
138 	 * Switches the label into “editing mode”.
139 	 */
140 	public void startEditing()
141 	{
142 		gtk_editable_label_start_editing(gtkEditableLabel);
143 	}
144 
145 	/**
146 	 * Switches the label out of “editing mode”.
147 	 *
148 	 * If @commit is %TRUE, the resulting text is kept as the
149 	 * [property@Gtk.Editable:text] property value, otherwise the
150 	 * resulting text is discarded and the label will keep its
151 	 * previous [property@Gtk.Editable:text] property value.
152 	 *
153 	 * Params:
154 	 *     commit = whether to set the edited text on the label
155 	 */
156 	public void stopEditing(bool commit)
157 	{
158 		gtk_editable_label_stop_editing(gtkEditableLabel, commit);
159 	}
160 }