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