[nautilus] search-provider: Use a serialized gicon instead of a to_string'd one
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] search-provider: Use a serialized gicon instead of a to_string'd one
- Date: Sat, 27 Jul 2013 00:32:50 +0000 (UTC)
commit 65e62a75e3a65c342d843048512aeaebd135759a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Jul 25 21:48:05 2013 -0400
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
src/nautilus-shell-search-provider.c | 45 ++++++----------------------------
1 files changed, 8 insertions(+), 37 deletions(-)
---
diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
index 5eaff72..2b45890 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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]