[gtksourceview/wip/encodings: 3/3] Ensure that UTF-8 and CURRENT are present in the candidate encodings
- From: SĂŠbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/encodings: 3/3] Ensure that UTF-8 and CURRENT are present in the candidate encodings
- Date: Sun, 10 Aug 2014 20:03:48 +0000 (UTC)
commit 62aa061817445305dcac476812255574e2a4973d
Author: SĂŠbastien Wilmet <swilmet gnome org>
Date: Sun Aug 10 21:59:40 2014 +0200
Ensure that UTF-8 and CURRENT are present in the candidate encodings
In the gedit translations, CURRENT was sometimes translated (and there
is a translator comment to explain that it should not be translated...).
So it's better to ensure that UTF-8 and CURRENT are present, just in
case.
gtksourceview/gtksourceencoding.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourceencoding.c b/gtksourceview/gtksourceencoding.c
index 6e65132..3f73a92 100644
--- a/gtksourceview/gtksourceencoding.c
+++ b/gtksourceview/gtksourceencoding.c
@@ -494,7 +494,8 @@ gtk_source_encoding_get_name (const GtkSourceEncoding* enc)
* gtk_source_file_loader_set_candidate_encodings().
*
* This function returns a different list depending on the current locale (i.e.
- * language, country and default encoding).
+ * language, country and default encoding). The UTF-8 encoding and the current
+ * locale encoding are guaranteed to be present in the returned list.
*
* Returns: (transfer container) (element-type GtkSource.Encoding): the list of
* default candidate encodings. Free with g_slist_free().
@@ -530,6 +531,16 @@ gtk_source_encoding_get_default_candidates (void)
encodings_list = _gtk_source_encoding_strv_to_list (encodings_strv);
+ /* Ensure that UTF-8 and CURRENT are present. */
+ encodings_list = g_slist_prepend (encodings_list,
+ (gpointer) gtk_source_encoding_get_current ());
+
+ encodings_list = g_slist_prepend (encodings_list,
+ (gpointer) &utf8_encoding);
+
+ encodings_list = gtk_source_encoding_remove_duplicates (encodings_list,
+ GTK_SOURCE_ENCODING_DUPLICATES_KEEP_LAST);
+
g_variant_unref (encodings_variant);
return encodings_list;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]