File Types

## File Types File Types — functions for getting information about files based on their MIME type |

## Synopsis

                GnomeVFSMimeApplication;
    GnomeVFSMimeApplication* gnome_vfs_mime_get_default_application
                                                (const char *mime_type);
    GnomeVFSMimeApplication* gnome_vfs_mime_get_default_application_for_uri
                                                (const char *uri,
                                                 const char *mime_type);
    GList*      gnome_vfs_mime_get_all_applications
                                                (const char *mime_type);
    Bonobo_ServerInfo* gnome_vfs_mime_get_default_component
                                                (const char *mime_type);
    GList*      gnome_vfs_mime_get_all_components
                                                (const char *mime_type);
    const char* gnome_vfs_mime_get_icon         (const char *mime_type);
    const char* gnome_vfs_mime_get_description  (const char *mime_type);
    gboolean    gnome_vfs_mime_can_be_executable
                                                (const char *mime_type);
    GnomeVFSMimeApplication* gnome_vfs_mime_application_new_from_desktop_id
                                                (const char *id);
    GnomeVFSResult gnome_vfs_mime_application_launch
                                                (GnomeVFSMimeApplication *app,
                                                 GList *uris);
    GnomeVFSResult gnome_vfs_mime_application_launch_with_env
                                                (GnomeVFSMimeApplication *app,
                                                 GList *uris,
                                                 char **envp);
    const char* gnome_vfs_mime_application_get_desktop_id
                                                (GnomeVFSMimeApplication *app);
    const char* gnome_vfs_mime_application_get_desktop_file_path
                                                (GnomeVFSMimeApplication *app);
    const char* gnome_vfs_mime_application_get_name
                                                (GnomeVFSMimeApplication *app);
    const char* gnome_vfs_mime_application_get_generic_name
                                                (GnomeVFSMimeApplication *app);
    const char* gnome_vfs_mime_application_get_icon
                                                (GnomeVFSMimeApplication *app);
    const char* gnome_vfs_mime_application_get_exec
                                                (GnomeVFSMimeApplication *app);
    gboolean    gnome_vfs_mime_application_requires_terminal
                                                (GnomeVFSMimeApplication *app);
    const char* gnome_vfs_mime_application_get_startup_wm_class
                                                (GnomeVFSMimeApplication *app);
    gboolean    gnome_vfs_mime_application_supports_startup_notification
                                                (GnomeVFSMimeApplication *app);
    const char* gnome_vfs_mime_application_get_binary_name
                                                (GnomeVFSMimeApplication *app);
    gboolean    gnome_vfs_mime_application_supports_uris
                                                (GnomeVFSMimeApplication *app);
    GnomeVFSMimeApplication* gnome_vfs_mime_application_copy
                                                (GnomeVFSMimeApplication *app);
    void        gnome_vfs_mime_application_free (GnomeVFSMimeApplication *app);
    void        gnome_vfs_mime_application_list_free
                                                (GList *list);
    void        gnome_vfs_mime_component_list_free
                                                (GList *list);
    #define     GNOME_VFS_MIME_TYPE_UNKNOWN
    const char* gnome_vfs_get_mime_type_for_data
                                                (gconstpointer data,
                                                 int data_size);
    char*       gnome_vfs_get_mime_type         (const char *text_uri);

## Description

## Details

### GnomeVFSMimeApplication

    typedef struct {
    	char *id; /* PRIVATE */
    	char *name;
    #ifndef GNOME_VFS_DISABLE_DEPRECATED
    	char *command;
    	gboolean can_open_multiple_files;
    	GnomeVFSMimeApplicationArgumentType expects_uris;
    	GList *supported_uri_schemes;
    #else
    	char *_command;
    	gboolean _can_open_multiple_files;
    	GnomeVFSMimeApplicationArgumentType _expects_uris;
    	GList *_supported_uri_schemes;
    #endif
    	gboolean requires_terminal;

    	/* Padded to avoid future breaks in ABI compatibility */
    	void *reserved1;

    	GnomeVFSMimeApplicationPrivate *priv;
    } GnomeVFSMimeApplication;

### gnome_vfs_mime_get_default_application ()

    GnomeVFSMimeApplication* gnome_vfs_mime_get_default_application
                                                (const char *mime_type);

Query the MIME database for the application to be executed on files of MIME type `mime_type` by default.

`mime_type` : | A const char * containing a mime type, e.g. "image/png"
Returns : | A GnomeVFSMimeApplication representing the default handler of `mime_type`

### gnome_vfs_mime_get_default_application_for_uri ()

    GnomeVFSMimeApplication* gnome_vfs_mime_get_default_application_for_uri
                                                (const char *uri,
                                                 const char *mime_type);

`uri` : |
`mime_type` : |
Returns : |

### gnome_vfs_mime_get_all_applications ()

    GList*      gnome_vfs_mime_get_all_applications
                                                (const char *mime_type);

Return an alphabetically sorted list of GnomeVFSMimeApplication data structures representing all applications in the MIME database registered to handle files of MIME type `mime_type` (and supertypes).

`mime_type` : | A const char * containing a mime type, e.g. "image/png"
Returns : | A GList * where the elements are GnomeVFSMimeApplication * representing applications that handle MIME type `mime_type`.

### gnome_vfs_mime_get_default_component ()

    Bonobo_ServerInfo* gnome_vfs_mime_get_default_component
                                                (const char *mime_type);

Query the MIME database for the default Bonobo component to be activated to view files of MIME type `mime_type`.

`mime_type` : | A const char * containing a mime type, e.g. "image/png"
Returns : | An Bonobo_ServerInfo * representing the OAF server to be activated to get a reference to the proper component.

### gnome_vfs_mime_get_all_components ()

    GList*      gnome_vfs_mime_get_all_components
                                                (const char *mime_type);

Return an alphabetically sorted list of Bonobo_ServerInfo data structures representing all Bonobo components registered to handle files of MIME type `mime_type` (and supertypes).

`mime_type` : | A const char * containing a mime type, e.g. "image/png"
Returns : | A GList * where the elements are Bonobo_ServerInfo * representing components that can handle MIME type `mime_type`.

### gnome_vfs_mime_get_icon ()

    const char* gnome_vfs_mime_get_icon         (const char *mime_type);

### Warning

`gnome_vfs_mime_get_icon` is deprecated and should not be used in newly-written code.

Query the MIME database for an icon representing the specified MIME type.

`mime_type` : | A const char * containing a MIME type
Returns : | The filename of the icon as listed in the MIME database. This is usually a filename without path information, e.g. "i-chardev.png", and sometimes does not have an extension, e.g. "i-regular" if the icon is supposed to be image type agnostic between icon themes. Icons are generic, and not theme specific. These will not necessarily match with the icons a user sees in Nautilus, you have been warned.

### gnome_vfs_mime_get_description ()

    const char* gnome_vfs_mime_get_description  (const char *mime_type);

Query the MIME database for a description of the specified MIME type.

`mime_type` : | the mime type
Returns : | A description of MIME type `mime_type`

### gnome_vfs_mime_can_be_executable ()

    gboolean    gnome_vfs_mime_can_be_executable
                                                (const char *mime_type);

Check whether files of this MIME type might conceivably be executable. Default for known types if FALSE. Default for unknown types is TRUE.

`mime_type` : | A const char * containing a mime type
Returns : | gboolean containing TRUE if some files of this MIME type are registered as being executable, and false otherwise.

### gnome_vfs_mime_application_new_from_desktop_id ()

    GnomeVFSMimeApplication* gnome_vfs_mime_application_new_from_desktop_id
                                                (const char *id);

Returns a new GnomeVFSMimeApplication.

