gtklinkbutton.c 19.7 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
2
 * gtklinkbutton.c - an hyperlink-enabled button
3
 *
4 5 6 7
 * Copyright (C) 2006 Emmanuele Bassi <ebassi@gmail.com>
 * All rights reserved.
 *
 * Based on gnome-href code by:
8 9
 *      James Henstridge <james@daa.com.au>
 *
10 11 12 13 14 15 16 17 18 19 20
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
Javier Jardón's avatar
Javier Jardón committed
21
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
22 23
 */

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/**
 * SECTION:gtklinkbutton
 * @Title: GtkLinkButton
 * @Short_description: Create buttons bound to a URL
 * @See_also: #GtkButton
 *
 * A GtkLinkButton is a #GtkButton with a hyperlink, similar to the one
 * used by web browsers, which triggers an action when clicked. It is useful
 * to show quick links to resources.
 *
 * A link button is created by calling either gtk_link_button_new() or
 * gtk_link_button_new_with_label(). If using the former, the URI you pass
 * to the constructor is used as a label for the widget.
 *
 * The URI bound to a GtkLinkButton can be set specifically using
 * gtk_link_button_set_uri(), and retrieved using gtk_link_button_get_uri().
 *
41
 * By default, GtkLinkButton calls gtk_show_uri_on_window() when the button is
42
 * clicked. This behaviour can be overridden by connecting to the
43 44
 * #GtkLinkButton::activate-link signal and returning %TRUE from the
 * signal handler.
45 46 47 48 49
 *
 * # CSS nodes
 *
 * GtkLinkButton has a single CSS node with name button. To differentiate
 * it from a plain #GtkButton, it gets the .link style class.
50 51
 */

52 53
#include "config.h"

54 55
#include "gtklinkbutton.h"

56 57 58 59 60
#include <string.h>

#include "gtkclipboard.h"
#include "gtkdnd.h"
#include "gtklabel.h"
61
#include "gtkmain.h"
62
#include "gtkmarshalers.h"
63 64
#include "gtkmenu.h"
#include "gtkmenuitem.h"
65
#include "gtksizerequest.h"
Matthias Clasen's avatar
Matthias Clasen committed
66
#include "gtkshow.h"
67
#include "gtktooltip.h"
68
#include "gtkprivate.h"
69
#include "gtkintl.h"
70
#include "gtktextutil.h"
71

72
#include "a11y/gtklinkbuttonaccessible.h"
73 74 75 76 77 78 79 80 81 82 83 84 85

struct _GtkLinkButtonPrivate
{
  gchar *uri;

  gboolean visited;

  GtkWidget *popup_menu;
};

enum
{
  PROP_0,
86 87
  PROP_URI,
  PROP_VISITED
88 89
};

90 91 92 93 94 95
enum
{
  ACTIVATE_LINK,

  LAST_SIGNAL
};
96 97 98 99 100 101 102 103 104 105 106 107 108 109

static void     gtk_link_button_finalize     (GObject          *object);
static void     gtk_link_button_get_property (GObject          *object,
					      guint             prop_id,
					      GValue           *value,
					      GParamSpec       *pspec);
static void     gtk_link_button_set_property (GObject          *object,
					      guint             prop_id,
					      const GValue     *value,
					      GParamSpec       *pspec);
static gboolean gtk_link_button_button_press (GtkWidget        *widget,
					      GdkEventButton   *event);
static void     gtk_link_button_clicked      (GtkButton        *button);
static gboolean gtk_link_button_popup_menu   (GtkWidget        *widget);
110
static void     gtk_link_button_realize      (GtkWidget        *widget);
111
static void     gtk_link_button_unrealize    (GtkWidget        *widget);
112 113
static void     gtk_link_button_drag_begin   (GtkWidget        *widget,
                                              GdkDragContext   *context);
114 115 116 117 118 119
static void gtk_link_button_drag_data_get_cb (GtkWidget        *widget,
					      GdkDragContext   *context,
					      GtkSelectionData *selection,
					      guint             _info,
					      guint             _time,
					      gpointer          user_data);
