Commit 65e62a75 authored by Jasper St. Pierre's avatar Jasper St. Pierre

search-provider: Use a serialized gicon instead of a to_string'd one

This improves deserialization performance in gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=704949
parent c17ac4cd
......@@ -69,28 +69,6 @@ struct _NautilusShellSearchProvider {
G_DEFINE_TYPE (NautilusShellSearchProvider, nautilus_shell_search_provider, G_TYPE_OBJECT)
static GVariant *
variant_from_pixbuf (GdkPixbuf *pixbuf)
{
GVariant *variant;
guchar *data;
guint length;
data = gdk_pixbuf_get_pixels_with_length (pixbuf, &length);
variant = g_variant_new ("(iiibii@ay)",
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_pixbuf_get_rowstride (pixbuf),
gdk_pixbuf_get_has_alpha (pixbuf),
gdk_pixbuf_get_bits_per_sample (pixbuf),
gdk_pixbuf_get_n_channels (pixbuf),
g_variant_new_from_data (G_VARIANT_TYPE_BYTESTRING,
data, length, TRUE,
(GDestroyNotify)g_object_unref,
g_object_ref (pixbuf)));
return variant;
}
static gchar *
get_display_name (NautilusShellSearchProvider *self,
NautilusFile *file)
......@@ -538,7 +516,7 @@ result_list_attributes_ready_cb (GList *file_list,
GList *l;
gchar *uri, *display_name;
GdkPixbuf *pix;
gchar *thumbnail_path, *gicon_str;
gchar *thumbnail_path;
GIcon *gicon;
GFile *location;
GVariant *meta_variant;
......@@ -568,22 +546,15 @@ result_list_attributes_ready_cb (GList *file_list,
gicon = get_gicon (data->self, file);
}
if (gicon != NULL) {
gicon_str = g_icon_to_string (gicon);
g_variant_builder_add (&meta, "{sv}",
"gicon", g_variant_new_string (gicon_str));
g_free (gicon_str);
g_object_unref (gicon);
} else {
pix = nautilus_file_get_icon_pixbuf (file, 128, TRUE,
NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS);
g_variant_builder_add (&meta, "{sv}",
"icon-data", variant_from_pixbuf (pix));
g_object_unref (pix);
if (gicon == NULL) {
gicon = G_ICON (nautilus_file_get_icon_pixbuf (file, 128, TRUE,
NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS));
}
g_variant_builder_add (&meta, "{sv}",
"icon", g_icon_serialize (gicon));
g_object_unref (gicon);
meta_variant = g_variant_builder_end (&meta);
g_hash_table_insert (data->self->metas_cache,
g_strdup (uri), g_variant_ref_sink (meta_variant));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment