FmTemplate

## FmTemplate FmTemplate — Templates for new files creation. |

## Synopsis

    #define             FM_TEMPLATE_TYPE
                        FmTemplate;
                        FmTemplateClass;
    gboolean            fm_template_create_file             (FmTemplate *templ,
                                                             GFile *path,
                                                             GError **error,
                                                             gboolean run_default);
    FmIcon *            fm_template_get_icon                (FmTemplate *templ);
    const gchar *       fm_template_get_label               (FmTemplate *templ);
    FmMimeType *        fm_template_get_mime_type           (FmTemplate *templ);
    const gchar *       fm_template_get_name                (FmTemplate *templ,
                                                             gint *nlen);
    const gchar *       fm_template_get_prompt              (FmTemplate *templ);
    gboolean            fm_template_is_directory            (FmTemplate *templ);
    GList *             fm_template_list_all                (gboolean user_only);

## Object Hierarchy

      GObject
       +----FmTemplate

## Description

`include`: libfm/fm.h

The FmTemplate object represents description which files was set for creation and how those files should be created - that includes custom prompt, file name template, and template contents.

## Details

### FM_TEMPLATE_TYPE

    #define FM_TEMPLATE_TYPE               (fm_template_get_type())

### FmTemplate

    typedef struct _FmTemplate FmTemplate;

### FmTemplateClass

    typedef struct _FmTemplateClass FmTemplateClass;

### fm_template_create_file ()

    gboolean            fm_template_create_file             (FmTemplate *templ,
                                                             GFile *path,
                                                             GError **error,
                                                             gboolean run_default);

Tries to create file at `path` using rules of creating from `templ`.

`templ` : | a template descriptor. [allow-none]
`path` : | path to file to create
`error` : | location to retrieve error. [allow-none]
`run_default` : | `TRUE` to run default application on new file
Returns : | `TRUE` if file created successfully.

Since 1.2.0

### fm_template_get_icon ()

    FmIcon *            fm_template_get_icon                (FmTemplate *templ);

Retrieves icon defined for `templ`. Returned data are owned by `templ` and should be not freed by caller.

`templ` : | a template descriptor
Returns : | icon for template. [transfer none]

Since 1.2.0

### fm_template_get_label ()

    const gchar *       fm_template_get_label               (FmTemplate *templ);

Retrieves label for `templ`. It can be used as label in menu. Returned data are owned by `templ` and should be not freed by caller.

`templ` : | a template descriptor
Returns : | template label. [transfer none]

Since 1.2.0

### fm_template_get_mime_type ()

    FmMimeType *        fm_template_get_mime_type           (FmTemplate *templ);

Retrieves MIME type descriptor for `templ`. Returned data are owned by `templ` and should be not freed by caller.

`templ` : | a template descriptor
Returns : | mime type descriptor. [transfer none]

Since 1.2.0

### fm_template_get_name ()

    const gchar *       fm_template_get_name                (FmTemplate *templ,
                                                             gint *nlen);

Retrieves file name template for `templ`. If `nlen` isn't `NULL` then it will receive length of file name template without suffix (in characters). Returned data are owned by `templ` and should be not freed by caller.

`templ` : | a template descriptor
`nlen` : | location to get template name length. [allow-none]
Returns : | file name template. [transfer none]

Since 1.2.0

### fm_template_get_prompt ()

    const gchar *       fm_template_get_prompt              (FmTemplate *templ);

Retrieves prompt for `templ`. It can be used as label in entry for the desired name. If no prompt is defined then returns `NULL`. Returned data are owned by `templ` and should be not freed by caller.

`templ` : | a template descriptor
Returns : | file prompt. [transfer none]

Since 1.2.0

### fm_template_is_directory ()

    gboolean            fm_template_is_directory            (FmTemplate *templ);

Checks if `templ` is directory template.

`templ` : | a template descriptor
Returns : | `TRUE` if `templ` is directory template.

Since 1.2.0

### fm_template_list_all ()

    GList *             fm_template_list_all                (gboolean user_only);

Retrieves list of all templates. Returned data should be freed after usage with g_list_free_full(list, g_object_unref).

`user_only` : | `TRUE` to ignore system templates
Returns : | list of all known templates. [transfer full][element-type FmTemplate]

Since 1.2.0