From 1ced9c3666e8ec3413df771498e0a1ae825353b7 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 19 Aug 2025 17:59:17 +0600 Subject: [PATCH] Added function to get dependences --- source/libublsettings-gtk3.c | 21 +++++++++++++++++++++ source/libublsettings-gtk3.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/source/libublsettings-gtk3.c b/source/libublsettings-gtk3.c index eb4e6a7..3876d09 100644 --- a/source/libublsettings-gtk3.c +++ b/source/libublsettings-gtk3.c @@ -219,6 +219,27 @@ char *yon_packages_get_description(enum YON_PACKAGES_DB_TYPE type, const char *p } } +config_str yon_packages_get_depends(enum YON_PACKAGES_DB_TYPE type, const char *package, int *size){ + (*size)=0; + if (yon_char_is_empty(package)) return NULL; + config_str depends = NULL; + + alpm_list_t *databases = _yon_packages_get_db_list(type); + alpm_list_t *iter = NULL, *pkg_iter = NULL; + for (iter = databases; iter; iter=iter->next){ + alpm_pkg_t *pkg = alpm_db_get_pkg(iter->data,package); + if (!pkg) continue; + alpm_list_t *list = alpm_pkg_compute_requiredby(pkg); + for (pkg_iter = list; pkg_iter; pkg_iter=pkg_iter->next){ + yon_char_parsed_add_or_create_if_exists(depends,size,pkg_iter->data); + + } + break; + } + + return depends; +} + void yon_packages_update(){ if (packages_struct.packages_handle) alpm_release(packages_struct.packages_handle); _yon_packages_get_db(); diff --git a/source/libublsettings-gtk3.h b/source/libublsettings-gtk3.h index 41d8533..c25d819 100644 --- a/source/libublsettings-gtk3.h +++ b/source/libublsettings-gtk3.h @@ -601,6 +601,8 @@ 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); +config_str yon_packages_get_depends(enum YON_PACKAGES_DB_TYPE type, const char *package, int *size); + void yon_combo_box_set_default(GtkComboBoxText *target, char *command, char*(result_callback)(char*)); int yon_ip_mask_get_bits(char *mask);