diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index 2b00ec3d9..1a0e5c2e5 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -74,6 +74,9 @@ struct _GtkTooltip guint keyboard_mode_enabled : 1; guint tip_area_set : 1; guint custom_was_reset : 1; + /* whether the query-tooltip handlers gave text and an icon again */ + guint label_was_set : 1; + guint icon_was_set : 1; }; struct _GtkTooltipClass @@ -268,6 +271,7 @@ gtk_tooltip_set_markup (GtkTooltip *tooltip, g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); gtk_label_set_markup (GTK_LABEL (tooltip->label), markup); + tooltip->label_was_set = TRUE; if (markup) gtk_widget_show (tooltip->label); @@ -292,6 +296,7 @@ gtk_tooltip_set_text (GtkTooltip *tooltip, g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); gtk_label_set_text (GTK_LABEL (tooltip->label), text); + tooltip->label_was_set = TRUE; if (text) gtk_widget_show (tooltip->label); @@ -319,6 +324,8 @@ gtk_tooltip_set_icon (GtkTooltip *tooltip, gtk_image_set_from_pixbuf (GTK_IMAGE (tooltip->image), pixbuf); + tooltip->icon_was_set = TRUE; + if (pixbuf) gtk_widget_show (tooltip->image); else @@ -346,6 +353,8 @@ gtk_tooltip_set_icon_from_stock (GtkTooltip *tooltip, gtk_image_set_from_stock (GTK_IMAGE (tooltip->image), stock_id, size); + tooltip->icon_was_set = TRUE; + if (stock_id) gtk_widget_show (tooltip->image); else @@ -373,6 +382,8 @@ gtk_tooltip_set_icon_from_icon_name (GtkTooltip *tooltip, gtk_image_set_from_icon_name (GTK_IMAGE (tooltip->image), icon_name, size); + tooltip->icon_was_set = TRUE; + if (icon_name) gtk_widget_show (tooltip->image); else @@ -400,6 +411,8 @@ gtk_tooltip_set_icon_from_gicon (GtkTooltip *tooltip, gtk_image_set_from_gicon (GTK_IMAGE (tooltip->image), gicon, size); + tooltip->icon_was_set = TRUE; + if (gicon) gtk_widget_show (tooltip->image); else @@ -531,8 +544,11 @@ gtk_tooltip_trigger_tooltip_query (GdkDisplay *display) static void gtk_tooltip_reset (GtkTooltip *tooltip) { - gtk_tooltip_set_markup (tooltip, NULL); - gtk_tooltip_set_icon (tooltip, NULL); + /* The text and icon stay until the query-tooltip handlers had their + * say: moving over a widget sets the same text again and again, and + * emptying the label first would lay it out twice per motion. */ + tooltip->label_was_set = FALSE; + tooltip->icon_was_set = FALSE; gtk_tooltip_set_tip_area (tooltip, NULL); /* See if the custom widget is again set from the query-tooltip @@ -1051,6 +1067,12 @@ gtk_tooltip_run_requery (GtkWidget **widget, if (!tooltip->custom_was_reset) gtk_tooltip_set_custom (tooltip, NULL); + /* the same for the text and the icon */ + if (!tooltip->label_was_set) + gtk_tooltip_set_markup (tooltip, NULL); + if (!tooltip->icon_was_set) + gtk_tooltip_set_icon (tooltip, NULL); + return return_value; }