[gtksourceview/wip/loader-saver] FileLoader: call the progress callback



commit bab36f3aa601908c2875a379b2d26396dc3e09b3
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Apr 3 21:16:03 2014 +0200

    FileLoader: call the progress callback

 gtksourceview/gtksourcefileloader.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/gtksourcefileloader.c b/gtksourceview/gtksourcefileloader.c
index cd8a42a..7e9062a 100644
--- a/gtksourceview/gtksourcefileloader.c
+++ b/gtksourceview/gtksourcefileloader.c
@@ -91,6 +91,7 @@ struct _GtkSourceFileLoaderPrivate
        GTask *task;
 
        goffset total_bytes_read;
+       goffset total_size;
        GFileProgressCallback progress_cb;
        gpointer progress_cb_data;
 
@@ -405,9 +406,11 @@ write_file_chunk (GtkSourceFileLoader *loader)
        /* FIXME: note that calling the progress callback blocks the read...
         * Check if it isn't a performance problem.
         */
-       if (loader->priv->progress_cb != NULL)
+       if (loader->priv->progress_cb != NULL && loader->priv->total_size > 0)
        {
-               /* TODO call the cb */
+               loader->priv->progress_cb (loader->priv->total_bytes_read,
+                                          loader->priv->total_size,
+                                          loader->priv->progress_cb_data);
        }
 
        read_file_chunk (loader);
@@ -579,6 +582,12 @@ query_info_cb (GFile               *file,
                return;
        }
 
+       if (g_file_info_has_attribute (loader->priv->info, G_FILE_ATTRIBUTE_STANDARD_SIZE))
+       {
+               loader->priv->total_size = g_file_info_get_attribute_uint64 (loader->priv->info,
+                                                                            G_FILE_ATTRIBUTE_STANDARD_SIZE);
+       }
+
        create_input_stream (loader);
 }
 


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