1 /*
2  * pluma-document-saver.h
3  * This file is part of pluma
4  *
5  * Copyright (C) 2005 - Paolo Maggi
6  * Copyrhing (C) 2007 - Paolo Maggi, Steve Frécinaux
7  * Copyright (C) 2012-2021 MATE Developers
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  */
24 
25 /*
26  * Modified by the pluma Team, 2005. See the AUTHORS file for a
27  * list of people on the pluma Team.
28  * See the ChangeLog files for a list of changes.
29  *
30  * $Id$
31  */
32 
33 #ifndef __PLUMA_DOCUMENT_SAVER_H__
34 #define __PLUMA_DOCUMENT_SAVER_H__
35 
36 #include <pluma/pluma-document.h>
37 
38 G_BEGIN_DECLS
39 
40 /*
41  * Type checking and casting macros
42  */
43 #define PLUMA_TYPE_DOCUMENT_SAVER              (pluma_document_saver_get_type())
44 #define PLUMA_DOCUMENT_SAVER(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), PLUMA_TYPE_DOCUMENT_SAVER, PlumaDocumentSaver))
45 #define PLUMA_DOCUMENT_SAVER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), PLUMA_TYPE_DOCUMENT_SAVER, PlumaDocumentSaverClass))
46 #define PLUMA_IS_DOCUMENT_SAVER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), PLUMA_TYPE_DOCUMENT_SAVER))
47 #define PLUMA_IS_DOCUMENT_SAVER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_DOCUMENT_SAVER))
48 #define PLUMA_DOCUMENT_SAVER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), PLUMA_TYPE_DOCUMENT_SAVER, PlumaDocumentSaverClass))
49 
50 /* Private structure type */
51 typedef struct _PlumaDocumentSaverPrivate PlumaDocumentSaverPrivate;
52 
53 /*
54  * Main object structure
55  */
56 typedef struct _PlumaDocumentSaver PlumaDocumentSaver;
57 
58 struct _PlumaDocumentSaver
59 {
60     GObject object;
61     PlumaDocumentSaverPrivate *priv;
62 };
63 
64 /*
65  * Class definition
66  */
67 typedef struct _PlumaDocumentSaverClass PlumaDocumentSaverClass;
68 
69 struct _PlumaDocumentSaverClass
70 {
71     GObjectClass parent_class;
72 
73     /* Signals */
74     void (* saving) (PlumaDocumentSaver  *saver,
75                      gboolean             completed,
76                      const GError        *error);
77 };
78 
79 /*
80  * Public methods
81  */
82 GType                   pluma_document_saver_get_type             (void) G_GNUC_CONST;
83 
84 /* If enconding == NULL, the encoding will be autodetected */
85 PlumaDocumentSaver     *pluma_document_saver_new                  (PlumaDocument           *doc,
86                                                                    const gchar             *uri,
87                                                                    const PlumaEncoding     *encoding,
88                                                                    PlumaDocumentNewlineType newline_type,
89                                                                    PlumaDocumentSaveFlags   flags);
90 
91 void                    pluma_document_saver_saving               (PlumaDocumentSaver *saver,
92                                                                    gboolean            completed,
93                                                                    GError             *error);
94 void                    pluma_document_saver_save                 (PlumaDocumentSaver  *saver,
95                                                                    gint64              *old_mtime);
96 
97 #if 0
98 void                    pluma_document_saver_cancel               (PlumaDocumentSaver  *saver);
99 #endif
100 
101 PlumaDocument           *pluma_document_saver_get_document        (PlumaDocumentSaver  *saver);
102 
103 const gchar             *pluma_document_saver_get_uri             (PlumaDocumentSaver  *saver);
104 
105 /* If backup_uri is NULL no backup will be made */
106 const gchar             *pluma_document_saver_get_backup_uri      (PlumaDocumentSaver  *saver);
107 void                    *pluma_document_saver_set_backup_uri      (PlumaDocumentSaver  *saver,
108                                                                    const gchar         *backup_uri);
109 
110 /* Returns 0 if file size is unknown */
111 goffset                 pluma_document_saver_get_file_size        (PlumaDocumentSaver  *saver);
112 
113 goffset                 pluma_document_saver_get_bytes_written    (PlumaDocumentSaver  *saver);
114 
115 GFileInfo              *pluma_document_saver_get_info             (PlumaDocumentSaver  *saver);
116 
117 G_END_DECLS
118 
119 #endif  /* __PLUMA_DOCUMENT_SAVER_H__  */
120