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