From 1245697d5bb03b1cd22f26e3754f3e0bfcdde589 Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Tue, 17 Feb 2026 09:48:18 +0600 Subject: [PATCH] Added new functions --- source/libublsettings-gtk3-packages.c | 62 +++++++++++++++++++++++++++ source/libublsettings-gtk3.h | 19 +++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/source/libublsettings-gtk3-packages.c b/source/libublsettings-gtk3-packages.c index c0afa9c..e17c8ac 100644 --- a/source/libublsettings-gtk3-packages.c +++ b/source/libublsettings-gtk3-packages.c @@ -185,6 +185,68 @@ char *yon_packages_get_description(enum YON_PACKAGES_DB_TYPE type, const char *p } } +char *yon_packages_get_groups(enum YON_PACKAGES_DB_TYPE type, const char *package){ + if (yon_char_is_empty(package)) return NULL; + alpm_list_t *databases = _yon_packages_get_db_list(type); + + alpm_list_t *iter = NULL; + for (iter = databases; iter; iter=iter->next){ + alpm_pkg_t *pkg = alpm_db_get_pkg(iter->data,package); + if (!pkg) continue; + const char *name = alpm_pkg_get_name(pkg); + if (!strcmp(name,package)){ + alpm_list_t *groups = alpm_pkg_get_groups(pkg); + alpm_list_t *iter; + config_str groups_list = NULL; + int parsed_size; + int size = alpm_list_count(groups); + + for (int i=0;idata)==-1){ + yon_char_parsed_add_or_create_if_exists(groups_list,&parsed_size,yon_char_new(groups->data)); + } + } + char *final = yon_char_parsed_to_string(groups_list,parsed_size,", "); + return yon_char_new(final); + } + } + return NULL; +} + +long yon_packages_get_installed_size(enum YON_PACKAGES_DB_TYPE type, const char *package){ + if (yon_char_is_empty(package)) return 0; + alpm_list_t *databases = _yon_packages_get_db_list(type); + + alpm_list_t *iter = NULL; + for (iter = databases; iter; iter=iter->next){ + alpm_pkg_t *pkg = alpm_db_get_pkg(iter->data,package); + if (!pkg) continue; + const char *name = alpm_pkg_get_name(pkg); + if (!strcmp(name,package)){ + long size = alpm_pkg_get_isize(pkg); + return size; + } + } + return 0; +} + +long yon_packages_get_size(enum YON_PACKAGES_DB_TYPE type, const char *package){ + if (yon_char_is_empty(package)) return 0; + alpm_list_t *databases = _yon_packages_get_db_list(type); + + alpm_list_t *iter = NULL; + for (iter = databases; iter; iter=iter->next){ + alpm_pkg_t *pkg = alpm_db_get_pkg(iter->data,package); + if (!pkg) continue; + const char *name = alpm_pkg_get_name(pkg); + if (!strcmp(name,package)){ + long size = alpm_pkg_get_size(pkg); + return size; + } + } + return 0; +} + char* yon_alpm_list_to_char(alpm_list_t *list){ if (!list) return NULL; int size = 0; diff --git a/source/libublsettings-gtk3.h b/source/libublsettings-gtk3.h index caa456a..b47ddff 100644 --- a/source/libublsettings-gtk3.h +++ b/source/libublsettings-gtk3.h @@ -591,7 +591,24 @@ config_str yon_packages_find(enum YON_PACKAGES_DB_TYPE type, const char *search_ char *yon_packages_get_version(enum YON_PACKAGES_DB_TYPE type, const char *package); char *yon_packages_get_description(enum YON_PACKAGES_DB_TYPE type, const char *package); - +char *yon_packages_get_groups(enum YON_PACKAGES_DB_TYPE type, const char *package); + +/// @brief Get installed size for package +/// @param type Source database for package +/// @param package Package name +/// @return The installed size of requested package in bytes +long yon_packages_get_installed_size(enum YON_PACKAGES_DB_TYPE type, const char *package); + +/// @brief Get installed size for package +/// @param type Source database for package +/// @param package Package name +/// @return The download size of requested package in bytes +long yon_packages_get_size(enum YON_PACKAGES_DB_TYPE type, const char *package); + +/// @brief Get dependences for package +/// @param type Source database for package +/// @param package Package name +/// @return A newly allocated char* array config_str yon_packages_get_depends(enum YON_PACKAGES_DB_TYPE type, const char *package, int *size); typedef struct {