Top | ![]() |
![]() |
![]() |
![]() |
ToolFileFormatToolFileFormat — Describes file format objects (name patterns, description, properties...). |
struct | ToolFileFormat |
struct | ToolFileFormatClass |
struct | ToolFileFormatIter |
#define | TOOL_FILE_FORMAT_ERROR |
enum | ToolFileFormatErrorFlag |
GObject ╰── ToolDbgObj ╰── ToolFileFormat ├── VisuDataLoader ├── VisuDump ╰── VisuScalarFieldMethod
When dealing with files, it is convenient to class then by formats, one format for JPEG files, one other for postscript... Such file formats are characterized by their description, explaining what they are, one or more name pattern (e.g. "*.jpg") and some properties (e.g. compression level for JPEG file).
This module describes objects that can store all these
informations and deals with them. To create a new file format, use
tool_file_format_new()
. A ToolFileFormat object can be used in a
GtkFileChooser object, using a GtkFileFilter. tool_file_format_getLabel()
will return directly the label to give to the GtkFileFilter and the
name patterns can be passed to it also.
A file format property is a ToolOption value. There are some
convenient routines to add common boolean or integer
properties. For instance, use tool_file_format_addPropertyBoolean()
to add a boolean property to a given ToolFileFormat object. Then the stored
properties can be iterated on using a ToolFileFormatIter iterator.
GQuark
tool_file_format_getQuark (void
);
Internal routine to get the GQuark to handle error related to file formats.
[skip]
gboolean
(*ToolFileFormatValidate) (const gchar *filename
);
Function to match a given filename
for a file format. See
tool_file_format_setValidator()
.
Since: 3.7
ToolFileFormat * tool_file_format_new (const gchar *descr
,const gchar **patterns
);
Allocate a new ToolFileFormat. The patterns
argument is copied in
the ToolFileFormat object and can be freed safely after the call to this method.
ToolFileFormat * tool_file_format_newRestricted (const gchar *descr
,const gchar **patterns
);
Allocate a new ToolFileFormat. The patterns
argument is copied in
the ToolFileFormat object and can be freed safely after the call to this method.
The patterns
list is not all the patterns supported by the format.
ToolFileFormat *
tool_file_format_copy (const ToolFileFormat *from
);
Copy the given file format from
a create a new one.
Since: 3.6
void tool_file_format_addPatterns (ToolFileFormat *fmt
,const gchar **patterns
);
A file format may have pattern for the naming scheme of files, like "*.jpg" and "*.jpeg" for JPEG files. It's not mandatory for a file format to match its own pattern anyway.
fmt |
a ToolFileFormat object. |
|
patterns |
a list of matching patterns. |
[array zero-terminated=1] |
Since: 3.7
const gchar *
tool_file_format_getName (ToolFileFormat *format
);
This method gives the name describing the file format.
const gchar *
tool_file_format_getLabel (ToolFileFormat *format
);
This method gives a label describing the file format.
const GList *
tool_file_format_getFilePatterns (ToolFileFormat *format
);
This method gives a list with the file patterns.
a list with the file patterns. This list should not be freed.
[transfer none][element-type utf8]
Since: 3.6
gboolean
tool_file_format_canMatch (ToolFileFormat *format
);
This method is used to know if the file pattern list can be used
to match a given filename with tool_file_format_match()
.
Since: 3.6
const gchar * tool_file_format_match (ToolFileFormat *format
,const gchar *filename
);
This method try to match the given string to one of the patterns of
the ToolFileFormat format
.
gboolean tool_file_format_validate (ToolFileFormat *format
,const gchar *filename
);
This method runs a minimal parsing routine set with
tool_file_format_setValidator()
to check if the provided filename
correspond to this file format.
TRUE, if the file (after minimal parsing) is of this file
format. If there is no validator routine, it is using a built-in
one, based on pattern matching with file types, see
tool_file_format_addPatterns()
.
Since: 3.7
void tool_file_format_setValidator (ToolFileFormat *format
,ToolFileFormatValidate validate
);
Set up a validating routine that do a minimal parsing to check that a provided file corresponds to this file format.
format |
a ToolFileFormat ; |
|
validate |
a pointer to a validator routine. |
[scope call][allow-none] |
Since: 3.7
void tool_file_format_addOption (ToolFileFormat *format
,ToolOption *opt
);
File format may have options, like pseudo-potential pparameters in case of BigDFT calculations.
Since: 3.7
ToolOption * tool_file_format_addPropertyBoolean (ToolFileFormat *format
,const gchar *name
,const gchar *label
,gboolean defaultVal
);
Add a new boolean property to the file format format
.
format |
the ToolFileFormat object. |
|
name |
a name ; |
|
label |
a description ; |
|
defaultVal |
a default value. |
ToolOption * tool_file_format_addPropertyInt (ToolFileFormat *format
,const gchar *name
,const gchar *label
,gint defaultVal
);
Add a new integer property to the file format format
.
format |
the ToolFileFormat object. |
|
name |
a name ; |
|
label |
a description ; |
|
defaultVal |
a default value. |
ToolOption * tool_file_format_addPropertyDouble (ToolFileFormat *format
,const gchar *name
,const gchar *label
,gdouble defaultVal
);
Add a new integer property to the file format format
.
format |
the ToolFileFormat object. |
|
name |
a name ; |
|
label |
a description ; |
|
defaultVal |
a default value. |
Since: 3.7
void
tool_file_format_setPropertiesFromCLI (ToolFileFormat *format
);
Scan all options from command line and affects values.
Since: 3.8
gboolean tool_file_format_getPropertyBoolean (const ToolFileFormat *format
,const gchar *name
);
Retrieves the value of property prop
.
Since: 3.8
gint tool_file_format_getPropertyInt (const ToolFileFormat *format
,const gchar *name
);
Retrieves the value of property prop
.
Since: 3.8
gboolean tool_file_format_iterNextProperty (ToolFileFormat *format
,ToolFileFormatIter *iter
);
Run to the next property of the file format format
. The iterator
attributes are updated so it's convenient to access the property
values and details, see ToolFileFormatIter.
Since: 3.6
struct ToolFileFormatClass { VisuObjectClass parent; };
An opaque structure.
struct ToolFileFormatIter { GList *lst; gchar *name; gchar *label; GValue *val; };
Iterator on ToolFileFormat object properties. See
tool_file_format_iterNextProperty()
.
Since: 3.6
#define TOOL_FILE_FORMAT_ERROR tool_file_format_getQuark()
Internal function for error handling.
“ignore-type”
property“ignore-type” gboolean
Don't restrict file matching to the given patterns.
Flags: Read / Write
Default value: FALSE
“label”
property“label” gchar *
Label used to show the file pattern.
Flags: Read
Default value: ""
“name”
property“name” gchar *
File format description.
Flags: Read / Write / Construct Only
Default value: ""