[Xfce4-commits] <xfce4-panel:master> Cache launcher menu tooltip pixbuf (bug #7146).
Nick Schermer
noreply at xfce.org
Sun Jan 23 12:46:01 CET 2011
Updating branch refs/heads/master
to cfad253bd5d09e0fc1e5493e3e621120c9250b9d (commit)
from 09922fc9951c107d915297d3d3874d2293d9cbf4 (commit)
commit cfad253bd5d09e0fc1e5493e3e621120c9250b9d
Author: Nick Schermer <nick at xfce.org>
Date: Sun Jan 23 12:41:39 2011 +0100
Cache launcher menu tooltip pixbuf (bug #7146).
Because the query-tooltip query in Gtk is not implemented correctly
(although the gtk docs say otherwise), see https://bugzilla.gnome.org/show_bug.cgi?id=516130
we cache the pixbuf, so setting the tooltip will be faster.
plugins/launcher/launcher.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c
index fd228cb..c3a5dce 100644
--- a/plugins/launcher/launcher.c
+++ b/plugins/launcher/launcher.c
@@ -2209,18 +2209,26 @@ launcher_plugin_item_query_tooltip (GtkWidget *widget,
gtk_tooltip_set_text (tooltip, name);
}
- /* we use the cached pixbuf for the button, because they are more
- * likely to occur and we don't want to poke the hard drive multiple
- * times for a simple pixbuf. for menu items this is not a big real,
- * so here we use the pixbuf directly */
+ /* the button uses a custom cache because the button widget is never
+ * destroyed, for menu items we cache the pixbuf by attaching the
+ * data on the menu item widget */
if (GTK_IS_MENU_ITEM (widget))
{
- pixbuf = launcher_plugin_tooltip_pixbuf (gtk_widget_get_screen (widget),
- garcon_menu_item_get_icon_name (item));
+ pixbuf = g_object_get_data (G_OBJECT (widget), I_("pixbuf-cache"));
if (G_LIKELY (pixbuf != NULL))
{
gtk_tooltip_set_icon (tooltip, pixbuf);
- g_object_unref (G_OBJECT (pixbuf));
+ }
+ else
+ {
+ pixbuf = launcher_plugin_tooltip_pixbuf (gtk_widget_get_screen (widget),
+ garcon_menu_item_get_icon_name (item));
+ if (G_LIKELY (pixbuf != NULL))
+ {
+ gtk_tooltip_set_icon (tooltip, pixbuf);
+ g_object_set_data_full (G_OBJECT (widget), I_("pixbuf-cache"), pixbuf,
+ (GDestroyNotify) g_object_unref);
+ }
}
}
More information about the Xfce4-commits
mailing list