Class: GtkSource::FileSaver

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Constructor Details

#initialize(buffer, file, target_location) ⇒ GtkSource::FileSaver

Creates a new Gtk::SourceFileSaver object with a target location.

When the file saving is finished successfully, target_location is set to the file's [propertyFile:location] property. If an error occurs, the previous valid location is still available in [classFile].

This constructor is suitable for a "save as" operation, or for saving a new buffer for the first time.

Parameters:

  • buffer (GtkSource::Buffer)

    the Gtk::SourceBuffer to save.

  • file (GtkSource::File)

    the Gtk::SourceFile.

  • target_location (Gio::File)

    the #GFile where to save the buffer to.

Instance Method Details

#bufferGtkSource::Buffer

The Gtk::SourceBuffer to save. The #GtkSourceFileSaver object has a weak reference to the buffer.

Returns:

#buffer=(buffer) ⇒ GtkSource::Buffer

The Gtk::SourceBuffer to save. The #GtkSourceFileSaver object has a weak reference to the buffer.

Parameters:

Returns:

#compression_typeGtkSource::CompressionType

The compression type.

Returns:

#compression_type=(compression_type) ⇒ GtkSource::CompressionType

The compression type.

Parameters:

Returns:

#encodingGtkSource::Encoding

The file's encoding.

Returns:

  • (GtkSource::Encoding)

    encoding

#encoding=(encoding) ⇒ GtkSource::Encoding

The file's encoding.

Parameters:

  • encoding (GtkSource::Encoding)

Returns:

  • (GtkSource::Encoding)

    encoding

  • (GtkSource::Encoding)

    encoding

#fileGtkSource::File

The Gtk::SourceFile. The #GtkSourceFileSaver object has a weak reference to the file.

Returns:

#file=(file) ⇒ GtkSource::File

The Gtk::SourceFile. The #GtkSourceFileSaver object has a weak reference to the file.

Parameters:

Returns:

#flagsGtkSource::FileSaverFlags

File saving flags.

Returns:

#flags=(flags) ⇒ GtkSource::FileSaverFlags

File saving flags.

Parameters:

Returns:

#locationGio::File

The #GFile where to save the buffer. By default the location is taken from the Gtk::SourceFile at construction time.

Returns:

  • (Gio::File)

    location

#location=(location) ⇒ Gio::File

The #GFile where to save the buffer. By default the location is taken from the Gtk::SourceFile at construction time.

Parameters:

  • location (Gio::File)

Returns:

  • (Gio::File)

    location

  • (Gio::File)

    location

#newline_typeGtkSource::NewlineType

The newline type.

Returns:

#newline_type=(newline_type) ⇒ GtkSource::NewlineType

The newline type.

Parameters:

Returns:

#save_async(io_priority, cancellable, progress_callback, progress_callback_data, progress_callback_notify, callback, user_data) ⇒ nil

Saves asynchronously the buffer into the file.

See the [ifaceGio.AsyncResult] documentation to know how to use this function.

Parameters:

  • io_priority (Integer)

    the I/O priority of the request. E.g. %G_PRIORITY_LOW, %G_PRIORITY_DEFAULT or %G_PRIORITY_HIGH.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • progress_callback (Gio::FileProgressCallback)

    function to call back with progress information, or nil if progress information is not needed.

  • progress_callback_data (GObject)

    user data to pass to progress_callback.

  • progress_callback_notify (GLib::DestroyNotify)

    function to call on progress_callback_data when the progress_callback is no longer needed, or nil.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback to call when the request is satisfied.

  • user_data (GObject)

    user data to pass to callback.

Returns:

  • (nil)

#save_finish(result) ⇒ Boolean

Finishes a file saving started with [methodFileSaver.save_async].

If the file has been saved successfully, the following [classFile] properties will be updated: the location, the encoding, the newline type and the compression type.

Since the 3.20 version, [methodGtk.TextBuffer.set_modified] is called with false if the file has been saved successfully.

Parameters:

  • result (Gio::AsyncResult)

    a GAsync::Result.

Returns:

  • (Boolean)

    whether the file was saved successfully.