`id` : | the identifier of a desktop entry
Returns : | a GnomeVFSMimeApplication

Since 2.10

### gnome_vfs_mime_application_launch ()

    GnomeVFSResult gnome_vfs_mime_application_launch
                                                (GnomeVFSMimeApplication *app,
                                                 GList *uris);

Launches the given mime application with the given parameters. Command line parameters will be expanded as required by the application. The application will also be launched in a terminal if that is required. If the application only supports one argument per instance then multiple instances of the application will be launched.

`app` : | the GnomeVFSMimeApplication to launch
`uris` : | parameters for the GnomeVFSMimeApplication
Returns : | GNOME_VFS_OK if the application was launched. GNOME_VFS_ERROR_NOT_SUPPORTED if the uri protocol is not supported by the application. GNOME_VFS_ERROR_PARSE if the application command can not be parsed. GNOME_VFS_ERROR_LAUNCH if the application command can not be launched. GNOME_VFS_ERROR_INTERNAL for other internal and GConf errors.

Since 2.4

### gnome_vfs_mime_application_launch_with_env ()

    GnomeVFSResult gnome_vfs_mime_application_launch_with_env
                                                (GnomeVFSMimeApplication *app,
                                                 GList *uris,
                                                 char **envp);

Same as gnome_vfs_mime_application_launch except that the application will be launched with the given environment.

`app` : |
`uris` : |
`envp` : |
Returns : | same as gnome_vfs_mime_application_launch

Since 2.4

### gnome_vfs_mime_application_get_desktop_id ()

    const char* gnome_vfs_mime_application_get_desktop_id
                                                (GnomeVFSMimeApplication *app);

`app` : |
Returns : |

### gnome_vfs_mime_application_get_desktop_file_path ()

    const char* gnome_vfs_mime_application_get_desktop_file_path
                                                (GnomeVFSMimeApplication *app);

Returns the path of the desktop entry, a configuration file describing the properties of a particular program like it's name, how it is to be launched, how it appears in menus.

`app` : | a GnomeVFSMimeApplication
Returns : | the path of the .desktop file

Since 2.10

### gnome_vfs_mime_application_get_name ()

    const char* gnome_vfs_mime_application_get_name
                                                (GnomeVFSMimeApplication *app);

Returns the name of the application.

`app` : | a GnomeVFSMimeApplication
Returns : | the name of the application.

Since 2.10

### gnome_vfs_mime_application_get_generic_name ()

    const char* gnome_vfs_mime_application_get_generic_name
                                                (GnomeVFSMimeApplication *app);

Returns the generic name of the application.

`app` : | a GnomeVFSMimeApplication
Returns : | the generic name of the application.

Since 2.10

### gnome_vfs_mime_application_get_icon ()

    const char* gnome_vfs_mime_application_get_icon
                                                (GnomeVFSMimeApplication *app);

Returns an icon representing the specified application.

`app` : | a GnomeVFSMimeApplication
Returns : | the filename of the icon usually without path information, e.g. "gedit-icon.png", and sometimes does not have an extension, e.g. "gnome-pdf" if the icon is supposed to be image type agnostic between icon themes. Icons are generic, and not theme specific.

Since 2.10

### gnome_vfs_mime_application_get_exec ()

    const char* gnome_vfs_mime_application_get_exec
                                                (GnomeVFSMimeApplication *app);

Returns the program to execute, possibly with arguments and parameter variables, as specified by the <ulink url="http://www.freedesktop.org/standards/desktop-entry-spec"> Desktop Entry Specification</ulink>

`app` : | a GnomeVFSMimeApplication
Returns : | the command line to execute

Since 2.10

### gnome_vfs_mime_application_requires_terminal ()

    gboolean    gnome_vfs_mime_application_requires_terminal
                                                (GnomeVFSMimeApplication *app);

Returns whether the application runs in a terminal window.

`app` : | a GnomeVFSMimeApplication
Returns : | `TRUE` if the application runs in a terminal