120 121 122 123 124 125
static gboolean gtk_link_button_query_tooltip_cb (GtkWidget    *widget,
                                                  gint          x,
                                                  gint          y,
                                                  gboolean      keyboard_tip,
                                                  GtkTooltip   *tooltip,
                                                  gpointer      data);
126
static gboolean gtk_link_button_activate_link (GtkLinkButton *link_button);
127 128 129 130 131 132

static const GtkTargetEntry link_drop_types[] = {
  { "text/uri-list", 0, 0 },
  { "_NETSCAPE_URL", 0, 0 }
};

133 134
static guint link_signals[LAST_SIGNAL] = { 0, };

135
G_DEFINE_TYPE_WITH_PRIVATE (GtkLinkButton, gtk_link_button, GTK_TYPE_BUTTON)
136 137 138 139 140 141 142

static void
gtk_link_button_class_init (GtkLinkButtonClass *klass)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
  GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
143

144 145 146
  gobject_class->set_property = gtk_link_button_set_property;
  gobject_class->get_property = gtk_link_button_get_property;
  gobject_class->finalize = gtk_link_button_finalize;
147

148 149
  widget_class->button_press_event = gtk_link_button_button_press;
  widget_class->popup_menu = gtk_link_button_popup_menu;
150
  widget_class->realize = gtk_link_button_realize;
151
  widget_class->unrealize = gtk_link_button_unrealize;
152
  widget_class->drag_begin = gtk_link_button_drag_begin;
153 154 155

  button_class->clicked = gtk_link_button_clicked;

156 157
  klass->activate_link = gtk_link_button_activate_link;

158
  /**
159 160 161
   * GtkLinkButton:uri:
   *
   * The URI bound to this button.
162 163 164 165
   *
   * Since: 2.10
   */
  g_object_class_install_property (gobject_class,
166 167 168 169 170 171 172
                                   PROP_URI,
                                   g_param_spec_string ("uri",
                                                        P_("URI"),
                                                        P_("The URI bound to this button"),
                                                        NULL,
                                                        GTK_PARAM_READWRITE));

173
  /**
174 175
   * GtkLinkButton:visited:
   *
176 177 178 179 180 181
   * The 'visited' state of this button. A visited link is drawn in a
   * different color.
   *
   * Since: 2.14
   */
  g_object_class_install_property (gobject_class,
182 183
                                   PROP_VISITED,
                                   g_param_spec_boolean ("visited",
184 185 186
                                                         P_("Visited"),
                                                         P_("Whether this link has been visited."),
                                                         FALSE,
187
                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
188 189 190 191 192 193 194 195

  /**
   * GtkLinkButton::activate-link:
   * @button: the #GtkLinkButton that emitted the signal
   *
   * The ::activate-link signal is emitted each time the #GtkLinkButton
   * has been clicked.
   *
196
   * The default handler will call gtk_show_uri_on_window() with the URI stored inside
197 198 199 200 201 202 203 204 205 206 207 208 209 210
   * the #GtkLinkButton:uri property.
   *
   * To override the default behavior, you can connect to the ::activate-link
   * signal and stop the propagation of the signal by returning %TRUE from
   * your handler.
   */
  link_signals[ACTIVATE_LINK] =
    g_signal_new (I_("activate-link"),
                  G_TYPE_FROM_CLASS (klass),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkLinkButtonClass, activate_link),
                  _gtk_boolean_handled_accumulator, NULL,
                  _gtk_marshal_BOOLEAN__VOID,
                  G_TYPE_BOOLEAN, 0);
211 212

  gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LINK_BUTTON_ACCESSIBLE);
213
  gtk_widget_class_set_css_name (widget_class, "button");
214 215 216 217 218
}

