FileSaver#
Superclasses: Object
Save a Buffer into a file.
A GtkSourceFileSaver object permits to save a Buffer into a
File.
A file saver should be used only for one save operation, including errors
handling. If an error occurs, you can reconfigure the saver and relaunch the
operation with save_async.
Constructors#
- class FileSaver
- classmethod new(buffer: Buffer, file: File) FileSaver#
- Creates a new - FileSaverobject. The- bufferwill be saved to the- File's location.- This constructor is suitable for a simple “save” operation, when the - filealready contains a non-- None- location.
 - classmethod new_with_target(buffer: Buffer, file: File, target_location: File) FileSaver#
- Creates a new - FileSaverobject with a target location.- When the file saving is finished successfully, - target_locationis set to the- file's- locationproperty. If an error occurs, the previous valid location is still available in- File.- This constructor is suitable for a “save as” operation, or for saving a new buffer for the first time. 
 
Methods#
- class FileSaver
- 
- get_compression_type() CompressionType#
 - get_flags() FileSaverFlags#
 - get_newline_type() NewlineType#
 - async save_async(self, io_priority: int, cancellable: Cancellable | None = None, progress_callback: Callable[[int, int, Any], None] | None = None) bool#
- This is the awaitable version of - save_async().- Parameters:
- io_priority – the I/O priority of the request. E.g. %G_PRIORITY_LOW, %G_PRIORITY_DEFAULT or %G_PRIORITY_HIGH. 
- cancellable – optional - Cancellableobject,- Noneto ignore.
- progress_callback – function to call back with progress information, or - Noneif progress information is not needed.
 
 
 - save_async(io_priority: int, cancellable: Cancellable | None = None, progress_callback: Callable[[int, int, Any], None] | None = None, progress_callback_data: Any = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
- Saves asynchronously the buffer into the file. - See the - AsyncResultdocumentation to know how to use this function.- Parameters:
- io_priority – the I/O priority of the request. E.g. %G_PRIORITY_LOW, %G_PRIORITY_DEFAULT or %G_PRIORITY_HIGH. 
- cancellable – optional - Cancellableobject,- Noneto ignore.
- progress_callback – function to call back with progress information, or - Noneif progress information is not needed.
- progress_callback_data – user data to pass to - progress_callback.
- callback – a - AsyncReadyCallbackto call when the request is satisfied.
- user_data – user data to pass to - callback.
 
 
 - save_finish(result: AsyncResult) bool#
- Finishes a file saving started with - save_async.- If the file has been saved successfully, the following - Fileproperties will be updated: the location, the encoding, the newline type and the compression type.- Since the 3.20 version, - set_modifiedis called with- Falseif the file has been saved successfully.- Parameters:
- result – a - AsyncResult.
 
 - set_compression_type(compression_type: CompressionType) None#
- Sets the compression type. By default the compression type is taken from the - File.- Parameters:
- compression_type – the new compression type. 
 
 - set_encoding(encoding: Encoding | None = None) None#
- Sets the encoding. If - encodingis- None, the UTF-8 encoding will be set.- By default the encoding is taken from the - File.- Parameters:
- encoding – the new encoding, or - Nonefor UTF-8.
 
 - set_flags(flags: FileSaverFlags) None#
- Parameters:
- flags – the new flags. 
 
 - set_newline_type(newline_type: NewlineType) None#
- Sets the newline type. By default the newline type is taken from the - File.- Parameters:
- newline_type – the new newline type. 
 
 
Properties#
- class FileSaver
- 
- props.compression_type: CompressionType#
- The type of the None singleton. 
 - props.flags: FileSaverFlags#
- The type of the None singleton. 
 - props.newline_type: NewlineType#
- The type of the None singleton.