[gtk+/gtk-3-10] GtkTooltip: Avoid extra work
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-10] GtkTooltip: Avoid extra work
- Date: Sun, 6 Apr 2014 03:41:57 +0000 (UTC)
commit 418573eca80cd36b12823a0d11d624fdad850ecc
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Feb 20 18:31:10 2014 -0500
GtkTooltip: Avoid extra work
When we are hiding the label or icon anyway, no need to change
it right before, causing reallocation overhead.
gtk/gtktooltip.c | 70 ++++++++++++++++++++++++++++++++++--------------------
1 files changed, 44 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 12e49ae..60fb11e 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -316,12 +316,15 @@ gtk_tooltip_set_markup (GtkTooltip *tooltip,
{
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
- gtk_label_set_markup (GTK_LABEL (tooltip->label), markup);
-
if (markup)
- gtk_widget_show (tooltip->label);
+ {
+ gtk_label_set_markup (GTK_LABEL (tooltip->label), markup);
+ gtk_widget_show (tooltip->label);
+ }
else
- gtk_widget_hide (tooltip->label);
+ {
+ gtk_widget_hide (tooltip->label);
+ }
}
/**
@@ -340,12 +343,15 @@ gtk_tooltip_set_text (GtkTooltip *tooltip,
{
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
- gtk_label_set_text (GTK_LABEL (tooltip->label), text);
-
if (text)
- gtk_widget_show (tooltip->label);
+ {
+ gtk_label_set_text (GTK_LABEL (tooltip->label), text);
+ gtk_widget_show (tooltip->label);
+ }
else
- gtk_widget_hide (tooltip->label);
+ {
+ gtk_widget_hide (tooltip->label);
+ }
}
/**
@@ -366,12 +372,15 @@ gtk_tooltip_set_icon (GtkTooltip *tooltip,
if (pixbuf)
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
- gtk_image_set_from_pixbuf (GTK_IMAGE (tooltip->image), pixbuf);
-
if (pixbuf)
- gtk_widget_show (tooltip->image);
+ {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (tooltip->image), pixbuf);
+ gtk_widget_show (tooltip->image);
+ }
else
- gtk_widget_hide (tooltip->image);
+ {
+ gtk_widget_hide (tooltip->image);
+ }
}
/**
@@ -395,14 +404,17 @@ gtk_tooltip_set_icon_from_stock (GtkTooltip *tooltip,
{
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_image_set_from_stock (GTK_IMAGE (tooltip->image), stock_id, size);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
if (stock_id)
- gtk_widget_show (tooltip->image);
+ {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ gtk_image_set_from_stock (GTK_IMAGE (tooltip->image), stock_id, size);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ gtk_widget_show (tooltip->image);
+ }
else
- gtk_widget_hide (tooltip->image);
+ {
+ gtk_widget_hide (tooltip->image);
+ }
}
/**
@@ -424,12 +436,15 @@ gtk_tooltip_set_icon_from_icon_name (GtkTooltip *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)
- gtk_widget_show (tooltip->image);
+ {
+ gtk_image_set_from_icon_name (GTK_IMAGE (tooltip->image), icon_name, size);
+ gtk_widget_show (tooltip->image);
+ }
else
- gtk_widget_hide (tooltip->image);
+ {
+ gtk_widget_hide (tooltip->image);
+ }
}
/**
@@ -451,12 +466,15 @@ gtk_tooltip_set_icon_from_gicon (GtkTooltip *tooltip,
{
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
- gtk_image_set_from_gicon (GTK_IMAGE (tooltip->image), gicon, size);
-
if (gicon)
- gtk_widget_show (tooltip->image);
+ {
+ gtk_image_set_from_gicon (GTK_IMAGE (tooltip->image), gicon, size);
+ gtk_widget_show (tooltip->image);
+ }
else
- gtk_widget_hide (tooltip->image);
+ {
+ gtk_widget_hide (tooltip->image);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]