![]() |
![]() |
![]() |
Libfm Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
Common Libfm utilities.Common Libfm utilities. — Common utility functions used by libfm and libfm-gtk. |
const char * (*FmAppCommandParseCallback) (char opt
,gpointer user_data
); struct FmAppCommandParseOption; int fm_app_command_parse (const char *cmd
,const FmAppCommandParseOption *opts
,char **ret
,gpointer user_data
); char * fm_canonicalize_filename (const char *filename
,const char *cwd
); char * fm_file_size_to_str (char *buf
,size_t buf_size
,goffset size
,gboolean si_prefix
); const char * fm_get_home_dir (void
); gboolean fm_key_file_get_bool (GKeyFile *kf
,const char *grp
,const char *key
,gboolean *val
); gboolean fm_key_file_get_int (GKeyFile *kf
,const char *grp
,const char *key
,int *val
); gboolean fm_run_in_default_main_context (GSourceFunc func
,gpointer data
); char * fm_strdup_replace (char *str
,char *old_str
,char *new_str
);
const char * (*FmAppCommandParseCallback) (char opt
,gpointer user_data
);
The handler which converts key char into string representation.
See also: fm_app_command_parse()
.
|
key character |
|
data passed from caller of fm_app_command_parse()
|
Returns : |
string representation. |
Since 1.0.0
struct FmAppCommandParseOption { char opt; FmAppCommandParseCallback callback; };
Element of correspondence for substitutions by fm_app_command_parse()
.
key character | |
FmAppCommandParseCallback |
subroutine to get string for substitution |
int fm_app_command_parse (const char *cmd
,const FmAppCommandParseOption *opts
,char **ret
,gpointer user_data
);
This function parses line that contains some %<char> commands and does substitutions on them using callbacks provided by caller.
|
line to parse |
|
plain list of possible options |
|
pointer for resulting string, string should be freed by caller. [out][transfer full] |
|
caller data to pass to callback |
Returns : |
number of valid options found in cmd . |
Since 1.0.0
char * fm_canonicalize_filename (const char *filename
,const char *cwd
);
Makes a canonical name with full path from filename
. Returned string
should be freed by caller after usage.
|
a filename |
|
current work directory path |
Returns : |
a canonical name. [transfer full] |
Since 0.1.0
char * fm_file_size_to_str (char *buf
,size_t buf_size
,goffset size
,gboolean si_prefix
);
Converts size
into text representation of form "21.4 kiB" for example.
|
pointer to array to make a string |
|
size of buf
|
|
number to convert |
|
TRUE to convert in SI units, FALSE to convert in IEC units |
Returns : |
buf . |
Since 0.1.0
const char * fm_get_home_dir (void
);
Retrieves valid path to home dir of user.
Returns : |
path string. |
Since 1.0.2
gboolean fm_key_file_get_bool (GKeyFile *kf
,const char *grp
,const char *key
,gboolean *val
);
Lookups key
in kf
and stores found value in val
if the key
was found.
|
a key file |
|
group to lookup key |
|
a key to lookup |
|
location to store value |
Returns : |
TRUE if key was found. |
Since 0.1.0
gboolean fm_key_file_get_int (GKeyFile *kf
,const char *grp
,const char *key
,int *val
);
Lookups key
in kf
and stores found value in val
if the key
was found.
|
a key file |
|
group to lookup key |
|
a key to lookup |
|
location to store value |
Returns : |
TRUE if key was found. |
Since 0.1.0
gboolean fm_run_in_default_main_context (GSourceFunc func
,gpointer data
);
Runs func
once in global main loop with supplied data
.
|
function to run |
|
data supplied for func
|
Returns : |
output of func . |
Since 1.0.2
char * fm_strdup_replace (char *str
,char *old_str
,char *new_str
);
Replaces every occurence of old_str
in str
with new_str
and returns
resulted string. Returned string should be freed with g_free()
after
usage.
Before 1.0.0 this API had name fm_str_replace.
|
a string |
|
substring to replace |
|
string to replace old_str
|
Returns : |
resulted string. [transfer full] |
Since 0.1.16