master #64

Merged
asmeron merged 6 commits from YanTheKaller/libublsettings-gtk3:master into master 3 months ago

@ -94,6 +94,13 @@ install: check
[ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \
ldconfig -n ${DESTDIR}${PREFIX}/lib; \
fi
@for LANG in $$(find ./locale -iname "*.po" -print | sed -En "s/.+_([[:alpha:]]+)\.po/\1/p" | sort -u); do \
install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \
# PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/${PKGNAME}.mo"; \
PATH_FILE_MO="${DESTDIR}/usr/share/locale/$${LANG}/LC_MESSAGES/${PKGNAME}.mo"; \
PKGNAME_PO="./locale/${PKGNAME}_$${LANG}.po"; [[ -f "$${PKGNAME_PO}" ]] || PKGNAME_PO= ; \
msgfmt --verbose --use-fuzzy --output-file "$${PATH_FILE_MO}" - < <(msgcat --use-first --no-wrap $${PKGNAME_PO} ./locale/*_$${LANG}.po); \
done
@echo "Install: OK"
clean:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -47,6 +47,7 @@ add_library(${PROJECT_NAME} SHARED
${PROJECT_NAME}-vte.c
${PROJECT_NAME}-webkit.c
${PROJECT_NAME}-window-config.c
${PROJECT_NAME}-timezone.c
${PROJECT_NAME}.c
${PROJECT_NAME}.h)

@ -92,7 +92,8 @@ int yon_packages_init(){
int yon_packages_check_exist(const char *package_name){
alpm_list_t *sync_db = _yon_packages_get_db_list(YON_PACKAGES_ALL);
for (alpm_list_t *iter=sync_db;iter;iter=alpm_list_next(iter)){
alpm_list_t *iter;
for (iter=sync_db;iter;iter=alpm_list_next(iter)){
alpm_db_t *database = iter->data;
alpm_pkg_t *package = alpm_db_get_pkg(database,package_name);
@ -184,6 +185,157 @@ char *yon_packages_get_description(enum YON_PACKAGES_DB_TYPE type, const char *p
}
}
char* yon_alpm_list_to_char(alpm_list_t *list){
if (!list) return NULL;
int size = 0;
size_t list_size = alpm_list_count(list);
config_str parsed = NULL;
for (size_t i=0;i<list_size;i++){
yon_char_parsed_add_or_create_if_exists(parsed,&size,list->data)
list=list->next;
}
char *final = yon_char_parsed_to_string(parsed,size," ");
yon_char_parsed_free(parsed,size);
return final;
}
yon_packages_info *yon_packages_get_info_struct(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)){
yon_packages_info *package_info = malloc(sizeof(yon_packages_info));
memset(package_info,0,sizeof(yon_packages_info));
package_info->repo_name = yon_char_new(alpm_db_get_name(iter->data));
package_info->package_name = yon_char_new(alpm_pkg_get_name(pkg));
package_info->version = yon_char_new(alpm_pkg_get_version(pkg));
package_info->description = yon_char_new(alpm_pkg_get_desc(pkg));
package_info->architecture = yon_char_new(alpm_pkg_get_arch(pkg));
package_info->url = yon_char_new(alpm_pkg_get_url(pkg));
size_t size=0;
alpm_list_t *licence_list = alpm_pkg_get_licenses(pkg);
package_info->licence = yon_alpm_list_to_char(licence_list);
alpm_list_free(licence_list);
alpm_list_t *groups_list = alpm_pkg_get_groups(pkg);
package_info->groups = yon_alpm_list_to_char(groups_list);
alpm_list_free(groups_list);
{
alpm_list_t *provides_list = alpm_pkg_get_provides(pkg);
size = alpm_list_count(provides_list);
int parsed_size=0;
config_str parsed = NULL;
for (int i=0;i<size;i++){
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)provides_list->data)->name);
}
package_info->provides = yon_char_parsed_to_string(parsed,parsed_size, " ");
alpm_list_free(provides_list);
}
{
alpm_list_t *depends_list = alpm_pkg_get_depends(pkg);
size = alpm_list_count(depends_list);
int parsed_size=0;
config_str parsed = NULL;
for (int i=0;i<size;i++){
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)depends_list->data)->name);
}
package_info->depends = yon_char_parsed_to_string(parsed,parsed_size, " ");
alpm_list_free(depends_list);
}
{
alpm_list_t *optdepends_list = alpm_pkg_get_optdepends(pkg);
size = alpm_list_count(optdepends_list);
int parsed_size=0;
config_str parsed = NULL;
for (int i=0;i<size;i++){
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)optdepends_list->data)->name);
}
package_info->optional_depends = yon_char_parsed_to_string(parsed,parsed_size, " ");
alpm_list_free(optdepends_list);
}
{
alpm_list_t *conflicts_list = alpm_pkg_get_conflicts(pkg);
size = alpm_list_count(conflicts_list);
int parsed_size=0;
config_str parsed = NULL;
for (int i=0;i<size;i++){
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)conflicts_list->data)->name);
}
package_info->conflicts = yon_char_parsed_to_string(parsed,parsed_size, " ");
alpm_list_free(conflicts_list);
}
{
alpm_list_t *replaces_list = alpm_pkg_get_replaces(pkg);
size = alpm_list_count(replaces_list);
int parsed_size=0;
config_str parsed = NULL;
for (int i=0;i<size;i++){
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)replaces_list->data)->name);
}
package_info->replaces = yon_char_parsed_to_string(parsed,parsed_size, " ");
alpm_list_free(replaces_list);
}
int size_mod = 0;
int fin_size = yon_size_convert_automatic(alpm_pkg_get_size(pkg),&size_mod);
char *size_letter = yon_size_get_mod(size_mod);
char *size_string = yon_char_from_int(fin_size);
package_info->download_size = yon_char_unite(size_string,size_letter,NULL);
free(size_string);
size_mod = 0;
fin_size = yon_size_convert_automatic(alpm_pkg_get_isize(pkg),&size_mod);
size_letter = yon_size_get_mod(size_mod);
size_string = yon_char_from_int(fin_size);
package_info->install_size = yon_char_unite(size_string,size_letter,NULL);
free(size_string);
package_info->packager = yon_char_new(alpm_pkg_get_packager(pkg));
GDateTime *datetime = g_date_time_new_from_unix_local(alpm_pkg_get_builddate(pkg));
package_info->build_date = g_date_time_format(datetime,"%Ec");
package_info->validate_by = alpm_pkg_get_validation(pkg);
return package_info;
}
}
}
char *yon_packages_get_info_string(yon_packages_info *info){
char *packager = yon_char_return_if_exist(info->packager,"");
char *info_label = yon_char_unite(
"<b>",_("Repository"),"</b>\t\t:",yon_char_return_if_exist(info->repo_name,""),"\n",
"<b>",_("Name"),"</b>\t\t\t:",yon_char_return_if_exist(info->package_name,""),"\n",
"<b>",_("Version"),"</b>\t\t:",yon_char_return_if_exist(info->version,""),"\n",
"<b>",_("Description"),"</b>\t:",yon_char_return_if_exist(info->description,""),"\n",
"<b>",_("Architecture"),"</b>\t:",yon_char_return_if_exist(info->architecture,""),"\n",
"<b>",_("URL"),"</b>\t\t\t:",yon_char_return_if_exist(info->url,""),"\n",
"<b>",_("Licenses"),"</b>\t\t:",yon_char_return_if_exist(info->licence,""),"\n",
"<b>",_("Groups"),"</b>\t\t\t:",yon_char_return_if_exist(info->groups,""),"\n",
"<b>",_("Provides"),"</b>\t\t:",yon_char_return_if_exist(info->provides,""),"\n",
"<b>",_("Depends On"),"</b>\t:",yon_char_return_if_exist(info->depends,""),"\n",
"<b>",_("Optional Deps"),"</b>\t:",yon_char_return_if_exist(info->optional_depends,""),"\n",
"<b>",_("Conflicts With"),"</b>\t:",yon_char_return_if_exist(info->conflicts,""),"\n",
"<b>",_("Replaces"),"</b>\t\t:",yon_char_return_if_exist(info->replaces,""),"\n",
"<b>",_("Download Size"),"</b>\t:",yon_char_return_if_exist(info->download_size,""),"\n",
"<b>",_("Installed Size"),"</b>\t:",yon_char_return_if_exist(info->install_size,""),"\n",
"<b>",_("Packager"),"</b>\t\t:",g_markup_escape_text(packager,strlen(packager)),"\n",
"<b>",_("Build Date"),"</b>\t\t:",yon_char_return_if_exist(info->build_date,""),"\n",
// "<b>",_("Validated By"),"</b>\t:",yon_char_return_if_exist(info->architecture,""),
NULL);
return info_label;
}
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;

@ -8,12 +8,6 @@ void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image
gtk_image_set_from_file(GTK_IMAGE(Image), image_path);
}
void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path)
{
gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head);
gtk_image_set_from_resource(GTK_IMAGE(Image), image_path);
}
int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label)
{
if(icon&&box&&label){

@ -0,0 +1,196 @@
#include "libublsettings-gtk3.h"
GHashTable *__yon_timezone = NULL;
#define timezone_path "/usr/share/zoneinfo/zone.tab"
#define timezone_countries_path "/usr/share/zoneinfo/iso3166.tab"
#define yon_timezone_check if (__yon_timezone&&g_hash_table_size(__yon_timezone))
typedef struct {
char *country_code;
char *timezone;
char *comments;
char *city;
char *country;
char *zone;
double lat;
double lon;
} yon_timezone_struct;
void _yon_timezone_countries_setup(GHashTable *timezone_countries){
g_hash_table_remove_all(timezone_countries);
int size;
config_str countries_file = yon_file_open(timezone_countries_path,&size);
for (int i=0;i<size;i++){
if (countries_file[i][0]=='#') continue;
yon_char_remove_last_symbol(countries_file[i],'\n');
int parsed_size;
config_str parsed = yon_char_parse(countries_file[i],&parsed_size,"\t");
if (size<2) continue;
g_hash_table_insert(timezone_countries,yon_char_new(parsed[0]),yon_char_new(parsed[1]));
yon_char_parsed_free(parsed,parsed_size);
}
yon_char_parsed_free(countries_file,size);
}
int yon_timezone_init(){
yon_timezone_check{
return 0;
} else {
GHashTable *timezone_countries = g_hash_table_new_full(g_str_hash, g_str_equal,free,free);
_yon_timezone_countries_setup(timezone_countries);
__yon_timezone = g_hash_table_new_full(g_str_hash,g_str_equal,free,free);
int size;
config_str timezone_file = yon_file_open(timezone_path,&size);
for (int i=0;i<size;i++){
if (timezone_file[i][0]=='#') continue;
yon_char_remove_last_symbol(timezone_file[i],'\n');
int parsed_size;
config_str parsed = yon_char_parse(timezone_file[i],&parsed_size,"\t");
if (parsed_size<3) continue;
yon_timezone_struct *timezone_info = malloc(sizeof(yon_timezone_struct));
memset(timezone_info,0,sizeof(yon_timezone_struct));
if (yon_char_count(parsed[2],"/")>1){
timezone_info->timezone = yon_char_new(parsed[2]);
free(yon_char_divide_search(timezone_info->timezone,"/",-1));
} else {
timezone_info->timezone = yon_char_new(parsed[2]);
}
char *city = strstr(timezone_info->timezone,"/");
if (city){
city++;
}
char *zone = yon_char_new(timezone_info->timezone);
char *temp = strstr(zone,"/");
if (temp){
temp[0]='\0';
}
timezone_info->country_code = yon_char_new(parsed[0]);
timezone_info->city = yon_char_new(city);
timezone_info->country = yon_char_new(g_hash_table_lookup(timezone_countries,parsed[0]));
timezone_info->zone = zone;
char *coords = yon_char_new(parsed[1]);
char *pos = strstr(coords+1,"+");
char *ngt = strstr(coords+1,"-");
char *lat = coords;
char *lon = !yon_char_is_empty(pos)?yon_char_new(pos):yon_char_new(ngt);
if (parsed_size>3){
timezone_info->comments = yon_char_new(parsed[3]);
}
g_hash_table_insert(__yon_timezone,yon_char_new(timezone_info->timezone),timezone_info);
yon_char_parsed_free(parsed,parsed_size);
}
yon_char_parsed_free(timezone_file,size);
g_hash_table_unref(timezone_countries);
}
return 1;
}
void yon_timezone_unref(){
yon_timezone_check{
g_hash_table_unref(__yon_timezone);
__yon_timezone = NULL;
}
}
config_str yon_timezone_get_all(size_t *size){
(*size) = 0;
yon_timezone_check{
config_str timezones = (config_str)g_hash_table_get_keys_as_array(__yon_timezone,(guint*)size);
qsort(timezones,*size,sizeof(char*),(__compar_fn_t)yon_char_parsed_compare);
return yon_char_parsed_copy(timezones,*size);
}
return NULL;
}
char *yon_timezone_get_country_code(const char *timezone){
yon_timezone_check{
yon_timezone_struct *timezone_info = g_hash_table_lookup(__yon_timezone,timezone);
if (timezone_info){
return yon_char_new(timezone_info->country_code);
}
}
return NULL;
}
char *yon_timezone_get_comments(const char *timezone){
yon_timezone_check{
yon_timezone_struct *timezone_info = g_hash_table_lookup(__yon_timezone,timezone);
if (timezone_info){
return yon_char_new(timezone_info->comments);
}
}
return NULL;
}
char *yon_timezone_get_city(const char *timezone){
yon_timezone_check{
yon_timezone_struct *timezone_info = g_hash_table_lookup(__yon_timezone,timezone);
if (timezone_info){
return yon_char_new(timezone_info->city);
}
}
return NULL;
}
char *yon_timezone_get_country(const char *timezone){
yon_timezone_check{
yon_timezone_struct *timezone_info = g_hash_table_lookup(__yon_timezone,timezone);
if (timezone_info){
return yon_char_new(timezone_info->country);
}
}
return NULL;
}
char *yon_timezone_get_zone(const char *timezone){
yon_timezone_check{
yon_timezone_struct *timezone_info = g_hash_table_lookup(__yon_timezone,timezone);
if (timezone_info){
return yon_char_new(timezone_info->zone);
}
}
return NULL;
}
#define get_utc_command(tz) yon_char_unite("TZ='",tz,"' date +%z",NULL);
char *yon_timezone_get_utc(const char *timezone){
char *command = get_utc_command(timezone);
int size;
config_str ret = yon_config_load(command,&size);
if (size>0){
yon_char_remove_last_symbol(ret[0],'\n');
char *temp = yon_char_new(ret[0]);
yon_char_parsed_free(ret,size);
return temp;
}
return NULL;
}
config_str yon_timezone_get_zones_from_region(char *region, size_t *size){
size_t timezones_size;
(*size) = 0;
yon_timezone_check{
config_str zones_final = NULL;
config_str timezones = (config_str)g_hash_table_get_keys_as_array(__yon_timezone,(guint*)&timezones_size);
for (size_t i=0;i<timezones_size;i++){
yon_timezone_struct *timezone_info = g_hash_table_lookup(__yon_timezone,timezones[i]);
if (timezone_info&&!yon_char_is_empty(timezone_info->zone)&&!strcmp(timezone_info->zone,region)){
yon_char_parsed_add_or_create_if_exists(zones_final,(int*)size,timezone_info->city);
}
}
qsort(zones_final,*size,sizeof(char*),(__compar_fn_t)yon_char_parsed_compare);
return zones_final;
}
}

@ -3,11 +3,13 @@
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gtk/gtkx.h>
#include <libintl.h>
#include <libublsettings.h>
#define _(String) gettext(String)
#ifdef __GTK_H__
#ifdef VTE_INCLUDE
#include <vte/vte.h>
/**
* void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument)
@ -59,6 +61,8 @@ void yon_terminal_window_launch_shell(GtkWindow *parent_window, char *command, c
void yon_terminal_window_update_button_launch(GtkWindow *parent_window, char *command, char *success_label,char *fail_label);
#endif
#define for_iter(model,iter) for(int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),iter);valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model),iter))
/**yon_gtk_widget_set_scroll_window_for_scroll(GtkWidget *target, GtkScrollbar *scroll)
@ -448,42 +452,6 @@ void yon_ubl_status_box_despawn(GtkContainer *status_container);
int yon_ubl_status_set_text(GtkContainer *status_placeholder,char *text);
/**yon_ubl_header_setup(overlay, head, image, imag_path)
* [EN]
* Sets up header of app.
* [overlay] is overlay for app header;
* [head] is box of header, which connects to [overlay]
* [image] is header background image;
* [imag_path] is path of image, shown in [image]
* [RU]
* Настраивает заголовок приложения.
* [overlay] - оверлей заголовка приложения;
* [head] - шапка заголовка, присоединяемая к [overlay]
* [image] - виджет картинки для заднего фона;
* [imag_path] - путь до картинки, загружаемой в [image]
*/
#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path)
/**yon_ubl_header_setup_resource(overlay, head, image, imag_path)
* [EN]
* Sets up header of app.
* [overlay] is overlay for app header;
* [head] is box of header, which connects to [overlay]
* [image] is header background image;
* [imag_path] is path of image, shown in [image]
* [RU]
* Настраивает заголовок приложения.
* [overlay] - оверлей заголовка приложения;
* [head] - шапка заголовка, присоединяемая к [overlay]
* [image] - виджет картинки для заднего фона;
* [imag_path] - путь до картинки в ресурсах утилиты, загружаемой в [image]
*/
#define yon_ubl_header_setup_resource(overlay, head, image, imag_path) _yon_ubl_header_setup_resource(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path)
void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path);
void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path);
//socket section
/**yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id)
* [EN]
@ -506,6 +474,11 @@ void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidg
void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id);
//webkit section
#ifdef WEBKIT_FOUND
#ifndef WEBKIT_INCLUDE
#define WEBKIT_INCLUDE
#endif
#endif
#ifdef WEBKIT_INCLUDE
#include <webkit2/webkit2.h>
@ -620,6 +593,31 @@ 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);
typedef struct {
char *repo_name;
char *package_name;
char *version;
char *description;
char *architecture;
char *url;
char *licence;
char *groups;
char *provides;
char *depends;
char *optional_depends;
char *conflicts;
char *replaces;
char *download_size;
char *install_size;
char *packager;
char *build_date;
int validate_by;
} yon_packages_info;
yon_packages_info *yon_packages_get_info_struct(enum YON_PACKAGES_DB_TYPE type, const char *package);
char *yon_packages_get_info_string(yon_packages_info *info);
void yon_combo_box_set_default(GtkComboBoxText *target, char *command, char*(result_callback)(char*));
int yon_ip_mask_get_bits(char *mask);
@ -670,4 +668,58 @@ config_str yon_apps_get_by_categories(config_str categories, int categories_size
/// @brief Block scroll element changing for GtkComboBox
/// @param target - GtkComboBox to block
void yon_gtk_combo_box_block_scroll(GtkComboBox *target);
//timezone section
#define timezone_locale_name "libublsettings-gtk3"
/// @brief Init timezone system
/// @return 1 if timezone system has been successfully initialised, 0 if failed
int yon_timezone_init();
/// @brief Finalize timezone system and free all memory;
void yon_timezone_unref();
/// @brief Get all timezones list
/// @param size pointer for list size;
/// @return A newly allocated char* array with timezones
config_str yon_timezone_get_all(size_t *size);
/// @brief Get list of zones for specific region
/// @param region The region for which the zone search will take place;
/// @param size size pointer of zones list;
/// @return New allocated char* array with zones
config_str yon_timezone_get_zones_from_region(char *region, size_t *size);
/// @brief Get a country code for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with country code or NULL
char *yon_timezone_get_country_code(const char *timezone);
/// @brief Get a comments for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with comments or NULL
char *yon_timezone_get_comments(const char *timezone);
/// @brief Get a city for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with city or NULL
char *yon_timezone_get_city(const char *timezone);
/// @brief Get a country for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with country or NULL
char *yon_timezone_get_country(const char *timezone);
/// @brief Get a zone for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with zone or NULL
char *yon_timezone_get_zone(const char *timezone);
/// @brief Get UTC modifier for timezone
/// @param timezone Requested timezone;
/// @return A newly allocated char string with UTC modifier or NULL
char *yon_timezone_get_utc(const char *timezone);
#endif
Loading…
Cancel
Save