## LatexilaUtils LatexilaUtils — Utilities functions |

## Functions

gchar * | latexila_utils_get_shortname ()
gchar * | latexila_utils_get_extension ()
gchar * | latexila_utils_replace_home_dir_with_tilde ()
void | latexila_utils_file_query_exists_async ()
gboolean | latexila_utils_file_query_exists_finish ()
gboolean | latexila_utils_create_parent_directories ()
void | latexila_utils_show_uri ()
GtkWidget * | latexila_utils_get_dialog_component ()
GtkWidget * | latexila_utils_join_widgets ()
GdkPixbuf * | latexila_utils_get_pixbuf_from_icon_name ()
gchar * | latexila_utils_str_replace ()
void | latexila_utils_register_icons ()

## Includes

    #include <latexila.h>

## Description

Various utilities functions.

## Functions

### latexila_utils_get_shortname ()

    gchar *
    latexila_utils_get_shortname (const gchar *filename);

#### Parameters

filename | a filename. |

#### Returns

the `filename` without its extension. Free with `g_free()`.

### latexila_utils_get_extension ()

    gchar *
    latexila_utils_get_extension (const gchar *filename);

#### Parameters

filename | a filename. |

#### Returns

the `filename` 's extension with the dot, in lowercase. Free with `g_free()`.

### latexila_utils_replace_home_dir_with_tilde ()

    gchar *
    latexila_utils_replace_home_dir_with_tilde
                                   (const gchar *filename);

Replaces the home directory with a tilde, if the home directory is present in the `filename` .

This function comes from gedit.

#### Parameters

filename | the filename. |

#### Returns

the new filename. Free with `g_free()`.

### latexila_utils_file_query_exists_async ()

    void
    latexila_utils_file_query_exists_async
                                   (GFile *file,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

The asynchronous version of `g_file_query_exists()`. When the operation is finished, `callback` will be called. You can then call `latexila_utils_file_query_exists_finish()` to get the result of the operation.

#### Parameters

file | a GFile. |
cancellable | a GCancellable. |
callback | the callback to call when the operation is finished. |
user_data | the data to pass to the callback function. |

### latexila_utils_file_query_exists_finish ()

    gboolean
    latexila_utils_file_query_exists_finish
                                   (GFile *file,
                                    GAsyncResult *result);

Finishes the operation started with `latexila_utils_file_query_exists_async()`. There is no output GError parameter, so you should check if the operation has been cancelled (in which case `FALSE` will be returned).

#### Parameters

file | a GFile. |
result | a GAsyncResult. |

#### Returns

`TRUE` if the file exists and the operation hasn't been cancelled, `FALSE` otherwise.

### latexila_utils_create_parent_directories ()

    gboolean
    latexila_utils_create_parent_directories
                                   (GFile *file,
                                    GError **error);

Synchronously creates parent directories of `file` , so that `file` can be saved.

#### Parameters

file | a file |
error | a location to a `NULL` GError, or `NULL`. | [out][optional]

#### Returns

whether the directories are correctly created. `FALSE` is returned on error.

### latexila_utils_show_uri ()

    void
    latexila_utils_show_uri (GdkScreen *screen,
                             const gchar *uri,
                             guint32 timestamp,
                             GError **error);

Shows the `uri` . If the URI is a PDF file and if Evince is the default document viewer, this function also connects the Evince window so the backward search works (switch from the PDF to the source file).

#### Parameters

screen | a GdkScreen, or `NULL`. | [nullable]
uri | the URI to show. |
timestamp | a timestamp. |
error | a `NULL` GError, or `NULL`. | [out][optional]

### latexila_utils_get_dialog_component ()

    GtkWidget *
    latexila_utils_get_dialog_component (const gchar *title,
                                         GtkWidget *widget);

Gets a GtkDialog component. When a dialog contains several components, or logical groups, this function is useful to attach the `widget` with a `title` . The title will be in bold, left-aligned, and the widget will have a left margin.

#### Parameters

title | the title of the dialog component. |
widget | the widget displayed below the title. |

#### Returns

the dialog component containing the `title` and the `widget` .

[transfer floating]

### latexila_utils_join_widgets ()

    GtkWidget *
    latexila_utils_join_widgets (GtkWidget *widget_top,
                                 GtkWidget *widget_bottom);

Joins two widgets vertically, with junction sides.

#### Parameters

widget_top | the GtkWidget at the top. |
widget_bottom | the GtkWidget at the bottom. |

#### Returns

a GtkContainer containing `widget_top` and `widget_bottom` .

[transfer floating]

### latexila_utils_get_pixbuf_from_icon_name ()

    GdkPixbuf *
    latexila_utils_get_pixbuf_from_icon_name
                                   (const gchar *icon_name,
                                    GtkIconSize icon_size);

#### Parameters

icon_name | an icon name. |
icon_size | an icon size. |

#### Returns

the corresponding GdkPixbuf.

[nullable][transfer full]

### latexila_utils_str_replace ()

    gchar *
    latexila_utils_str_replace (const gchar *string,
                                const gchar *search,
                                const gchar *replacement);

Replaces all occurences of `search` by `replacement` .

#### Parameters

string | a string |
search | the search string |
replacement | the replacement string |

#### Returns

A newly allocated string with the replacements. Free with `g_free()`.

### latexila_utils_register_icons ()

    void
    latexila_utils_register_icons (void);

Register the LaTeXila icons to the GtkIconTheme as built-in icons. For example the icon located at data/images/stock-icons/badbox.png in the LaTeXila git repository will be available with the icon name "badbox". The "stock-icons" directory name is for historical reasons and should be changed when stock icons are no longer used in LaTeXila.

TODO: prefix icon names with "latexila-", so the badbox.png would be "latexila-badbox".

## Types and Values