[gtksourceview/wip/misc: 1/2] GtkSourceFile: a NULL encoding by default
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/misc: 1/2] GtkSourceFile: a NULL encoding by default
- Date: Fri, 1 Aug 2014 19:39:50 +0000 (UTC)
commit 2a7e4e8c027d756e2f23518a04321f3a1a91f17e
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Aug 1 15:05:37 2014 +0200
GtkSourceFile: a NULL encoding by default
The default encoding was UTF-8. Now it is NULL by default, which means
that the UTF-8 encoding will be used, but it also means that the
encoding hasn't yet been set. So the private function is_encoding_set()
is no longer needed.
It will be useful for gedit too.
docs/reference/gtksourceview-3.0-sections.txt | 1 +
gtksourceview/gtksourcefile.c | 28 +++++++-----------------
gtksourceview/gtksourcefile.h | 3 --
gtksourceview/gtksourcefileloader.c | 8 +++++-
4 files changed, 15 insertions(+), 25 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index fe3c0b4..acd010c 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -222,6 +222,7 @@ gtk_source_encoding_to_string
gtk_source_encoding_get_name
gtk_source_encoding_get_charset
gtk_source_encoding_foreach
+gtk_source_encoding_get_default_candidates
gtk_source_encoding_copy
gtk_source_encoding_free
<SUBSECTION Standard>
diff --git a/gtksourceview/gtksourcefile.c b/gtksourceview/gtksourcefile.c
index d889676..d53b764 100644
--- a/gtksourceview/gtksourcefile.c
+++ b/gtksourceview/gtksourcefile.c
@@ -65,9 +65,6 @@ struct _GtkSourceFilePrivate
GTimeVal modification_time;
guint modification_time_set : 1;
-
- /* TRUE if the encoding has been set by a FileLoader or a FileSaver. */
- guint encoding_set : 1;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceFile, gtk_source_file, G_TYPE_OBJECT)
@@ -176,7 +173,9 @@ gtk_source_file_class_init (GtkSourceFileClass *klass)
/**
* GtkSourceFile:encoding:
*
- * The character encoding. UTF-8 by default.
+ * The character encoding. %NULL by default, which means that the UTF-8
+ * encoding is used. After using a #GtkSourceFileLoader or
+ * #GtkSourceFileSaver, the encoding is non-%NULL.
*
* Since: 3.14
*/
@@ -229,8 +228,7 @@ gtk_source_file_init (GtkSourceFile *file)
{
file->priv = gtk_source_file_get_instance_private (file);
- file->priv->encoding = gtk_source_encoding_get_utf8 ();
- file->priv->encoding_set = FALSE;
+ file->priv->encoding = NULL;
}
/**
@@ -299,13 +297,6 @@ _gtk_source_file_set_encoding (GtkSourceFile *file,
{
g_return_if_fail (GTK_SOURCE_IS_FILE (file));
- file->priv->encoding_set = TRUE;
-
- if (encoding == NULL)
- {
- encoding = gtk_source_encoding_get_utf8 ();
- }
-
if (file->priv->encoding != encoding)
{
file->priv->encoding = encoding;
@@ -313,17 +304,14 @@ _gtk_source_file_set_encoding (GtkSourceFile *file,
}
}
-/* Returns TRUE if the encoding has been set by a FileLoader or a FileSaver. */
-gboolean
-_gtk_source_file_is_encoding_set (GtkSourceFile *file)
-{
- return file->priv->encoding_set;
-}
-
/**
* gtk_source_file_get_encoding:
* @file: a #GtkSourceFile.
*
+ * By default %NULL is returned, which means that the UTF-8 encoding is used.
+ * After using a #GtkSourceFileLoader or #GtkSourceFileSaver, the encoding is no
+ * longer %NULL.
+ *
* Returns: the character encoding.
* Since: 3.14
*/
diff --git a/gtksourceview/gtksourcefile.h b/gtksourceview/gtksourcefile.h
index 922eb6b..e4859f1 100644
--- a/gtksourceview/gtksourcefile.h
+++ b/gtksourceview/gtksourcefile.h
@@ -92,9 +92,6 @@ void _gtk_source_file_set_encoding (GtkSourceFile
*file,
const GtkSourceEncoding *encoding);
G_GNUC_INTERNAL
-gboolean _gtk_source_file_is_encoding_set (GtkSourceFile *file);
-
-G_GNUC_INTERNAL
void _gtk_source_file_set_newline_type (GtkSourceFile *file,
GtkSourceNewlineType newline_type);
diff --git a/gtksourceview/gtksourcefileloader.c b/gtksourceview/gtksourcefileloader.c
index f297a9e..dbd9e05 100644
--- a/gtksourceview/gtksourcefileloader.c
+++ b/gtksourceview/gtksourcefileloader.c
@@ -271,14 +271,18 @@ set_default_candidate_encodings (GtkSourceFileLoader *loader)
*/
list = gtk_source_encoding_get_default_candidates ();
- if (loader->priv->file == NULL ||
- !_gtk_source_file_is_encoding_set (loader->priv->file))
+ if (loader->priv->file == NULL)
{
goto end;
}
file_encoding = gtk_source_file_get_encoding (loader->priv->file);
+ if (file_encoding == NULL)
+ {
+ goto end;
+ }
+
/* Remove file_encoding from the list, if already present, and prepend
* it to the list.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]