static void
gtk_link_button_init (GtkLinkButton *link_button)
{
219 220
  GtkStyleContext *context;

221
  link_button->priv = gtk_link_button_get_instance_private (link_button);
222

223
  gtk_button_set_relief (GTK_BUTTON (link_button), GTK_RELIEF_NONE);
224 225
  gtk_widget_set_state_flags (GTK_WIDGET (link_button), GTK_STATE_FLAG_LINK, FALSE);

226
  g_signal_connect (link_button, "drag-data-get",
227
  		    G_CALLBACK (gtk_link_button_drag_data_get_cb), NULL);
228

229 230 231
  g_object_set (link_button, "has-tooltip", TRUE, NULL);
  g_signal_connect (link_button, "query-tooltip",
                    G_CALLBACK (gtk_link_button_query_tooltip_cb), NULL);
232

233 234 235 236 237
  /* enable drag source */
  gtk_drag_source_set (GTK_WIDGET (link_button),
  		       GDK_BUTTON1_MASK,
  		       link_drop_types, G_N_ELEMENTS (link_drop_types),
  		       GDK_ACTION_COPY);
238 239 240

  context = gtk_widget_get_style_context (GTK_WIDGET (link_button));
  gtk_style_context_add_class (context, "link");
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
}

static void
gtk_link_button_finalize (GObject *object)
{
  GtkLinkButton *link_button = GTK_LINK_BUTTON (object);
  
  g_free (link_button->priv->uri);
  
  G_OBJECT_CLASS (gtk_link_button_parent_class)->finalize (object);
}

static void
gtk_link_button_get_property (GObject    *object,
			      guint       prop_id,
			      GValue     *value,
			      GParamSpec *pspec)
{
  GtkLinkButton *link_button = GTK_LINK_BUTTON (object);
  
  switch (prop_id)
    {
    case PROP_URI:
      g_value_set_string (value, link_button->priv->uri);
      break;
266 267 268
    case PROP_VISITED:
      g_value_set_boolean (value, link_button->priv->visited);
      break;
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
gtk_link_button_set_property (GObject      *object,
			      guint         prop_id,
			      const GValue *value,
			      GParamSpec   *pspec)
{
  GtkLinkButton *link_button = GTK_LINK_BUTTON (object);
  
  switch (prop_id)
    {
    case PROP_URI:
      gtk_link_button_set_uri (link_button, g_value_get_string (value));
      break;
288 289 290
    case PROP_VISITED:
      gtk_link_button_set_visited (link_button, g_value_get_boolean (value));
      break;
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
set_hand_cursor (GtkWidget *widget,
		 gboolean   show_hand)
{
  GdkDisplay *display;
  GdkCursor *cursor;

  display = gtk_widget_get_display (widget);

  cursor = NULL;
  if (show_hand)
308
    cursor = gdk_cursor_new_from_name (display, "pointer");
309

310
  gdk_window_set_cursor (gtk_button_get_event_window (GTK_BUTTON (widget)), cursor);
311 312 313
  gdk_display_flush (display);

  if (cursor)
314
    g_object_unref (cursor);
315 316
}

317 318 319 320 321 322 323 324
static void
gtk_link_button_realize (GtkWidget *widget)
{
  GTK_WIDGET_CLASS (gtk_link_button_parent_class)->realize (widget);

  set_hand_cursor (widget, TRUE);
}

325 326 327 328 329 330 331 332
static void
gtk_link_button_unrealize (GtkWidget *widget)
{
  set_hand_cursor (widget, FALSE);

  GTK_WIDGET_CLASS (gtk_link_button_parent_class)->unrealize (widget);
}

333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
static void
popup_menu_detach (GtkWidget *attach_widget,
		   GtkMenu   *menu)
{
  GtkLinkButton *link_button = GTK_LINK_BUTTON (attach_widget);

  link_button->priv->popup_menu = NULL;
}

static void
copy_activate_cb (GtkWidget     *widget,
		  GtkLinkButton *link_button)
{
  GtkLinkButtonPrivate *priv = link_button->priv;
  
  gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (link_button),
			  			    GDK_SELECTION_CLIPBOARD),
		  	  priv->uri, -1);
}

static void
gtk_link_button_do_popup (GtkLinkButton  *link_button,
355
                          const GdkEvent *event)
356 357 358
{
  GtkLinkButtonPrivate *priv = link_button->priv;

359
  if (gtk_widget_get_realized (GTK_WIDGET (link_button)))
360 361
    {
      GtkWidget *menu_item;
362

363 364 365 366
      if (priv->popup_menu)
	gtk_widget_destroy (priv->popup_menu);

      priv->popup_menu = gtk_menu_new ();
367 368 369
      gtk_style_context_add_class (gtk_widget_get_style_context (priv->popup_menu),
                                   GTK_STYLE_CLASS_CONTEXT_MENU);

370 371 372 373
      gtk_menu_attach_to_widget (GTK_MENU (priv->popup_menu),
		      		 GTK_WIDGET (link_button),
				 popup_menu_detach);

374
      menu_item = gtk_menu_item_new_with_mnemonic (_("Copy URL"));
375 376 377 378
      g_signal_connect (menu_item, "activate",
		        G_CALLBACK (copy_activate_cb), link_button);
      gtk_widget_show (menu_item);
      gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), menu_item);
379

380 381
      if (event && gdk_event_triggers_context_menu (event))
        gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), event);
