## thunar-util

thunar-util

## Functions

void | ( *ThunarBookmarksFunc ) ()
gchar * | thunar_util_str_get_extension ()
void | thunar_util_load_bookmarks ()
gboolean | thunar_util_looks_like_an_uri ()
gchar * | thunar_util_expand_filename ()
guint64 | thunar_util_get_file_time ()
gchar * | thunar_util_humanize_file_time ()
GdkScreen * | thunar_util_parse_parent ()
time_t | thunar_util_time_from_rfc3339 ()
gchar * | thunar_util_change_working_directory ()
void | thunar_setup_display_cb ()
gchar * | thunar_util_next_new_file_name ()
gchar * | thunar_util_next_new_file_name_raw ()
const char * | thunar_util_get_search_prefix ()
gboolean | thunar_util_is_a_search_query ()
gchar * | thunar_util_strjoin_list ()
void | thunar_util_clip_view_background ()
gchar ** | thunar_util_split_search_query ()
gboolean | thunar_util_search_terms_match ()
gboolean | thunar_util_save_geometry_timer ()
gchar * | thunar_util_get_statusbar_text_for_files ()
gchar * | thunar_util_get_statusbar_text_for_single_file ()
gchar * | thunar_util_accel_path_to_id ()

## Types and Values

#define | ALPHA_BACKDROP
#define | ALPHA_FOCUSED
#define | STACK_ALLOC_LIMIT
#define | MAX_EMBLEMS_PER_FILE
enum | ThunarNextFileNameMode

## Description

## Functions

### ThunarBookmarksFunc ()

    void
    (*ThunarBookmarksFunc) (GFile *file,
                            const gchar *name,
                            gint row_num,
                            gpointer user_data);

### thunar_util_str_get_extension ()

    gchar *
    thunar_util_str_get_extension (const gchar *name);

Returns a pointer to the extension in `filename` .

This is an improved version of g_utf8_strrchr with improvements to recognize compound extensions like ".tar.gz" and ".desktop.in.in".

#### Parameters

filename | an UTF-8 filename |

#### Returns

pointer to the extension in `filename` or NULL.

### thunar_util_load_bookmarks ()

    void
    thunar_util_load_bookmarks (GFile *bookmarks_file,
                                ThunarBookmarksFunc foreach_func,
                                gpointer user_data);

### thunar_util_looks_like_an_uri ()

    gboolean
    thunar_util_looks_like_an_uri (const gchar *string);

### thunar_util_expand_filename ()

    gchar *
    thunar_util_expand_filename (const gchar *filename,
                                 GFile *working_directory,
                                 GError **error);

Takes a user-typed `filename` and expands a tilde at the beginning of the `filename` . It also resolves paths prefixed with '.' using the current working directory.

The caller is responsible to free the returned string using `g_free()` when no longer needed.

#### Parameters

filename | a local filename. |
working_directory | GFile of the current working directory. |
error | return location for errors or `NULL`. |

#### Returns

the expanded `filename` or `NULL` on error.

### thunar_util_get_file_time ()

    guint64
    thunar_util_get_file_time (GFileInfo *file_info,
                               ThunarFileDateType date_type);

Queries the given `date_type` from `file_info` and returns the result.

#### Parameters

file_info | a GFileInfo instance. |
date_type | the kind of date you are interested in. |

#### Returns

the time for `file_info` of the given `date_type` .

### thunar_util_humanize_file_time ()

    gchar *
    thunar_util_humanize_file_time (guint64 file_time,
                                    ThunarDateStyle date_style,
                                    const gchar *date_custom_style);

Returns a human readable date representation of the specified `file_time` . The caller is responsible to free the returned string using `g_free()` when no longer needed.

#### Parameters

file_time | a guint64 timestamp. |
date_style | the ThunarDateFormat used to humanize the `file_time` . |
date_custom_style | custom style to apply, if `date_style` is set to custom |

#### Returns

a human readable date representation of `file_time` according to the `date_format` .

### thunar_util_parse_parent ()

    GdkScreen *
    thunar_util_parse_parent (gpointer parent,
                              GtkWindow **window_return);

Determines the screen for the `parent` and returns that GdkScreen. If `window_return` is not `NULL`, the pointer to the GtkWindow is placed into it, or `NULL` if the window could not be determined.

#### Parameters

parent | a GtkWidget, a GdkScreen or `NULL`. |
window_return | return location for the toplevel GtkWindow or `NULL`. |

#### Returns

the GdkScreen for the `parent` .

### thunar_util_time_from_rfc3339 ()

    time_t
    thunar_util_time_from_rfc3339 (const gchar *date_string);

Decodes the `date_string` , which must be in the special RFC 3339 format `YYYY-MM-DDThh:mm:ss`. This method is used to decode deletion dates of files in the trash. See the Trash Specification for details.

#### Parameters

date_string | an RFC 3339 encoded date string. |

#### Returns

the time value matching the `date_string` or `0` if the `date_string` could not be parsed.

### thunar_util_change_working_directory ()

    gchar *
    thunar_util_change_working_directory (const gchar *new_directory);

### thunar_setup_display_cb ()

    void
    thunar_setup_display_cb (gpointer data);

