gtk+ r21032 - in trunk: . gtk
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r21032 - in trunk: . gtk
- Date: Thu, 7 Aug 2008 11:37:57 +0000 (UTC)
Author: neo
Date: Thu Aug 7 11:37:57 2008
New Revision: 21032
URL: http://svn.gnome.org/viewvc/gtk+?rev=21032&view=rev
Log:
2008-08-07 Sven Neumann <sven gimp org>
Bug 546771 - Add writable property "visited" to GtkLinkButton
* gtk/gtk.symbols
* gtk/gtklinkbutton.[ch]: expose the 'visited' state as a
read-write property with getters and setters. Also move the nick
and blurb of the "uri" property to the proper translation
domain.
Modified:
trunk/ChangeLog
trunk/gtk/gtk.symbols
trunk/gtk/gtklinkbutton.c
trunk/gtk/gtklinkbutton.h
Modified: trunk/gtk/gtk.symbols
==============================================================================
--- trunk/gtk/gtk.symbols (original)
+++ trunk/gtk/gtk.symbols Thu Aug 7 11:37:57 2008
@@ -2103,6 +2103,8 @@
gtk_link_button_get_uri
gtk_link_button_set_uri
gtk_link_button_set_uri_hook
+gtk_link_button_get_visited
+gtk_link_button_set_visited
#endif
#endif
Modified: trunk/gtk/gtklinkbutton.c
==============================================================================
--- trunk/gtk/gtklinkbutton.c (original)
+++ trunk/gtk/gtklinkbutton.c Thu Aug 7 11:37:57 2008
@@ -54,8 +54,8 @@
enum
{
PROP_0,
-
- PROP_URI
+ PROP_URI,
+ PROP_VISITED
};
#define GTK_LINK_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_LINK_BUTTON, GtkLinkButtonPrivate))
@@ -141,10 +141,25 @@
g_object_class_install_property (gobject_class,
PROP_URI,
g_param_spec_string ("uri",
- _("URI"),
- _("The URI bound to this button"),
+ P_("URI"),
+ P_("The URI bound to this button"),
NULL,
G_PARAM_READWRITE));
+ /**
+ * GtkLinkButton:visited
+ *
+ * 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,
+ PROP_VISITED,
+ g_param_spec_boolean ("visited",
+ P_("Visited"),
+ P_("Whether this link has been visited."),
+ FALSE,
+ G_PARAM_READWRITE));
g_type_class_add_private (gobject_class, sizeof (GtkLinkButtonPrivate));
}
@@ -156,12 +171,13 @@
gtk_button_set_relief (GTK_BUTTON (link_button), GTK_RELIEF_NONE);
- g_signal_connect (link_button, "enter_notify_event",
+ g_signal_connect (link_button, "enter-notify-event",
G_CALLBACK (gtk_link_button_enter_cb), NULL);
- g_signal_connect (link_button, "leave_notify_event",
+ g_signal_connect (link_button, "leave-notify-event",
G_CALLBACK (gtk_link_button_leave_cb), NULL);
- g_signal_connect (link_button, "drag_data_get",
+ 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);
@@ -196,6 +212,9 @@
case PROP_URI:
g_value_set_string (value, link_button->priv->uri);
break;
+ case PROP_VISITED:
+ g_value_set_boolean (value, link_button->priv->visited);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -215,6 +234,9 @@
case PROP_URI:
gtk_link_button_set_uri (link_button, g_value_get_string (value));
break;
+ case PROP_VISITED:
+ gtk_link_button_set_visited (link_button, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -450,9 +472,7 @@
if (uri_func)
(* uri_func) (link_button, link_button->priv->uri, uri_func_data);
- link_button->priv->visited = TRUE;
-
- set_link_color (link_button);
+ gtk_link_button_set_visited (link_button, TRUE);
}
static gboolean
@@ -612,7 +632,8 @@
* @link_button: a #GtkLinkButton
* @uri: a valid URI
*
- * Sets @uri as the URI where the #GtkLinkButton points.
+ * Sets @uri as the URI where the #GtkLinkButton points. As a side-effect
+ * this unsets the 'visited' state of the button.
*
* Since: 2.10
*/
@@ -630,13 +651,9 @@
g_free (priv->uri);
priv->uri = g_strdup (uri);
- if (priv->visited)
- {
- priv->visited = FALSE;
- set_link_color (link_button);
- }
-
g_object_notify (G_OBJECT (link_button), "uri");
+
+ gtk_link_button_set_visited (link_button, FALSE);
}
/**
@@ -691,5 +708,56 @@
return old_uri_func;
}
+/**
+ * gtk_link_button_set_visited:
+ * @link_button: a #GtkLinkButton
+ * @visited: the new 'visited' state
+ *
+ * Sets the 'visited' state of the URI where the #GtkLinkButton
+ * 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;
+
+ set_link_color (link_button);
+
+ g_object_notify (G_OBJECT (link_button), "visited");
+ }
+}
+
+/**
+ * gtk_link_button_get_visited:
+ * @link_button: a #GtkLinkButton
+ *
+ * Retrieves the 'visited' state of the URI where the #GtkLinkButton
+ * points. The button becomes visited when it is clicked. If the URI
+ * is changed on the button, the 'visited' state is unset again.
+ *
+ * The state may also be changed using gtk_link_button_set_visited().
+ *
+ * Return value: %TRUE if the link has been visited, %FALSE otherwise
+ *
+ * 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;
+}
+
+
#define __GTK_LINK_BUTTON_C__
#include "gtkaliasdef.c"
Modified: trunk/gtk/gtklinkbutton.h
==============================================================================
--- trunk/gtk/gtklinkbutton.h (original)
+++ trunk/gtk/gtklinkbutton.h Thu Aug 7 11:37:57 2008
@@ -79,6 +79,11 @@
gpointer data,
GDestroyNotify destroy);
+gboolean gtk_link_button_get_visited (GtkLinkButton *link_button);
+void gtk_link_button_set_visited (GtkLinkButton *link_button,
+ gboolean visited);
+
+
G_END_DECLS
#endif /* __GTK_LINK_BUTTON_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]