master #58

Merged
asmeron merged 2 commits from YanTheKaller/libublsettings-gtk3:master into master 3 weeks ago

@ -19,10 +19,8 @@ int yon_app_set_from_file(apps *target, const char *path){
GKeyFile *cur_file = g_key_file_new(); GKeyFile *cur_file = g_key_file_new();
if (!g_key_file_load_from_file(cur_file,path,G_KEY_FILE_KEEP_TRANSLATIONS,NULL)) return 0; if (!g_key_file_load_from_file(cur_file,path,G_KEY_FILE_KEEP_TRANSLATIONS,NULL)) return 0;
gsize names_size; target->Name = g_key_file_get_locale_string(cur_file,"Desktop Entry","Name",NULL,NULL);
config_str names = g_key_file_get_locale_string_list(cur_file,"Desktop Entry","Name",NULL,&names_size,NULL);
target->Desktop_path = yon_char_new(path); target->Desktop_path = yon_char_new(path);
target->Name = names[0];
target->Comment = g_key_file_get_string(cur_file,"Desktop Entry","Comment",NULL); target->Comment = g_key_file_get_string(cur_file,"Desktop Entry","Comment",NULL);
char *categories = g_key_file_get_string(cur_file,"Desktop Entry","Categories",NULL); char *categories = g_key_file_get_string(cur_file,"Desktop Entry","Categories",NULL);
target->Categories = yon_char_parse(categories,&target->categories_size,";"); target->Categories = yon_char_parse(categories,&target->categories_size,";");
@ -34,6 +32,7 @@ int yon_app_set_from_file(apps *target, const char *path){
target->DualPluggable = !yon_char_is_empty(dual_pluggable)&&!strcmp(dual_pluggable,"true"); target->DualPluggable = !yon_char_is_empty(dual_pluggable)&&!strcmp(dual_pluggable,"true");
char *type = g_key_file_get_string(cur_file,"Desktop Entry","Type",NULL); char *type = g_key_file_get_string(cur_file,"Desktop Entry","Type",NULL);
target->Type = !yon_char_is_empty(type)&&!strcmp(type,"Application"); target->Type = !yon_char_is_empty(type)&&!strcmp(type,"Application");
target->keywords = g_key_file_get_locale_string(cur_file,"Desktop Entry","Keywords",NULL,NULL);
if (!yon_char_is_empty(target->Exec)){ if (!yon_char_is_empty(target->Exec)){
int parsed_size; int parsed_size;
@ -66,7 +65,7 @@ void yon_apps_init(){
char *cur_path = yon_char_unite(DesktopPath,"/",paths[i],NULL); char *cur_path = yon_char_unite(DesktopPath,"/",paths[i],NULL);
apps *cur_app = yon_app_new(); apps *cur_app = yon_app_new();
yon_app_set_from_file(cur_app,cur_path); yon_app_set_from_file(cur_app,cur_path);
g_hash_table_insert(_apps,yon_char_new(cur_app->Name),cur_app); g_hash_table_insert(_apps,yon_char_new(cur_app->Desktop_path),cur_app);
} }
} }
@ -99,7 +98,7 @@ config_str yon_apps_get_by_categories(config_str categories, int categories_size
for (iter=list;iter;iter=iter->next){ for (iter=list;iter;iter=iter->next){
apps *cur_app = (apps*)iter->data; apps *cur_app = (apps*)iter->data;
if (yon_char_parsed_includes_char_parsed(cur_app->Categories,categories,cur_app->categories_size, categories_size)){ if (yon_char_parsed_includes_char_parsed(cur_app->Categories,categories,cur_app->categories_size, categories_size)){
yon_char_parsed_add_or_create_if_exists(final,final_size,cur_app->Name); yon_char_parsed_add_or_create_if_exists(final,final_size,cur_app->Desktop_path);
} }
} }
return final; return final;

@ -117,7 +117,7 @@ alpm_list_t *_yon_packages_get_db_list(enum YON_PACKAGES_DB_TYPE type){
} }
int yon_packages_init(){ int yon_packages_init(){
if (packages_struct.packages_handle) return 0; if (packages_struct.packages_handle||getuid()) return 0;
int status = _yon_packages_get_db(); int status = _yon_packages_get_db();
if (!status) return 0; if (!status) return 0;
@ -241,6 +241,7 @@ config_str yon_packages_get_depends(enum YON_PACKAGES_DB_TYPE type, const char *
} }
void yon_packages_update(){ void yon_packages_update(){
if (getuid()) return;
if (packages_struct.packages_handle) alpm_release(packages_struct.packages_handle); if (packages_struct.packages_handle) alpm_release(packages_struct.packages_handle);
packages_struct.packages_handle=NULL; packages_struct.packages_handle=NULL;
_yon_packages_get_db(); _yon_packages_get_db();

@ -629,6 +629,7 @@ typedef struct apps
char *Icon; char *Icon;
int Pluggable; int Pluggable;
int DualPluggable; int DualPluggable;
char *keywords;
} apps; } apps;
/// @brief Initiallize applications system /// @brief Initiallize applications system

Loading…
Cancel
Save