Class File
- All Implemented Interfaces:
Proxy
Buffer
.
A GtkSourceFile
object is the on-disk representation of a Buffer
.
With a GtkSourceFile
, you can create and configure a FileLoader
and 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
File.Builder<B extends File.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionFile()
File
(MemorySegment address) Create a File proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected File
asParent()
Returns this instance as if it were its parent type.static File.Builder
<? extends File.Builder> builder()
AFile.Builder
object constructs aFile
with the specified properties.void
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.The encoding is initiallynull
.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the File classboolean
Returns whether the file has been deleted.boolean
Returns whether the file is externally modified.boolean
isLocal()
Returns whether the file is local.boolean
Returns whether the file is read-only.void
setLocation
(File location) Sets the location.void
Sets aMountOperationFactory
function that will be called when aMountOperation
must be created.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
File
Create a File proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
File
public File()
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
checkFileOnDisk
public void checkFileOnDisk()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.GtkSourceFile
doesn't create aFileMonitor
to track those properties, so this function needs to be called instead. Creating lots ofFileMonitor
's would take lots of resources.Since this function is synchronous, it is advised to call it only on local files. See
isLocal()
. -
getCompressionType
-
getEncoding
The encoding is initiallynull
. After a successful file loading or saving operation, the encoding is non-null
.- Returns:
- the character encoding.
-
getLocation
-
getNewlineType
-
isDeleted
public boolean isDeleted()Returns whether the file has been deleted. If theFile:location
isnull
, returnsfalse
.To have an up-to-date value, you must first call
checkFileOnDisk()
.- Returns:
- whether the file has been deleted.
-
isExternallyModified
public boolean isExternallyModified()Returns whether the file is externally modified. If theFile:location
isnull
, returnsfalse
.To have an up-to-date value, you must first call
checkFileOnDisk()
.- Returns:
- whether the file is externally modified.
-
isLocal
public boolean isLocal()Returns whether the file is local. If theFile:location
isnull
, returnsfalse
.- Returns:
- whether the file is local.
-
isReadonly
public boolean isReadonly()Returns whether the file is read-only. If theFile:location
isnull
, returnsfalse
.To have an up-to-date value, you must first call
checkFileOnDisk()
.- Returns:
- whether the file is read-only.
-
setLocation
Sets the location.- Parameters:
location
- the newGFile
, ornull
.
-
setMountOperationFactory
Sets aMountOperationFactory
function that will be called when aMountOperation
must be created.This is useful for creating a
MountOperation
with the parentWindow
.If a mount operation factory isn't set,
MountOperation()
will be called.- Parameters:
callback
- aGtkSourceMountOperationFactory
to call when aGMountOperation
is needed.
-
builder
AFile.Builder
object constructs aFile
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withFile.Builder.build()
.
-