You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
4.2 KiB
141 lines
4.2 KiB
#include "libublsettings-gtk3.h"
|
|
|
|
#ifdef __GTK_H__
|
|
|
|
// GtkEntry section
|
|
// struct entry_pattern_data {
|
|
// GtkEntry *entry;
|
|
// char *pattern; // %d %s
|
|
// };
|
|
|
|
// char *yon_gtk_entry_pattern_format(GtkWidget *target, struct entry_pattern_data *data){
|
|
// if (target){
|
|
// const char *entry_data = gtk_entry_get_text(target);
|
|
// int next_track=0;
|
|
// for (int i=0; i<strlen(data->pattern);i++){
|
|
// char target_letter=-1;
|
|
// target_letter = ;
|
|
// switch (data->pattern[i]){
|
|
// case '%':next_track=1;
|
|
// break;
|
|
// case 'd':if (next_track){
|
|
|
|
// }
|
|
// break;
|
|
// case 's':
|
|
// break;
|
|
// default:
|
|
|
|
// }
|
|
// }
|
|
|
|
// };
|
|
// }
|
|
|
|
// void yon_gtk_entry_set_pattern(GtkEntry *entry, char *pattern){
|
|
// struct entry_pattern_data *data = malloc(sizeof(struct entry_pattern_data));
|
|
// data->entry=entry;
|
|
// data->pattern=pattern;
|
|
// char *current_text = gtk_entry_get_text(entry);
|
|
|
|
// }
|
|
|
|
|
|
struct packages {
|
|
GHashTable *all_list;
|
|
GHashTable *installed_list;
|
|
} packages_struct;
|
|
|
|
int yon_packages_init(){
|
|
if (getuid()) return 0;
|
|
packages_struct.all_list = g_hash_table_new_full(g_str_hash,g_str_equal,free,NULL);
|
|
packages_struct.installed_list = g_hash_table_new_full(g_str_hash,g_str_equal,free,NULL);
|
|
|
|
int size;
|
|
int installed_size;
|
|
config_str package_list = yon_config_load("pacman -Slq",&size);
|
|
config_str installed = yon_config_load("pacman -Qq",&installed_size);
|
|
|
|
for (int i=0;i<size;i++){
|
|
yon_char_remove_last_symbol(package_list[i],'\n');
|
|
g_hash_table_add(packages_struct.all_list,package_list[i]);
|
|
}
|
|
|
|
for (int i=0;i<installed_size;i++){
|
|
yon_char_remove_last_symbol(package_list[i],'\n');
|
|
g_hash_table_add(packages_struct.installed_list,installed[i]);
|
|
}
|
|
free(package_list);
|
|
free(installed);
|
|
|
|
if (g_hash_table_size(packages_struct.all_list)&&g_hash_table_size(packages_struct.installed_list))
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int yon_packages_check_exist(char *package){
|
|
return g_hash_table_contains(packages_struct.all_list,package);
|
|
}
|
|
|
|
int yon_packages_check_installed(char *package){
|
|
return g_hash_table_contains(packages_struct.installed_list,package);
|
|
}
|
|
|
|
void yon_packages_finish(){
|
|
g_hash_table_unref(packages_struct.all_list);
|
|
g_hash_table_unref(packages_struct.installed_list);
|
|
}
|
|
|
|
config_str yon_resource_open_file(const char *path, int *size){
|
|
config_str parsed = NULL;
|
|
char *modules;
|
|
gsize sz;
|
|
GFile *file = g_file_new_for_uri(path);
|
|
g_file_load_contents(file,NULL,&modules,&sz,NULL,NULL);
|
|
g_object_unref(G_OBJECT(file));
|
|
parsed = yon_char_parse(modules,size,"\n");
|
|
return parsed;
|
|
}
|
|
|
|
// dictionary *__yon_config_listeners = NULL;
|
|
// typedef struct {
|
|
// GtkWidget *target;
|
|
// char *widget_parameter;
|
|
// void *check_function;
|
|
// char *parameter;
|
|
// char *save_command;
|
|
// } config_listener;
|
|
|
|
// void __yon_gtk_config_activated(GtkWidget *, config_listener *current){
|
|
// char *parameter;
|
|
|
|
// if (((int (*)(char*, GtkWidget*, char*))(current->check_function))(parameter,current->target, current->parameter)) {
|
|
// }
|
|
|
|
// }
|
|
|
|
// int yon_gtk_config_add_listener (GtkWidget *target, char *parameter, char *save_command,int(check_function)(char*,GtkWidget*,char*)){
|
|
// if (__yon_config_listeners){
|
|
// dictionary *dict;
|
|
// for_dictionaries(dict,__yon_config_listeners){
|
|
// if (target==((config_listener*)dict->data)->target){
|
|
// return 0;
|
|
// }
|
|
// }
|
|
// }
|
|
// config_listener *current = malloc(sizeof(config_listener));
|
|
// current->target=target;
|
|
// current->parameter = parameter;
|
|
// current->save_command = save_command;
|
|
// current->check_function = (void*)check_function;
|
|
// if (GTK_IS_TOGGLE_BUTTON(target)){
|
|
// g_signal_connect(G_OBJECT(target),"toggled",C_CALLBACK(__yon_gtk_config_activated),current);
|
|
|
|
// }
|
|
|
|
// yon_dictionary_add_or_create_if_exists_with_data(__yon_config_listeners,NULL,current);
|
|
// return 0;
|
|
// }
|
|
|
|
#endif |