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.LinkButton;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import gobject.Signals;
32 private import gtk.Button;
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  * A `GtkLinkButton` is a button with a hyperlink.
41  * 
42  * ![An example GtkLinkButton](link-button.png)
43  * 
44  * It is useful to show quick links to resources.
45  * 
46  * A link button is created by calling either [ctor@Gtk.LinkButton.new] or
47  * [ctor@Gtk.LinkButton.new_with_label]. If using the former, the URI you
48  * pass to the constructor is used as a label for the widget.
49  * 
50  * The URI bound to a `GtkLinkButton` can be set specifically using
51  * [method@Gtk.LinkButton.set_uri].
52  * 
53  * By default, `GtkLinkButton` calls [func@Gtk.show_uri] when the button
54  * is clicked. This behaviour can be overridden by connecting to the
55  * [signal@Gtk.LinkButton::activate-link] signal and returning %TRUE from
56  * the signal handler.
57  * 
58  * # CSS nodes
59  * 
60  * `GtkLinkButton` has a single CSS node with name button. To differentiate
61  * it from a plain `GtkButton`, it gets the .link style class.
62  * 
63  * # Accessibility
64  * 
65  * `GtkLinkButton` uses the #GTK_ACCESSIBLE_ROLE_LINK role.
66  */
67 public class LinkButton : Button
68 {
69 	/** the main Gtk struct */
70 	protected GtkLinkButton* gtkLinkButton;
71 
72 	/** Get the main Gtk struct */
73 	public GtkLinkButton* getLinkButtonStruct(bool transferOwnership = false)
74 	{
75 		if (transferOwnership)
76 			ownedRef = false;
77 		return gtkLinkButton;
78 	}
79 
80 	/** the main Gtk struct as a void* */
81 	protected override void* getStruct()
82 	{
83 		return cast(void*)gtkLinkButton;
84 	}
85 
86 	/**
87 	 * Sets our main struct and passes it to the parent class.
88 	 */
89 	public this (GtkLinkButton* gtkLinkButton, bool ownedRef = false)
90 	{
91 		this.gtkLinkButton = gtkLinkButton;
92 		super(cast(GtkButton*)gtkLinkButton, ownedRef);
93 	}
94 
95 
96 	/** */
97 	public static GType getType()
98 	{
99 		return gtk_link_button_get_type();
100 	}
101 
102 	/**
103 	 * Creates a new `GtkLinkButton` with the URI as its text.
104 	 *
105 	 * Params:
106 	 *     uri = a valid URI
107 	 *
108 	 * Returns: a new link button widget.
109 	 *
110 	 * Throws: ConstructionException GTK+ fails to create the object.
111 	 */
112 	public this(string uri)
113 	{
114 		auto __p = gtk_link_button_new(Str.toStringz(uri));
115 
116 		if(__p is null)
117 		{
118 			throw new ConstructionException("null returned by new");
119 		}
120 
121 		this(cast(GtkLinkButton*) __p);
122 	}
123 
124 	/**
125 	 * Creates a new `GtkLinkButton` containing a label.
126 	 *
127 	 * Params:
128 	 *     uri = a valid URI
129 	 *     label = the text of the button
130 	 *
131 	 * Returns: a new link button widget.
132 	 *
133 	 * Throws: ConstructionException GTK+ fails to create the object.
134 	 */
135 	public this(string uri, string label)
136 	{
137 		auto __p = gtk_link_button_new_with_label(Str.toStringz(uri), Str.toStringz(label));
138 
139 		if(__p is null)
140 		{
141 			throw new ConstructionException("null returned by new_with_label");
142 		}
143 
144 		this(cast(GtkLinkButton*) __p);
145 	}
146 
147 	/**
148 	 * Retrieves the URI of the `GtkLinkButton`.
149 	 *
150 	 * Returns: a valid URI. The returned string is owned by the link button
151 	 *     and should not be modified or freed.
152 	 */
153 	public string getUri()
154 	{
155 		return Str.toString(gtk_link_button_get_uri(gtkLinkButton));
156 	}
157 
158 	/**
159 	 * Retrieves the “visited” state of the `GtkLinkButton`.
160 	 *
161 	 * The button becomes visited when it is clicked. If the URI
162 	 * is changed on the button, the “visited” state is unset again.
163 	 *
164 	 * The state may also be changed using [method@Gtk.LinkButton.set_visited].
165 	 *
166 	 * Returns: %TRUE if the link has been visited, %FALSE otherwise
167 	 */
168 	public bool getVisited()
169 	{
170 		return gtk_link_button_get_visited(gtkLinkButton) != 0;
171 	}
172 
173 	/**
174 	 * Sets @uri as the URI where the `GtkLinkButton` points.
175 	 *
176 	 * As a side-effect this unsets the “visited” state of the button.
177 	 *
178 	 * Params:
179 	 *     uri = a valid URI
180 	 */
181 	public void setUri(string uri)
182 	{
183 		gtk_link_button_set_uri(gtkLinkButton, Str.toStringz(uri));
184 	}
185 
186 	/**
187 	 * Sets the “visited” state of the `GtkLinkButton`.
188 	 *
189 	 * See [method@Gtk.LinkButton.get_visited] for more details.
190 	 *
191 	 * Params:
192 	 *     visited = the new “visited” state
193 	 */
194 	public void setVisited(bool visited)
195 	{
196 		gtk_link_button_set_visited(gtkLinkButton, visited);
197 	}
198 
199 	/**
200 	 * Emitted each time the `GtkLinkButton` is clicked.
201 	 *
202 	 * The default handler will call [func@Gtk.show_uri] with the URI
203 	 * stored inside the [property@Gtk.LinkButton:uri] property.
204 	 *
205 	 * To override the default behavior, you can connect to the
206 	 * ::activate-link signal and stop the propagation of the signal
207 	 * by returning %TRUE from your handler.
208 	 *
209 	 * Returns: %TRUE if the signal has been handled
210 	 */
211 	gulong addOnActivateLink(bool delegate(LinkButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
212 	{
213 		return Signals.connect(this, "activate-link", dlg, connectFlags ^ ConnectFlags.SWAPPED);
214 	}
215 }