### thunar_util_next_new_file_name ()

    gchar *
    thunar_util_next_new_file_name (ThunarFile *dir,
                                    const gchar *file_name,
                                    ThunarNextFileNameMode name_mode,
                                    gboolean is_directory);

### thunar_util_next_new_file_name_raw ()

    gchar *
    thunar_util_next_new_file_name_raw (GList *file_list,
                                        const gchar *file_name,
                                        ThunarNextFileNameMode name_mode,
                                        gboolean is_directory);

Returns a filename that is like `file_name` with the possible addition of a number to differentiate it from other similarly named files. In other words it searches `dir` for incrementally named files starting from `file_name` and returns the first available increment.

e.g. in a folder with the following files:

- file

- empty

- file_copy

Calling this functions with the above folder and `file_name` equal to 'file' the returned filename will be 'file 1' for the mode "new file".

The caller is responsible to free the returned string using `g_free()` when no longer needed.

#### Parameters

file_name | the filename which will be used as the basis/default |
ThunarNextFileNameMode | To decide if the naming should follow "file copy","file link" or "new file" syntax |
is_directory | TRUE, if `file_name` is supposed to be the name of a directory |

#### Returns

pointer to the new filename.

### thunar_util_get_search_prefix ()

    const char *
    thunar_util_get_search_prefix (void);

#### Returns

The localized search prefix

### thunar_util_is_a_search_query ()

    gboolean
    thunar_util_is_a_search_query (const gchar *string);

#### Parameters

string | the string to check |

#### Returns

a boolean that is TRUE if `string` starts with 'Search: '.

### thunar_util_strjoin_list ()

    gchar *
    thunar_util_strjoin_list (GList *string_list,
                              const gchar *separator);

Joins a number of strings together to form one long string, with the optional separator inserted between each of them. It skips all the NULL values passed in the list. The returned string should be freed with `g_free()`. Similar to `g_strjoin()`.

The caller is responsible to free the returned text using `g_free()` when it is no longer needed

#### Parameters

data | list of strings which needs to be appended. |
separator | text which needs to be added as a seperator |

#### Returns

the concatenated string

### thunar_util_clip_view_background ()

    void
    thunar_util_clip_view_background (GtkCellRenderer *cell,
                                      cairo_t *cr,
                                      const GdkRectangle *background_area,
                                      GtkWidget *widget,
                                      GtkCellRendererState flags);

### thunar_util_split_search_query ()

    gchar **
    thunar_util_split_search_query (const gchar *search_query_normalized,
                                    GError **error);

Search terms are split on whitespace. Search queries must be normalized before passing to this function.

See also: `thunar_g_utf8_normalize_for_search()`.

#### Parameters

search_query | The search query to split. |
error | Return location for regex compilation errors. |

#### Returns

a list of search terms which must be freed with `g_strfreev()`

### thunar_util_search_terms_match ()

    gboolean
    thunar_util_search_terms_match (gchar **terms,
                                    gchar *str);

All search terms must match. Thunar uses simple substring matching for the broadest multilingual support. `str` must be normalized before passing to this function.

See also: `thunar_g_utf8_normalize_for_search()`.

#### Parameters

terms | The search terms to look for, prepared with `thunar_util_split_search_query()`. |
str | The string which the search terms might be found in. |

#### Returns

TRUE if all terms matched, FALSE otherwise.

### thunar_util_save_geometry_timer ()

    gboolean
    thunar_util_save_geometry_timer (gpointer user_data);

### thunar_util_get_statusbar_text_for_files ()

    gchar *
    thunar_util_get_statusbar_text_for_files
                                   (GHashTable *files,
                                    gboolean show_hidden,
                                    gboolean show_file_size_binary_format,
                                    ThunarDateStyle date_style,
                                    const gchar *date_custom_style,
                                    guint status_bar_actve_info);

Generates the statusbar text for the given `files` .

The caller is reponsible to free the returned text using `g_free()` when it's no longer needed.

#### Parameters

files | list of GFile's for which a text is requested |
show_hidden | whether hidden files are shown |
show_file_size_binary_format | whether the file size should be displayed in binary format |
date_style | the ThunarDateFormat used to humanize the `file_time` . |
date_custom_style | custom style to apply, if `date_style` is set to custom |

#### Returns

the statusbar text with the given `files` .

### thunar_util_get_statusbar_text_for_single_file ()

    gchar *
    thunar_util_get_statusbar_text_for_single_file
                                   (ThunarFile *file);

### thunar_util_accel_path_to_id ()

    gchar *
    thunar_util_accel_path_to_id (const gchar *accel_path);

## Types and Values

### ALPHA_BACKDROP

    #define ALPHA_BACKDROP 0.5

### ALPHA_FOCUSED

    #define ALPHA_FOCUSED 1.0

### STACK_ALLOC_LIMIT

    #define STACK_ALLOC_LIMIT 2000

### MAX_EMBLEMS_PER_FILE

    #define MAX_EMBLEMS_PER_FILE 4

### enum ThunarNextFileNameMode

#### Members

THUNAR_NEXT_FILE_NAME_MODE_NEW |  |
THUNAR_NEXT_FILE_NAME_MODE_COPY |  |
THUNAR_NEXT_FILE_NAME_MODE_LINK |  |