Since 2.10

### gnome_vfs_mime_application_get_startup_wm_class ()

    const char* gnome_vfs_mime_application_get_startup_wm_class
                                                (GnomeVFSMimeApplication *app);

Returns the WM class of the main window of the application.

`app` : | a GnomeVFSMimeApplication
Returns : | The WM class of the application's window

Since 2.10

### gnome_vfs_mime_application_supports_startup_notification ()

    gboolean    gnome_vfs_mime_application_supports_startup_notification
                                                (GnomeVFSMimeApplication *app);

Returns whether the application supports startup notification. If true, it is KNOWN that the application will send a "remove" message when started with the DESKTOP_LAUNCH_ID environment variable set.

`app` : | a GnomeVFSMimeApplication
Returns : | `TRUE` if the application supports startup notification

Since 2.10

### gnome_vfs_mime_application_get_binary_name ()

    const char* gnome_vfs_mime_application_get_binary_name
                                                (GnomeVFSMimeApplication *app);

Returns the binary name of the specified application. Useful to implement startup notification. Note that this only provide partial information about application execution, it misses arguments and macros. DO NOT USE it to launch the application. Use gnome_vfs_mime_application_launch or gnome_vfs_mime_application_get_exec if you really need to write a custom launcher.

`app` : | a GnomeVFSMimeApplication
Returns : | the application's binary name

Since 2.10

### gnome_vfs_mime_application_supports_uris ()

    gboolean    gnome_vfs_mime_application_supports_uris
                                                (GnomeVFSMimeApplication *app);

Returns whether the application accept uris as command lines arguments.

`app` : | a GnomeVFSMimeApplication
Returns : | `TRUE` if the application can handle uris

Since 2.10

### gnome_vfs_mime_application_copy ()

    GnomeVFSMimeApplication* gnome_vfs_mime_application_copy
                                                (GnomeVFSMimeApplication *app);

Creates a newly referenced copy of a GnomeVFSMimeApplication object.

`app` : |
Returns : | A copy of `application`

### gnome_vfs_mime_application_free ()

    void        gnome_vfs_mime_application_free (GnomeVFSMimeApplication *app);

Frees a GnomeVFSMimeApplication *.

`app` : |

### gnome_vfs_mime_application_list_free ()

    void        gnome_vfs_mime_application_list_free
                                                (GList *list);

Frees lists of GnomeVFSApplications, as returned from functions such as `gnome_vfs_get_all_applications()`.

`list` : | a GList of GnomeVFSApplication * to be freed

### gnome_vfs_mime_component_list_free ()

    void        gnome_vfs_mime_component_list_free
                                                (GList *list);

Frees lists of Bonobo_ServerInfo * (as returned from functions such as `gnome_vfs_get_all_components`)

`list` : | a GList of Bonobo_ServerInfo * to be freed

### GNOME_VFS_MIME_TYPE_UNKNOWN

    #define GNOME_VFS_MIME_TYPE_UNKNOWN "application/octet-stream"

The value returned for the MIME type when a file did not match any entries in the MIME database. May be treated as a file of an unknown type.

### gnome_vfs_get_mime_type_for_data ()

    const char* gnome_vfs_get_mime_type_for_data
                                                (gconstpointer data,
                                                 int data_size);

Tries to guess the mime type of the data in `data` using the magic patterns.

`data` : | A pointer to data in memory.
`data_size` : | Size of the data.
Returns : | the mime-type for this filename.

### gnome_vfs_get_mime_type ()

    char*       gnome_vfs_get_mime_type         (const char *text_uri);

Determine the mime type of `text_uri`. The mime type is determined in the same way as by `gnome_vfs_get_file_info()`. This is meant as a convenience function for times when you only want the mime type.

`text_uri` : | URI of the file for which to get the mime type
Returns : | The mime type, or NULL if there is an error reading the file.