GtkSource.FileSaver¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
|||
r/w/c |
|||
r/w/c |
|||
r/w/co |
|||
r/w/c |
|||
r/w/co |
|||
r/w/c |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class GtkSource.FileSaver(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Save a [class`Buffer`] into a file.
A
GtkSourceFileSaver
object permits to save a [class`Buffer`] into a [iface`Gio`.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 [method`FileSaver`.save_async].
- classmethod new(buffer, file)¶
- Parameters:
buffer (
GtkSource.Buffer
) – theGtkSource.Buffer
to save.file (
GtkSource.File
) – theGtkSource.File
.
- Returns:
a new
GtkSource.FileSaver
object.- Return type:
Creates a new
GtkSource.FileSaver
object. The buffer will be saved to the [class`File`]’s location.This constructor is suitable for a simple “save” operation, when the file already contains a non-
None
[property`File`:py:data::location<GtkSource.FileSaver.props.location>].
- classmethod new_with_target(buffer, file, target_location)¶
- Parameters:
buffer (
GtkSource.Buffer
) – theGtkSource.Buffer
to save.file (
GtkSource.File
) – theGtkSource.File
.target_location (
Gio.File
) – theGio.File
where to save the buffer to.
- Returns:
a new
GtkSource.FileSaver
object.- Return type:
Creates a new
GtkSource.FileSaver
object with a target location.When the file saving is finished successfully, target_location is set to the file's [property`File`:py:data::location<GtkSource.FileSaver.props.location>] property. If an error occurs, the previous valid location is still available in [class`File`].
This constructor is suitable for a “save as” operation, or for saving a new buffer for the first time.
- get_buffer()¶
- Returns:
the
GtkSource.Buffer
to save.- Return type:
- get_compression_type()¶
- Returns:
the compression type.
- Return type:
- get_encoding()¶
- Returns:
the encoding.
- Return type:
- get_file()¶
- Returns:
the
GtkSource.File
.- Return type:
- get_flags()¶
- Returns:
the flags.
- Return type:
- get_newline_type()¶
- Returns:
the newline type.
- Return type:
- save_async(io_priority, cancellable, progress_callback, progress_callback_data, callback, *user_data)¶
- Parameters:
io_priority (
int
) – the I/O priority of the request. E.g.GLib.PRIORITY_LOW
,GLib.PRIORITY_DEFAULT
orGLib.PRIORITY_HIGH
.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.progress_callback (
Gio.FileProgressCallback
orNone
) – function to call back with progress information, orNone
if progress information is not needed.progress_callback_data (
object
orNone
) – user data to pass to progress_callback.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfied.
Saves asynchronously the buffer into the file.
See the [iface`Gio`.AsyncResult] documentation to know how to use this function.
- save_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Raises:
- Returns:
whether the file was saved successfully.
- Return type:
Finishes a file saving started with [method`FileSaver`.save_async].
If the file has been saved successfully, the following [class`File`] properties will be updated: the location, the encoding, the newline type and the compression type.
Since the 3.20 version, [method`Gtk`.TextBuffer.set_modified] is called with
False
if the file has been saved successfully.
- set_compression_type(compression_type)¶
- Parameters:
compression_type (
GtkSource.CompressionType
) – the new compression type.
Sets the compression type. By default the compression type is taken from the
GtkSource.File
.
- set_encoding(encoding)¶
- Parameters:
encoding (
GtkSource.Encoding
orNone
) – the new encoding, orNone
for UTF-8.
Sets the encoding. If encoding is
None
, the UTF-8 encoding will be set.By default the encoding is taken from the
GtkSource.File
.
- set_flags(flags)¶
- Parameters:
flags (
GtkSource.FileSaverFlags
) – the new flags.
- set_newline_type(newline_type)¶
- Parameters:
newline_type (
GtkSource.NewlineType
) – the new newline type.
Sets the newline type. By default the newline type is taken from the
GtkSource.File
.
Property Details¶
- GtkSource.FileSaver.props.buffer¶
- Name:
buffer
- Type:
- Default Value:
- Flags:
The
GtkSource.Buffer
to save. TheGtkSource.FileSaver
object has a weak reference to the buffer.
- GtkSource.FileSaver.props.compression_type¶
- Name:
compression-type
- Type:
- Default Value:
- Flags:
The compression type.
- GtkSource.FileSaver.props.encoding¶
- Name:
encoding
- Type:
- Default Value:
- Flags:
The file’s encoding.
- GtkSource.FileSaver.props.file¶
- Name:
file
- Type:
- Default Value:
- Flags:
The
GtkSource.File
. TheGtkSource.FileSaver
object has a weak reference to the file.
- GtkSource.FileSaver.props.flags¶
- Name:
flags
- Type:
- Default Value:
- Flags:
File saving flags.
- GtkSource.FileSaver.props.location¶
- Name:
location
- Type:
- Default Value:
- Flags:
The
Gio.File
where to save the buffer. By default the location is taken from theGtkSource.File
at construction time.
- GtkSource.FileSaver.props.newline_type¶
- Name:
newline-type
- Type:
- Default Value:
- Flags:
The newline type.