GtkSource.File

g GObject.Object GObject.Object GtkSource.File GtkSource.File GObject.Object->GtkSource.File

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

check_file_on_disk ()

get_compression_type ()

get_encoding ()

get_location ()

get_newline_type ()

is_deleted ()

is_externally_modified ()

is_local ()

is_readonly ()

set_location (location)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

compression-type

GtkSource.CompressionType

r

encoding

GtkSource.Encoding

r

location

Gio.File

r/w/c

newline-type

GtkSource.NewlineType

r

read-only

bool

r

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class GtkSource.File(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GtkSource.FileClass

On-disk representation of a [class`Buffer`].

A GtkSourceFile object is the on-disk representation of a [class`Buffer`]. With a GtkSourceFile, you can create and configure a [class`FileLoader`] and [class`FileSaver`] which take by default the values of the GtkSourceFile properties (except for the file loader which auto-detect some properties). On a successful load or save operation, the GtkSourceFile properties are updated. If an operation fails, the GtkSourceFile properties have still the previous valid values.

classmethod new()
Returns:

a new GtkSource.File object.

Return type:

GtkSource.File

check_file_on_disk()

Checks synchronously the file on disk, to know whether the file is externally modified, or has been deleted, and whether the file is read-only.

GtkSource.File doesn’t create a [class`Gio`.FileMonitor] to track those properties, so this function needs to be called instead. Creating lots of [class`Gio`.FileMonitor]’s would take lots of resources.

Since this function is synchronous, it is advised to call it only on local files. See [method`File`.is_local].

get_compression_type()
Returns:

the compression type.

Return type:

GtkSource.CompressionType

get_encoding()
Returns:

the character encoding.

Return type:

GtkSource.Encoding

The encoding is initially None. After a successful file loading or saving operation, the encoding is non-None.

get_location()
Returns:

the Gio.File.

Return type:

Gio.File

get_newline_type()
Returns:

the newline type.

Return type:

GtkSource.NewlineType

is_deleted()
Returns:

whether the file has been deleted.

Return type:

bool

Returns whether the file has been deleted. If the [property`File`:py:data::location<GtkSource.File.props.location>] is None, returns False.

To have an up-to-date value, you must first call [method`File`.check_file_on_disk].

is_externally_modified()
Returns:

whether the file is externally modified.

Return type:

bool

Returns whether the file is externally modified. If the [property`File`:py:data::location<GtkSource.File.props.location>] is None, returns False.

To have an up-to-date value, you must first call [method`File`.check_file_on_disk].

is_local()
Returns:

whether the file is local.

Return type:

bool

Returns whether the file is local. If the [property`File`:py:data::location<GtkSource.File.props.location>] is None, returns False.

is_readonly()
Returns:

whether the file is read-only.

Return type:

bool

Returns whether the file is read-only. If the [property`File`:py:data::location<GtkSource.File.props.location>] is None, returns False.

To have an up-to-date value, you must first call [method`File`.check_file_on_disk].

set_location(location)
Parameters:

location (Gio.File or None) – the new Gio.File, or None.

Sets the location.

Property Details

GtkSource.File.props.compression_type
Name:

compression-type

Type:

GtkSource.CompressionType

Default Value:

GtkSource.CompressionType.NONE

Flags:

READABLE

The compression type.

GtkSource.File.props.encoding
Name:

encoding

Type:

GtkSource.Encoding

Default Value:

None

Flags:

READABLE

The character encoding, initially None. After a successful file loading or saving operation, the encoding is non-None.

GtkSource.File.props.location
Name:

location

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The location.

GtkSource.File.props.newline_type
Name:

newline-type

Type:

GtkSource.NewlineType

Default Value:

GtkSource.NewlineType.LF

Flags:

READABLE

The line ending type.

GtkSource.File.props.read_only
Name:

read-only

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the file is read-only or not. The value of this property is not updated automatically (there is no file monitors).