mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Show the URI in a tooltip. (#505480, Teppo Turtiainen)
2008-02-16 Matthias Clasen <mclasen@redhat.com> * gtk/gtklinkbutton.c: Show the URI in a tooltip. (#505480, Teppo Turtiainen) svn path=/trunk/; revision=19596
This commit is contained in:
parent
580ae3106d
commit
311cdbb346
@ -1,3 +1,8 @@
|
||||
2008-02-16 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtklinkbutton.c: Show the URI in a tooltip. (#505480,
|
||||
Teppo Turtiainen)
|
||||
|
||||
2008-02-15 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gdk/Makefile.am: Don't install private headers. (#463510)
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "gtkmenu.h"
|
||||
#include "gtkmenuitem.h"
|
||||
#include "gtkstock.h"
|
||||
#include "gtktooltip.h"
|
||||
|
||||
#include "gtklinkbutton.h"
|
||||
|
||||
@ -92,6 +93,12 @@ static void gtk_link_button_drag_data_get_cb (GtkWidget *widget,
|
||||
guint _info,
|
||||
guint _time,
|
||||
gpointer user_data);
|
||||
static gboolean gtk_link_button_query_tooltip_cb (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean keyboard_tip,
|
||||
GtkTooltip *tooltip,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static const GtkTargetEntry link_drop_types[] = {
|
||||
@ -159,6 +166,9 @@ gtk_link_button_init (GtkLinkButton *link_button)
|
||||
G_CALLBACK (gtk_link_button_leave_cb), NULL);
|
||||
g_signal_connect (link_button, "drag_data_get",
|
||||
G_CALLBACK (gtk_link_button_drag_data_get_cb), NULL);
|
||||
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);
|
||||
|
||||
/* enable drag source */
|
||||
gtk_drag_source_set (GTK_WIDGET (link_button),
|
||||
@ -538,8 +548,8 @@ gtk_link_button_new (const gchar *uri)
|
||||
}
|
||||
|
||||
retval = g_object_new (GTK_TYPE_LINK_BUTTON,
|
||||
"uri", uri,
|
||||
"label", utf8_uri,
|
||||
"uri", uri,
|
||||
NULL);
|
||||
|
||||
g_free (utf8_uri);
|
||||
@ -577,6 +587,30 @@ gtk_link_button_new_with_label (const gchar *uri,
|
||||
return retval;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
label = gtk_button_get_label (GTK_BUTTON (link_button));
|
||||
uri = link_button->priv->uri;
|
||||
|
||||
if (label && *label != '\0' && uri && strcmp (label, uri) != 0)
|
||||
{
|
||||
gtk_tooltip_set_text (tooltip, uri);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_link_button_set_uri:
|
||||
* @link_button: a #GtkLinkButton
|
||||
@ -590,17 +624,18 @@ void
|
||||
gtk_link_button_set_uri (GtkLinkButton *link_button,
|
||||
const gchar *uri)
|
||||
{
|
||||
gchar *tmp;
|
||||
GtkLinkButtonPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_LINK_BUTTON (link_button));
|
||||
g_return_if_fail (uri != NULL);
|
||||
|
||||
tmp = link_button->priv->uri;
|
||||
link_button->priv->uri = g_strdup (uri);
|
||||
g_free (tmp);
|
||||
|
||||
link_button->priv->visited = FALSE;
|
||||
|
||||
priv = link_button->priv;
|
||||
|
||||
g_free (priv->uri);
|
||||
priv->uri = g_strdup (uri);
|
||||
|
||||
priv->visited = FALSE;
|
||||
|
||||
g_object_notify (G_OBJECT (link_button), "uri");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user