Top | ![]() |
![]() |
![]() |
![]() |
AutoarFormat | default-filter | Read / Write |
AutoarFormat | default-format | Read / Write |
gboolean | delete-if-succeed | Read / Write |
GStrv | file-mime-type | Read / Write |
GStrv | file-name-suffix | Read / Write |
GStrv | pattern-to-ignore | Read / Write |
The AutoarPref is used to store the user preferences related to archives. It is a required argument to create an AutoarCreate or AutoarExtract object. It also provides some convenient methods to read and write settings with GSettings, or check whether a file should be regarded as an archive. An AutoarPref can be used multiple times, so you can use the same AutoarPref object to create many AutoarCreate or AutoarExtract objects.
In order to allow applications to override user preferences, no binding is
created between the AutoarPref object and the GSettings object in order
to prevent unnecesssary writes. AutoarPref holds no reference to the
GSettings object, too. Additionally, there are modification
flags for each property inside the AutoarPref object, so
autoar_pref_write_gsettings()
only writes settings which are changed
since the last call to autoar_pref_read_gsettings()
.
If you do not like this behavior, there are also methods
provided to override it.
AutoarPref *
autoar_pref_new (void
);
Create a new AutoarPref object. All strings will be initialized as NULL
.
AutoarPref *
autoar_pref_new_with_gsettings (GSettings *settings
);
Create a new AutoarPref object and read settings from settings
. Calling
this function is equivalent to calling autoar_pref_read_gsettings()
on
the object returned by autoar_pref_new()
.
void autoar_pref_read_gsettings (AutoarPref *arpref
,GSettings *settings
);
Read settings from settings
.
void autoar_pref_write_gsettings (AutoarPref *arpref
,GSettings *settings
);
Write settings to settings
. If you do not read from GSettings before
calling this functions, it will be the same as calling
autoar_pref_write_gsettings_force()
. If autoar_pref_read_gsettings()
has called on arpref
, or arpref
is created using
autoar_pref_new_with_gsettings()
, only settings changed since the last
time reading from GSettings will be written.
It is allowed to write to a GSettings object which is different from the
object you read from. However, AutoarPref cannot detect this situation,
and you may want to call autoar_pref_write_gsettings_force()
instead.
void autoar_pref_write_gsettings_force (AutoarPref *arpref
,GSettings *settings
);
Write settings to settings
, ignoring the internal modification flags of
AutoarPref. All properties will be written even if it is not changed, and
modification flags are not cleared after calling this function.
gboolean
autoar_pref_has_changes (AutoarPref *arpref
);
Gets whether there are changes to properties which are not written.
void
autoar_pref_forget_changes (AutoarPref *arpref
);
Clear the modification flags, so the next call to
autoar_pref_write_gsettings()
will write nothing if you have read from
GSettings before calling it.
gboolean autoar_pref_check_file_name (AutoarPref *arpref
,const char *filepath
);
Checks whether the file filepath
has the suffix listed in
“file-name-suffix”. This function does not do any
I/O operation.
gboolean autoar_pref_check_file_name_file (AutoarPref *arpref
,GFile *file
);
Checks whether the file file
has the suffix listed in
“file-name-suffix”. This function does not do any
I/O operation.
gboolean autoar_pref_check_file_name_d (AutoarPref *arpref
,const char *extension
);
Checks whether extension
is listed in “file-name-suffix”.
This function is the same as comparing extension
with strings using
strcmp()
.
gboolean autoar_pref_check_mime_type (AutoarPref *arpref
,const char *filepath
);
Checks whether the MIME type of filepath
is listed in
“file-mime-type”.
gboolean autoar_pref_check_mime_type_file (AutoarPref *arpref
,GFile *file
);
Checks whether the MIME type of file
is listed in
“file-mime-type”.
gboolean autoar_pref_check_mime_type_d (AutoarPref *arpref
,const char *mime_type
);
Checks whether mime_type
is listed in “file-mime-type”.
This function is the same as comparing mime_type
with strings using
strcmp()
.
AutoarFormat
autoar_pref_get_default_format (AutoarPref *arpref
);
Gets the default format for new archives.
AutoarFilter
autoar_pref_get_default_filter (AutoarPref *arpref
);
Gets the default filter for new archives.
const char **
autoar_pref_get_file_name_suffix (AutoarPref *arpref
);
Gets the list of file name extensions which should be regarded as archives.
const char **
autoar_pref_get_file_mime_type (AutoarPref *arpref
);
Gets the list of MIME types which should be regarded as archives.
const char **
autoar_pref_get_pattern_to_ignore (AutoarPref *arpref
);
Gets the list of filename patterns which will be ignored when extracting archives. That is, a file will not be extracted from the archive if its name matches any patterns in the list.
gboolean
autoar_pref_get_delete_if_succeed (AutoarPref *arpref
);
Gets whether the source archive will be deleted after it is successfully extracted.
void autoar_pref_set_default_format (AutoarPref *arpref
,AutoarFormat format
);
void autoar_pref_set_default_filter (AutoarPref *arpref
,AutoarFilter filter
);
void autoar_pref_set_file_name_suffix (AutoarPref *arpref
,const char **strv
);
void autoar_pref_set_file_mime_type (AutoarPref *arpref
,const char **strv
);
void autoar_pref_set_pattern_to_ignore (AutoarPref *arpref
,const char **strv
);
void autoar_pref_set_delete_if_succeed (AutoarPref *arpref
,gboolean delete_yes
);
#define AUTOAR_PREF_DEFAULT_GSCHEMA_ID "org.gnome.desktop.archives"
Default GSettings schema ID for storing and retrieving user preferences in the AutoarPref object. If you want to share preferences related to archives with other applications, you should use this schema ID.
“default-filter”
property“default-filter” AutoarFormat
Default filter to create archives.
Flags: Read / Write
Default value: AUTOAR_FORMAT_ZIP
“default-format”
property“default-format” AutoarFormat
Default file format for new archives.
Flags: Read / Write
Default value: AUTOAR_FORMAT_ZIP
“delete-if-succeed”
property “delete-if-succeed” gboolean
Delete the archive file if extraction is succeeded.
Flags: Read / Write
Default value: TRUE
“file-mime-type”
property “file-mime-type” GStrv
File MIME type whitelist for automatic extraction.
Flags: Read / Write
“file-name-suffix”
property “file-name-suffix” GStrv
File name suffix whitelist for automatic extraction.
Flags: Read / Write