[gedit] tab: add GtkSourceFile's encoding to the candidate encodings



commit 74faf7c0843e760d9ca3a37cf5f7ea3a2861af3e
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Aug 13 14:58:37 2014 +0200

    tab: add GtkSourceFile's encoding to the candidate encodings
    
    The GtkSourceFile's encoding (if set) has a higher priority than the
    metadata, which itself has a higher priority than the encodings listed
    in the auto-detected gsetting.

 gedit/gedit-tab.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 0ec789c..4e9db3e 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -1919,6 +1919,8 @@ get_candidate_encodings (GeditTab *tab)
        GSettings *enc_settings;
        gchar **enc_strv;
        gchar *metadata_charset;
+       GtkSourceFile *file;
+       const GtkSourceEncoding *file_encoding;
        GSList *encodings;
 
        enc_settings = g_settings_new ("org.gnome.gedit.preferences.encodings");
@@ -1940,12 +1942,19 @@ get_candidate_encodings (GeditTab *tab)
                {
                        encodings = g_slist_prepend (encodings, (gpointer)metadata_enc);
                }
+       }
+
+       file = gedit_document_get_file (doc);
+       file_encoding = gtk_source_file_get_encoding (file);
 
-               g_free (metadata_charset);
+       if (file_encoding != NULL)
+       {
+               encodings = g_slist_prepend (encodings, (gpointer)file_encoding);
        }
 
-       g_strfreev (enc_strv);
        g_object_unref (enc_settings);
+       g_strfreev (enc_strv);
+       g_free (metadata_charset);
 
        return encodings;
 }


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