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