package Gtk_File_Chooser_Action_Properties is new Generic_Internal_Discrete_Property (Gtk_File_Chooser_Action);
package Gtk_File_Chooser_Confirmation_Properties is new Generic_Internal_Discrete_Property (Gtk_File_Chooser_Confirmation);
package Gtk_File_Chooser_Error_Properties is new Generic_Internal_Discrete_Property (Gtk_File_Chooser_Error);
type Gtk_File_Chooser is new Glib.Types.GType_Interface;
type Gtk_File_Chooser_Action is ( Action_Open, Action_Save, Action_Select_Folder, Action_Create_Folder);
type Gtk_File_Chooser_Confirmation is ( Confirmation_Confirm, Confirmation_Accept_Filename, Confirmation_Select_Again);
type Gtk_File_Chooser_Error is ( Error_Nonexistent, Error_Bad_Filename, Error_Already_Exists, Error_Incomplete_Hostname);
type Property_Gtk_File_Chooser_Action is new Gtk_File_Chooser_Action_Properties.Property;
type Property_Gtk_File_Chooser_Confirmation is new Gtk_File_Chooser_Confirmation_Properties.Property;
type Property_Gtk_File_Chooser_Error is new Gtk_File_Chooser_Error_Properties.Property;
type Cb_Gtk_File_Chooser_Gtk_File_Chooser_Confirmation is not null access function (Self : Gtk_File_Chooser) return Gtk_File_Chooser_Confirmation;
type Cb_GObject_Gtk_File_Chooser_Confirmation is not null access function (Self : access Glib.Object.GObject_Record'Class) return Gtk_File_Chooser_Confirmation;
type Cb_Gtk_File_Chooser_Void is not null access procedure (Self : Gtk_File_Chooser);
type Cb_GObject_Void is not null access procedure (Self : access Glib.Object.GObject_Record'Class);
Null_Gtk_File_Chooser : constant Gtk_File_Chooser;
Action_Property : constant Gtk.File_Chooser.Property_Gtk_File_Chooser_Action;
Create_Folders_Property : constant Glib.Properties.Property_Boolean;
Do_Overwrite_Confirmation_Property : constant Glib.Properties.Property_Boolean;
Extra_Widget_Property : constant Glib.Properties.Property_Object;
Filter_Property : constant Glib.Properties.Property_Object;
Local_Only_Property : constant Glib.Properties.Property_Boolean;
Preview_Widget_Property : constant Glib.Properties.Property_Object;
Preview_Widget_Active_Property : constant Glib.Properties.Property_Boolean;
Select_Multiple_Property : constant Glib.Properties.Property_Boolean;
Show_Hidden_Property : constant Glib.Properties.Property_Boolean;
Use_Preview_Label_Property : constant Glib.Properties.Property_Boolean;
Signal_Confirm_Overwrite : constant Glib.Signal_Name := "confirm-overwrite";
Signal_Current_Folder_Changed : constant Glib.Signal_Name := "current-folder-changed";
Signal_File_Activated : constant Glib.Signal_Name := "file-activated";
Signal_Selection_Changed : constant Glib.Signal_Name := "selection-changed";
Signal_Update_Preview : constant Glib.Signal_Name := "update-preview";
function Get_Type return Glib.GType;
procedure Add_Filter
( | Chooser | : Gtk_File_Chooser; |
Filter | : not null access Gtk.File_Filter.Gtk_File_Filter_Record'Class); |
function Add_Shortcut_Folder
( | Chooser | : Gtk_File_Chooser; |
Folder | : UTF8_String) return Boolean; |
function Add_Shortcut_Folder_Uri
( | Chooser | : Gtk_File_Chooser; |
URI | : UTF8_String) return Boolean; |
function Get_Action
( | Chooser | : Gtk_File_Chooser) return Gtk_File_Chooser_Action; |
procedure Set_Action
( | Chooser | : Gtk_File_Chooser; |
Action | : Gtk_File_Chooser_Action); |
function Get_Create_Folders
( | Chooser | : Gtk_File_Chooser) return Boolean; |
procedure Set_Create_Folders
( | Chooser | : Gtk_File_Chooser; |
Create_Folders | : Boolean); |
function Get_Current_Folder
( | Chooser | : Gtk_File_Chooser) return UTF8_String; |
function Set_Current_Folder
( | Chooser | : Gtk_File_Chooser; |
Filename | : UTF8_String) return Boolean; |
function Get_Current_Folder_Uri
( | Chooser | : Gtk_File_Chooser) return UTF8_String; |
function Set_Current_Folder_Uri
( | Chooser | : Gtk_File_Chooser; |
URI | : UTF8_String) return Boolean; |
function Get_Do_Overwrite_Confirmation
( | Chooser | : Gtk_File_Chooser) return Boolean; |
procedure Set_Do_Overwrite_Confirmation
( | Chooser | : Gtk_File_Chooser; |
Do_Overwrite_Confirmation | : Boolean); |
function Get_Extra_Widget
( | Chooser | : Gtk_File_Chooser) return Gtk.Widget.Gtk_Widget; |
procedure Set_Extra_Widget
( | Chooser | : Gtk_File_Chooser; |
Extra_Widget | : not null access Gtk.Widget.Gtk_Widget_Record'Class); |
function Get_Filename
( | Chooser | : Gtk_File_Chooser) return UTF8_String; |
function Set_Filename
( | Chooser | : Gtk_File_Chooser; |
Filename | : UTF8_String) return Boolean; |
function Get_Filenames
( | Chooser | : Gtk_File_Chooser) return Gtk.Enums.String_SList.GSlist; |
function Get_Filter
( | Chooser | : Gtk_File_Chooser) return Gtk.File_Filter.Gtk_File_Filter; |
procedure Set_Filter
( | Chooser | : Gtk_File_Chooser; |
Filter | : not null access Gtk.File_Filter.Gtk_File_Filter_Record'Class); |
function Get_Local_Only
( | Chooser | : Gtk_File_Chooser) return Boolean; |
procedure Set_Local_Only
( | Chooser | : Gtk_File_Chooser; |
Local_Only | : Boolean); |
function Get_Preview_Filename
( | Chooser | : Gtk_File_Chooser) return UTF8_String; |
function Get_Preview_Uri
( | Chooser | : Gtk_File_Chooser) return UTF8_String; |
function Get_Preview_Widget
( | Chooser | : Gtk_File_Chooser) return Gtk.Widget.Gtk_Widget; |
procedure Set_Preview_Widget
( | Chooser | : Gtk_File_Chooser; |
Preview_Widget | : not null access Gtk.Widget.Gtk_Widget_Record'Class); |
function Get_Preview_Widget_Active
( | Chooser | : Gtk_File_Chooser) return Boolean; |
procedure Set_Preview_Widget_Active
( | Chooser | : Gtk_File_Chooser; |
Active | : Boolean); |
function Get_Select_Multiple
( | Chooser | : Gtk_File_Chooser) return Boolean; |
procedure Set_Select_Multiple
( | Chooser | : Gtk_File_Chooser; |
Select_Multiple | : Boolean); |
function Get_Show_Hidden
( | Chooser | : Gtk_File_Chooser) return Boolean; |
procedure Set_Show_Hidden
( | Chooser | : Gtk_File_Chooser; |
Show_Hidden | : Boolean); |
function Get_Uri
( | Chooser | : Gtk_File_Chooser) return UTF8_String; |
function Set_Uri
( | Chooser | : Gtk_File_Chooser; |
URI | : UTF8_String) return Boolean; |
function Get_Uris
( | Chooser | : Gtk_File_Chooser) return Gtk.Enums.String_SList.GSlist; |
function Get_Use_Preview_Label
( | Chooser | : Gtk_File_Chooser) return Boolean; |
procedure Set_Use_Preview_Label
( | Chooser | : Gtk_File_Chooser; |
Use_Label | : Boolean); |
function List_Filters
( | Chooser | : Gtk_File_Chooser) return Glib.Object.Object_List.GSlist; |
function List_Shortcut_Folder_Uris
( | Chooser | : Gtk_File_Chooser) return Gtk.Enums.String_SList.GSlist; |
function List_Shortcut_Folders
( | Chooser | : Gtk_File_Chooser) return Gtk.Enums.String_SList.GSlist; |
procedure Remove_Filter
( | Chooser | : Gtk_File_Chooser; |
Filter | : not null access Gtk.File_Filter.Gtk_File_Filter_Record'Class); |
function Remove_Shortcut_Folder
( | Chooser | : Gtk_File_Chooser; |
Folder | : UTF8_String) return Boolean; |
function Remove_Shortcut_Folder_Uri
( | Chooser | : Gtk_File_Chooser; |
URI | : UTF8_String) return Boolean; |
procedure Select_All
( | Chooser | : Gtk_File_Chooser); |
function Select_Filename
( | Chooser | : Gtk_File_Chooser; |
Filename | : UTF8_String) return Boolean; |
function Select_Uri
( | Chooser | : Gtk_File_Chooser; |
URI | : UTF8_String) return Boolean; |
procedure Set_Current_Name
( | Chooser | : Gtk_File_Chooser; |
Name | : UTF8_String); |
procedure Unselect_All
( | Chooser | : Gtk_File_Chooser); |
procedure Unselect_Filename
( | Chooser | : Gtk_File_Chooser; |
Filename | : UTF8_String); |
procedure Unselect_Uri
( | Chooser | : Gtk_File_Chooser; |
URI | : UTF8_String); |
procedure On_Confirm_Overwrite
( | Self | : Gtk_File_Chooser; |
Call | : Cb_Gtk_File_Chooser_Gtk_File_Chooser_Confirmation; | |
After | : Boolean := False); |
procedure On_Confirm_Overwrite
( | Self | : Gtk_File_Chooser; |
Call | : Cb_GObject_Gtk_File_Chooser_Confirmation; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Current_Folder_Changed
( | Self | : Gtk_File_Chooser; |
Call | : Cb_Gtk_File_Chooser_Void; | |
After | : Boolean := False); |
procedure On_Current_Folder_Changed
( | Self | : Gtk_File_Chooser; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_File_Activated
( | Self | : Gtk_File_Chooser; |
Call | : Cb_Gtk_File_Chooser_Void; | |
After | : Boolean := False); |
procedure On_File_Activated
( | Self | : Gtk_File_Chooser; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Selection_Changed
( | Self | : Gtk_File_Chooser; |
Call | : Cb_Gtk_File_Chooser_Void; | |
After | : Boolean := False); |
procedure On_Selection_Changed
( | Self | : Gtk_File_Chooser; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Update_Preview
( | Self | : Gtk_File_Chooser; |
Call | : Cb_Gtk_File_Chooser_Void; | |
After | : Boolean := False); |
procedure On_Update_Preview
( | Self | : Gtk_File_Chooser; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
function "+"
( | W | : Gtk_File_Chooser) return Gtk_File_Chooser; |
Gtk.File_Chooser.Gtk_File_Chooser is an interface that can be implemented by file selection widgets. In GTK+, the main objects that implement this interface are Gtk.File_Chooser_Widget.Gtk_File_Chooser_Widget, Gtk.File_Chooser_Dialog.Gtk_File_Chooser_Dialog, and Gtk.File_Chooser_Button.Gtk_File_Chooser_Button. You do not need to write an object that implements the Gtk.File_Chooser.Gtk_File_Chooser interface unless you are trying to adapt an existing file selector to expose a standard programming interface.
Gtk.File_Chooser.Gtk_File_Chooser 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: '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. 'Shortcuts' * can be provided by the application or by the underlying filesystem abstraction (e.g. both the gnome-vfs and the Windows filesystems provide "Desktop" shortcuts). Shortcuts cannot be modified by the user. 'Volumes' * are provided by the underlying filesystem abstraction. They are the "roots" of the filesystem. == File Names and Encodings == When the user is finished selecting files in a Gtk.File_Chooser.Gtk_File_Chooser, 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 <envar>G_FILENAME_ENCODING</envar> environment variable. Please see the GLib documentation for more details about this variable.
Note: This means that while you can pass the result of Gtk.File_Chooser.Get_Filename to <function>open(2)</function> or <function>fopen(3)</function>, you may not be able to directly set it as the text of a Gtk.Label.Gtk_Label widget unless you convert it first to UTF-8, which all GTK+ widgets expect. You should use g_filename_to_utf8 to convert filenames into strings that can be passed to GTK+ widgets. == 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 Gtk.File_Chooser.Set_Preview_Widget. Then, connect to the Gtk.File_Chooser.Gtk_File_Chooser::update-preview signal to get notified when you need to update the contents of the preview.
Your callback should use Gtk.File_Chooser.Get_Preview_Filename to see what needs previewing. Once you have generated the preview for the corresponding file, you must call Gtk.File_Chooser.Set_Preview_Widget_Active with a boolean flag that indicates whether your callback could successfully generate a preview.
== GtkFileChooser key binding example == The default keys that activate the key-binding signals in <classname>GtkFileChooserDefaultClass</classname> are as follows: Signal name Default key combinations location-popup ['Control''L'] (empty path); '/' (path of "/") [ Both the individual '/' key and the numeric keypad's "divide" key are supported. ]; '~' (path of "~") up-folder ['Alt''Up']; ['Alt''Shift''Up'] [ Both the individual Up key and the numeric keypad's Up key are supported. ]; 'Backspace' down-folder ['Alt''Down']; ['Alt''Shift''Down'] [ Both the individual Down key and the numeric keypad's Down key are supported. ] home-folder ['Alt''Home'] desktop-folder ['Alt''D'] quick-bookmark ['Alt''1'] through ['Alt''0'] You can change these defaults to something else. For example, to add a 'Shift' modifier to a few of the default bindings, you can include the following fragment in your '.config/gtk-3.0/gtk.css' file: Binding-set MyOwnFilechooserBindings { bind "<Alt><Shift>Up" { "up-folder" () } bind "<Alt><Shift>Down" { "down-folder" () } bind "<Alt><Shift>Home" { "home-folder" () } } GtkFileChooserDefault { gtk-key-bindings: MyOwnFilechooserBindings } == The "GtkFileChooserDefault::location-popup" signal == void user_function (GtkFileChooserDefault *chooser, const char *path, <link linkend="gpointer">gpointer</link> user_data); This is used to make the file chooser show a "Location" dialog which the user can use to manually type the name of the file he wishes to select. The 'path' argument is a string that gets put in the text entry for the file name. By default this is bound to ['Control''L'] with a 'path' string of "" (the empty string). It is also bound to '/' with a 'path' string of "'/'" (a slash): this lets you type '/' and immediately type a path name. On Unix systems, this is bound to '~' (tilde) with a 'path' string of "~" itself for access to home directories. ''chooser' :' * the object which received the signal. ''path' :' * default contents for the text entry for the file name ''user_data' :' * user data set when the signal handler was connected.
Note: You can create your own bindings for the Gtk_File_Chooser_Default::location-popup signal with custom 'path' strings, and have a crude form of easily-to-type bookmarks. For example, say you access the path '/home/username/misc' very frequently. You could then create an [ 'Alt' 'M' ] shortcut by including the following in your '.config/gtk-3.0/gtk.css': Binding-set MiscShortcut { bind "<Alt>M" { "location-popup" ("/home/username/misc") } } GtkFileChooserDefault { gtk-key-bindings: MiscShortcut } == The "GtkFileChooserDefault::up-folder" signal == void user_function (GtkFileChooserDefault *chooser, <link linkend="gpointer">gpointer</link> user_data); This is used to make the file chooser go to the parent of the current folder in the file hierarchy. By default this is bound to 'Backspace' and ['Alt''Up'] (the Up key in the numeric keypad also works). ''chooser' :' * the object which received the signal. ''user_data' :' * user data set when the signal handler was connected. == The "GtkFileChooserDefault::down-folder" signal == void user_function (GtkFileChooserDefault *chooser, <link linkend="gpointer">gpointer</link> user_data); This is used to make the file chooser go to a child of the current folder in the file hierarchy. The subfolder that will be used is displayed in the path bar widget of the file chooser. For example, if the path bar is showing "/foo/*bar/*baz", then this will cause the file chooser to switch to the "baz" subfolder. By default this is bound to ['Alt''Down'] (the Down key in the numeric keypad also works). ''chooser' :' * the object which received the signal. ''user_data' :' * user data set when the signal handler was connected. == The "GtkFileChooserDefault::home-folder" signal == void user_function (GtkFileChooserDefault *chooser, <link linkend="gpointer">gpointer</link> user_data); This is used to make the file chooser show the user's home folder in the file list. By default this is bound to ['Alt''Home'] (the Home key in the numeric keypad also works). ''chooser' :' * the object which received the signal. ''user_data' :' * user data set when the signal handler was connected. == The "GtkFileChooserDefault::desktop-folder" signal == void user_function (GtkFileChooserDefault *chooser, <link linkend="gpointer">gpointer</link> user_data); This is used to make the file chooser show the user's Desktop folder in the file list. By default this is bound to ['Alt''D']. ''chooser' :' * the object which received the signal. ''user_data' :' * user data set when the signal handler was connected. == The "GtkFileChooserDefault::quick-bookmark" signal == void user_function (GtkFileChooserDefault *chooser, gint bookmark_index, <link linkend="gpointer">gpointer</link> user_data); This is used to make the file chooser switch to the bookmark specified in the 'bookmark_index' parameter. For example, if you have three bookmarks, you can pass 0, 1, 2 to this signal to switch to each of them, respectively. By default this is bound to ['Alt''1'], ['Alt''2'], etc. until ['Alt''0']. Note that in the default binding, that ['Alt''1'] is actually defined to switch to the bookmark at index 0, and so on successively; ['Alt''0'] is defined to switch to the bookmark at index 10. ''chooser' :' * the object which received the signal. ''bookmark_indes' :' * index of the bookmark to switch to; the indices start at 0. ''user_data' :' * user data set when the signal handler was connected. </description>