diff src/gtkimhtml.c @ 10799:6f67d4088da0

[gaim-migrate @ 12442] added some things to the change log added mouse-over hyperlink colorage committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sat, 09 Apr 2005 01:24:28 +0000
parents 08981462ebbb
children 364a2ef907ae
line wrap: on
line diff
--- a/src/gtkimhtml.c	Fri Apr 08 22:44:02 2005 +0000
+++ b/src/gtkimhtml.c	Sat Apr 09 01:24:28 2005 +0000
@@ -420,21 +420,47 @@
 	int x, y;
 	char *tip = NULL;
 	GSList *tags = NULL, *templist = NULL;
+	GdkColor *norm, *pre;
+	GtkTextTag *tag = NULL, *oldprelit_tag;
+
+	oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag;
+
 	gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL);
 	gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET,
-										  event->x, event->y, &x, &y);
+	                                      event->x, event->y, &x, &y);
 	gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y);
 	tags = gtk_text_iter_get_tags(&iter);
 
 	templist = tags;
 	while (templist) {
-		GtkTextTag *tag = templist->data;
+		tag = templist->data;
 		tip = g_object_get_data(G_OBJECT(tag), "link_url");
 		if (tip)
 			break;
 		templist = templist->next;
 	}
 
+	if (tip) {
+		gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-prelight-color", &pre, NULL);
+		GTK_IMHTML(imhtml)->prelit_tag = tag;
+		if (tag != oldprelit_tag) {
+			if (pre)
+				g_object_set(G_OBJECT(tag), "foreground-gdk", pre, NULL);
+			else
+				g_object_set(G_OBJECT(tag), "foreground", "light blue", NULL);
+		}
+	} else {
+		GTK_IMHTML(imhtml)->prelit_tag = NULL;
+	}
+	
+	if (GTK_IMHTML(imhtml)->prelit_tag != oldprelit_tag) {
+		gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &norm, NULL);
+		if (norm)
+			g_object_set(G_OBJECT(oldprelit_tag), "foreground-gdk", norm, NULL);
+		else
+			g_object_set(G_OBJECT(oldprelit_tag), "foreground", "blue", NULL);
+	}
+
 	if (GTK_IMHTML(imhtml)->tip) {
 		if ((tip == GTK_IMHTML(imhtml)->tip)) {
 			return FALSE;
@@ -453,7 +479,7 @@
 		GTK_IMHTML(imhtml)->tip_timer = 0;
 	}
 
-	if(tip){
+	if (tip){
 		if (!GTK_IMHTML(imhtml)->editable)
 			gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor);
 		GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT,
@@ -468,6 +494,16 @@
 gboolean gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data)
 {
 	/* when leaving the widget, clear any current & pending tooltips and restore the cursor */
+	if (GTK_IMHTML(imhtml)->prelit_tag) {
+		GdkColor *norm;
+		gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &norm, NULL);
+		if (norm)
+			g_object_set(G_OBJECT(GTK_IMHTML(imhtml)->prelit_tag), "foreground-gdk", norm, NULL);
+		else
+			g_object_set(G_OBJECT(GTK_IMHTML(imhtml)->prelit_tag), "foreground", "blue", NULL);
+		GTK_IMHTML(imhtml)->prelit_tag = NULL;
+	}
+
 	if (GTK_IMHTML(imhtml)->tip_window) {
 		gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window);
 		GTK_IMHTML(imhtml)->tip_window = NULL;
@@ -1175,6 +1211,10 @@
 	                                        _("Hyperlink color"),
 	                                        _("Color to draw hyperlinks."),
 	                                        GDK_TYPE_COLOR, G_PARAM_READABLE));
+	gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color",
+	                                        _("Hyperlink prelight color"),
+	                                        _("Color to draw hyperlinks when mouse is over them."),
+	                                        GDK_TYPE_COLOR, G_PARAM_READABLE));
 
 	binding_set = gtk_binding_set_by_class (parent_class);
 	gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD);