GtkTooltip: Avoid extra work

When we are hiding the label or icon anyway, no need to change
it right before, causing reallocation overhead.
This commit is contained in:
Matthias Clasen 2014-02-20 18:31:10 -05:00
parent 0997303378
commit 55b0019589

View File

@ -291,13 +291,16 @@ gtk_tooltip_set_markup (GtkTooltip *tooltip,
{ {
g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
gtk_label_set_markup (GTK_LABEL (tooltip->label), markup);
if (markup) if (markup)
{
gtk_label_set_markup (GTK_LABEL (tooltip->label), markup);
gtk_widget_show (tooltip->label); gtk_widget_show (tooltip->label);
}
else else
{
gtk_widget_hide (tooltip->label); gtk_widget_hide (tooltip->label);
} }
}
/** /**
* gtk_tooltip_set_text: * gtk_tooltip_set_text:
@ -315,13 +318,16 @@ gtk_tooltip_set_text (GtkTooltip *tooltip,
{ {
g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
gtk_label_set_text (GTK_LABEL (tooltip->label), text);
if (text) if (text)
{
gtk_label_set_text (GTK_LABEL (tooltip->label), text);
gtk_widget_show (tooltip->label); gtk_widget_show (tooltip->label);
}
else else
{
gtk_widget_hide (tooltip->label); gtk_widget_hide (tooltip->label);
} }
}
/** /**
* gtk_tooltip_set_icon: * gtk_tooltip_set_icon:
@ -341,13 +347,16 @@ gtk_tooltip_set_icon (GtkTooltip *tooltip,
if (pixbuf) if (pixbuf)
g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
gtk_image_set_from_pixbuf (GTK_IMAGE (tooltip->image), pixbuf);
if (pixbuf) if (pixbuf)
{
gtk_image_set_from_pixbuf (GTK_IMAGE (tooltip->image), pixbuf);
gtk_widget_show (tooltip->image); gtk_widget_show (tooltip->image);
}
else else
{
gtk_widget_hide (tooltip->image); gtk_widget_hide (tooltip->image);
} }
}
/** /**
* gtk_tooltip_set_icon_from_stock: * gtk_tooltip_set_icon_from_stock:
@ -370,15 +379,18 @@ gtk_tooltip_set_icon_from_stock (GtkTooltip *tooltip,
{ {
g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
if (stock_id)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_image_set_from_stock (GTK_IMAGE (tooltip->image), stock_id, size); gtk_image_set_from_stock (GTK_IMAGE (tooltip->image), stock_id, size);
G_GNUC_END_IGNORE_DEPRECATIONS; G_GNUC_END_IGNORE_DEPRECATIONS;
if (stock_id)
gtk_widget_show (tooltip->image); gtk_widget_show (tooltip->image);
}
else else
{
gtk_widget_hide (tooltip->image); gtk_widget_hide (tooltip->image);
} }
}
/** /**
* gtk_tooltip_set_icon_from_icon_name: * gtk_tooltip_set_icon_from_icon_name:
@ -399,13 +411,16 @@ gtk_tooltip_set_icon_from_icon_name (GtkTooltip *tooltip,
{ {
g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
gtk_image_set_from_icon_name (GTK_IMAGE (tooltip->image), icon_name, size);
if (icon_name) if (icon_name)
{
gtk_image_set_from_icon_name (GTK_IMAGE (tooltip->image), icon_name, size);
gtk_widget_show (tooltip->image); gtk_widget_show (tooltip->image);
}
else else
{
gtk_widget_hide (tooltip->image); gtk_widget_hide (tooltip->image);
} }
}
/** /**
* gtk_tooltip_set_icon_from_gicon: * gtk_tooltip_set_icon_from_gicon:
@ -426,13 +441,16 @@ gtk_tooltip_set_icon_from_gicon (GtkTooltip *tooltip,
{ {
g_return_if_fail (GTK_IS_TOOLTIP (tooltip)); g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
gtk_image_set_from_gicon (GTK_IMAGE (tooltip->image), gicon, size);
if (gicon) if (gicon)
{
gtk_image_set_from_gicon (GTK_IMAGE (tooltip->image), gicon, size);
gtk_widget_show (tooltip->image); gtk_widget_show (tooltip->image);
}
else else
{
gtk_widget_hide (tooltip->image); gtk_widget_hide (tooltip->image);
} }
}
/** /**
* gtk_tooltip_set_custom: * gtk_tooltip_set_custom: