]> Pileus Git - ~andy/gtk/blob - gtk/gtklinkbutton.c
Remove url hooks from GtkAboutDialog and GtkLinkButton
[~andy/gtk] / gtk / gtklinkbutton.c
1 /* GTK - The GIMP Toolkit
2  * gtklinkbutton.c - an hyperlink-enabled button
3  * 
4  * Copyright (C) 2006 Emmanuele Bassi <ebassi@gmail.com>
5  * All rights reserved.
6  *
7  * Based on gnome-href code by:
8  *      James Henstridge <james@daa.com.au>
9  * 
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
23  */
24
25 #include "config.h"
26
27 #include "gtklinkbutton.h"
28
29 #include <string.h>
30
31 #include "gtkclipboard.h"
32 #include "gtkdnd.h"
33 #include "gtkimagemenuitem.h"
34 #include "gtklabel.h"
35 #include "gtkmain.h"
36 #include "gtkmenu.h"
37 #include "gtkmenuitem.h"
38 #include "gtksizerequest.h"
39 #include "gtkstock.h"
40 #include "gtkshow.h"
41 #include "gtktooltip.h"
42
43 #include "gtkintl.h"
44
45
46 struct _GtkLinkButtonPrivate
47 {
48   gchar *uri;
49
50   gboolean visited;
51
52   GtkWidget *popup_menu;
53 };
54
55 enum
56 {
57   PROP_0,
58   PROP_URI,
59   PROP_VISITED
60 };
61
62
63 static void     gtk_link_button_finalize     (GObject          *object);
64 static void     gtk_link_button_get_property (GObject          *object,
65                                               guint             prop_id,
66                                               GValue           *value,
67                                               GParamSpec       *pspec);
68 static void     gtk_link_button_set_property (GObject          *object,
69                                               guint             prop_id,
70                                               const GValue     *value,
71                                               GParamSpec       *pspec);
72 static void     gtk_link_button_add          (GtkContainer     *container,
73                                               GtkWidget        *widget);
74 static gboolean gtk_link_button_button_press (GtkWidget        *widget,
75                                               GdkEventButton   *event);
76 static void     gtk_link_button_clicked      (GtkButton        *button);
77 static gboolean gtk_link_button_popup_menu   (GtkWidget        *widget);
78 static void     gtk_link_button_style_set    (GtkWidget        *widget,
79                                               GtkStyle         *old_style);
80 static gboolean gtk_link_button_enter_cb     (GtkWidget        *widget,
81                                               GdkEventCrossing *event,
82                                               gpointer          user_data);
83 static gboolean gtk_link_button_leave_cb     (GtkWidget        *widget,
84                                               GdkEventCrossing *event,
85                                               gpointer          user_data);
86 static void gtk_link_button_drag_data_get_cb (GtkWidget        *widget,
87                                               GdkDragContext   *context,
88                                               GtkSelectionData *selection,
89                                               guint             _info,
90                                               guint             _time,
91                                               gpointer          user_data);
92 static gboolean gtk_link_button_query_tooltip_cb (GtkWidget    *widget,
93                                                   gint          x,
94                                                   gint          y,
95                                                   gboolean      keyboard_tip,
96                                                   GtkTooltip   *tooltip,
97                                                   gpointer      data);
98
99
100 static const GtkTargetEntry link_drop_types[] = {
101   { "text/uri-list", 0, 0 },
102   { "_NETSCAPE_URL", 0, 0 }
103 };
104
105 static const GdkColor default_link_color = { 0, 0, 0, 0xeeee };
106 static const GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };
107
108 G_DEFINE_TYPE (GtkLinkButton, gtk_link_button, GTK_TYPE_BUTTON)
109
110 static void
111 gtk_link_button_class_init (GtkLinkButtonClass *klass)
112 {
113   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
114   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
115   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
116   GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
117   
118   gobject_class->set_property = gtk_link_button_set_property;
119   gobject_class->get_property = gtk_link_button_get_property;
120   gobject_class->finalize = gtk_link_button_finalize;
121   
122   widget_class->button_press_event = gtk_link_button_button_press;
123   widget_class->popup_menu = gtk_link_button_popup_menu;
124   widget_class->style_set = gtk_link_button_style_set;
125   
126   container_class->add = gtk_link_button_add;
127
128   button_class->clicked = gtk_link_button_clicked;
129
130   /**
131    * GtkLinkButton:uri
132    * 
133    * The URI bound to this button. 
134    *
135    * Since: 2.10
136    */
137   g_object_class_install_property (gobject_class,
138                                    PROP_URI,
139                                    g_param_spec_string ("uri",
140                                                         P_("URI"),
141                                                         P_("The URI bound to this button"),
142                                                         NULL,
143                                                         G_PARAM_READWRITE));
144   /**
145    * GtkLinkButton:visited
146    * 
147    * The 'visited' state of this button. A visited link is drawn in a
148    * different color.
149    *
150    * Since: 2.14
151    */
152   g_object_class_install_property (gobject_class,
153                                    PROP_VISITED,
154                                    g_param_spec_boolean ("visited",
155                                                          P_("Visited"),
156                                                          P_("Whether this link has been visited."),
157                                                          FALSE,
158                                                          G_PARAM_READWRITE));
159   
160   g_type_class_add_private (gobject_class, sizeof (GtkLinkButtonPrivate));
161 }
162
163 static void
164 gtk_link_button_init (GtkLinkButton *link_button)
165 {
166   link_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (link_button,
167                                                    GTK_TYPE_LINK_BUTTON,
168                                                    GtkLinkButtonPrivate);
169
170   gtk_button_set_relief (GTK_BUTTON (link_button), GTK_RELIEF_NONE);
171   
172   g_signal_connect (link_button, "enter-notify-event",
173                     G_CALLBACK (gtk_link_button_enter_cb), NULL);
174   g_signal_connect (link_button, "leave-notify-event",
175                     G_CALLBACK (gtk_link_button_leave_cb), NULL);
176   g_signal_connect (link_button, "drag-data-get",
177                     G_CALLBACK (gtk_link_button_drag_data_get_cb), NULL);
178
179   g_object_set (link_button, "has-tooltip", TRUE, NULL);
180   g_signal_connect (link_button, "query-tooltip",
181                     G_CALLBACK (gtk_link_button_query_tooltip_cb), NULL);
182   
183   /* enable drag source */
184   gtk_drag_source_set (GTK_WIDGET (link_button),
185                        GDK_BUTTON1_MASK,
186                        link_drop_types, G_N_ELEMENTS (link_drop_types),
187                        GDK_ACTION_COPY);
188 }
189
190 static void
191 gtk_link_button_finalize (GObject *object)
192 {
193   GtkLinkButton *link_button = GTK_LINK_BUTTON (object);
194   
195   g_free (link_button->priv->uri);
196   
197   G_OBJECT_CLASS (gtk_link_button_parent_class)->finalize (object);
198 }
199
200 static void
201 gtk_link_button_get_property (GObject    *object,
202                               guint       prop_id,
203                               GValue     *value,
204                               GParamSpec *pspec)
205 {
206   GtkLinkButton *link_button = GTK_LINK_BUTTON (object);
207   
208   switch (prop_id)
209     {
210     case PROP_URI:
211       g_value_set_string (value, link_button->priv->uri);
212       break;
213     case PROP_VISITED:
214       g_value_set_boolean (value, link_button->priv->visited);
215       break;
216     default:
217       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
218       break;
219     }
220 }
221
222 static void
223 gtk_link_button_set_property (GObject      *object,
224                               guint         prop_id,
225                               const GValue *value,
226                               GParamSpec   *pspec)
227 {
228   GtkLinkButton *link_button = GTK_LINK_BUTTON (object);
229   
230   switch (prop_id)
231     {
232     case PROP_URI:
233       gtk_link_button_set_uri (link_button, g_value_get_string (value));
234       break;
235     case PROP_VISITED:
236       gtk_link_button_set_visited (link_button, g_value_get_boolean (value));
237       break;
238     default:
239       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
240       break;
241     }
242 }
243
244 static void
245 set_link_color (GtkLinkButton *link_button)
246 {
247   GdkColor *link_color = NULL;
248   GtkWidget *label;
249
250   label = gtk_bin_get_child (GTK_BIN (link_button));
251   if (!GTK_IS_LABEL (label))
252     return;
253
254   if (link_button->priv->visited)
255     {
256       gtk_widget_style_get (GTK_WIDGET (link_button),
257                             "visited-link-color", &link_color, NULL);
258       if (!link_color)
259         link_color = (GdkColor *) &default_visited_link_color;
260     }
261   else
262     {
263       gtk_widget_style_get (GTK_WIDGET (link_button),
264                             "link-color", &link_color, NULL);
265       if (!link_color)
266         link_color = (GdkColor *) &default_link_color;
267     }
268
269   gtk_widget_modify_fg (label, GTK_STATE_NORMAL, link_color);
270   gtk_widget_modify_fg (label, GTK_STATE_ACTIVE, link_color);
271   gtk_widget_modify_fg (label, GTK_STATE_PRELIGHT, link_color);
272   gtk_widget_modify_fg (label, GTK_STATE_SELECTED, link_color);
273
274   if (link_color != &default_link_color &&
275       link_color != &default_visited_link_color)
276     gdk_color_free (link_color);
277 }
278
279 static void
280 set_link_underline (GtkLinkButton *link_button)
281 {
282   GtkWidget *label;
283   
284   label = gtk_bin_get_child (GTK_BIN (link_button));
285   if (GTK_IS_LABEL (label))
286     {
287       PangoAttrList *attributes;
288       PangoAttribute *uline;
289
290       uline = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
291       uline->start_index = 0;
292       uline->end_index = G_MAXUINT;
293       attributes = pango_attr_list_new ();
294       pango_attr_list_insert (attributes, uline); 
295       gtk_label_set_attributes (GTK_LABEL (label), attributes);
296       pango_attr_list_unref (attributes);
297     }
298 }
299
300 static void
301 gtk_link_button_add (GtkContainer *container,
302                      GtkWidget    *widget)
303 {
304   GTK_CONTAINER_CLASS (gtk_link_button_parent_class)->add (container, widget);
305
306   set_link_color (GTK_LINK_BUTTON (container));
307   set_link_underline (GTK_LINK_BUTTON (container));
308 }
309
310 static void
311 gtk_link_button_style_set (GtkWidget *widget,
312                            GtkStyle  *old_style)
313 {
314   GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
315
316   set_link_color (link_button);
317 }
318
319 static void
320 set_hand_cursor (GtkWidget *widget,
321                  gboolean   show_hand)
322 {
323   GdkDisplay *display;
324   GdkCursor *cursor;
325
326   display = gtk_widget_get_display (widget);
327
328   cursor = NULL;
329   if (show_hand)
330     cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
331
332   gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
333   gdk_display_flush (display);
334
335   if (cursor)
336     gdk_cursor_unref (cursor);
337 }
338
339 static void
340 popup_menu_detach (GtkWidget *attach_widget,
341                    GtkMenu   *menu)
342 {
343   GtkLinkButton *link_button = GTK_LINK_BUTTON (attach_widget);
344
345   link_button->priv->popup_menu = NULL;
346 }
347
348 static void
349 popup_position_func (GtkMenu  *menu,
350                      gint     *x,
351                      gint     *y,
352                      gboolean *push_in,
353                      gpointer  user_data)
354 {
355   GtkLinkButton *link_button = GTK_LINK_BUTTON (user_data);
356   GtkLinkButtonPrivate *priv = link_button->priv;
357   GtkAllocation allocation;
358   GtkWidget *widget = GTK_WIDGET (link_button);
359   GdkScreen *screen = gtk_widget_get_screen (widget);
360   GtkRequisition req;
361   gint monitor_num;
362   GdkRectangle monitor;
363   
364   g_return_if_fail (gtk_widget_get_realized (widget));
365
366   gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
367
368   gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->popup_menu),
369                              &req, NULL);
370
371   gtk_widget_get_allocation (widget, &allocation);
372   *x += allocation.width / 2;
373   *y += allocation.height;
374
375   monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
376   gtk_menu_set_monitor (menu, monitor_num);
377   gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
378
379   *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
380   *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
381
382   *push_in = FALSE;
383 }
384
385 static void
386 copy_activate_cb (GtkWidget     *widget,
387                   GtkLinkButton *link_button)
388 {
389   GtkLinkButtonPrivate *priv = link_button->priv;
390   
391   gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (link_button),
392                                                     GDK_SELECTION_CLIPBOARD),
393                           priv->uri, -1);
394 }
395
396 static void
397 gtk_link_button_do_popup (GtkLinkButton  *link_button,
398                           GdkEventButton *event)
399 {
400   GtkLinkButtonPrivate *priv = link_button->priv;
401   gint button;
402   guint time;
403   
404   if (event)
405     {
406       button = event->button;
407       time = event->time;
408     }
409   else
410     {
411       button = 0;
412       time = gtk_get_current_event_time ();
413     }
414
415   if (gtk_widget_get_realized (GTK_WIDGET (link_button)))
416     {
417       GtkWidget *menu_item;
418       
419       if (priv->popup_menu)
420         gtk_widget_destroy (priv->popup_menu);
421
422       priv->popup_menu = gtk_menu_new ();
423       
424       gtk_menu_attach_to_widget (GTK_MENU (priv->popup_menu),
425                                  GTK_WIDGET (link_button),
426                                  popup_menu_detach);
427
428       menu_item = gtk_image_menu_item_new_with_mnemonic (_("Copy URL"));
429       gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
430                                      gtk_image_new_from_stock (GTK_STOCK_COPY,
431                                                                GTK_ICON_SIZE_MENU));
432       g_signal_connect (menu_item, "activate",
433                         G_CALLBACK (copy_activate_cb), link_button);
434       gtk_widget_show (menu_item);
435       gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), menu_item);
436       
437       if (button)
438         gtk_menu_popup (GTK_MENU (priv->popup_menu), NULL, NULL,
439                         NULL, NULL,
440                         button, time);
441       else
442         {
443           gtk_menu_popup (GTK_MENU (priv->popup_menu), NULL, NULL,
444                           popup_position_func, link_button,
445                           button, time);
446           gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->popup_menu), FALSE);
447         }
448     }
449 }
450
451 static gboolean
452 gtk_link_button_button_press (GtkWidget      *widget,
453                               GdkEventButton *event)
454 {
455   if (!gtk_widget_has_focus (widget))
456     gtk_widget_grab_focus (widget);
457
458   if ((event->button == 3) && (event->type == GDK_BUTTON_PRESS))
459     {
460       gtk_link_button_do_popup (GTK_LINK_BUTTON (widget), event);
461       
462       return TRUE;
463     }
464
465   if (GTK_WIDGET_CLASS (gtk_link_button_parent_class)->button_press_event)
466     return GTK_WIDGET_CLASS (gtk_link_button_parent_class)->button_press_event (widget, event);
467   
468   return FALSE;
469 }
470
471 static void
472 gtk_link_button_clicked (GtkButton *button)
473 {
474   GtkLinkButton *link_button = GTK_LINK_BUTTON (button);
475   GdkScreen *screen;
476   GError *error;
477
478   if (gtk_widget_has_screen (GTK_WIDGET (button)))
479     screen = gtk_widget_get_screen (GTK_WIDGET (button));
480   else
481     screen = NULL;
482
483   error = NULL;
484   gtk_show_uri (screen, link_button->priv->uri, GDK_CURRENT_TIME, &error);
485   if (error)
486     {
487       g_warning ("Unable to show '%s': %s",
488                  link_button->priv->uri,
489                  error->message);
490       g_error_free (error);
491     }
492
493   gtk_link_button_set_visited (link_button, TRUE);
494 }
495
496 static gboolean
497 gtk_link_button_popup_menu (GtkWidget *widget)
498 {
499   gtk_link_button_do_popup (GTK_LINK_BUTTON (widget), NULL);
500
501   return TRUE; 
502 }
503
504 static gboolean
505 gtk_link_button_enter_cb (GtkWidget        *widget,
506                           GdkEventCrossing *crossing,
507                           gpointer          user_data)
508 {
509   set_hand_cursor (widget, TRUE);
510   
511   return FALSE;
512 }
513
514 static gboolean
515 gtk_link_button_leave_cb (GtkWidget        *widget,
516                           GdkEventCrossing *crossing,
517                           gpointer          user_data)
518 {
519   set_hand_cursor (widget, FALSE);
520   
521   return FALSE;
522 }
523
524 static void
525 gtk_link_button_drag_data_get_cb (GtkWidget        *widget,
526                                   GdkDragContext   *context,
527                                   GtkSelectionData *selection,
528                                   guint             _info,
529                                   guint             _time,
530                                   gpointer          user_data)
531 {
532   GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
533   gchar *uri;
534   
535   uri = g_strdup_printf ("%s\r\n", link_button->priv->uri);
536   gtk_selection_data_set (selection,
537                           selection->target,
538                           8,
539                           (guchar *) uri,
540                           strlen (uri));
541   
542   g_free (uri);
543 }
544
545 /**
546  * gtk_link_button_new:
547  * @uri: a valid URI
548  *
549  * Creates a new #GtkLinkButton with the URI as its text.
550  *
551  * Return value: a new link button widget.
552  *
553  * Since: 2.10
554  */
555 GtkWidget *
556 gtk_link_button_new (const gchar *uri)
557 {
558   gchar *utf8_uri = NULL;
559   GtkWidget *retval;
560   
561   g_return_val_if_fail (uri != NULL, NULL);
562   
563   if (g_utf8_validate (uri, -1, NULL))
564     {
565       utf8_uri = g_strdup (uri);
566     }
567   else
568     {
569       GError *conv_err = NULL;
570     
571       utf8_uri = g_locale_to_utf8 (uri, -1, NULL, NULL, &conv_err);
572       if (conv_err)
573         {
574           g_warning ("Attempting to convert URI `%s' to UTF-8, but failed "
575                      "with error: %s\n",
576                      uri,
577                      conv_err->message);
578           g_error_free (conv_err);
579         
580           utf8_uri = g_strdup (_("Invalid URI"));
581         }
582     }
583   
584   retval = g_object_new (GTK_TYPE_LINK_BUTTON,
585                          "label", utf8_uri,
586                          "uri", uri,
587                          NULL);
588   
589   g_free (utf8_uri);
590   
591   return retval;
592 }
593
594 /**
595  * gtk_link_button_new_with_label:
596  * @uri: a valid URI
597  * @label: (allow-none): the text of the button
598  *
599  * Creates a new #GtkLinkButton containing a label.
600  *
601  * Return value: (transfer none): a new link button widget.
602  *
603  * Since: 2.10
604  */
605 GtkWidget *
606 gtk_link_button_new_with_label (const gchar *uri,
607                                 const gchar *label)
608 {
609   GtkWidget *retval;
610   
611   g_return_val_if_fail (uri != NULL, NULL);
612   
613   if (!label)
614     return gtk_link_button_new (uri);
615
616   retval = g_object_new (GTK_TYPE_LINK_BUTTON,
617                          "label", label,
618                          "uri", uri,
619                          NULL);
620
621   return retval;
622 }
623
624 static gboolean 
625 gtk_link_button_query_tooltip_cb (GtkWidget    *widget,
626                                   gint          x,
627                                   gint          y,
628                                   gboolean      keyboard_tip,
629                                   GtkTooltip   *tooltip,
630                                   gpointer      data)
631 {
632   GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
633   const gchar *label, *uri;
634
635   label = gtk_button_get_label (GTK_BUTTON (link_button));
636   uri = link_button->priv->uri;
637
638   if (!gtk_widget_get_tooltip_text (widget)
639     && !gtk_widget_get_tooltip_markup (widget)
640     && label && *label != '\0' && uri && strcmp (label, uri) != 0)
641     {
642       gtk_tooltip_set_text (tooltip, uri);
643       return TRUE;
644     }
645
646   return FALSE;
647 }
648
649
650 /**
651  * gtk_link_button_set_uri:
652  * @link_button: a #GtkLinkButton
653  * @uri: a valid URI
654  *
655  * Sets @uri as the URI where the #GtkLinkButton points. As a side-effect
656  * this unsets the 'visited' state of the button.
657  *
658  * Since: 2.10
659  */
660 void
661 gtk_link_button_set_uri (GtkLinkButton *link_button,
662                          const gchar   *uri)
663 {
664   GtkLinkButtonPrivate *priv;
665
666   g_return_if_fail (GTK_IS_LINK_BUTTON (link_button));
667   g_return_if_fail (uri != NULL);
668
669   priv = link_button->priv;
670
671   g_free (priv->uri);
672   priv->uri = g_strdup (uri);
673
674   g_object_notify (G_OBJECT (link_button), "uri");
675
676   gtk_link_button_set_visited (link_button, FALSE);
677 }
678
679 /**
680  * gtk_link_button_get_uri:
681  * @link_button: a #GtkLinkButton
682  *
683  * Retrieves the URI set using gtk_link_button_set_uri().
684  *
685  * Return value: a valid URI.  The returned string is owned by the link button
686  *   and should not be modified or freed.
687  *
688  * Since: 2.10
689  */
690 G_CONST_RETURN gchar *
691 gtk_link_button_get_uri (GtkLinkButton *link_button)
692 {
693   g_return_val_if_fail (GTK_IS_LINK_BUTTON (link_button), NULL);
694   
695   return link_button->priv->uri;
696 }
697
698 /**
699  * gtk_link_button_set_visited:
700  * @link_button: a #GtkLinkButton
701  * @visited: the new 'visited' state
702  *
703  * Sets the 'visited' state of the URI where the #GtkLinkButton
704  * points.  See gtk_link_button_get_visited() for more details.
705  *
706  * Since: 2.14
707  */
708 void
709 gtk_link_button_set_visited (GtkLinkButton *link_button,
710                              gboolean       visited)
711 {
712   g_return_if_fail (GTK_IS_LINK_BUTTON (link_button));
713
714   visited = visited != FALSE;
715
716   if (link_button->priv->visited != visited)
717     {
718       link_button->priv->visited = visited;
719
720       set_link_color (link_button);
721
722       g_object_notify (G_OBJECT (link_button), "visited");
723     }
724 }
725
726 /**
727  * gtk_link_button_get_visited:
728  * @link_button: a #GtkLinkButton
729  *
730  * Retrieves the 'visited' state of the URI where the #GtkLinkButton
731  * points. The button becomes visited when it is clicked. If the URI
732  * is changed on the button, the 'visited' state is unset again.
733  *
734  * The state may also be changed using gtk_link_button_set_visited().
735  *
736  * Return value: %TRUE if the link has been visited, %FALSE otherwise
737  *
738  * Since: 2.14
739  */
740 gboolean
741 gtk_link_button_get_visited (GtkLinkButton *link_button)
742 {
743   g_return_val_if_fail (GTK_IS_LINK_BUTTON (link_button), FALSE);
744   
745   return link_button->priv->visited;
746 }