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 * Conversion parameters: 26 * inFile = GtkLinkButton.html 27 * outPack = gtk 28 * outFile = LinkButton 29 * strct = GtkLinkButton 30 * realStrct= 31 * ctorStrct= 32 * clss = LinkButton 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_link_button_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * structWrap: 49 * module aliases: 50 * local aliases: 51 * overrides: 52 */ 53 54 module gtk.LinkButton; 55 56 public import gtkc.gtktypes; 57 58 private import gtkc.gtk; 59 private import glib.ConstructionException; 60 private import gobject.ObjectG; 61 62 private import gobject.Signals; 63 public import gtkc.gdktypes; 64 65 private import glib.Str; 66 67 68 69 private import gtk.Button; 70 71 /** 72 * A GtkLinkButton is a GtkButton with a hyperlink, similar to the one 73 * used by web browsers, which triggers an action when clicked. It is useful 74 * to show quick links to resources. 75 * 76 * A link button is created by calling either gtk_link_button_new() or 77 * gtk_link_button_new_with_label(). If using the former, the URI you pass 78 * to the constructor is used as a label for the widget. 79 * 80 * The URI bound to a GtkLinkButton can be set specifically using 81 * gtk_link_button_set_uri(), and retrieved using gtk_link_button_get_uri(). 82 * 83 * By default, GtkLinkButton calls gtk_show_uri() when the button is 84 * clicked. This behaviour can be overridden by connecting to the 85 * "activate-link" signal and returning TRUE from the 86 * signal handler. 87 */ 88 public class LinkButton : Button 89 { 90 91 /** the main Gtk struct */ 92 protected GtkLinkButton* gtkLinkButton; 93 94 95 public GtkLinkButton* getLinkButtonStruct() 96 { 97 return gtkLinkButton; 98 } 99 100 101 /** the main Gtk struct as a void* */ 102 protected override void* getStruct() 103 { 104 return cast(void*)gtkLinkButton; 105 } 106 107 /** 108 * Sets our main struct and passes it to the parent class 109 */ 110 public this (GtkLinkButton* gtkLinkButton) 111 { 112 super(cast(GtkButton*)gtkLinkButton); 113 this.gtkLinkButton = gtkLinkButton; 114 } 115 116 protected override void setStruct(GObject* obj) 117 { 118 super.setStruct(obj); 119 gtkLinkButton = cast(GtkLinkButton*)obj; 120 } 121 122 /** 123 */ 124 int[string] connectedSignals; 125 126 bool delegate(LinkButton)[] onActivateLinkListeners; 127 /** 128 * The ::activate-link signal is emitted each time the GtkLinkButton 129 * has been clicked. 130 * The default handler will call gtk_show_uri() with the URI stored inside 131 * the "uri" property. 132 * To override the default behavior, you can connect to the ::activate-link 133 * signal and stop the propagation of the signal by returning TRUE from 134 * your handler. 135 * See Also 136 * GtkButton 137 */ 138 void addOnActivateLink(bool delegate(LinkButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 139 { 140 if ( !("activate-link" in connectedSignals) ) 141 { 142 Signals.connectData( 143 getStruct(), 144 "activate-link", 145 cast(GCallback)&callBackActivateLink, 146 cast(void*)this, 147 null, 148 connectFlags); 149 connectedSignals["activate-link"] = 1; 150 } 151 onActivateLinkListeners ~= dlg; 152 } 153 extern(C) static gboolean callBackActivateLink(GtkLinkButton* buttonStruct, LinkButton _linkButton) 154 { 155 foreach ( bool delegate(LinkButton) dlg ; _linkButton.onActivateLinkListeners ) 156 { 157 if ( dlg(_linkButton) ) 158 { 159 return 1; 160 } 161 } 162 163 return 0; 164 } 165 166 167 /** 168 * Creates a new GtkLinkButton with the URI as its text. 169 * Since 2.10 170 * Params: 171 * uri = a valid URI 172 * Throws: ConstructionException GTK+ fails to create the object. 173 */ 174 public this (string uri) 175 { 176 // GtkWidget * gtk_link_button_new (const gchar *uri); 177 auto p = gtk_link_button_new(Str.toStringz(uri)); 178 if(p is null) 179 { 180 throw new ConstructionException("null returned by gtk_link_button_new(Str.toStringz(uri))"); 181 } 182 this(cast(GtkLinkButton*) p); 183 } 184 185 /** 186 * Creates a new GtkLinkButton containing a label. 187 * Since 2.10 188 * Params: 189 * uri = a valid URI 190 * label = the text of the button. [allow-none] 191 * Throws: ConstructionException GTK+ fails to create the object. 192 */ 193 public this (string uri, string label) 194 { 195 // GtkWidget * gtk_link_button_new_with_label (const gchar *uri, const gchar *label); 196 auto p = gtk_link_button_new_with_label(Str.toStringz(uri), Str.toStringz(label)); 197 if(p is null) 198 { 199 throw new ConstructionException("null returned by gtk_link_button_new_with_label(Str.toStringz(uri), Str.toStringz(label))"); 200 } 201 this(cast(GtkLinkButton*) p); 202 } 203 204 /** 205 * Retrieves the URI set using gtk_link_button_set_uri(). 206 * Since 2.10 207 * Returns: a valid URI. The returned string is owned by the link button and should not be modified or freed. 208 */ 209 public string getUri() 210 { 211 // const gchar * gtk_link_button_get_uri (GtkLinkButton *link_button); 212 return Str.toString(gtk_link_button_get_uri(gtkLinkButton)); 213 } 214 215 /** 216 * Sets uri as the URI where the GtkLinkButton points. As a side-effect 217 * this unsets the 'visited' state of the button. 218 * Since 2.10 219 * Params: 220 * uri = a valid URI 221 */ 222 public void setUri(string uri) 223 { 224 // void gtk_link_button_set_uri (GtkLinkButton *link_button, const gchar *uri); 225 gtk_link_button_set_uri(gtkLinkButton, Str.toStringz(uri)); 226 } 227 228 /** 229 * Retrieves the 'visited' state of the URI where the GtkLinkButton 230 * points. The button becomes visited when it is clicked. If the URI 231 * is changed on the button, the 'visited' state is unset again. 232 * The state may also be changed using gtk_link_button_set_visited(). 233 * Since 2.14 234 * Returns: TRUE if the link has been visited, FALSE otherwise 235 */ 236 public int getVisited() 237 { 238 // gboolean gtk_link_button_get_visited (GtkLinkButton *link_button); 239 return gtk_link_button_get_visited(gtkLinkButton); 240 } 241 242 /** 243 * Sets the 'visited' state of the URI where the GtkLinkButton 244 * points. See gtk_link_button_get_visited() for more details. 245 * Since 2.14 246 * Params: 247 * visited = the new 'visited' state 248 */ 249 public void setVisited(int visited) 250 { 251 // void gtk_link_button_set_visited (GtkLinkButton *link_button, gboolean visited); 252 gtk_link_button_set_visited(gtkLinkButton, visited); 253 } 254 }