382 383
      else
        {
384 385 386 387 388 389 390 391
          gtk_menu_popup_at_widget (GTK_MENU (priv->popup_menu),
                                    GTK_WIDGET (link_button),
                                    GDK_GRAVITY_SOUTH,
                                    GDK_GRAVITY_NORTH_WEST,
                                    event);

          gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->popup_menu), FALSE);
        }
392 393 394 395 396 397 398
    }
}

static gboolean
gtk_link_button_button_press (GtkWidget      *widget,
			      GdkEventButton *event)
{
399
  if (!gtk_widget_has_focus (widget))
400 401
    gtk_widget_grab_focus (widget);

402 403 404 405
  /* Don't popup the menu if there's no URI set,
   * otherwise the menu item will trigger a warning */
  if (gdk_event_triggers_context_menu ((GdkEvent *) event) &&
      GTK_LINK_BUTTON (widget)->priv->uri != NULL)
406
    {
407
      gtk_link_button_do_popup (GTK_LINK_BUTTON (widget), (GdkEvent *) event);
408

409 410 411 412
      return TRUE;
    }

  if (GTK_WIDGET_CLASS (gtk_link_button_parent_class)->button_press_event)
413
    return GTK_WIDGET_CLASS (gtk_link_button_parent_class)->button_press_event (widget, event);
414 415 416 417
  
  return FALSE;
}

418 419
static gboolean
gtk_link_button_activate_link (GtkLinkButton *link_button)
420
{
421
  GtkWidget *toplevel;
422
  GError *error;
423

424
  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (link_button));
425

426
  error = NULL;
427
  gtk_show_uri_on_window (GTK_WINDOW (toplevel), link_button->priv->uri, GDK_CURRENT_TIME, &error);
428 429 430 431 432 433
  if (error)
    {
      g_warning ("Unable to show '%s': %s",
                 link_button->priv->uri,
                 error->message);
      g_error_free (error);
434 435

      return FALSE;
436
    }
437

438
  gtk_link_button_set_visited (link_button, TRUE);
439 440 441 442 443 444 445 446 447 448

  return TRUE;
}

static void
gtk_link_button_clicked (GtkButton *button)
{
  gboolean retval = FALSE;

  g_signal_emit (button, link_signals[ACTIVATE_LINK], 0, &retval);
449 450 451 452 453 454 455 456 457 458
}

static gboolean
gtk_link_button_popup_menu (GtkWidget *widget)
{
  gtk_link_button_do_popup (GTK_LINK_BUTTON (widget), NULL);

  return TRUE; 
}

