### ----------------------------------------------------
### -- Gnome::Gtk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: lib/Gnome/Gtk3/FileChooser.rakumod
### ----------------------------------------------------
### -- Chunk 1 of 4
#TL:1:Gnome::Gtk3::FileChooser:

use v6;
#-------------------------------------------------------------------------------
=begin pod

=TITLE Gnome::Gtk3::FileChooser

=SUBTITLE File chooser interface used by Gnome::Gtk3::FileChooserWidget and Gnome::Gtk3::FileChooserDialog

=head1 Description

I<Gnome::Gtk3::FileChooser> is an interface that can be implemented by file selection widgets. In GTK+, the main objects that implement this interface are I<Gnome::Gtk3::FileChooserWidget>, I<Gnome::Gtk3::FileChooserDialog>, and I<Gnome::Gtk3::FileChooserButton>. You do not need to write an object that implements the I<Gnome::Gtk3::FileChooser> interface unless you are trying to adapt an existing file selector to expose a standard programming interface.

I<Gnome::Gtk3::FileChooser> allows for shortcuts to various places in the filesystem. In the default implementation these are displayed in the left pane. It may be a bit confusing at first that these shortcuts come from various sources and in various flavours, so lets explain the terminology here:

=item Bookmarks: are created by the user, by dragging folders from the right pane to the left pane, or by using the “Add”. Bookmarks can be renamed and deleted by the user.

=item Shortcuts: can be provided by the application. For example, a Paint program may want to add a shortcut for a Clipart folder. Shortcuts cannot be modified by the user.

=item Volumes: are provided by the underlying filesystem abstraction. They are the “roots” of the filesystem.

=head2 File Names and Encodings

When the user is finished selecting files in a I<Gnome::Gtk3::FileChooser>, your program can get the selected names either as filenames or as URIs. For URIs, the normal escaping rules are applied if the URI contains non-ASCII characters. However, filenames are always returned in the character set specified by the `G_FILENAME_ENCODING` environment variable. Please see the GLib documentation for more details about this variable.

This means that while you can pass the result of C<.get-filename()> to Raku C<IO>, you may not be able to directly set it as the text of a I<Gnome::Gtk3::Label> widget unless you convert it first to UTF-8, which all GTK+ widgets expect. You should use C<g_filename_to_utf8()> to convert filenames into strings that can be passed to GTK+ widgets. B<Note: open() and fopen() are C functions which are not needed by the Raku user. Furthermore, the Str Raku type is already UTF-8>.

=begin comment
=head2 Adding a Preview Widget

You can add a custom preview widget to a file chooser and then get notification about when the preview needs to be updated. To install a preview widget, use C<.set_preview_widget()>. Then, connect to the prop I<update-preview> signal to get notified when you need to update the contents of the preview.

Your callback should use C<gtk_file_chooser_get_preview_filename()> to see what needs previewing. Once you have generated the preview for the corresponding file, you must call C<gtk_file_chooser_set_preview_widget_active()> with a boolean flag (B<Int for Raku>) that indicates whether your callback could successfully generate a preview.

## Example: Using a Preview Widget ## {I<gtkfilechooser>-preview}
|[<!-- language="C" -->
{
  B<Gnome::Gtk3::Image> *preview;

  ...

  preview = C<gtk_image_new()>;

  gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
  g_signal_connect (my_file_chooser, "update-preview",
		    G_CALLBACK (update_preview_cb), preview);
}

static void
update_preview_cb (B<Gnome::Gtk3::FileChooser> *file_chooser, gpointer data)
{
  B<Gnome::Gtk3::Widget> *preview;
  char *filename;
  B<Gnome::Gdk3::Pixbuf> *pixbuf;
  gboolean have_preview;

  preview = GTK_WIDGET (data);
  filename = gtk_file_chooser_get_preview_filename (file_chooser);

  pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
  have_preview = (pixbuf != NULL);
  g_free (filename);

  gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
  if (pixbuf)
    g_object_unref (pixbuf);

  gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
}
]|
=end comment


=head2 Adding Extra Widgets

You can add extra widgets to a file chooser to provide options that are not present in the default design. For example, you can add a toggle button to give the user the option to open a file in read-only mode. You can use C<.set-extra-widget()> to insert additional widgets in a file chooser.

