[gtksourceview/wip/loader-saver] File loading: set candidate encodings



commit b517f221ed31529bffa92402b36b8b792567e992
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Mar 7 19:03:07 2014 +0100

    File loading: set candidate encodings

 gtksourceview/gtksourcefile.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourcefile.c b/gtksourceview/gtksourcefile.c
index a7070d3..72cdf78 100644
--- a/gtksourceview/gtksourcefile.c
+++ b/gtksourceview/gtksourcefile.c
@@ -514,6 +514,8 @@ gtk_source_file_load_async (GtkSourceFile         *file,
                            GAsyncReadyCallback    callback,
                            gpointer               user_data)
 {
+       GSList *encodings = NULL;
+
        g_return_if_fail (GTK_SOURCE_IS_FILE (file));
 
        if (file->priv->loader != NULL)
@@ -532,7 +534,16 @@ gtk_source_file_load_async (GtkSourceFile         *file,
 
        file->priv->loader = gtk_source_file_loader_new (file, file->priv->ensure_trailing_newline);
 
-       gtk_source_file_loader_set_candidate_encodings (file->priv->loader, NULL);
+       if (file->priv->encoding != NULL)
+       {
+               encodings = g_slist_prepend (encodings, (gpointer) file->priv->encoding);
+       }
+       else
+       {
+               encodings = g_slist_prepend (encodings, (gpointer) gtk_source_encoding_get_utf8 ());
+       }
+
+       gtk_source_file_loader_set_candidate_encodings (file->priv->loader, encodings);
 
        gtk_source_file_loader_load_async (file->priv->loader,
                                           io_priority,
@@ -541,6 +552,8 @@ gtk_source_file_load_async (GtkSourceFile         *file,
                                           progress_callback_data,
                                           callback,
                                           user_data);
+
+       g_slist_free (encodings);
 }
 
 gboolean


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