Hi all. While developing my application I was surprised that tooltip text I've set for my entry primary icon was never shown. To discover the problem I've connected to default callback gtk_entry_query_tooltip() in gtkentry.c. While debugging I found that gtk_entry_get_icon_at_pos() always returned -1. The problem is that get_frame_size() function returns entry allocation x and y those are relative to container where entry is packed in. But x and y that came in query_tooltip callback as parameters are relative to entry widget. So, if we do not adjust x and y by subtraction frame_x and frame_y everything should work right. Because after we compare x and y to icon allocation where cooardinates also relative to entry widget. /** * gtk_entry_get_icon_at_pos: * @entry: a #GtkEntry * @x: the x coordinate of the position to find * @y: the y coordinate of the position to find * * Finds the icon at the given position and return its index. * If @x, @y doesn't lie inside an icon, -1 is returned. * This function is intended for use in a #GtkWidget::query-tooltip * signal handler. * * Returns: the index of the icon at the given position, or -1 * * Since: 2.16 */ gint gtk_entry_get_icon_at_pos (GtkEntry *entry, gint x, gint y) { GtkAllocation primary; GtkAllocation secondary; gint frame_x, frame_y; g_return_val_if_fail (GTK_IS_ENTRY (entry), -1); /* this commented code is not needed to show icon * tooltip properly * * get_frame_size (entry, &frame_x, &frame_y, NULL, NULL); * x -= frame_x; * y -= frame_y; */ get_icon_allocations (entry, &primary, &secondary); if (primary.x <= x && x < primary.x + primary.width && primary.y <= y && y < primary.y + primary.height) return GTK_ENTRY_ICON_PRIMARY; if (secondary.x <= x && x < secondary.x + secondary.width && secondary.y <= y && y < secondary.y + secondary.height) return GTK_ENTRY_ICON_SECONDARY; return -1; } --------- gtk+-3.0.8 -- Andrew E. Makeev <andrew@xxxxxxxx> Solvo Logistic _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list