AutoarPref

AutoarPref — Prefrences related to archives

Functions

Properties

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

Types and Values

Object Hierarchy

    GObject
    ╰── AutoarPref

Includes

#include <gnome-autoar/autoar.h>

Description

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.

Functions

autoar_pref_new ()

AutoarPref *
autoar_pref_new (void);

Create a new AutoarPref object. All strings will be initialized as NULL.

Returns

a new AutoarPref object.

[transfer full]


autoar_pref_new_with_gsettings ()

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().

Parameters

settings

a GSettings object to read settings from

 

Returns

a new AutoarPref object.

[transfer full]


autoar_pref_read_gsettings ()

void
autoar_pref_read_gsettings (AutoarPref *arpref,
                            GSettings *settings);

Read settings from settings .

Parameters

arpref

an AutoarPref object

 

settings

a GSettings object to read settings from

 

autoar_pref_write_gsettings ()

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.

Parameters

arpref

an AutoarPref object

 

settings

a GSettings object to write settings to

 

autoar_pref_write_gsettings_force ()

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.

Parameters

arpref

an AutoarPref object

 

settings

a GSettings object to write settings to

 

autoar_pref_has_changes ()

gboolean
autoar_pref_has_changes (AutoarPref *arpref);

Gets whether there are changes to properties which are not written.

Parameters

arpref

an AutoarPref object

 

Returns

TRUE if there are changes since the last reading from GSettings. FALSE if there is no change or you have not read from GSettings.


autoar_pref_forget_changes ()

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.

Parameters

arpref

an AutoarPref object

 

autoar_pref_check_file_name ()

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.

Parameters

arpref

an AutoarPref object

 

filepath

the filename or the path of the file

 

Returns

TRUE if it is matched


autoar_pref_check_file_name_file ()

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.

Parameters

arpref

an AutoarPref object

 

file

a GFile object

 

Returns

TRUE if it is matched


autoar_pref_check_file_name_d ()

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().

Parameters

arpref

an AutoarPref object

 

extension

a file name extension

 

Returns

TRUE if it is matched


autoar_pref_check_mime_type ()

gboolean
autoar_pref_check_mime_type (AutoarPref *arpref,
                             const char *filepath);

Checks whether the MIME type of filepath is listed in “file-mime-type”.

Parameters

arpref

an AutoarPref object

 

filepath

the filename or the path of the file

 

Returns

TRUE if it is matched


autoar_pref_check_mime_type_file ()

gboolean
autoar_pref_check_mime_type_file (AutoarPref *arpref,
                                  GFile *file);

Checks whether the MIME type of file is listed in “file-mime-type”.

Parameters

arpref

an AutoarPref object

 

file

a GFile object

 

Returns

TRUE if it is matched


autoar_pref_check_mime_type_d ()

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().

Parameters

arpref

an AutoarPref object

 

mime_type

a MIME type

 

Returns

TRUE if it is matched


autoar_pref_get_default_format ()

AutoarFormat
autoar_pref_get_default_format (AutoarPref *arpref);

Gets the default format for new archives.

Parameters

arpref

an AutoarPref

 

Returns

an AutoarFormat


autoar_pref_get_default_filter ()

AutoarFilter
autoar_pref_get_default_filter (AutoarPref *arpref);

Gets the default filter for new archives.

Parameters

arpref

an AutoarPref

 

Returns

an AutoarFilter


autoar_pref_get_file_name_suffix ()

const char **
autoar_pref_get_file_name_suffix (AutoarPref *arpref);

Gets the list of file name extensions which should be regarded as archives.

Parameters

arpref

an AutoarPref

 

Returns

a NULL-terminated array of strings.

[transfer none]


autoar_pref_get_file_mime_type ()

const char **
autoar_pref_get_file_mime_type (AutoarPref *arpref);

Gets the list of MIME types which should be regarded as archives.

Parameters

arpref

an AutoarPref

 

Returns

a NULL-terminated array of strings.

[transfer none]


autoar_pref_get_pattern_to_ignore ()

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.

Parameters

arpref

an AutoarPref

 

Returns

a NULL-terminated array of strings.

[transfer none]


autoar_pref_get_delete_if_succeed ()

gboolean
autoar_pref_get_delete_if_succeed (AutoarPref *arpref);

Gets whether the source archive will be deleted after it is successfully extracted.

Parameters

arpref

an AutoarPref

 

Returns

TRUE if the source archive should be deleted


autoar_pref_set_default_format ()

void
autoar_pref_set_default_format (AutoarPref *arpref,
                                AutoarFormat format);

See autoar_pref_get_default_format().

Parameters

arpref

an AutoarPref

 

format

a valid AutoarFormat

 

autoar_pref_set_default_filter ()

void
autoar_pref_set_default_filter (AutoarPref *arpref,
                                AutoarFilter filter);

See autoar_pref_get_default_filter().

Parameters

arpref

an AutoarPref

 

filter

a valid AutoarFilter

 

autoar_pref_set_file_name_suffix ()

void
autoar_pref_set_file_name_suffix (AutoarPref *arpref,
                                  const char **strv);

See autoar_pref_get_file_name_suffix().

Parameters

arpref

an AutoarPref

 

strv

a NULL-terminated array of strings

 

autoar_pref_set_file_mime_type ()

void
autoar_pref_set_file_mime_type (AutoarPref *arpref,
                                const char **strv);

See autoar_pref_get_file_mime_type().

Parameters

arpref

an AutoarPref

 

strv

a NULL-terminated array of strings

 

autoar_pref_set_pattern_to_ignore ()

void
autoar_pref_set_pattern_to_ignore (AutoarPref *arpref,
                                   const char **strv);

See autoar_pref_get_pattern_to_ignore().

Parameters

arpref

an AutoarPref

 

strv

a NULL-terminated array of strings

 

autoar_pref_set_delete_if_succeed ()

void
autoar_pref_set_delete_if_succeed (AutoarPref *arpref,
                                   gboolean delete_yes);

See autoar_pref_get_delete_if_succeed().

Parameters

arpref

an AutoarPref

 

delete_yes

TRUE if the source archive should be deleted

 

Types and Values

AUTOAR_PREF_DEFAULT_GSCHEMA_ID

#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.

Property Details

The “default-filter” property

  “default-filter”           AutoarFormat

Default filter to create archives.

Flags: Read / Write

Default value: AUTOAR_FORMAT_ZIP


The “default-format” property

  “default-format”           AutoarFormat

Default file format for new archives.

Flags: Read / Write

Default value: AUTOAR_FORMAT_ZIP


The “delete-if-succeed” property

  “delete-if-succeed”        gboolean

Delete the archive file if extraction is succeeded.

Flags: Read / Write

Default value: TRUE


The “file-mime-type” property

  “file-mime-type”           GStrv

File MIME type whitelist for automatic extraction.

Flags: Read / Write


The “file-name-suffix” property

  “file-name-suffix”         GStrv

File name suffix whitelist for automatic extraction.

Flags: Read / Write


The “pattern-to-ignore” property

  “pattern-to-ignore”        GStrv

Pattern of file name to skip when extracting files.

Flags: Read / Write