=begin comment
An example for adding extra widgets:
|[<!-- language="C" -->

  B<Gnome::Gtk3::Widget> *toggle;

  ...

  toggle = gtk_check_button_new_with_label ("Open file read-only");
  gtk_widget_show (toggle);
  gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
}
]|
=end comment

If you want to set more than one extra widget in the file chooser, you can a container such as a I<Gnome::Gtk3::Box> or a I<Gnome::Gtk3::Grid> and include your widgets in it. Then, set the container as the whole extra widget.


=head2 See Also

I<Gnome::Gtk3::FileChooserDialog>, I<Gnome::Gtk3::FileChooserWidget>, I<Gnome::Gtk3::FileChooserButton>


=head1 Synopsis
=head2 Declaration

  unit role Gnome::Gtk3::FileChooser;
  also is Gnome::GObject::Object;


=head2 Example to show how to get filenames from the dialog

  my Gnome::Gtk3::FileChooserDialog $file-select-dialog .= new(
    :build-id($target-widget-name)
  );

  # get-filenames() is from FileChooser class
  my Gnome::Glib::SList $fnames .= new(
    :native-object($file-select-dialog.get-filenames)
  );

  my @files-to-process = ();
  for ^$fnames.g-slist-length -> $i {
    @files-to-process.push($fnames.nth-data-str($i));
  }

  # get the file and directory names
  for @files-to-process -> $file {
    note "Process $file";
  };

  $fnames.g-slist-free;

=end pod
#-------------------------------------------------------------------------------
use NativeCall;

#use Gnome::N::X:api<1>;
use Gnome::N::N-GObject:api<1>;
use Gnome::N::NativeLib:api<1>;
use Gnome::N::GlibToRakuTypes:api<1>;

use Gnome::Glib::Error:api<1>;
use Gnome::Glib::SList:api<1>;

use Gnome::GObject::Object:api<1>;
#use Gnome::Gtk3::FileFilter:api<1>;

#-------------------------------------------------------------------------------
# Note that enums must be kept outside roles
=begin pod
=head1 Types
=end pod
#-------------------------------------------------------------------------------
=begin pod
=head2 enum GtkFileChooserAction

Describes whether a I<Gnome::Gtk3::FileChooser> is being used to open existing files or to save to a possibly new file.

=item GTK_FILE_CHOOSER_ACTION_OPEN: Indicates open mode. The file chooser will only let the user pick an existing file.
=item GTK_FILE_CHOOSER_ACTION_SAVE: Indicates save mode. The file chooser will let the user pick an existing file, or type in a new filename.
=item GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: Indicates an Open mode for selecting folders. The file chooser will let the user pick an existing folder.
=item GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: Indicates a mode for creating a new folder. The file chooser will let the user name an existing or new folder.

=end pod

