[gnome-font-viewer] font-model: don't use sync g_file_query_info()



commit d360c01838265ae684bf8ac21fa24b51cba1cda1
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jun 11 13:41:33 2012 -0400

    font-model: don't use sync g_file_query_info()
    
    Use g_file_query_info_async() instead.

 src/font-model.c |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/src/font-model.c b/src/font-model.c
index faafa42..b1bfaf6 100644
--- a/src/font-model.c
+++ b/src/font-model.c
@@ -114,7 +114,6 @@ create_thumbnail (GIOSchedulerJob *job,
     }
 
   g_object_unref (info);
-  g_object_unref (file);
   g_object_unref (factory);
   g_clear_object (&pixbuf);
 
@@ -351,19 +350,18 @@ thumb_file_read_async_ready_cb (GObject *source,
 }
 
 static void
-ensure_thumbnail (FontViewModel *self,
-                  const gchar *path)
+thumbnail_query_info_cb (GObject *source,
+                         GAsyncResult *res,
+                         gpointer user_data)
 {
-    GFile *file, *thumb_file = NULL;
+    FontViewModel *self = user_data;
+    GFile *file = G_FILE (source);
+    GFile *thumb_file = NULL;
     GFileInfo *info;
     const gchar *thumb_path;
     LoadThumbnailData *data;
 
-    file = g_file_new_for_path (path);
-    info = g_file_query_info (file, G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
-                              G_FILE_ATTRIBUTE_THUMBNAILING_FAILED,
-                              G_FILE_QUERY_INFO_NONE,
-                              NULL, NULL);
+    info = g_file_query_info_finish (file, res, NULL);
 
     if (!info ||
         g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED)) {
@@ -389,10 +387,25 @@ ensure_thumbnail (FontViewModel *self,
     }
 
  out:
-    g_clear_object (&file);
     g_clear_object (&info);
 }
 
+static void
+ensure_thumbnail (FontViewModel *self,
+                  const gchar *path)
+{
+    GFile *file;
+
+    file = g_file_new_for_path (path);
+    g_file_query_info_async (file, 
+                             G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
+                             G_FILE_ATTRIBUTE_THUMBNAILING_FAILED,
+                             G_FILE_QUERY_INFO_NONE,
+                             G_PRIORITY_DEFAULT, NULL, 
+                             thumbnail_query_info_cb, self);
+    g_object_unref (file);
+}
+
 /* make sure the font list is valid */
 static void
 ensure_font_list (FontViewModel *self)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]