Added new size function

pull/66/head
parent 1245697d5b
commit 0693c4b9e2

@ -130,6 +130,24 @@ void yon_gtk_widget_register_parameter_activate(){
}
}
char *yon_size_get_name_from_letter(char letter){
switch (letter){
case 'K': return yon_char_new(KB_LABEL); break;
case 'M': return yon_char_new(MB_LABEL); break;
case 'G': return yon_char_new(GB_LABEL); break;
case 'T': return yon_char_new(TB_LABEL); break;
}
return NULL;
}
char *yon_size_long_convert_automatic_to_string(unsigned long bytes){
char mod = '\0';
double size_converted = yon_size_long_convert_automatic(bytes, &mod);
char *size_converted_str = yon_char_from_double(size_converted);
char *final = yon_char_unite(size_converted_str, " ", yon_size_get_name_from_letter(mod),NULL);
return final;
}
// dictionary *__yon_config_listeners = NULL;
// typedef struct {
// GtkWidget *target;

@ -589,8 +589,22 @@ int yon_packages_remove(char *package);
config_str yon_packages_find(enum YON_PACKAGES_DB_TYPE type, const char *search_string, gsize *size);
/// @brief Get groups string for package
/// @param type Source database for package
/// @param package Package name
/// @return A newly allocated string of groups for requested package in bytes
char *yon_packages_get_version(enum YON_PACKAGES_DB_TYPE type, const char *package);
/// @brief Get description for package
/// @param type Source database for package
/// @param package Package name
/// @return A newly allocated description string for requested package in bytes
char *yon_packages_get_description(enum YON_PACKAGES_DB_TYPE type, const char *package);
/// @brief Get groups string for package
/// @param type Source database for package
/// @param package Package name
/// @return A newly allocated string of groups for requested package in bytes
char *yon_packages_get_groups(enum YON_PACKAGES_DB_TYPE type, const char *package);
/// @brief Get installed size for package
@ -741,4 +755,14 @@ char *yon_timezone_get_zone(const char *timezone);
/// @return A newly allocated char string with UTC modifier or NULL
char *yon_timezone_get_utc(const char *timezone);
#define KB_LABEL _("Kb")
#define MB_LABEL _("Mb")
#define GB_LABEL _("Gb")
#define TB_LABEL _("Tb")
/// @brief Get a string of bytes, converted to kilobytes, megabytes gigabytes or terabytes (K, M, G, T)
/// @param bytes bytes to convert
/// @return A newly allocated string with converted representation of bytes
char *yon_size_long_convert_automatic_to_string(unsigned long bytes);
#endif
Loading…
Cancel
Save