#TE:2:GtkFileChooserAction:t/FileChooserDialog.t
enum GtkFileChooserAction is export (
  'GTK_FILE_CHOOSER_ACTION_OPEN',
  'GTK_FILE_CHOOSER_ACTION_SAVE',
  'GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER',
  'GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GtkFileChooserConfirmation

Used as a return value of handlers for the prop I<confirm-overwrite> signal of a I<Gnome::Gtk3::FileChooser>. This value determines whether the file chooser will present the stock confirmation dialog, accept the user’s choice of a filename, or let the user choose another filename.

Since: 2.8

=item GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM: The file chooser will present its stock dialog to confirm about overwriting an existing file.
=item GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME: The file chooser will terminate and accept the user’s choice of a file name.
=item GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN: The file chooser will continue running, so as to let the user select another file name.

=end pod

#TE:0:GtkFileChooserConfirmation:
enum GtkFileChooserConfirmation is export (
  'GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM',
  'GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME',
  'GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN'
);

#-------------------------------------------------------------------------------
=begin pod
=head2 enum GtkFileChooserError

These identify the various errors that can occur while calling I<Gnome::Gtk3::FileChooser> functions.

=item GTK_FILE_CHOOSER_ERROR_NONEXISTENT: Indicates that a file does not exist.
=item GTK_FILE_CHOOSER_ERROR_BAD_FILENAME: Indicates a malformed filename.
=item GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS: Indicates a duplicate path (e.g. when adding a bookmark).
=item GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME: Indicates an incomplete hostname (e.g. "http://foo" without a slash after that).

=end pod

#TE:0:GtkFileChooserError:
enum GtkFileChooserError is export (
  'GTK_FILE_CHOOSER_ERROR_NONEXISTENT',
  'GTK_FILE_CHOOSER_ERROR_BAD_FILENAME',
  'GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS',
  'GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME'
);

#-------------------------------------------------------------------------------
# See /usr/include/gtk-3.0/gtk/gtkfilechooser.h
# https://developer.gnome.org/gtk3/stable/GtkFileChooser.html
unit role Gnome::Gtk3::FileChooser:auth<github:MARTIMM>:api<1>;
also is Gnome::GObject::Object;

#-------------------------------------------------------------------------------
my Bool $signals-added = False;
#-------------------------------------------------------------------------------
=begin pod
=head1 Methods
=end pod

#-------------------------------------------------------------------------------
#TM:2:new():interfacing:t/FileChooserDialog.t
# interfaces are not instantiated
#submethod BUILD ( *%options ) { }

#-------------------------------------------------------------------------------
# setup signals from interface
method _add_file_chooser_signal_types ( Str $class-name ) {

  self.add-signal-types( $class-name,
    :w0< current-folder-changed file-activated selection-changed
         update-preview confirm-overwrite
       >,
  );
}

#-------------------------------------------------------------------------------
# no pod. user does not have to know about it.
# Hook for modules using this interface. Same principle as _fallback but
# does not need callsame. Also this method must be usable without
# an instated object
method _file_chooser_interface ( Str $native-sub --> Callable ) {

  my Str $new-patt = $native-sub.subst( '_', '-', :g);

  my Callable $s;
  try { $s = &::("gtk_file_chooser_$native-sub"); };
  if ?$s {
    Gnome::N::deprecate(
      "gtk_file_chooser_$native-sub", $new-patt, '0.47.4', '0.50.0'
    );
  }

  else {
    try { $s = &::("gtk_$native-sub"); } unless ?$s;
    if ?$s {
      Gnome::N::deprecate(
        "gtk_$native-sub", $new-patt.subst('file-chooser-'),
        '0.47.4', '0.50.0'
      );
    }

    else {
      try { $s = &::($native-sub); } if !$s and $native-sub ~~ m/^ 'gtk_' /;
      if ?$s {
        Gnome::N::deprecate(
          "$native-sub", $new-patt.subst('gtk-file-chooser-'),
          '0.47.4', '0.50.0'
        );
      }
    }
  }

  $s
}


#-------------------------------------------------------------------------------
#TM:0:add-choice:
=begin pod
=head2 add-choice

Adds a 'choice' to the file chooser. This is typically implemented as a combobox or, for boolean choices, as a checkbutton. You can select a value using C<set_choice()> before the dialog is shown, and you can obtain the user-selected value in the I<response> signal handler using C<get-choice()>.

Compare C<set-extra-widget()>.

  method add-choice ( Str $id, Str $label, CArray[Str] $options, CArray[Str] $option_labels )

=item $id; id for the added choice
=item $label; user-visible label for the added choice
=item $options; ids for the options of the choice, or C<undefined> for a boolean choice
=item $option_labels; user-visible labels for the options, must be the same length as I<options>
=end pod

method add-choice ( Str $id, Str $label, CArray[Str] $options, CArray[Str] $option_labels ) {
  gtk_file_chooser_add_choice( self._f('GtkFileChooser'), $id, $label, $options, $option_labels);
}

sub gtk_file_chooser_add_choice (
  N-GObject $chooser, gchar-ptr $id, gchar-ptr $label, gchar-pptr $options, gchar-pptr $option_labels
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:add-filter:
=begin pod
=head2 add-filter

Adds I<filter> to the list of filters that the user can select between. When a filter is selected, only files that are passed by that filter are displayed.

Note that the I<chooser> takes ownership of the filter, so you have to ref and sink it if you want to keep a reference.

  method add-filter ( N-GObject() $filter )

=item $filter; a B<Gnome::Gtk3::FileFilter>
=end pod

method add-filter ( N-GObject() $filter ) {
  gtk_file_chooser_add_filter( self._f('GtkFileChooser'), $filter);
}

sub gtk_file_chooser_add_filter (
  N-GObject $chooser, N-GObject $filter
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:add-shortcut-folder:
=begin pod
=head2 add-shortcut-folder

Adds a folder to be displayed with the shortcut folders in a file chooser. Note that shortcut folders do not get saved, as they are provided by the application. For example, you can use this to add a “/usr/share/mydrawprogram/Clipart” folder to the volume list.

Returns: C<True> if the folder could be added successfully, C<False> otherwise. In the latter case, the I<error> will be set as appropriate.

  method add-shortcut-folder ( Str $folder, N-GError $error --> Bool )

=item $folder; (type filename): filename of the folder to add
=item $error; location to store error, or C<undefined>
=end pod

method add-shortcut-folder ( Str $folder, $error is copy --> Bool ) {
  $error .= _get-native-object-no-reffing unless $error ~~ N-GError;
  gtk_file_chooser_add_shortcut_folder( self._f('GtkFileChooser'), $folder, $error).Bool
}

sub gtk_file_chooser_add_shortcut_folder (
  N-GObject $chooser, gchar-ptr $folder, N-GError $error --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:add-shortcut-folder-uri:
=begin pod
=head2 add-shortcut-folder-uri

Adds a folder URI to be displayed with the shortcut folders in a file chooser. Note that shortcut folders do not get saved, as they are provided by the application. For example, you can use this to add a “file:///usr/share/mydrawprogram/Clipart” folder to the volume list.

Returns: C<True> if the folder could be added successfully, C<False> otherwise. In the latter case, the I<error> will be set as appropriate.

  method add-shortcut-folder-uri ( Str $uri, N-GError $error --> Bool )

=item $uri; URI of the folder to add
=item $error; location to store error, or C<undefined>
=end pod

method add-shortcut-folder-uri ( Str $uri, $error is copy --> Bool ) {
  $error .= _get-native-object-no-reffing unless $error ~~ N-GError;
  gtk_file_chooser_add_shortcut_folder_uri( self._f('GtkFileChooser'), $uri, $error).Bool
}

sub gtk_file_chooser_add_shortcut_folder_uri (
  N-GObject $chooser, gchar-ptr $uri, N-GError $error --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:error-quark:
=begin pod
=head2 error-quark

Registers an error quark for B<Gnome::Gtk3::FileChooser> if necessary.

Returns: The error quark used for B<Gnome::Gtk3::FileChooser> errors.

  method error-quark ( --> UInt )

=end pod

method error-quark ( --> UInt ) {
  gtk_file_chooser_error_quark( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_error_quark (
   --> GQuark
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-action:
=begin pod
=head2 get-action

Gets the type of operation that the file chooser is performing; see C<set_action()>.

Returns: the action that the file selector is performing

  method get-action ( --> GtkFileChooserAction )

=end pod

method get-action ( --> GtkFileChooserAction ) {
  GtkFileChooserAction(gtk_file_chooser_get_action( self._f('GtkFileChooser')))
}

sub gtk_file_chooser_get_action (
  N-GObject $chooser --> GEnum
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-choice:
=begin pod
=head2 get-choice

Gets the currently selected option in the 'choice' with the given ID.

Returns: the ID of the currenly selected option

  method get-choice ( Str $id --> Str )

=item $id; the ID of the choice to get
=end pod

method get-choice ( Str $id --> Str ) {
  gtk_file_chooser_get_choice( self._f('GtkFileChooser'), $id)
}

sub gtk_file_chooser_get_choice (
  N-GObject $chooser, gchar-ptr $id --> gchar-ptr
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-create-folders:
=begin pod
=head2 get-create-folders

Gets whether file choser will offer to create new folders. See C<set_create_folders()>.

Returns: C<True> if the Create Folder button should be displayed.

  method get-create-folders ( --> Bool )

=end pod

method get-create-folders ( --> Bool ) {
  gtk_file_chooser_get_create_folders( self._f('GtkFileChooser')).Bool
}

sub gtk_file_chooser_get_create_folders (
  N-GObject $chooser --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-current-folder:
=begin pod
=head2 get-current-folder

Gets the current folder of I<chooser> as a local filename. See C<set_current_folder()>.

Note that this is the folder that the file chooser is currently displaying (e.g. "/home/username/Documents"), which is not the same as the currently-selected folder if the chooser is in C<GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER> mode (e.g. "/home/username/Documents/selected-folder/". To get the currently-selected folder in that mode, use C<get_uri()> as the usual way to get the selection.

Returns:  (type filename): the full path of the current folder, or C<undefined> if the current path cannot be represented as a local filename. Free with C<g_free()>. This function will also return C<undefined> if the file chooser was unable to load the last folder that was requested from it; for example, as would be for calling C<set_current_folder()> on a nonexistent folder.

  method get-current-folder ( --> Str )

=end pod

method get-current-folder ( --> Str ) {
  gtk_file_chooser_get_current_folder( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_current_folder (
  N-GObject $chooser --> gchar-ptr
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-current-folder-file:
=begin pod
=head2 get-current-folder-file

Gets the current folder of I<chooser> as B<Gnome::Gio::File>. See C<get_current_folder_uri()>.

Returns: the B<Gnome::Gio::File> for the current folder.

  method get-current-folder-file ( --> N-GObject )

=end pod

method get-current-folder-file ( --> N-GObject ) {
  gtk_file_chooser_get_current_folder_file( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_current_folder_file (
  N-GObject $chooser --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-current-folder-uri:
=begin pod
=head2 get-current-folder-uri

Gets the current folder of I<chooser> as an URI. See C<set_current_folder_uri()>.

Note that this is the folder that the file chooser is currently displaying (e.g. "file:///home/username/Documents"), which is not the same as the currently-selected folder if the chooser is in C<GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER> mode (e.g. "file:///home/username/Documents/selected-folder/". To get the currently-selected folder in that mode, use C<get_uri()> as the usual way to get the selection.

Returns: the URI for the current folder. Free with C<g_free()>. This function will also return C<undefined> if the file chooser was unable to load the last folder that was requested from it; for example, as would be for calling C<set_current_folder_uri()> on a nonexistent folder.

  method get-current-folder-uri ( --> Str )

=end pod

method get-current-folder-uri ( --> Str ) {
  gtk_file_chooser_get_current_folder_uri( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_current_folder_uri (
  N-GObject $chooser --> gchar-ptr
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-current-name:
=begin pod
=head2 get-current-name

Gets the current name in the file selector, as entered by the user in the text entry for “Name”.

This is meant to be used in save dialogs, to get the currently typed filename when the file itself does not exist yet. For example, an application that adds a custom extra widget to the file chooser for “file format” may want to change the extension of the typed filename based on the chosen format, say, from “.jpg” to “.png”.

Returns: The raw text from the file chooser’s “Name” entry. Free this with C<g_free()>. Note that this string is not a full pathname or URI; it is whatever the contents of the entry are. Note also that this string is in UTF-8 encoding, which is not necessarily the system’s encoding for filenames.

  method get-current-name ( --> Str )

=end pod

method get-current-name ( --> Str ) {
  gtk_file_chooser_get_current_name( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_current_name (
  N-GObject $chooser --> gchar-ptr
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-do-overwrite-confirmation:
=begin pod
=head2 get-do-overwrite-confirmation

Queries whether a file chooser is set to confirm for overwriting when the user types a file name that already exists.

Returns: C<True> if the file chooser will present a confirmation dialog; C<False> otherwise.

  method get-do-overwrite-confirmation ( --> Bool )

=end pod

method get-do-overwrite-confirmation ( --> Bool ) {
  gtk_file_chooser_get_do_overwrite_confirmation( self._f('GtkFileChooser')).Bool
}

sub gtk_file_chooser_get_do_overwrite_confirmation (
  N-GObject $chooser --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-extra-widget:
=begin pod
=head2 get-extra-widget

Gets the current extra widget; see C<set_extra_widget()>.

Returns: the current extra widget, or C<undefined>

  method get-extra-widget ( --> N-GObject )

=end pod

method get-extra-widget ( --> N-GObject ) {
  gtk_file_chooser_get_extra_widget( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_extra_widget (
  N-GObject $chooser --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-file:
=begin pod
=head2 get-file

Gets the B<Gnome::Gio::File> for the currently selected file in the file selector. If multiple files are selected, one of the files will be returned at random.

If the file chooser is in folder mode, this function returns the selected folder.

Returns: a selected B<Gnome::Gio::File>. You own the returned file; use C<g_object_unref()> to release it.

  method get-file ( --> N-GObject )

=end pod

method get-file ( --> N-GObject ) {
  gtk_file_chooser_get_file( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_file (
  N-GObject $chooser --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-filename:
=begin pod
=head2 get-filename

Gets the filename for the currently selected file in the file selector. The filename is returned as an absolute path. If multiple files are selected, one of the filenames will be returned at random.

If the file chooser is in folder mode, this function returns the selected folder.

Returns:  (type filename): The currently selected filename, or C<undefined> if no file is selected, or the selected file can't be represented with a local filename. Free with C<g_free()>.

  method get-filename ( --> Str )

=end pod

method get-filename ( --> Str ) {
  gtk_file_chooser_get_filename( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_filename (
  N-GObject $chooser --> gchar-ptr
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-filenames:
=begin pod
=head2 get-filenames

Lists all the selected files and subfolders in the current folder of I<chooser>. The returned names are full absolute paths. If files in the current folder cannot be represented as local filenames they will be ignored. (See C<get_uris()>)

Returns: (element-type filename) : a B<Gnome::Gio::SList> containing the filenames of all selected files and subfolders in the current folder. Free the returned list with C<g_slist_free()>, and the filenames with C<g_free()>.

  method get-filenames ( --> N-GSList )

=end pod

method get-filenames ( --> N-GSList ) {
  gtk_file_chooser_get_filenames( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_filenames (
  N-GObject $chooser --> N-GSList
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-files:
=begin pod
=head2 get-files

Lists all the selected files and subfolders in the current folder of I<chooser> as B<Gnome::Gio::File>. An internal function, see C<get_uris()>.

Returns: (element-type GFile) : a B<Gnome::Gio::SList> containing a B<Gnome::Gio::File> for each selected file and subfolder in the current folder. Free the returned list with C<g_slist_free()>, and the files with C<g_object_unref()>.

  method get-files ( --> N-GSList )

=end pod

method get-files ( --> N-GSList ) {
  gtk_file_chooser_get_files( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_files (
  N-GObject $chooser --> N-GSList
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-filter:
=begin pod
=head2 get-filter

Gets the current filter; see C<set_filter()>.

Returns: the current filter, or C<undefined>

  method get-filter ( --> N-GObject )

=end pod

method get-filter ( --> N-GObject ) {
  gtk_file_chooser_get_filter( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_filter (
  N-GObject $chooser --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-local-only:
=begin pod
=head2 get-local-only

Gets whether only local files can be selected in the file selector. See C<set_local_only()>

Returns: C<True> if only local files can be selected.

  method get-local-only ( --> Bool )

=end pod

method get-local-only ( --> Bool ) {
  gtk_file_chooser_get_local_only( self._f('GtkFileChooser')).Bool
}

sub gtk_file_chooser_get_local_only (
  N-GObject $chooser --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-preview-file:
=begin pod
=head2 get-preview-file

Gets the B<Gnome::Gio::File> that should be previewed in a custom preview Internal function, see C<get_preview_uri()>.

Returns: the B<Gnome::Gio::File> for the file to preview, or C<undefined> if no file is selected. Free with C<g_object_unref()>.

  method get-preview-file ( --> N-GObject )

=end pod

method get-preview-file ( --> N-GObject ) {
  gtk_file_chooser_get_preview_file( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_preview_file (
  N-GObject $chooser --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-preview-filename:
=begin pod
=head2 get-preview-filename

Gets the filename that should be previewed in a custom preview widget. See C<set_preview_widget()>.

Returns:  (type filename): the filename to preview, or C<undefined> if no file is selected, or if the selected file cannot be represented as a local filename. Free with C<g_free()>

  method get-preview-filename ( --> Str )

=end pod

method get-preview-filename ( --> Str ) {
  gtk_file_chooser_get_preview_filename( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_preview_filename (
  N-GObject $chooser --> gchar-ptr
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-preview-uri:
=begin pod
=head2 get-preview-uri

Gets the URI that should be previewed in a custom preview widget. See C<set_preview_widget()>.

Returns: the URI for the file to preview, or C<undefined> if no file is selected. Free with C<g_free()>.

  method get-preview-uri ( --> Str )

=end pod

method get-preview-uri ( --> Str ) {
  gtk_file_chooser_get_preview_uri( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_preview_uri (
  N-GObject $chooser --> gchar-ptr
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-preview-widget:
=begin pod
=head2 get-preview-widget

Gets the current preview widget; see C<set_preview_widget()>.

Returns: the current preview widget, or C<undefined>

  method get-preview-widget ( --> N-GObject )

=end pod

method get-preview-widget ( --> N-GObject ) {
  gtk_file_chooser_get_preview_widget( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_preview_widget (
  N-GObject $chooser --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-preview-widget-active:
=begin pod
=head2 get-preview-widget-active

Gets whether the preview widget set by C<set_preview_widget()> should be shown for the current filename. See C<set_preview_widget_active()>.

Returns: C<True> if the preview widget is active for the current filename.

  method get-preview-widget-active ( --> Bool )

=end pod

method get-preview-widget-active ( --> Bool ) {
  gtk_file_chooser_get_preview_widget_active( self._f('GtkFileChooser')).Bool
}

sub gtk_file_chooser_get_preview_widget_active (
  N-GObject $chooser --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-select-multiple:
=begin pod
=head2 get-select-multiple

Gets whether multiple files can be selected in the file selector. See C<set_select_multiple()>.

Returns: C<True> if multiple files can be selected.

  method get-select-multiple ( --> Bool )

=end pod

method get-select-multiple ( --> Bool ) {
  gtk_file_chooser_get_select_multiple( self._f('GtkFileChooser')).Bool
}

sub gtk_file_chooser_get_select_multiple (
  N-GObject $chooser --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-show-hidden:
=begin pod
=head2 get-show-hidden

Gets whether hidden files and folders are displayed in the file selector. See C<set_show_hidden()>.

Returns: C<True> if hidden files and folders are displayed.

  method get-show-hidden ( --> Bool )

=end pod

method get-show-hidden ( --> Bool ) {
  gtk_file_chooser_get_show_hidden( self._f('GtkFileChooser')).Bool
}

sub gtk_file_chooser_get_show_hidden (
  N-GObject $chooser --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-uri:
=begin pod
=head2 get-uri

Gets the URI for the currently selected file in the file selector. If multiple files are selected, one of the filenames will be returned at random.

If the file chooser is in folder mode, this function returns the selected folder.

Returns: The currently selected URI, or C<undefined> if no file is selected. If C<set_local_only()> is set to C<True> (the default) a local URI will be returned for any FUSE locations. Free with C<g_free()>

  method get-uri ( --> Str )

=end pod

method get-uri ( --> Str ) {
  gtk_file_chooser_get_uri( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_uri (
  N-GObject $chooser --> gchar-ptr
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-uris:
=begin pod
=head2 get-uris

Lists all the selected files and subfolders in the current folder of I<chooser>. The returned names are full absolute URIs.

Returns: (element-type utf8) : a B<Gnome::Gio::SList> containing the URIs of all selected files and subfolders in the current folder. Free the returned list with C<g_slist_free()>, and the filenames with C<g_free()>.

  method get-uris ( --> N-GSList )

=end pod

method get-uris ( --> N-GSList ) {
  gtk_file_chooser_get_uris( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_get_uris (
  N-GObject $chooser --> N-GSList
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-use-preview-label:
=begin pod
=head2 get-use-preview-label

Gets whether a stock label should be drawn with the name of the previewed file. See C<set_use_preview_label()>.

Returns: C<True> if the file chooser is set to display a label with the name of the previewed file, C<False> otherwise.

  method get-use-preview-label ( --> Bool )

=end pod

method get-use-preview-label ( --> Bool ) {
  gtk_file_chooser_get_use_preview_label( self._f('GtkFileChooser')).Bool
}

sub gtk_file_chooser_get_use_preview_label (
  N-GObject $chooser --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:list-filters:
=begin pod
=head2 list-filters

Lists the current set of user-selectable filters; see C<add_filter()>, C<remove_filter()>.

Returns: (element-type GtkFileFilter) (transfer container): a B<Gnome::Gio::SList> containing the current set of user selectable filters. The contents of the list are owned by GTK+, but you must free the list itself with C<g_slist_free()> when you are done with it.

  method list-filters ( --> N-GSList )

=end pod

method list-filters ( --> N-GSList ) {
  gtk_file_chooser_list_filters( self._f('GtkFileChooser'))
}

sub gtk_file_chooser_list_filters (
  N-GObject $chooser --> N-GSList
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:list-shortcut-folder-uris:
=begin pod
=head2 list-shortcut-folder-ur