type G_Key_File is new Glib.C_Proxy;
type G_Key_File_Error is (Error_Unknown_Encoding, Error_Parse, Error_Not_Found, Error_Key_Not_Found, Error_Group_Not_Found, Error_Invalid_Value);
type Double_List is array (Integer range <>) of Gdouble;
type Integer_List is array (Integer range <>) of Gint;
Desktop_Group : constant String := "Desktop Entry";
Desktop_Key_Startup_Notify : constant String := "StartupNotify";
Desktop_Key_Startup_Wm_Class : constant String := "StartupWMClass";
function Error_Quark return GQuark;
procedure Gtk_New
( | Key_File | : out G_Key_File); |
procedure Set_List_Separator
( | Key_File | : G_Key_File; |
Separator | : Gchar); |
function Get_Start_Group
( | Key_File | : G_Key_File) return String; |
function Get_Groups
( | Key_File | : G_Key_File) return GNAT.Strings.String_List; |
function Has_Group
( | Key_File | : G_Key_File; |
Group_Name | : String) return Boolean; |
function Remove_Group
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Get_Keys
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Error | : Glib.Error.GError := null) return GNAT.Strings.String_List; |
function Has_Key
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Remove_Key
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Get_Comment
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return String; |
function Set_Comment
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String := ""; | |
Comment | : String; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Remove_Comment
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String := ""; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Get_Boolean
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return Boolean; |
procedure Set_Boolean
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
Value | : Boolean); |
function Get_Boolean_List
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return Boolean_List; |
procedure Set_Boolean_List
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
List | : Boolean_List); |
function Get_Double
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return Gdouble; |
procedure Set_Double
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
Value | : Gdouble); |
function Get_Double_List
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return Double_List; |
procedure Set_Double_List
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
List | : Double_List); |
function Get_Integer
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return Gint; |
procedure Set_Integer
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
Value | : Gint); |
function Get_Integer_List
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return Integer_List; |
procedure Set_Integer_List
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
List | : Integer_List); |
function Get_String
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return String; |
procedure Set_String
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
The_String | : String); |
function Get_String_List
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return GNAT.Strings.String_List; |
procedure Set_String_List
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
List | : GNAT.Strings.String_List); |
function Get_Value
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Error | : Glib.Error.GError := null) return String; |
procedure Set_Value
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
Value | : String); |
function Load_From_Data
( | Key_File | : G_Key_File; |
Data | : String; | |
Flags | : G_Key_File_Flags; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Load_From_Data_Dirs
( | Key_File | : G_Key_File; |
File | : String; | |
Flags | : G_Key_File_Flags; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Load_From_Dirs
( | Key_File | : G_Key_File; |
File | : String; | |
Search_Dirs | : GNAT.Strings.String_List; | |
Flags | : G_Key_File_Flags; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Load_From_File
( | Key_File | : G_Key_File; |
File | : String; | |
Flags | : G_Key_File_Flags; | |
Error | : Glib.Error.GError := null) return Boolean; |
function Get_Locale_String
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Locale | : String) return String; |
procedure Set_Locale_String
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
Locale | : String; | |
The_String | : String); |
function Get_Locale_String_List
( | Key_File | : G_Key_File; |
Group_Name | : String; | |
Key | : String; | |
Locale | : String; | |
Error | : Glib.Error.GError := null) return GNAT.Strings.String_List; |
procedure Set_Locale_String_List
( | Key_File | : G_Key_File; |
Group_Name | : String := ""; | |
Key | : String; | |
Locale | : String; | |
List | : GNAT.Strings.String_List); |
G_Key_File lets you parse, edit or create files containing groups of key-value pairs, which we call key files for lack of a better name. Several freedesktop.org specifications use key files now, e.g the Desktop Entry Specification and the Icon Theme Specification.
The syntax of key files is described in detail in the Desktop Entry Specification, here is a quick summary: Key files consists of groups of key-value pairs, interspersed with comments. # this is just an example # there can be comments before the first group [First Group] Name=Key File Example\tthis value shows\nescaping # localized strings are stored in multiple key-value pairs Welcome=Hello Welcome[de]=Hallo Welcome[fr_FR]=Bonjour Welcome[it]=Ciao Welcome[be@latin]=Hello [Another Group] Numbers=2;20;-200;0 Booleans=true;false;true;true Groups are started by a header line containing the group name enclosed in '[' and ']', and ended implicitly by the start of the next group or the end of the file. Each key-value pair must be contained in a group.
Key-value pairs generally have the form key=value, with the exception of localized strings, which have the form key[locale]=value, with a locale identifier of the form lang_COUNTRYMODIFIER where COUNTRY and MODIFIER are optional. Space before and after the '=' character are ignored. Newline, tab, carriage return and backslash characters in value are escaped as \n, \t, \r, and \\, respectively. To preserve leading spaces in values, these can also be escaped as \s.
Key files can store strings (possibly with localized variants), integers, booleans and lists of these. Lists are separated by a separator character, typically ';' or ','. To use the list separator character in a value in a list, it has to be escaped by prefixing it with a backslash.
This syntax is obviously inspired by the .ini files commonly met on Windows, but there are some important differences: .ini files use the ';' character to begin comments, key files use the '#' character.
Key files do not allow for ungrouped keys meaning only comments can precede the first group.
Key files are always encoded in UTF-8.
Key and Group names are case-sensitive, for example a group called [GROUP] is a different group from [group]. .ini files don't have a strongly typed boolean entry type, they only have GetProfileInt. In G_Key_File only true and false (in lower case) are allowed.
Note that in contrast to the Desktop Entry Specification, groups in key files may contain the same key multiple times; the last entry wins. Key files may also contain multiple groups with the same name; they are merged together. Another difference is that keys and group names in key files are not restricted to ASCII characters.
Binding from C File version 2.16.6