[gedit/wip/reusable-code] DocumentSaver: remove dependency to GeditDocument
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/reusable-code] DocumentSaver: remove dependency to GeditDocument
- Date: Tue, 17 Sep 2013 20:25:14 +0000 (UTC)
commit 0205592c329414471c1c1a6363791aafb3d8997f
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Sep 16 19:22:06 2013 +0200
DocumentSaver: remove dependency to GeditDocument
A GtkTextBuffer is now sufficient.
gedit-document.h is still needed for GeditMountOperationFactory.
gedit/gedit-document-saver.c | 43 ++++++++++++++++++++---------------------
gedit/gedit-document-saver.h | 10 +++++++-
gedit/gedit-document.c | 2 +-
3 files changed, 30 insertions(+), 25 deletions(-)
---
diff --git a/gedit/gedit-document-saver.c b/gedit/gedit-document-saver.c
index d3e1c9e..0d85b13 100644
--- a/gedit/gedit-document-saver.c
+++ b/gedit/gedit-document-saver.c
@@ -28,11 +28,10 @@
#include <string.h>
#include "gedit-document-saver.h"
-#include "gedit-document.h"
#include "gedit/gedit-document-input-stream.h"
-#include "gedit-marshal.h"
#include "gedit/gedit-utils.h"
-#include "gedit-enum-types.h"
+#include "gedit/libgedit-enum-types.h"
+#include "gedit-marshal.h"
#define WRITE_CHUNK_SIZE 8192
@@ -55,7 +54,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
enum {
PROP_0,
- PROP_DOCUMENT,
+ PROP_BUFFER,
PROP_LOCATION,
PROP_ENCODING,
PROP_NEWLINE_TYPE,
@@ -83,7 +82,7 @@ static void check_modified_async (AsyncData *async);
struct _GeditDocumentSaverPrivate
{
GFileInfo *info;
- GeditDocument *document;
+ GtkTextBuffer *buffer;
GFile *location;
const GeditEncoding *encoding;
@@ -122,9 +121,9 @@ gedit_document_saver_set_property (GObject *object,
switch (prop_id)
{
- case PROP_DOCUMENT:
- g_return_if_fail (saver->priv->document == NULL);
- saver->priv->document = g_value_get_object (value);
+ case PROP_BUFFER:
+ g_return_if_fail (saver->priv->buffer == NULL);
+ saver->priv->buffer = g_value_get_object (value);
break;
case PROP_LOCATION:
g_return_if_fail (saver->priv->location == NULL);
@@ -162,8 +161,8 @@ gedit_document_saver_get_property (GObject *object,
switch (prop_id)
{
- case PROP_DOCUMENT:
- g_value_set_object (value, saver->priv->document);
+ case PROP_BUFFER:
+ g_value_set_object (value, saver->priv->buffer);
break;
case PROP_LOCATION:
g_value_set_object (value, saver->priv->location);
@@ -252,11 +251,11 @@ gedit_document_saver_class_init (GeditDocumentSaverClass *klass)
object_class->get_property = gedit_document_saver_get_property;
g_object_class_install_property (object_class,
- PROP_DOCUMENT,
- g_param_spec_object ("document",
- "Document",
- "The GeditDocument this GeditDocumentSaver is
associated with",
- GEDIT_TYPE_DOCUMENT,
+ PROP_BUFFER,
+ g_param_spec_object ("buffer",
+ "Buffer",
+ "The GtkTextBuffer this GeditDocumentSaver is
associated with",
+ GTK_TYPE_TEXT_BUFFER,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@@ -350,7 +349,7 @@ gedit_document_saver_init (GeditDocumentSaver *saver)
}
GeditDocumentSaver *
-gedit_document_saver_new (GeditDocument *doc,
+gedit_document_saver_new (GtkTextBuffer *buffer,
GFile *location,
const GeditEncoding *encoding,
GeditDocumentNewlineType newline_type,
@@ -358,13 +357,13 @@ gedit_document_saver_new (GeditDocument *doc,
GeditDocumentSaveFlags flags,
gboolean ensure_trailing_newline)
{
- g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL);
+ g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
if (encoding == NULL)
encoding = gedit_encoding_get_utf8 ();
return GEDIT_DOCUMENT_SAVER (g_object_new (GEDIT_TYPE_DOCUMENT_SAVER,
- "document", doc,
+ "buffer", buffer,
"location", location,
"encoding", encoding,
"newline_type", newline_type,
@@ -809,7 +808,7 @@ async_replace_ready_callback (GFile *source,
saver->priv->stream = G_OUTPUT_STREAM (base_stream);
}
- saver->priv->input = gedit_document_input_stream_new (GTK_TEXT_BUFFER (saver->priv->document),
+ saver->priv->input = gedit_document_input_stream_new (saver->priv->buffer,
saver->priv->newline_type,
saver->priv->ensure_trailing_newline);
@@ -1096,12 +1095,12 @@ gedit_document_saver_saving (GeditDocumentSaver *saver,
}
}
-GeditDocument *
-gedit_document_saver_get_document (GeditDocumentSaver *saver)
+GtkTextBuffer *
+gedit_document_saver_get_buffer (GeditDocumentSaver *saver)
{
g_return_val_if_fail (GEDIT_IS_DOCUMENT_SAVER (saver), NULL);
- return saver->priv->document;
+ return saver->priv->buffer;
}
GFile *
diff --git a/gedit/gedit-document-saver.h b/gedit/gedit-document-saver.h
index a929ef5..bcb4912 100644
--- a/gedit/gedit-document-saver.h
+++ b/gedit/gedit-document-saver.h
@@ -25,6 +25,9 @@
#ifndef __GEDIT_DOCUMENT_SAVER_H__
#define __GEDIT_DOCUMENT_SAVER_H__
+#include <gtk/gtk.h>
+#include "gedit/gedit-document-enums.h"
+#include "gedit/gedit-encodings.h"
#include "gedit-document.h"
G_BEGIN_DECLS
@@ -60,7 +63,7 @@ struct _GeditDocumentSaverClass
GType gedit_document_saver_get_type (void) G_GNUC_CONST;
/* If enconding == NULL, the encoding will be autodetected */
-GeditDocumentSaver *gedit_document_saver_new (GeditDocument *doc,
+GeditDocumentSaver *gedit_document_saver_new (GtkTextBuffer *buffer,
GFile *location,
const GeditEncoding *encoding,
GeditDocumentNewlineType newline_type,
@@ -71,15 +74,17 @@ GeditDocumentSaver *gedit_document_saver_new (GeditDocument
*d
void gedit_document_saver_saving (GeditDocumentSaver *saver,
gboolean completed,
GError *error);
+
void gedit_document_saver_save (GeditDocumentSaver *saver,
GTimeVal *old_mtime);
-GeditDocument *gedit_document_saver_get_document (GeditDocumentSaver *saver);
+GtkTextBuffer *gedit_document_saver_get_buffer (GeditDocumentSaver *saver);
GFile *gedit_document_saver_get_location (GeditDocumentSaver *saver);
/* If backup_uri is NULL no backup will be made */
const gchar *gedit_document_saver_get_backup_uri (GeditDocumentSaver *saver);
+
void *gedit_document_saver_set_backup_uri (GeditDocumentSaver *saver,
const gchar *backup_uri);
@@ -98,4 +103,5 @@ void gedit_document_saver_set_mount_operation_factory
G_END_DECLS
#endif /* __GEDIT_DOCUMENT_SAVER_H__ */
+
/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index d4b1483..150f5dc 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -1830,7 +1830,7 @@ gedit_document_save_real (GeditDocument *doc,
GEDIT_SETTINGS_ENSURE_TRAILING_NEWLINE);
/* create a saver, it will be destroyed once saving is complete */
- doc->priv->saver = gedit_document_saver_new (doc,
+ doc->priv->saver = gedit_document_saver_new (GTK_TEXT_BUFFER (doc),
location,
encoding,
newline_type,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]