# HG changeset patch # User Sean Egan # Date 1047546380 0 # Node ID beffb3109ddb919bd7307aa4763e72b48fdc9c3c # Parent 5c720bc4c23dad7fa6b44a1764563e7146a8fba4 [gaim-migrate @ 5055] This is a slightly better way to do tooltips in gtkimhtml. committer: Tailor Script diff -r 5c720bc4c23d -r beffb3109ddb src/gtkimhtml.c --- a/src/gtkimhtml.c Thu Mar 13 09:00:42 2003 +0000 +++ b/src/gtkimhtml.c Thu Mar 13 09:06:20 2003 +0000 @@ -342,41 +342,45 @@ GtkTextIter iter; GdkWindow *win = event->window; int x, y; + char *tip = NULL; GSList *tags = NULL, *templist = NULL; - 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); gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); - - if (GTK_IMHTML(imhtml)->tip_window) { - gtk_widget_destroy (GTK_IMHTML(imhtml)->tip_window); - GTK_IMHTML(imhtml)->tip_window = NULL; - } - if (GTK_IMHTML(imhtml)->tip_timer) { - gtk_timeout_remove (GTK_IMHTML(imhtml)->tip_timer); - GTK_IMHTML(imhtml)->tip_timer = 0; - } - - GTK_IMHTML(imhtml)->tip = NULL; - tags = gtk_text_iter_get_tags(&iter); - for(templist = tags; !GTK_IMHTML(imhtml)->tip && templist; templist = templist->next){ + templist = tags; + while (templist) { GtkTextTag *tag = templist->data; - GTK_IMHTML(imhtml)->tip = g_object_get_data(G_OBJECT(tag), "link_url"); + tip = g_object_get_data(G_OBJECT(tag), "link_url"); + if (tip) + break; + templist = templist->next; } - - if(GTK_IMHTML(imhtml)->tip){ + + if (GTK_IMHTML(imhtml)->tip) { + if ((tip == GTK_IMHTML(imhtml)->tip)) { + return FALSE; + } + /* We've left the cell. Remove the timeout and create a new one below */ + if (GTK_IMHTML(imhtml)->tip_window) { + gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); + GTK_IMHTML(imhtml)->tip_window = NULL; + } + gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->arrow_cursor); + if (GTK_IMHTML(imhtml)->tip_timer) + g_source_remove(GTK_IMHTML(imhtml)->tip_timer); + GTK_IMHTML(imhtml)->tip_timer = 0; + } + + if(tip){ gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor); - GTK_IMHTML(imhtml)->tip_timer = gtk_timeout_add (TOOLTIP_TIMEOUT, - gtk_imhtml_tip, imhtml); + GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, + gtk_imhtml_tip, imhtml); } - else{ - gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->arrow_cursor); - } - + + GTK_IMHTML(imhtml)->tip = tip; g_slist_free(tags); return FALSE; } diff -r 5c720bc4c23d -r beffb3109ddb src/gtkimhtml.h --- a/src/gtkimhtml.h Thu Mar 13 09:00:42 2003 +0000 +++ b/src/gtkimhtml.h Thu Mar 13 09:06:20 2003 +0000 @@ -60,6 +60,7 @@ GtkWidget *tip_window; char *tip; guint tip_timer; + GdkRectangle rect; }; struct _GtkIMHtmlClass {