[gtksourceview/wip/loader-saver] Remove ensure-trailing-newline and remove-trailing-newline properties
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/loader-saver] Remove ensure-trailing-newline and remove-trailing-newline properties
- Date: Tue, 1 Apr 2014 21:37:18 +0000 (UTC)
commit abde7acf49c3cd04ec652b40f5eb88bf01990e79
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Apr 1 23:36:14 2014 +0200
Remove ensure-trailing-newline and remove-trailing-newline properties
Only implicit-trailing-newline is enough.
docs/reference/gtksourceview-3.0-sections.txt | 4 --
gtksourceview/gtksourcebuffer.c | 34 +++++-------
gtksourceview/gtksourcefileloader.c | 72 ++----------------------
gtksourceview/gtksourcefileloader.h | 7 ---
gtksourceview/gtksourcefilesaver.c | 72 ++-----------------------
gtksourceview/gtksourcefilesaver.h | 7 ---
6 files changed, 25 insertions(+), 171 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index b4cd333..7e5e75f 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -247,8 +247,6 @@ gtk_source_file_loader_set_candidate_encodings
gtk_source_file_loader_get_buffer
gtk_source_file_loader_get_file
gtk_source_file_loader_get_input_stream
-gtk_source_file_loader_set_remove_trailing_newline
-gtk_source_file_loader_get_remove_trailing_newline
gtk_source_file_loader_set_mount_operation_factory
gtk_source_file_loader_load_async
gtk_source_file_loader_load_finish
@@ -280,8 +278,6 @@ gtk_source_file_saver_set_newline_type
gtk_source_file_saver_get_newline_type
gtk_source_file_saver_set_compression_type
gtk_source_file_saver_get_compression_type
-gtk_source_file_saver_set_ensure_trailing_newline
-gtk_source_file_saver_get_ensure_trailing_newline
gtk_source_file_saver_set_create_backup
gtk_source_file_saver_get_create_backup
gtk_source_file_saver_set_mount_operation_factory
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index c3200ed..d4f59a7 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -2727,26 +2727,20 @@ gtk_source_buffer_get_compression_type (GtkSourceBuffer *buffer)
*
* Sets whether the @buffer has an implicit trailing newline.
*
- * If a trailing newline is present in a #GtkTextBuffer, there will be one more
- * visible line in a #GtkTextView. This is generally not what the user expects.
- * So instead of having an explicit trailing newline in the @buffer, there can
- * be an implicit trailing newline: the trailing newline is actually not in the
- * @buffer, but when saving the file with a #GtkSourceFileSaver, there will be a
- * trailing newline in the file.
- *
- * By default, both the #GtkSourceFileLoader:remove-trailing-newline property of
- * #GtkSourceFileLoader and the #GtkSourceFileSaver:ensure-trailing-newline
- * property of #GtkSourceFileSaver have the same value as
- * #GtkSourceBuffer:implicit-trailing-newline.
- *
- * So by default, if @implicit_trailing_newline is %TRUE, the trailing newline
- * (if present) is removed when the file is loaded into the @buffer. And when
- * the buffer is saved into a file, a trailing newline is always added (by
- * default).
- *
- * On the other hand, when @implicit_trailing_newline is %FALSE, the file's
- * content is not modified when loaded into the @buffer (by default), and the
- * buffer's content is not modified when saved into the file (by default).
+ * If an explicit trailing newline is present in a #GtkTextBuffer, there will be
+ * one more visible line in a #GtkTextView. This is generally not what the user
+ * expects.
+ *
+ * If @implicit_trailing_newline is %TRUE (the default value):
+ * - when a #GtkSourceFileLoader loads the content of a file into the @buffer,
+ * the trailing newline (if present in the file) is not inserted into the
+ * @buffer.
+ * - when a #GtkSourceFileSaver saves the content of the @buffer into a file, a
+ * trailing newline is added to the file.
+ *
+ * On the other hand, if @implicit_trailing_newline is %FALSE, the file's
+ * content is not modified when loaded into the @buffer, and the @buffer's
+ * content is not modified when saved into a file.
*
* Since: 3.14
*/
diff --git a/gtksourceview/gtksourcefileloader.c b/gtksourceview/gtksourcefileloader.c
index b44e522..3843690 100644
--- a/gtksourceview/gtksourcefileloader.c
+++ b/gtksourceview/gtksourcefileloader.c
@@ -50,8 +50,7 @@ enum
PROP_0,
PROP_BUFFER,
PROP_FILE,
- PROP_INPUT_STREAM,
- PROP_REMOVE_TRAILING_NEWLINE
+ PROP_INPUT_STREAM
};
#define READ_CHUNK_SIZE 8192
@@ -106,7 +105,6 @@ struct _GtkSourceFileLoaderPrivate
GOutputStream *output_stream;
guint guess_content_type_from_content : 1;
- guint remove_trailing_newline : 1;
guint tried_mount : 1;
};
@@ -158,10 +156,6 @@ gtk_source_file_loader_set_property (GObject *object,
loader->priv->input_stream_property = g_value_dup_object (value);
break;
- case PROP_REMOVE_TRAILING_NEWLINE:
- gtk_source_file_loader_set_remove_trailing_newline (loader, g_value_get_boolean
(value));
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -190,10 +184,6 @@ gtk_source_file_loader_get_property (GObject *object,
g_value_set_object (value, loader->priv->input_stream_property);
break;
- case PROP_REMOVE_TRAILING_NEWLINE:
- g_value_set_boolean (value, loader->priv->remove_trailing_newline);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -291,22 +281,6 @@ gtk_source_file_loader_class_init (GtkSourceFileLoaderClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
-
- /**
- * GtkSourceFileLoader:remove-trailing-newline:
- *
- * When loading the content, remove the trailing newline if present.
- *
- * Since: 3.14
- */
- g_object_class_install_property (object_class, PROP_REMOVE_TRAILING_NEWLINE,
- g_param_spec_boolean ("remove-trailing-newline",
- _("Remove Trailing Newline"),
- "Remove the trailing newline if present",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
}
static void
@@ -816,44 +790,6 @@ gtk_source_file_loader_get_input_stream (GtkSourceFileLoader *loader)
}
/**
- * gtk_source_file_loader_set_remove_trailing_newline:
- * @loader: a #GtkSourceFileLoader.
- * @remove_trailing_newline: whether to remove the trailing newline.
- *
- * Since: 3.14
- */
-void
-gtk_source_file_loader_set_remove_trailing_newline (GtkSourceFileLoader *loader,
- gboolean remove_trailing_newline)
-{
- g_return_if_fail (GTK_SOURCE_IS_FILE_LOADER (loader));
- g_return_if_fail (loader->priv->task == NULL);
-
- remove_trailing_newline = remove_trailing_newline != FALSE;
-
- if (loader->priv->remove_trailing_newline != remove_trailing_newline)
- {
- loader->priv->remove_trailing_newline = remove_trailing_newline;
- g_object_notify (G_OBJECT (loader), "remove-trailing-newline");
- }
-}
-
-/**
- * gtk_source_file_loader_get_remove_trailing_newline:
- * @loader: a #GtkSourceFileLoader.
- *
- * Returns: whether to remove the trailing newline.
- * Since: 3.14
- */
-gboolean
-gtk_source_file_loader_get_remove_trailing_newline (GtkSourceFileLoader *loader)
-{
- g_return_val_if_fail (GTK_SOURCE_IS_FILE_LOADER (loader), TRUE);
-
- return loader->priv->remove_trailing_newline;
-}
-
-/**
* gtk_source_file_loader_load_async:
* @loader: a #GtkSourceFileLoader.
* @io_priority: the I/O priority of the request. E.g. %G_PRIORITY_LOW,
@@ -881,6 +817,8 @@ gtk_source_file_loader_load_async (GtkSourceFileLoader *loader,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ gboolean implicit_trailing_newline;
+
g_return_if_fail (GTK_SOURCE_IS_FILE_LOADER (loader));
g_return_if_fail (loader->priv->task == NULL);
@@ -896,13 +834,15 @@ gtk_source_file_loader_load_async (GtkSourceFileLoader *loader,
g_print ("Start loading\n");
});
+ implicit_trailing_newline = gtk_source_buffer_get_implicit_trailing_newline
(loader->priv->source_buffer);
+
/* The BufferOutputStream has a strong reference to the source_buffer.
* We create the BufferOutputStream here so we are sure that the
* source_buffer will not be destroyed during the file loading.
*/
loader->priv->output_stream = gtk_source_buffer_output_stream_new (loader->priv->source_buffer,
loader->priv->candidate_encodings,
-
loader->priv->remove_trailing_newline);
+ implicit_trailing_newline);
if (loader->priv->input_stream_property != NULL)
{
diff --git a/gtksourceview/gtksourcefileloader.h b/gtksourceview/gtksourcefileloader.h
index 2732d90..cf34d31 100644
--- a/gtksourceview/gtksourcefileloader.h
+++ b/gtksourceview/gtksourcefileloader.h
@@ -84,13 +84,6 @@ GFile *gtk_source_file_loader_get_file (GtkSourceFileLoader
*loader);
GInputStream *gtk_source_file_loader_get_input_stream
(GtkSourceFileLoader *loader);
-void gtk_source_file_loader_set_remove_trailing_newline
- (GtkSourceFileLoader *loader,
- gboolean
remove_trailing_newline);
-
-gboolean gtk_source_file_loader_get_remove_trailing_newline
- (GtkSourceFileLoader *loader);
-
void gtk_source_file_loader_load_async (GtkSourceFileLoader *loader,
gint io_priority,
GCancellable *cancellable,
diff --git a/gtksourceview/gtksourcefilesaver.c b/gtksourceview/gtksourcefilesaver.c
index ee0c38b..937dbd1 100644
--- a/gtksourceview/gtksourcefilesaver.c
+++ b/gtksourceview/gtksourcefilesaver.c
@@ -62,7 +62,6 @@ enum
PROP_ENCODING,
PROP_NEWLINE_TYPE,
PROP_COMPRESSION_TYPE,
- PROP_ENSURE_TRAILING_NEWLINE,
PROP_CREATE_BACKUP
};
@@ -111,7 +110,6 @@ struct _GtkSourceFileSaverPrivate
GFileInfo *info;
- guint ensure_trailing_newline : 1;
guint create_backup : 1;
guint tried_mount : 1;
};
@@ -156,10 +154,6 @@ gtk_source_file_saver_set_property (GObject *object,
gtk_source_file_saver_set_compression_type (saver, g_value_get_enum (value));
break;
- case PROP_ENSURE_TRAILING_NEWLINE:
- gtk_source_file_saver_set_ensure_trailing_newline (saver, g_value_get_boolean
(value));
- break;
-
case PROP_CREATE_BACKUP:
gtk_source_file_saver_set_create_backup (saver, g_value_get_boolean (value));
break;
@@ -200,10 +194,6 @@ gtk_source_file_saver_get_property (GObject *object,
g_value_set_enum (value, saver->priv->compression_type);
break;
- case PROP_ENSURE_TRAILING_NEWLINE:
- g_value_set_boolean (value, saver->priv->ensure_trailing_newline);
- break;
-
case PROP_CREATE_BACKUP:
g_value_set_boolean (value, saver->priv->create_backup);
break;
@@ -341,23 +331,6 @@ gtk_source_file_saver_class_init (GtkSourceFileSaverClass *klass)
G_PARAM_STATIC_STRINGS));
/**
- * GtkSourceFileSaver:ensure-trailing-newline:
- *
- * Ensure the file ends with a trailing newline.
- *
- * Since: 3.14
- */
- g_object_class_install_property (object_class,
- PROP_ENSURE_TRAILING_NEWLINE,
- g_param_spec_boolean ("ensure-trailing-newline",
- _("Ensure Trailing Newline"),
- NULL,
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
-
- /**
* GtkSourceFileSaver:create-backup:
*
* Create a backup before saving the file.
@@ -996,45 +969,6 @@ gtk_source_file_saver_get_compression_type (GtkSourceFileSaver *saver)
}
/**
- * gtk_source_file_saver_set_ensure_trailing_newline:
- * @saver: a #GtkSourceFileSaver.
- * @ensure_trailing_newline: whether the file should end with a trailing
- * newline.
- *
- * Since: 3.14
- */
-void
-gtk_source_file_saver_set_ensure_trailing_newline (GtkSourceFileSaver *saver,
- gboolean ensure_trailing_newline)
-{
- g_return_if_fail (GTK_SOURCE_IS_FILE_SAVER (saver));
- g_return_if_fail (saver->priv->task == NULL);
-
- ensure_trailing_newline = ensure_trailing_newline != FALSE;
-
- if (saver->priv->ensure_trailing_newline != ensure_trailing_newline)
- {
- saver->priv->ensure_trailing_newline = ensure_trailing_newline;
- g_object_notify (G_OBJECT (saver), "ensure-trailing-newline");
- }
-}
-
-/**
- * gtk_source_file_saver_get_ensure_trailing_newline:
- * @saver: a #GtkSourceFileSaver.
- *
- * Returns: whether the file should end with a trailing newline.
- * Since: 3.14
- */
-gboolean
-gtk_source_file_saver_get_ensure_trailing_newline (GtkSourceFileSaver *saver)
-{
- g_return_val_if_fail (GTK_SOURCE_IS_FILE_SAVER (saver), TRUE);
-
- return saver->priv->ensure_trailing_newline;
-}
-
-/**
* gtk_source_file_saver_set_create_backup:
* @saver: a #GtkSourceFileSaver.
* @create_backup: whether to create a backup before saving the file.
@@ -1100,6 +1034,8 @@ gtk_source_file_saver_save_async (GtkSourceFileSaver *saver,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ gboolean implicit_trailing_newline;
+
g_return_if_fail (GTK_SOURCE_IS_FILE_SAVER (saver));
g_return_if_fail (saver->priv->task == NULL);
g_return_if_fail (saver->priv->source_buffer != NULL);
@@ -1116,13 +1052,15 @@ gtk_source_file_saver_save_async (GtkSourceFileSaver *saver,
g_print ("Start saving\n");
});
+ implicit_trailing_newline = gtk_source_buffer_get_implicit_trailing_newline
(saver->priv->source_buffer);
+
/* The BufferInputStream has a strong reference to the source_buffer.
* We create the BufferInputStream here so we are sure that the
* source_buffer will not be destroyed during the file saving.
*/
saver->priv->input_stream = _gtk_source_buffer_input_stream_new (GTK_TEXT_BUFFER
(saver->priv->source_buffer),
saver->priv->newline_type,
-
saver->priv->ensure_trailing_newline);
+ implicit_trailing_newline);
begin_write (saver);
}
diff --git a/gtksourceview/gtksourcefilesaver.h b/gtksourceview/gtksourcefilesaver.h
index 2649310..d2e988d 100644
--- a/gtksourceview/gtksourcefilesaver.h
+++ b/gtksourceview/gtksourcefilesaver.h
@@ -79,13 +79,6 @@ void gtk_source_file_saver_set_compression_type
GtkSourceCompressionType gtk_source_file_saver_get_compression_type
(GtkSourceFileSaver *saver);
-void gtk_source_file_saver_set_ensure_trailing_newline
- (GtkSourceFileSaver *saver,
- gboolean
ensure_trailing_newline);
-
-gboolean gtk_source_file_saver_get_ensure_trailing_newline
- (GtkSourceFileSaver *saver);
-
void gtk_source_file_saver_set_create_backup
(GtkSourceFileSaver *saver,
gboolean create_backup);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]