summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2013-07-25 21:48:05 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2013-07-26 14:43:37 -0400
commit65e62a75e3a65c342d843048512aeaebd135759a (patch)
tree03199894123bedeab156cc079af03c361ce71d55 /src
parentc17ac4cd42e05950ad193b44fcf1c22367b4f496 (diff)
downloadnautilus-65e62a75e3a65c342d843048512aeaebd135759a.tar.gz
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
Diffstat (limited to 'src')
-rw-r--r--src/nautilus-shell-search-provider.c45
1 files changed, 8 insertions, 37 deletions
diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
index 5eaff7286..2b4589065 100644
--- a/src/nautilus-shell-search-provider.c
+++ b/src/nautilus-shell-search-provider.c
@@ -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));