459 460 461 462 463 464 465
static void
gtk_link_button_drag_begin (GtkWidget      *widget,
                            GdkDragContext *context)
{
  gtk_drag_set_icon_name (context, "text-x-generic", 0, 0);
}

466 467 468 469 470 471 472 473 474 475 476 477 478
static void
gtk_link_button_drag_data_get_cb (GtkWidget        *widget,
				  GdkDragContext   *context,
				  GtkSelectionData *selection,
				  guint             _info,
				  guint             _time,
				  gpointer          user_data)
{
  GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
  gchar *uri;
  
  uri = g_strdup_printf ("%s\r\n", link_button->priv->uri);
  gtk_selection_data_set (selection,
479
                          gtk_selection_data_get_target (selection),
480 481 482 483 484 485 486 487 488 489 490 491 492
  			  8,
  			  (guchar *) uri,
			  strlen (uri));
  
  g_free (uri);
}

/**
 * gtk_link_button_new:
 * @uri: a valid URI
 *
 * Creates a new #GtkLinkButton with the URI as its text.
 *
493
 * Returns: a new link button widget.
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
 *
 * Since: 2.10
 */
GtkWidget *
gtk_link_button_new (const gchar *uri)
{
  gchar *utf8_uri = NULL;
  GtkWidget *retval;
  
  g_return_val_if_fail (uri != NULL, NULL);
  
  if (g_utf8_validate (uri, -1, NULL))
    {
      utf8_uri = g_strdup (uri);
    }
  else
    {
      GError *conv_err = NULL;
    
      utf8_uri = g_locale_to_utf8 (uri, -1, NULL, NULL, &conv_err);
      if (conv_err)
        {
516
          g_warning ("Attempting to convert URI '%s' to UTF-8, but failed "
517
                     "with error: %s",
518 519 520 521 522 523 524 525 526
                     uri,
                     conv_err->message);
          g_error_free (conv_err);
        
          utf8_uri = g_strdup (_("Invalid URI"));
        }
    }
  
  retval = g_object_new (GTK_TYPE_LINK_BUTTON,
527
  			 "label", utf8_uri,
528
  			 "uri", uri,
529 530 531 532 533 534 535 536 537 538
  			 NULL);
  
  g_free (utf8_uri);
  
  return retval;
}

/**
 * gtk_link_button_new_with_label:
 * @uri: a valid URI
539
 * @label: (allow-none): the text of the button
540 541 542
 *
 * Creates a new #GtkLinkButton containing a label.
 *
543
 * Returns: (transfer none): a new link button widget.
544 545 546 547 548 549 550 551 552
 *
 * Since: 2.10
 */
GtkWidget *
gtk_link_button_new_with_label (const gchar *uri,
				const gchar *label)
{
  GtkWidget *retval;
  
553
  g_return_val_if_fail (uri != NULL, NULL);
554 555 556 557 558 559 560 561 562 563 564 565
  
  if (!label)
    return gtk_link_button_new (uri);

  retval = g_object_new (GTK_TYPE_LINK_BUTTON,
		         "label", label,
			 "uri", uri,
			 NULL);

  return retval;
}

566 567 568 569 570 571 572 573 574 575
static gboolean 
gtk_link_button_query_tooltip_cb (GtkWidget    *widget,
                                  gint          x,
                                  gint          y,
                                  gboolean      keyboard_tip,
                                  GtkTooltip   *tooltip,
                                  gpointer      data)
{
  GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
  const gchar *label, *uri;
576
  gchar *text, *markup;
577 578 579

  label = gtk_button_get_label (GTK_BUTTON (link_button));
  uri = link_button->priv->uri;
580 581
  text = gtk_widget_get_tooltip_text (widget);
  markup = gtk_widget_get_tooltip_markup (widget);
582

583 584 585
  if (text == NULL &&
      markup == NULL &&
      label && *label != '\0' && uri && strcmp (label, uri) != 0)
586 587 588 589 590
    {
      gtk_tooltip_set_text (tooltip, uri);
      return TRUE;
    }

591 592 593
  g_free (text);
  g_free (markup);

594 595 596 597
  return FALSE;
}


598

599 600 601 602 603
/**
 * gtk_link_button_set_uri:
 * @link_button: a #GtkLinkButton
 * @uri: a valid URI
 *
604
 * Sets @uri as the URI where the #GtkLinkButton points. As a side-effect
605
 * this unsets the “visited” state of the button.
606 607 608 609 610 611 612
 *
 * Since: 2.10
 */
void
gtk_link_button_set_uri (GtkLinkButton *link_button,
			 const gchar   *uri)
{
613
  GtkLinkButtonPrivate *priv;
614 615 616 617

  g_return_if_fail (GTK_IS_LINK_BUTTON (link_button));
  g_return_if_fail (uri != NULL);

618 619 620 621 622
  priv = link_button->priv;

  g_free (priv->uri);
  priv->uri = g_strdup (uri);

623
  g_object_notify (G_OBJECT (link_button), "uri");
624 625

  gtk_link_button_set_visited (link_button, FALSE);
626 627 628 629 630 631 632 633
}

/**
 * gtk_link_button_get_uri:
 * @link_button: a #GtkLinkButton
 *
 * Retrieves the URI set using gtk_link_button_set_uri().
 *
634
 * Returns: a valid URI.  The returned string is owned by the link button
635 636 637 638
 *   and should not be modified or freed.
 *
 * Since: 2.10
 */
639
const gchar *
640 641 642 643 644 645 646
gtk_link_button_get_uri (GtkLinkButton *link_button)
{
  g_return_val_if_fail (GTK_IS_LINK_BUTTON (link_button), NULL);
  
  return link_button->priv->uri;
}

647 648 649
/**
 * gtk_link_button_set_visited:
 * @link_button: a #GtkLinkButton
650
 * @visited: the new “visited” state
651
 *
652
 * Sets the “visited” state of the URI where the #GtkLinkButton
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
 * points.  See gtk_link_button_get_visited() for more details.
 *
 * Since: 2.14
 */
void
gtk_link_button_set_visited (GtkLinkButton *link_button,
                             gboolean       visited)
{
  g_return_if_fail (GTK_IS_LINK_BUTTON (link_button));

  visited = visited != FALSE;

  if (link_button->priv->visited != visited)
    {
      link_button->priv->visited = visited;

669 670 671 672 673 674 675 676 677 678
      if (visited)
        {
          gtk_widget_unset_state_flags (GTK_WIDGET (link_button), GTK_STATE_FLAG_LINK);
          gtk_widget_set_state_flags (GTK_WIDGET (link_button), GTK_STATE_FLAG_VISITED, FALSE);
        }
      else
        {
          gtk_widget_unset_state_flags (GTK_WIDGET (link_button), GTK_STATE_FLAG_VISITED);
          gtk_widget_set_state_flags (GTK_WIDGET (link_button), GTK_STATE_FLAG_LINK, FALSE);
        }
679 680 681 682 683 684 685 686 687

      g_object_notify (G_OBJECT (link_button), "visited");
    }
}

/**
 * gtk_link_button_get_visited:
 * @link_button: a #GtkLinkButton
 *
688
 * Retrieves the “visited” state of the URI where the #GtkLinkButton
689
 * points. The button becomes visited when it is clicked. If the URI
690
 * is changed on the button, the “visited” state is unset again.
691 692 693
 *
 * The state may also be changed using gtk_link_button_set_visited().
 *
694
 * Returns: %TRUE if the link has been visited, %FALSE otherwise
695 696 697 698 699 700 701 702 703 704
 *
 * Since: 2.14
 */
gboolean
gtk_link_button_get_visited (GtkLinkButton *link_button)
{
  g_return_val_if_fail (GTK_IS_LINK_BUTTON (link_button), FALSE);
  
  return link_button->priv->visited;
}