From b343bce5c7ae2b3a65fe3cab92ef527841acf744 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 13 Dec 2023 16:33:38 +0600 Subject: [PATCH] Utils functions updates --- source/ubl-utils.c | 949 +++++++++++++-------------------------------- source/ubl-utils.h | 805 +++++++++++++++++++++++++++++++++++--- 2 files changed, 1026 insertions(+), 728 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 824324a..f121652 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -2,12 +2,6 @@ // dictionary functions -/**yon_dictionary_new(): - * [EN] - * Creates and returns empty dictionary - * [RU] - * Создаёт и возвращает пустой словарь. - */ dictionary *yon_dictionary_new() { dictionary *dict = malloc(sizeof(dictionary)); @@ -20,24 +14,12 @@ dictionary *yon_dictionary_new() return dict; } -/**yon_dictionary_copy(dictionary *dict) - * [EN] - * - * [RU] - * Создаёт и возвращает копию элемента словаря [dict] -*/ dictionary *yon_dictinoary_copy(dictionary *dict){ dictionary *dct = yon_dictionary_new_with_data(dict->key,dict->data); dct->data_type= dict->data_type; return dct; } -/**yon_dictionary_copy_deep(dictionary *dict) - * [EN] - * - * [RU] - * Создаёт полную копию словаря [dict] и возвращает первый элемент -*/ dictionary *yon_dictionary_copy_deep(dictionary *dict){ dictionary *dct = NULL; dictionary *newone=NULL; @@ -48,69 +30,33 @@ dictionary *yon_dictionary_copy_deep(dictionary *dict){ return newone->first; } -/**int yon_dictionary_set_data(dictionary *dict, void *data) - * [EN] - * - * [RU] - * Установить элементу словаря [dict] значение [data] -*/ int yon_dictionary_set_data(dictionary *dict, void *data){ dict->data=data; } -/**int yon_dictionary_set_key(dictionary *dict, char *key) - * [EN] - * - * [RU] - * Изменяет ключ элемента словаря [dict] на [key] -*/ int yon_dictionary_set_key(dictionary *dict, char *key){ dict->key=key; return 1; } -/** int yon_dictionary_set(dictionary *dict, char *key, void *data) - * [EN] - * - * [RU] -* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] -*/ int yon_dictionary_set(dictionary *dict, char *key, void *data){ dict->key=key; dict->data=data; return 1; } -/**int yon_dictionary_empty(dictionary *dict) - * [EN] - * - * [RU] - * Очищает элемент словаря [dict] от данных -*/ int yon_dictionary_empty(dictionary *dict){ dict->data=NULL; dict->data_type=DICTIONARY_OTHER_TYPE; return 1; } -/**yon_dictionary_switch_to_last(dictionary **dict) - * [EN] - * - * [RU] - * Переключает словарь [dict] на последний элемент. -*/ void yon_dictionary_switch_to_last(dictionary **dict) { dictionary *dct=NULL, *dact=*dict; for_dictionaries(dct,dact); } -/**yon_dictionary_create_conneced(dictionary *targetdict) - * [EN] - * - * [RU] - * Создаёт новый элемент словаря [targetdict] -*/ dictionary *yon_dictionary_append(dictionary *targetdict) { targetdict = yon_dictionary_get_last(targetdict); @@ -121,14 +67,6 @@ dictionary *yon_dictionary_append(dictionary *targetdict) return targetdict->next; } -/**yon_dictionary_get_last(dictionary *dict) - * [EN] - * - * [RU] - * Возвращает последний элемент словаря [dict]. - * В отличае от yon_dictionary_switch_to_last() - * словарь [dict] остаётся на прежнем элементе. -*/ dictionary *yon_dictionary_get_last(dictionary *dict) { if (dict->next){ @@ -138,14 +76,6 @@ dictionary *yon_dictionary_get_last(dictionary *dict) } else return dict; } -/**yon_dictionary_switch_places(dictionary *dict, int aim) - * [EN] - * - * [RU] - * Меняет элемент словаря [dict] местами с другим элементом. - * если [aim]<0 элемент меняется местами с левым элементом; - * если [aim]>0 элемент меняется местами с правым элементом; -*/ dictionary *yon_dictionary_swap(dictionary *dict, int aim) { if (aim < 0) @@ -247,13 +177,6 @@ dictionary *yon_dictionary_swap(dictionary *dict, int aim) } } -/**yon_dictionary_make_first(dictionary *dict) - * [EN] - * - * [RU] - * Устанавливает указатель первого элемента словаря [dict] - * на текущий элемент. Не использовать. -*/ void yon_dictionary_make_first(dictionary *dict) { for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) @@ -262,12 +185,6 @@ void yon_dictionary_make_first(dictionary *dict) } } -/**yon_dictionary_make_nth(dictionary *dict, int nth) - * [EN] - * - * [RU] - * Перемещает элемент словаря [dict] на позицию [nth]. -*/ void yon_dictionary_make_nth(dictionary *dict, int nth) { dictionary *dct = dict->first; @@ -286,12 +203,6 @@ void yon_dictionary_make_nth(dictionary *dict, int nth) dct->prev = dict; } -/**yon_dictionary_create_with_data(char *key, void *data) - * [EN] - * - * [RU] - * Создаёт новый словарь с ключом [key] и указателем на данные [data] -*/ dictionary *yon_dictionary_new_with_data(char *key, void *data) { dictionary *dct = yon_dictionary_new(); @@ -301,12 +212,6 @@ dictionary *yon_dictionary_new_with_data(char *key, void *data) return dct; } -/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) - * [EN] - * Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary. - * [RU] - * Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря. -*/ void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){ dictionary *dict=NULL; for_dictionaries(dict,dictionary_to_free){ @@ -319,13 +224,6 @@ void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipul return NULL; } -/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) - * [EN] - * - * [RU] - * Создаёт новый элемент словаря, присоединяемый в конец словаря [dict] - * с ключом [key] и указателем на данные [data] -*/ dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data) { dictionary *dct = yon_dictionary_append(dict); @@ -335,12 +233,6 @@ dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *d return dct; } -/**yon_dictionary_connect(dictionary *old, dictionary *toconnect) - * [EN] - * - * [RU] - * Присоединяет словарь [toconnect] в конец словаря [old]. -*/ dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) { dictionary *dict = yon_dictionary_get_last(old); @@ -350,33 +242,29 @@ dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) return toconnect; } -/**yon_dictionary_get(dictionary **dict, char *key) - * [EN] - * - * [RU] - * Возвращает элемент словаря [dict] с ключом [key]. - * Если такого элемента не было обнаружено, возвращается NULL -*/ +dictionary *yon_dictionary_merge(dictionary *dict1,dictionary *dict2){ + dictionary *dct = NULL; + for_dictionaries(dct,dict2){ + if (!yon_dictionary_get(&dict1,dct->key)) + yon_dictionary_connect(dict1,dct); + } + return dict1; +} + dictionary *yon_dictionary_get(dictionary **dict, char *key) { dictionary *dct = *dict; - for (dictionary *pointer = dct->first; pointer != NULL; pointer = pointer->next) - { - if (strcmp(pointer->key, key) == 0) - { - *dict = pointer; - return pointer; + if (dct){ + for (dictionary *pointer = dct->first; pointer != NULL; pointer = pointer->next){ + if (pointer->key&&strcmp(pointer->key, key) == 0){ + *dict = pointer; + return pointer; + } } } return NULL; } -/**yon_dictionary_rip(dictionary *dict) - * [EN] - * - * [RU] - * Вырезает элемент из словаря и возвращает вырезанный элемент. -*/ dictionary *yon_dictionary_rip(dictionary *dict) { if (!dict->next&&!dict->prev) return NULL; @@ -412,12 +300,6 @@ dictionary *yon_dictionary_rip(dictionary *dict) } } -/**yon_dictionary_get_nth(dictionary *dict, int place) - * [EN] - * - * [RU] - * Возвращает [place]-й элемент словаря [dict] -*/ dictionary *yon_dictionary_get_nth(dictionary *dict, int place) { if (dict){ @@ -444,10 +326,6 @@ int yon_char_find_last(char *source, char find){ return i; } -/**[EN] - * - * creates new char string by combining two char strings. - */ char *yon_char_append(char *source, char *append) { if (source && append) @@ -465,10 +343,6 @@ char *yon_char_append(char *source, char *append) return NULL; } -/**[EN] - * - * creates new char string by copying another char. - */ char *yon_char_new(char *chr) { if (chr){ @@ -480,12 +354,6 @@ char *yon_char_new(char *chr) return NULL; } -/**yon_char_unite(char *source, ...) - * [En] - * - * [RU] - * Объединяет строку [source] со всеми строками, написанными в [...] -*/ char *yon_char_unite(char *source, ...){ va_list arglist; char *new_char=NULL; @@ -501,10 +369,6 @@ char *yon_char_unite(char *source, ...){ return new_char; } -/**yon_cut(char *source, int size, int startpos) - * [EN] - * cuts source string by size length from startpos position. - */ char *yon_cut(char *source, int size, int startpos) { char *cut = NULL; @@ -514,12 +378,6 @@ char *yon_cut(char *source, int size, int startpos) return cut; } -/**yon_char_divide(char *source, int dividepos) - * [EN] - * divides source string in dividepos position, - * returning left part of divided string and - * inserting right part to source string. - */ char *yon_char_divide(char *source, int dividepos) { if (source){ @@ -536,12 +394,6 @@ char *yon_char_divide(char *source, int dividepos) return NULL; } -/**yon_char_find_count(char *source, char *find) - * [EN] - * - * [RU] - * Считает количество символов [find] в строке [source] -*/ int yon_char_find_count(char *source, char *find){ char *working_string=yon_char_new(source); int i=0; @@ -552,28 +404,9 @@ int yon_char_find_count(char *source, char *find){ if(strstr(rtn[j],find)) i++; } - printf("%d\n",i); return i; } -/**yon_char_divide_search(char *source, char *dividepos, int delete_divider) - * [EN] - * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) - * searches string [dividepos] in [source] string and divides it, - * returning left part of divided string and - * inserting right part to [source] string. - * if [delete_divider] is 0, left part will contain [delete_divider] substring, else - * if [delete_divider] is 1 it will stay in right part, else - * if [delete_divider] is -1 it will be deleted from string. - * - * [RU] - * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) - * Ищет строку [dividepos] в строке [source] и делит её в этом месте, - * возвращая левую часть разделённой строки и устанавливает в [source] правую часть. - * Если [delete_divider] равен 0, [dividepos] останется в левой строке, иначе - * если [delete_divider] равен 1, [dividepos] останется в правой строке, иначе - * если [delete_divider] равен -1, [dividepos] удаляется из строки. - */ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) { if (source&÷pos){ @@ -588,15 +421,6 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) return source; } -/**yon_char_from_int(int int_to_convert) - * [EN] - * char *yon_char_from_int(int int_to_convert) - * converts int to char*. - * - * [RU] - * char *yon_char_from_int(int int_to_convert) - * Конвертирует int в char* - */ char *yon_char_from_int(int int_to_convert) { int i = 1; @@ -605,18 +429,12 @@ char *yon_char_from_int(int int_to_convert) { convert_check = convert_check / 10; } - char *ch = g_malloc0(i * sizeof(char) + 1); + char *ch = malloc(i * sizeof(char) + 1); + memset(ch,0,i * sizeof(char) + 1); sprintf(ch, "%d", int_to_convert); return ch; } -/**yon_char_from_float(int int_to_convert) - * [EN] - * converts float to char*. - * - * [RU] - * Конвертирует float в char* - */ char *yon_char_from_float(float int_to_convert) { int i = 1; @@ -625,18 +443,12 @@ char *yon_char_from_float(float int_to_convert) { convert_check = convert_check / 10; } - char *ch = g_malloc0((i + 9)* sizeof(char)); + char *ch = malloc((i + 9)* sizeof(char)); + memset(ch,0,(i + 9)* sizeof(char)); sprintf(ch, "%.2f", int_to_convert); return ch; } -/**yon_char_from_long(int int_to_convert) - * [EN] - * converts long to char*. - * - * [RU] - * Конвертирует long в char* - */ char *yon_char_from_long(long int_to_convert) { int i = 1; @@ -645,17 +457,12 @@ char *yon_char_from_long(long int_to_convert) { convert_check = convert_check / 10; } - char *ch = g_malloc0(i * sizeof(char) + 1); + char *ch = malloc(i * sizeof(char) + 1); + memset(ch,0,i * sizeof(char) + 1); sprintf(ch, "%ld", int_to_convert); return ch; } -/**yon_char_replace(char *source, char *find, char*replace) - * [EN] - * - * [RU] - * Заменяет в строке [source] все вхождения строки [find] на [replace] -*/ char *yon_char_replace(char *source, char *find, char*replace){ if (!strstr(replace,find)){ @@ -676,12 +483,6 @@ char *yon_char_replace(char *source, char *find, char*replace){ return source; } -/**yon_char_parse(char *parameters, int *size, char *divider) - * [EN] - * Parses string [parameters], divided by [divider], - * then returns parsed string array and sets [size] to - * size of returned array -*/ char **yon_char_parse(char *parameters, int *size, char *divider){ if (parameters){ char **string=NULL; @@ -701,13 +502,6 @@ char **yon_char_parse(char *parameters, int *size, char *divider){ return NULL; } -/**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) - * [EN] - * - * [RU] - * Удаляет элемент [item_to_delete] из массива строк [char_string], размера [size] - * Возвращает получившийся массив, в [size] загружается размер нового массива. -*/ char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete){ char **new_char_parsed=NULL; new_char_parsed=malloc(sizeof(char*)*((*size)-1)); @@ -727,14 +521,6 @@ char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete){ return new_char_parsed; } -/**yon_char_parsed_check_exist(char **parameters, int size, char *param) - * [EN] - * Checks if [parameters] string array of length [size] - * has [param] element; - * [RU] - * Проверяет есть ли в массиве строк [parameters], размера [size] - * элемент [param] -*/ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ for (int i=0;i0){ + int final_size=0; + config_str final = yon_char_parsed_new(&final_size,to_copy[0],NULL); + for (int i=1;i0&&size2>0){ + *final_size=0; + config_str parsed_final = yon_char_parsed_new(final_size,array1[0],NULL); + for (int i=1;i0&&size2>0){ + *final_size=0; + int new_size=0; + config_str parsed_final = yon_char_parsed_new(final_size,array1[0],NULL); + for (int i=1;i0){ + for (int i=0;i0){ + for (int i=0;i0){ + dictionary *dict = NULL; + for (int i=0;i0){ + dictionary *dict = NULL; + for (int i=0;i1024;*size=*size+1){ @@ -930,131 +747,121 @@ float yon_size_convert_automatic(int bytes, int *size){ return byte_float; } -apps *yon_apps_scan_and_parse_desktops(int *sizef) -{ - int size = 0; - struct apps *applist; - { - DIR *directory = opendir(DesktopPath); - struct dirent *de; - while ((de = readdir(directory))) - { - FILE *file; - char *path = yon_char_append(DesktopPath, de->d_name); - file = fopen(path, "r"); - if (strlen(de->d_name) > 9) - { - char *extension = strstr(path, "."); - if (extension != NULL) - { - if (strcmp(extension, ".desktop") == 0) - { - apps tempapp; - GKeyFile *gfile = g_key_file_new(); - GError *err = NULL; - g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); - char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err); - if (err) - { - printf("%s\n", err->message); - } - if (strcmp(Type, "Application") == 0) - tempapp.Type = 1; - else if (strcmp(Type, "pyApplication") == 0) - tempapp.Type = 2; - else - continue; - tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); - if (tempapp.Name == NULL) - continue; - tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); - if (tempapp.Categories == NULL) - continue; - tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); - if (tempapp.Exec == NULL) - continue; - tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); - if (tempapp.Icon == NULL) - continue; - tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); - if (!tempapp.Pluggable) - tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); - if (tempapp.Pluggable) - tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); - if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) - if (size == 0) - { - applist = (apps *)malloc(size + 1 * sizeof(apps)); - applist[0].Name = yon_char_new(tempapp.Name); - applist[0].Categories = yon_char_new(tempapp.Categories); - applist[0].Exec = yon_char_new(tempapp.Exec); - applist[0].Icon = yon_char_new(tempapp.Icon); - applist[0].Type = tempapp.Type; - applist[0].Pluggable = tempapp.Pluggable; - applist[0].DualPluggable = tempapp.DualPluggable; - size++; - } - else - { - applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); - applist[size].Name = yon_char_new(tempapp.Name); - applist[size].Categories = yon_char_new(tempapp.Categories); - applist[size].Exec = yon_char_new(tempapp.Exec); - applist[size].Icon = yon_char_new(tempapp.Icon); - applist[size].Pluggable = tempapp.Pluggable; - applist[size].DualPluggable = tempapp.DualPluggable; - applist[size].Type = tempapp.Type; - size++; - } - } - } - } - } - } - *sizef = size; - return applist; -}; - -void yon_apps_sort(apps *applist, int size) -{ - apps tmp; - if (size > 2) - { - for (int i = 1; i < size; i++) - { - for (int j = 1; j < size; j++) - { - if (strcmp(applist[j].Name, applist[j - 1].Name) < 0) - { - tmp = applist[j]; - applist[j] = applist[j - 1]; - applist[j - 1] = tmp; - }; - } - }; - } -}; - -apps *yon_apps_get_by_name(apps *applist, char *name, int size) -{ - for (int i = 0; i < size; i++) - { - if (strcmp(applist[i].Name, name) == 0) - return &applist[i]; - } - return NULL; -}; - +// apps *yon_apps_scan_and_parse_desktops(int *sizef) +// { +// int size = 0; +// struct apps *applist; +// { +// DIR *directory = opendir(DesktopPath); +// struct dirent *de; +// while ((de = readdir(directory))) +// { +// FILE *file; +// char *path = yon_char_append(DesktopPath, de->d_name); +// file = fopen(path, "r"); +// if (strlen(de->d_name) > 9) +// { +// char *extension = strstr(path, "."); +// if (extension != NULL) +// { +// if (strcmp(extension, ".desktop") == 0) +// { +// apps tempapp; +// GKeyFile *gfile = g_key_file_new(); +// GError *err = NULL; +// g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); +// char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err); +// if (err) +// { +// printf("%s\n", err->message); +// } +// if (strcmp(Type, "Application") == 0) +// tempapp.Type = 1; +// else if (strcmp(Type, "pyApplication") == 0) +// tempapp.Type = 2; +// else +// continue; +// tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); +// if (tempapp.Name == NULL) +// continue; +// tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); +// if (tempapp.Categories == NULL) +// continue; +// tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); +// if (tempapp.Exec == NULL) +// continue; +// tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); +// if (tempapp.Icon == NULL) +// continue; +// tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); +// if (!tempapp.Pluggable) +// tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); +// if (tempapp.Pluggable) +// tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); +// if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) +// if (size == 0) +// { +// applist = (apps *)malloc(size + 1 * sizeof(apps)); +// applist[0].Name = yon_char_new(tempapp.Name); +// applist[0].Categories = yon_char_new(tempapp.Categories); +// applist[0].Exec = yon_char_new(tempapp.Exec); +// applist[0].Icon = yon_char_new(tempapp.Icon); +// applist[0].Type = tempapp.Type; +// applist[0].Pluggable = tempapp.Pluggable; +// applist[0].DualPluggable = tempapp.DualPluggable; +// size++; +// } +// else +// { +// applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); +// applist[size].Name = yon_char_new(tempapp.Name); +// applist[size].Categories = yon_char_new(tempapp.Categories); +// applist[size].Exec = yon_char_new(tempapp.Exec); +// applist[size].Icon = yon_char_new(tempapp.Icon); +// applist[size].Pluggable = tempapp.Pluggable; +// applist[size].DualPluggable = tempapp.DualPluggable; +// applist[size].Type = tempapp.Type; +// size++; +// } +// } +// } +// } +// } +// } +// *sizef = size; +// return applist; +// }; + +// void yon_apps_sort(apps *applist, int size) +// { +// apps tmp; +// if (size > 2) +// { +// for (int i = 1; i < size; i++) +// { +// for (int j = 1; j < size; j++) +// { +// if (strcmp(applist[j].Name, applist[j - 1].Name) < 0) +// { +// tmp = applist[j]; +// applist[j] = applist[j - 1]; +// applist[j - 1] = tmp; +// }; +// } +// }; +// } +// }; + +// apps *yon_apps_get_by_name(apps *applist, char *name, int size) +// { +// for (int i = 0; i < size; i++) +// { +// if (strcmp(applist[i].Name, name) == 0) +// return &applist[i]; +// } +// return NULL; +// }; -/** - * yon_dir_get_contents(char *dir_path, int *size) - * [EN] - * - * [RU] - * Проверяет существует ли папка [dir_path] и - * возвращает список всех вложенных файлов и папок, - * передавая в [size] длину списка. -*/ config_str yon_dir_get_contents(char *dir_path, int *size){ config_str dir = NULL; *size=0; @@ -1108,17 +915,10 @@ yon_config_parameter *yon_config_parameter_append_with_data(yon_config_parameter static yon_config_parameter *__yon__config__strings = NULL; #define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) -#define for_config dictionary temp = NULL; for_dictionary(temp,(dictionary*)__yon__config__strings) +#define for_config dictionary *temp = NULL; for_dictionaries(temp,(dictionary*)__yon__config__strings) #define yon_config_parameter_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_config_parameter_new_with_data(key,data); \ else dict=yon_config_parameter_append_with_data(dict,key,data);} -/**yon_config_load_register(char *command) - * [EN] - * - * [RU] - * Выполняет команду [command]. - * Полученные данные парсятся и регистрируются в конфиг. -*/ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...){ if (__yon__config__strings){ __yon__config__strings = yon_dictionary_free_all((dictionary*)__yon__config__strings,NULL); @@ -1163,12 +963,6 @@ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *par else return 0; } -/**yon_config_remove_by_key(char *key) - * [EN] - * - * [RU] - * Удаляет параметр конфига по ключу [key] -*/ int yon_config_remove_by_key(char *key){ check_config{ dictionary *dict = yon_dictionary_get((dictionary**)&__yon__config__strings,key); @@ -1180,12 +974,6 @@ int yon_config_remove_by_key(char *key){ return 0; } -/**yon_config_remove_element(char *key, char *deleted) - * [EN] - * - * [RU] - * Удаляет элемент [deleted] из массива параметров с ключом [key] -*/ int yon_config_remove_element(char *key, char *deleted){ check_config{ yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key); @@ -1207,12 +995,14 @@ int yon_config_remove_element(char *key, char *deleted){ } else return 0; } -/**yon_config_get_by_key(char *key) - * [EN] - * - * [RU] - * Возвращает значение параметра конфига с ключом [key] -*/ +void yon_config_set_status(int status){ + check_config{ + for_config{ + ((yon_config_parameter*)temp)->flag1=status; + } + } +} + void *yon_config_get_by_key(char *key){ check_config{ dictionary *dict = NULL; @@ -1225,6 +1015,18 @@ void *yon_config_get_by_key(char *key){ return NULL; } +char *yon_config_get_section_for_key(char *key){ + check_config{ + for_config{ + if (!yon_char_is_empty(temp->key)){ + if (!strcmp(temp->key,key)){ + return yon_char_new(((yon_config_parameter*)temp)->section); + } + } + } + } +} + void *yon_config_get_all_by_key(char *key, int *size){ check_config{ config_str ret_data=NULL; @@ -1240,31 +1042,19 @@ void *yon_config_get_all_by_key(char *key, int *size){ } } -/**yon_config_get_key_by_data(char *data) - * [EN] - * - * [RU] - * Возвращает ключ параметра конфига со значением [data]. - * Если параметр с таким значением не найден, возвращается NULL -*/ -char *yon_config_get_key_by_data(char *data){ +config_str yon_config_get_all_keys(int *size){ check_config{ - dictionary *dict = NULL; - for_dictionaries(dict, (dictionary*)__yon__config__strings){ - if (strcmp(((char*)dict->data),data)==0){ - return dict->key; - } + *size=0; + config_str final = NULL; + for_config{ + if (!final) final = yon_char_parsed_new(size,temp->key,NULL); + else final = yon_char_parsed_append(final,size,temp->key); } + return final; } return NULL; } -/**yon_config_set(char *key, void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу и заменяет значение параметра с ключом [key] на новое значение [data]; -*/ int yon_config_set(char *key, void *data){ check_config{ yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key); @@ -1274,13 +1064,6 @@ int yon_config_set(char *key, void *data){ } else return 0; } - -/**yon_config_append(char *key, void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу и дополняет значение параметра с ключом [key] значением [data]; -*/ int yon_config_append(char *key, char *data){ check_config{ yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key); @@ -1292,13 +1075,6 @@ int yon_config_append(char *key, char *data){ } else return 0; } - -/**yon_config_clean() - * [EN] - * Erase all parameters from config; - * [RU] - * Удаляет все параметры из конфига; -*/ int yon_config_clean(){ check_config{ __yon__config__strings = (yon_config_parameter*)yon_dictionary_free_all((dictionary*)__yon__config__strings, NULL); @@ -1307,31 +1083,21 @@ int yon_config_clean(){ else return 0; } -/**yon_config_register(char *key, void *data) - * [EN] - * - * [RU] - * Регистрирует новый параметр конфига. - * [key] - ключ параметра; - * [data] - значение параметра; -*/ void yon_config_register(char *key, char *config_section, void *data){ if (!__yon__config__strings||!yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,data); + __yon__config__strings->flag1=1; + } + else if (yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ + if (data!=__yon__config__strings->data&&strcmp(__yon__config__strings->data,data)){ + __yon__config__strings->data=data; + __yon__config__strings->flag1=1; + } } - else if (yon_dictionary_get((dictionary**)&__yon__config__strings,key)) __yon__config__strings->data=data; __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; - __yon__config__strings->flag1=1; __yon__config__strings->section=yon_char_new(config_section); } -/**yon_config_load(char *command, int *str_len) - * [EN] - * - * [RU] - * Выполняет команду [command] и возвращает распаршеный результат выполнения команды. - * В [str_len] возвращается длина возвращаемого массива -*/ config_str yon_config_load(char *command, int *str_len){ FILE *output = popen(command, "r"); char **output_strings = NULL; @@ -1359,18 +1125,6 @@ config_str yon_config_load(char *command, int *str_len){ } } -/**int yon_config_save_registered(char *path) - * [EN] - * Saves config at [path] config. - * [path] can be: - * system - * global - * [RU] - * Сохраняет конфигурацию в [path] конфиг. - * [path] может быть - * system - локальный конфиг - * global - глобальный конфиг -*/ int yon_config_save_registered(char *path){ check_config{ dictionary *dct; @@ -1404,18 +1158,6 @@ int yon_config_save_registered(char *path){ } else return 1; } -/**int yon_config_force_save_registered(char *path, char *section) - * [EN] - * Force config to save at [path] config ignoring parameter save status. - * [path] can be: - * system - * global - * [RU] - * Принудительно сохраняет конфигурацию в [path] конфиг игнорируя статус параметра. - * [path] может быть - * system - локальный конфиг - * global - глобальный конфиг -*/ int yon_config_force_save_registered(char *path){ check_config{ dictionary *dct; @@ -1448,13 +1190,6 @@ int yon_config_force_save_registered(char *path){ } else return 1; } -/**yon_config_get_all(int *size) - * [EN] - * - * [RU] - * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL - * [size] - указатель, в который выгружается длина массива -*/ config_str yon_config_get_all(int *size){ check_config{ *size = 1; @@ -1472,14 +1207,6 @@ config_str yon_config_get_all(int *size){ } else return NULL; } -/**char *yon_config_get_parameter(config parameters, int size, char *param) - * [EN] - * Gets parameter [param] from parameter list [parameters] of size [size]; - * or NULL if nothing were found - * [RU] - * Возвращает параметр [param] из массива строк [parameters] размером [size] - * или NULL если такой не был найден -*/ char *yon_config_get_parameter(config_str parameters, int size, char *param) { if (param[0]==' ') @@ -1518,13 +1245,6 @@ config_str yon_file_open(char *file_path, int *size){ } } -/**yon_file_create(char *path, char *name, int rules) - * [EN] - * - * [RU] - * Создать файл с названием [name], находящимся по пути [path] - * С правами доступа [rules] (от 0000 до 0777) -*/ int yon_file_create(char *path, char *name, int rules){ if (path&&name){ char *full_path = yon_char_unite(path,"/",name,NULL); @@ -1545,13 +1265,6 @@ int yon_file_create(char *path, char *name, int rules){ } } -/**yon_file_create_full_path(char *path, char *name, int rules) - * [EN] - * - * [RU] - * Создать файл по пути [path] - * С правами доступа [rules] (от 0000 до 0777) -*/ int yon_file_create_full_path(char *path, int rules){ if (path){ if (access(path,F_OK)){ @@ -1573,12 +1286,6 @@ int yon_file_create_full_path(char *path, int rules){ // terminal-using functions -/**yon_launch_app_with_arguments(char *name, char *args) - * [EN] - * Execute [command] in separate thread; - * [RU] - * Выполнить команду [command] в отдельном потоке; -*/ int yon_launch_app_with_arguments(char *name, char *args) { char *path = yon_char_unite("/usr/bin/", name, " ", args,NULL); @@ -1588,26 +1295,17 @@ int yon_launch_app_with_arguments(char *name, char *args) pthread_create(&thread_id, NULL, (void *)yon_launch, command); }; -/**yon_launch(char *command) - * [EN] - * Execute command [command] - * [RU] - * Выполнить команду [command] -*/ void yon_launch(char *command) { system(command); } -// Gtk functions -#ifdef __GTK_H__ -static render_data render; -#ifdef VTE_TERMINAL +static render_data render; static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) { @@ -1616,17 +1314,6 @@ static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data)); } -/** - * void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument) - * [EN] - * launches terminal with specific [command], - * terminal is shown in [place_to_show] container, - * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. - * [RU] - * Запускает терминал с командой [command], - * терминал добавляется в контейнер [place_to_show] виджета, - * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. -*/ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument){ char **commands=new_arr(char*,2); gchar **envp = g_get_environ(); @@ -1672,16 +1359,6 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi gtk_widget_show_all(terminal); } -/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument) - * [EN] - * launches terminal with specific [command], - * terminal is shown in [place_to_show] container, - * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. - * [RU] - * Запускает терминал с командой [command], - * терминал добавляется в контейнер [place_to_show] виджета, - * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. -*/ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){ char **commands=new_arr(char*,2); gchar **envp = g_get_environ(); @@ -1724,7 +1401,6 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); gtk_widget_show_all(terminal); } -#endif // Window config functions @@ -1839,12 +1515,6 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end } } - /**yon_window_config_setup(GtkWindow *window) - * [EN] - * - * [RU] - * Устанавливает указатель на окно для отслеживания его положения и размера - */ void yon_window_config_setup(GtkWindow *window){ __yon_window_config_target_window = window; g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); @@ -1856,12 +1526,6 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end if(__yon_main_window_config.fullscreen ==1) gtk_window_maximize(__yon_window_config_target_window); } - /**yon_window_config_load(char *path) - * [EN] - * - * [RU] - * Загружает конфиг окна и инициализирует отслеживание его параметров - */ int yon_window_config_load(char *path){ __yon_window_config_file = g_key_file_new(); __yon_window_config_path=yon_char_new(path); @@ -1925,12 +1589,6 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end return key; } - /**yon_window_config_add_custom_parameter(GtkWidget *widget, char *param_name, char *widget_property) - * [EN] - * - * [RU] - * Добавляет параметр виджета [widget] по названию [widget_property] для отслеживания и сохраняет его в конфиг под ключом [param_name]. - */ void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type){ __yon_listener_parameter *param = NULL; param = yon_remalloc(param,sizeof(__yon_listener_parameter)); @@ -2107,12 +1765,6 @@ GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ // other Gtk functions -/**yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size) - * [EN] - * - * [RU] - * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] -*/ int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ if (combo&¶meters){ for (int i=0;i-1){ gtk_widget_hide(gtk_widget_get_toplevel(main_window)); @@ -2445,14 +2054,6 @@ void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWi } } -#ifdef WEBKIT_FOUND - -/**yon_ubl_browser_window_open(char *link, char *browser_window_name) - * [EN] - * Launches integrated browser window, named [browser_window_name] at header with [link]. - * [RU] - * Открывает встроенный браузер с именем [browser_window_name] и показываемой страницей по ссылке [link] -*/ void yon_ubl_browser_window_open(char *link, char *browser_window_name){ GtkWidget *browser=gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *web_place=gtk_box_new(GTK_ORIENTATION_VERTICAL,0); @@ -2468,24 +2069,4 @@ void yon_ubl_browser_window_open(char *link, char *browser_window_name){ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(WebView),link); gtk_box_pack_start(GTK_BOX(web_place),WebView,1,1,0); gtk_widget_show_all(browser); -} -#else - -/**yon_ubl_browser_window_open(char *link, char *browser_window_name) - * [EN] - * Launches browser with [link]. - * [browser_window_name] is't used. It's needed for compatibility with webkit version of that function. - * [RU] - * Открывает браузер со страницей по ссылке [link] - * [browser_window_name] не используется. Нужна для совместимости с webkit версией этой функции. -*/ -void yon_ubl_browser_window_open(char *link, char *browser_window_name){ - char *user=getenv("SUDO_USER"); - if (!user) - user=getlogin(); - char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL); - yon_launch_app(command); -} -#endif - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 4be7328..ba77a7c 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,13 @@ #endif #define DesktopPath "/usr/share/applications/" -#define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) +/**for_dictionaries(element, stack) + * [EN] + * + * [RU] + * Работает как for, но нужен для перечисления элементов словаря типа dictioary [stack]. Каждый цикл текущий элемент попадает в [element] +*/ +#define for_dictionaries(element, stack) for (element = stack->first; element != NULL; element = element->next) #define new(type) malloc(sizeof(type)) #define new_arr(type,size) malloc(sizeof(type)*size) @@ -32,9 +39,7 @@ typedef enum { - #ifdef __GTK_H__ DICTIONARY_GTK_WIDGETS_TYPE, - #endif DICTIONARY_OTHER_TYPE=0, DICTIONARY_CHAR_TYPE, DICTIONARY_INT_TYPE, @@ -42,6 +47,15 @@ typedef enum } DICT_TYPE; +/** + * Структура именованого списка. + * [key] - ключ элемента + * [data] - хранимое значение + * [next] - следующий элемент списка + * [prev] - предыдущий элемент списка + * [first] - первый элемент списка + * [data_type] - Тип значения в словаре +*/ typedef struct dictionary { char *key; @@ -68,6 +82,9 @@ typedef struct apps typedef char** config_str; +/**config(key) + * Возвращает элемент конфигурации ubconfig с ключом [key] или NULL если такого нет +*/ #define config(key) yon_config_get_by_key(key) #define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) @@ -95,30 +112,173 @@ typedef char** config_str; #define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_new_with_data(key,data); \ else dict=yon_dictionary_append_with_data(dict,key,data);} +/**yon_dictionary_new(): + * [EN] + * Creates and returns empty dictionary + * [RU] + * Создаёт и возвращает пустой словарь. + */ dictionary *yon_dictionary_new(); +/**yon_dictionary_copy(dictionary *dict) + * [EN] + * + * [RU] + * Создаёт и возвращает копию элемента словаря [dict] +*/ +dictionary *yon_dictinoary_copy(dictionary *dict); + +/**yon_dictionary_copy_deep(dictionary *dict) + * [EN] + * + * [RU] + * Создаёт полную копию словаря [dict] и возвращает первый элемент +*/ +dictionary *yon_dictionary_copy_deep(dictionary *dict); + +/**int yon_dictionary_set_data(dictionary *dict, void *data) + * [EN] + * + * [RU] + * Установить элементу словаря [dict] значение [data] +*/ +int yon_dictionary_set_data(dictionary *dict, void *data); + +/**int yon_dictionary_set_key(dictionary *dict, char *key) + * [EN] + * + * [RU] + * Изменяет ключ элемента словаря [dict] на [key] +*/ +int yon_dictionary_set_key(dictionary *dict, char *key); + +/** int yon_dictionary_set(dictionary *dict, char *key, void *data) + * [EN] + * + * [RU] +* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] +*/ +int yon_dictionary_set(dictionary *dict, char *key, void *data); + +/**int yon_dictionary_empty(dictionary *dict) + * [EN] + * + * [RU] + * Очищает элемент словаря [dict] от данных +*/ +int yon_dictionary_empty(dictionary *dict); + +/**yon_dictionary_switch_to_last(dictionary **dict) + * [EN] + * + * [RU] + * Переключает словарь [dict] на последний элемент. +*/ +void yon_dictionary_switch_to_last(dictionary **dict); + +/**yon_dictionary_create_conneced(dictionary *targetdict) + * [EN] + * + * [RU] + * Создаёт новый элемент словаря [targetdict] +*/ dictionary *yon_dictionary_append(dictionary *targetdict); +/**yon_dictionary_get_last(dictionary *dict) + * [EN] + * + * [RU] + * Возвращает последний элемент словаря [dict]. + * В отличае от yon_dictionary_switch_to_last() + * словарь [dict] остаётся на прежнем элементе. +*/ dictionary *yon_dictionary_get_last(dictionary *dict); +/**yon_dictionary_switch_places(dictionary *dict, int aim) + * [EN] + * + * [RU] + * Меняет элемент словаря [dict] местами с другим элементом. + * если [aim]<0 элемент меняется местами с левым элементом; + * если [aim]>0 элемент меняется местами с правым элементом; +*/ dictionary *yon_dictionary_swap(dictionary *dict, int aim); +/**yon_dictionary_make_first(dictionary *dict) + * [EN] + * + * [RU] + * Устанавливает указатель первого элемента словаря [dict] + * на текущий элемент. Не использовать. +*/ void yon_dictionary_make_first(dictionary *dict); +/**yon_dictionary_make_nth(dictionary *dict, int nth) + * [EN] + * + * [RU] + * Перемещает элемент словаря [dict] на позицию [nth]. +*/ void yon_dictionary_make_nth(dictionary *dict, int nth); +/**yon_dictionary_create_with_data(char *key, void *data) + * [EN] + * + * [RU] + * Создаёт новый словарь с ключом [key] и указателем на данные [data] +*/ dictionary *yon_dictionary_new_with_data(char *key, void *data); +/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) + * [EN] + * + * [RU] + * Создаёт новый элемент словаря, присоединяемый в конец словаря [dict] + * с ключом [key] и указателем на данные [data] +*/ dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data); +/**yon_dictionary_connect(dictionary *old, dictionary *toconnect) + * [EN] + * + * [RU] + * Присоединяет словарь [toconnect] в конец словаря [old]. +*/ dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); +dictionary *yon_dictionary_merge(dictionary *dict1,dictionary *dict2); + +/**yon_dictionary_get(dictionary **dict, char *key) + * [EN] + * + * [RU] + * Возвращает элемент словаря [dict] с ключом [key]. + * Если такого элемента не было обнаружено, возвращается NULL +*/ dictionary *yon_dictionary_get(dictionary **dict, char *key); +/**yon_dictionary_rip(dictionary *dict) + * [EN] + * + * [RU] + * Вырезает элемент из словаря и возвращает вырезанный элемент. +*/ dictionary *yon_dictionary_rip(dictionary *dict); +/**yon_dictionary_get_nth(dictionary *dict, int place) + * [EN] + * + * [RU] + * Возвращает [place]-й элемент словаря [dict] +*/ dictionary *yon_dictionary_get_nth(dictionary *dict, int place); +/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) + * [EN] + * Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary. + * [RU] + * Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря. +*/ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); // char functions @@ -129,72 +289,296 @@ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(vo int yon_char_find_last(char *source, char find); +/**[EN] + * + * creates new char string by combining two char strings. + */ char *yon_char_append(char *source, char *append); +/**[EN] + * + * creates new char string by copying another char. + */ char *yon_char_new(char *chr); +/**yon_char_unite(char *source, ...) + * [En] + * + * [RU] + * Объединяет строку [source] со всеми строками, написанными в [...]. Последний элемент должен быть NULL +*/ char *yon_char_unite(char *source, ...); +/**yon_cut(char *source, int size, int startpos) + * [EN] + * cuts source string by size length from startpos position. + */ char *yon_cut(char *source, int size, int startpos); +/**yon_char_divide(char *source, int dividepos) + * [EN] + * divides source string in dividepos position, + * returning left part of divided string and + * inserting right part to source string. + */ char *yon_char_divide(char *source, int dividepos); +/**yon_char_divide_search(char *source, char *dividepos, int delete_divider) + * [EN] + * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) + * searches string [dividepos] in [source] string and divides it, + * returning left part of divided string and + * inserting right part to [source] string. + * if [delete_divider] is 0, left part will contain [delete_divider] substring, else + * if [delete_divider] is 1 it will stay in right part, else + * if [delete_divider] is -1 it will be deleted from string. + * + * [RU] + * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) + * Ищет строку [dividepos] в строке [source] и делит её в этом месте, + * возвращая левую часть разделённой строки и устанавливает в [source] правую часть. + * Если [delete_divider] равен 0, [dividepos] останется в левой строке, иначе + * если [delete_divider] равен 1, [dividepos] останется в правой строке, иначе + * если [delete_divider] равен -1, [dividepos] удаляется из строки. + */ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); +/**yon_char_from_int(int int_to_convert) + * [EN] + * char *yon_char_from_int(int int_to_convert) + * converts int to char*. + * + * [RU] + * char *yon_char_from_int(int int_to_convert) + * Конвертирует int в char* + */ char *yon_char_from_int(int int_to_convert); +/**yon_char_from_float(int int_to_convert) + * [EN] + * converts float to char*. + * + * [RU] + * Конвертирует float в char* + */ char *yon_char_from_float(float int_to_convert); +/**yon_char_from_long(int int_to_convert) + * [EN] + * converts long to char*. + * + * [RU] + * Конвертирует long в char* + */ char *yon_char_from_long(long int_to_convert); +/**yon_char_replace(char *source, char *find, char*replace) + * [EN] + * + * [RU] + * Заменяет в строке [source] все вхождения строки [find] на [replace] +*/ char *yon_char_replace(char *source, char *find, char*replace); +/**yon_char_parse(char *parameters, int *size, char *divider) + * [EN] + * Parses string [parameters], divided by [divider], + * then returns parsed string array and sets [size] to + * size of returned array +*/ char **yon_char_parse(char *parameters, int *size, char *divider); +#define yon_char_parsed_add_or_create_if_exists(parsed,size,data) {if (!parsed) parsed = yon_char_parsed_new(size,data,NULL);\ + else parsed = yon_char_parsed_append(parsed,size,data);} + +/**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) + * [EN] + * + * [RU] + * Удаляет элемент [item_to_delete] из массива строк [char_string], размера [size] + * Возвращает получившийся массив, в [size] загружается размер нового массива. +*/ char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); +/**yon_char_parsed_check_exist(char **parameters, int size, char *param) + * [EN] + * Checks if [parameters] string array of length [size] + * has [param] element; + * [RU] + * Проверяет есть ли в массиве строк [parameters], размера [size] + * элемент [param] +*/ int yon_char_parsed_check_exist(char **parameters, int size, char *param); +/**yon_char_parsed_check_repeats(char **parameters, int size) + * [EN] + * Checks if [parameters] string array of length [size] + * has repeated elements; + * [RU] + * Проверяет есть ли в массиве строк [parameters], размера [size] + * повторения +*/ int yon_char_parsed_check_repeats(char **parameters, int size, int *first_overlap, int *second_overlap); +/**yon_char_find_count(char *source, char *find) + * [EN] + * + * [RU] + * Считает количество символов [find] в строке [source] +*/ int yon_char_find_count(char *source, char *find); +/**yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size) + * [EN] + * + * [RU] + * Проверяет, включает ли в себя [source] размера [source_size] + * массив строк [to_check] размера [check_size] +*/ int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size); +/**yon_char_parsed_new (config_str old, int *old_size, ...) + * [EN] + * + * [RU] + * Создаёт новый массив строк. В [size] выгружается его размер + * [...] - неограниченное количество строк. +*/ config_str yon_char_parsed_new (int *size, ...); void yon_char_parsed_free(config_str source, int size); -void yon_char_parsed_copy(config_str *source, config_str *to_copy); +/**config_str yon_char_parsed_copy(config_str to_copy, int size) + * [EN] + * + * [RU] + * Возвращает копию массива строк [to_copy] размера [size] +*/ +config_str yon_char_parsed_copy(config_str to_copy, int size); +/**config_str yon_char_parsed_append(config_str parsed, int *size, char *string) + * [EN] + * Adds [string] at the end of [parsed] string array of [size] length. + * [RU] + * Добавляет строку [string] в конец массива строк [parsed] с длинной [size]. +*/ config_str yon_char_parsed_append(config_str parsed, int *size, char *string); +/**yon_char_parsed_merge(config_str array1, int size1, config_str array2, int size2, int *final_size) + * [EN] + * + * [RU] + * Объединяет два массива строк в один. + * [array1] - первый массив строк размера [size1] + * [array2] - второй массив строк размера [size2] + * [final_size] - указатель на целочисленную переменную в которую должен вернуться размер нового массива +*/ +config_str yon_char_parsed_merge(config_str array1, int size1, config_str array2, int size2, int *final_size); + +/**yon_char_parsed_merge_no_repeats(config_str array1, int size1, config_str array2, int size2, int *final_size) + * [EN] + * + * [RU] + * Объединяет два массива строк в один с предотвращением дублей. + * [array1] - первый массив строк размера [size1] + * [array2] - второй массив строк размера [size2] + * [final_size] - указатель на целочисленную переменную в которую должен вернуться размер нового массива +*/ +config_str yon_char_parsed_merge_no_repeats(config_str array1, int size1, config_str array2, int size2, int *final_size); + +int yon_char_parsed_divide_full(config_str parsed,int size,int divide_pos); + +int yon_char_parsed_divide_search_full(config_str parsed,int size,char *divide_pos, int delete_divider); + +dictionary *yon_char_parsed_convert_to_dictionary(config_str parsed, int size); + +dictionary *yon_char_parsed_convert_copy_to_dictionary(config_str parsed, int size); + +/**yon_ubl_check_root() + * [EN] + * + * [RU] + * Возвращает 1 если приложение было запущено от root +*/ int yon_ubl_check_root(); +/**yon_ubl_root_user_get() + * [EN] + * + * [RU] + * Возвращает имя пользователя. + * Если пользователь запустил приложение через root, выводится имя пользователя, запустившего приложение через root +*/ char *yon_ubl_root_user_get(); +/** yon_ubl_user_get_home_directory() + * [EN] + * + * [RU] + * Возвращает домашний каталог пользователя. + * Если пользователь открыл утилиту с правами суперпользователя, всё равно возвращает каталог пользователя, а не root +*/ char *yon_ubl_user_get_home_directory(); +/** yon_ubl_get_all_users(int *user_size) + * [EN] + * + * [RU] + * Возвращает массив всех пользователей в системе и записывает его размер в [user_size] +*/ config_str yon_ubl_get_all_users(int *user_size); // parsing functions +/** yon_size_convert_automatic(int bytes, int *size) + * [EN] + * + * [RU] + * Делит число [bytes] на 1024 пока оно не станет меньше 1024. + * Возвращает получившееся число и устанавливает [size] равным количеству делений. +*/ float yon_size_convert_automatic(int bytes, int *size); -config_str philos_list_user(int* size); - apps *yon_apps_scan_and_parse_desktops(int *sizef); void yon_apps_sort(apps *applist, int size); apps *yon_apps_get_by_name(apps *applist, char *name, int size); +/**yon_file_open(char *file_path, int *size) + * [EN] + * + * [RU] + * Открывает файл [file_path], возвращает содержимое в виде массива строк размера [size] +*/ config_str yon_file_open(char *file_path, int *size); +/**yon_file_create(char *path, char *name, int rules) + * [EN] + * + * [RU] + * Создать файл с названием [name], находящимся по пути [path] + * С правами доступа [rules] (от 0000 до 0777) +*/ int yon_file_create(char *path, char *name, int rules); +/**yon_file_create_full_path(char *path, char *name, int rules) + * [EN] + * + * [RU] + * Создать файл по пути [path] + * С правами доступа [rules] (от 0000 до 0777) +*/ int yon_file_create_full_path(char *path, int rules); +/** yon_dir_get_contents(char *dir_path, int *size) + * [EN] + * + * [RU] + * Проверяет существует ли папка [dir_path] и + * возвращает список всех вложенных файлов и папок, + * передавая в [size] длину списка. +*/ config_str yon_dir_get_contents(char *dir_path, int *size); //config functions @@ -202,123 +586,417 @@ config_str yon_dir_get_contents(char *dir_path, int *size); #define ubconfig_save_command "ubconfig" #define ubconfig_load_command "ubconfig --source" +/** + * Типы конфигураций ubconfig-а +*/ typedef enum { YON_CONFIG_LOCAL=0, YON_CONFIG_GLOBAL, YON_CONFIG_BOTH } YON_CONFIG_TYPE; +/**yon_config_load(char *command, int *str_len) + * [EN] + * + * [RU] + * Выполняет команду [command] и возвращает результат выполнения команды, разделяя на строки. + * В [str_len] возвращается длина возвращаемого массива +*/ config_str yon_config_load(char *command, int *str_len); +/**int yon_config_save_registered(char *path) + * [EN] + * Saves config at [path] config. + * [path] can be: + * system + * global + * [RU] + * Сохраняет конфигурацию в [path] конфиг. + * [path] может быть + * system - локальный конфиг + * global - глобальный конфиг +*/ int yon_config_save_registered(char *path); -int yon_config_force_save_registered(char *path); - +/**char *yon_config_get_parameter(config parameters, int size, char *param) + * [EN] + * Gets parameter [param] from parameter list [parameters] of size [size]; + * or NULL if nothing were found + * [RU] + * Возвращает параметр [param] из массива строк [parameters] размером [size] + * или NULL если такой не был найден +*/ char *yon_config_get_parameter(config_str parameters, int size, char *param); +/**yon_config_load_register(char *command) + * [EN] + * + * [RU] + * Выполняет команду [command]. + * Полученные данные парсятся и регистрируются в конфиг. +*/ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...); +/**yon_config_remove_by_key(char *key) + * [EN] + * + * [RU] + * Удаляет параметр конфига по ключу [key] +*/ int yon_config_remove_by_key(char *key); -int yon_config_remove_by_data(void *data); - +/**yon_config_remove_element(char *key, char *deleted) + * [EN] + * + * [RU] + * Удаляет элемент [deleted] из массива параметров с ключом [key] +*/ int yon_config_remove_element(char *key, char *deleted); +void yon_config_set_status(int status); + +/**yon_config_get_key_by_key(char *data) + * [EN] + * + * [RU] + * Возвращает значение параметра конфига с ключом [key]. + * Если параметр с таким значением не найден, возвращается NULL +*/ void *yon_config_get_by_key(char *key); +char *yon_config_get_section_for_key(char *key); + +/**yon_config_get_all_by_key(char *data) + * [EN] + * + * [RU] + * Возвращает значение всех параметров конфига с ключом включающем строку [key]. + * Если параметр с таким значением не найден, возвращается NULL +*/ void *yon_config_get_all_by_key(char *key, int *size); -char *yon_config_get_key_by_data(char *data); +/**yon_config_get_all_keys(int *size) + * [EN] + * + * [RU] + * Возвращает массив с ключами всех параметров внутреннего конфига +*/ +config_str yon_config_get_all_keys(int *size); +/**yon_config_set(char *key, void *data) + * [EN] + * + * [RU] + * Производит поиск по конфигу и заменяет значение параметра с ключом [key] на новое значение [data]; +*/ int yon_config_set(char *key, void *data); +/**yon_config_append(char *key, void *data) + * [EN] + * + * [RU] + * Производит поиск по конфигу и дополняет значение параметра с ключом [key] значением [data]; +*/ +int yon_config_append(char *key, char *data); + +/**yon_config_clean() + * [EN] + * Erase all parameters from config; + * [RU] + * Удаляет все параметры из конфига; +*/ int yon_config_clean(); +/**yon_config_register(char *key, void *data) + * [EN] + * + * [RU] + * Регистрирует новый параметр конфига. + * [key] - ключ параметра; + * [data] - значение параметра; +*/ void yon_config_register(char *key, char* config_section, void *data); -config_str yon_config_get_all(); +/**int yon_config_force_save_registered(char *path, char *section) + * [EN] + * Force config to save at [path] config ignoring parameter save status. + * [path] can be: + * system + * global + * [RU] + * Принудительно сохраняет конфигурацию в [path] конфиг игнорируя статус параметра. + * [path] может быть + * system - локальный конфиг + * global - глобальный конфиг +*/ +int yon_config_force_save_registered(char *path); + +/**yon_config_get_all(int *size) + * [EN] + * + * [RU] + * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL + * [size] - указатель, в который выгружается длина массива +*/ +config_str yon_config_get_all(int *size); // terminal-using functions +/**yon_launch_app_with_arguments(char *name, char *args) + * [EN] + * Execute [command] in separate thread; + * [RU] + * Выполнить команду [command] в отдельном потоке; +*/ int yon_launch_app_with_arguments(char *name, char *args); +/**yon_launch(char *command) + * [EN] + * Execute command [command] + * [RU] + * Выполнить команду [command] +*/ void yon_launch(char *command); -// Gtk functions - #ifdef __GTK_H__ -#ifdef VTE_TERMINAL +/** + * void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument) + * [EN] + * launches terminal with specific [command], + * terminal is shown in [place_to_show] container, + * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. + * [RU] + * Запускает терминал с командой [command], + * терминал добавляется в контейнер [place_to_show] виджета, + * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. +*/ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument); +/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument) + * [EN] + * launches terminal with specific [command], + * terminal is shown in [place_to_show] container, + * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. + * [RU] + * Запускает терминал с командой [command], + * терминал добавляется в контейнер [place_to_show] виджета, + * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. +*/ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); -#endif - +/**YON_TYPE + * [EN] + * + * [RU] + * Типы, поддерживаемые функциями сохранения/загрузки конфигурации утилиты +*/ enum YON_TYPE{ YON_TYPE_STRING, YON_TYPE_STRING_LIST, YON_TYPE_INT, YON_TYPE_BOOLEAN, - YON_TYPE_OTHER -}; - -GtkWidget *yon_ubl_menu_item_about_new(char *buttonname); -GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname); + YON_TYPE_OTHER}; /**yon_gtk_builder_get_widget(builder, widget_name) * [EN] * Returns GtkWidget from GtkBuilder *[builder]. * [builder] is GtkBuilder*; * [widget_name] is id of widget; + * [RU] + * Возвращает виджет GtkWidget c id [widget_name] из [builder] */ #define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name)) -typedef struct -{ - GtkWidget *Icon; - GtkWidget *Label; - GtkWidget *IconView; - GtkListStore *List; -} expander_icon_view; - +/**yon_window_config_setup(GtkWindow *window) + * [EN] + * + * [RU] + * Устанавливает указатель на окно для отслеживания его положения и размера +*/ void yon_window_config_setup(GtkWindow *window); +/**yon_window_config_load(char *path) + * [EN] + * + * [RU] + * Загружает конфиг окна и инициализирует отслеживание его параметров +*/ int yon_window_config_load(char *path); +/**yon_window_config_get_section(char *section, gsize *size) + * [EN] + * + * [RU] + * Возвращает все параметры раздела [section] конфига утилиты и записывает в [size] количество считанных параметров. +*/ config_str yon_window_config_get_section(char *section, gsize *size); +/**yon_window_config_add_custom_parameter(GtkWidget *widget, char *param_name, char *widget_property) + * [EN] + * + * [RU] + * Добавляет параметр виджета [widget] по названию [widget_property] для отслеживания и сохраняет его в конфиг под ключом [param_name]. +*/ void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type); +/**yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type) + * [EN] + * + * [RU] + * Добавить параметр в конфиг утилиты. + * Параметр [param_name] добавляется в раздел [section] конфига утилиты со значением [tracked value]. + * Тип указывается в [type] +*/ void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); void yon_window_config_add_instant_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); +/**yon_window_config_erase_custom_parameter(char *param_name, char *section) + * [EN] + * + * [RU] + * Удаляет параметр из конфига утилиты. + * Удаляет параметр [param_name] из раздела [section] конфига утилиты. +*/ void yon_window_config_erase_custom_parameter(char *param_name, char *section); +/**yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type) + * [EN] + * + * [RU] + * Возвращает параметр из конфига утилиты. + * Параметр [config_parameter] из раздела [section] возвращается в [return_value] + * Возвращаемый тип указывается в [type] +*/ int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type); +/**yon_window_config_custom_window_setup(GtkWindow *window, char *window_name) + * [EN] + * + * [RU] + * Зарегистрировать окно [window] в конфиге утилиты под именем [window_name] +*/ void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name); +/**yon_window_config_custom_window_set(GtkWindow *window, char *window_name) + * [EN] + * + * [RU] + * Загрузить и применить параметры окна [window], сохранёнными в конфигурации утилиты под именем [window_name] +*/ void yon_window_config_custom_window_get(GtkWindow *window, char *window_name); +/**yon_window_config_custom_window_set(GtkWindow *window, char *window_name) + * [EN] + * + * [RU] + * Сохранить параметры окна [window] в конфигурацию утилиты под именем [window_name] +*/ void yon_window_config_custom_window_set(GtkWindow *window, char *window_name); +int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); + +/**yon_ubl_menu_item_documentation_new(char *buttonname) + * [EN] + * + * [RU] + * Создаёт элемент меню GtkMenu с текстом [buttonname]. Кнопка настроена для отображения диалогового окна информации об утилите +*/ +GtkWidget *yon_ubl_menu_item_about_new(char *buttonname); + +/**yon_ubl_menu_item_documentation_new(char *buttonname) + * [EN] + * + * [RU] + * Создаёт элемент меню GtkMenu с текстом [buttonname]. Кнопка настроена для отображения диалогового окна подтверждения перехода на страницу wiki +*/ +GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname); + +// other Gtk functions + +/**yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size) + * [EN] + * + * [RU] + * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] +*/ int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); +/**yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find) + * [EN] + * + * [RU] + * Проивзодит поиск по GtkComboBoxText [combo_box] + * возвращает 1 если элемент [text_to_find] найден, иначе возвращает 0 +*/ int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); +/**yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column) + * [EN] + * + * [RU] + * Установить минимальный размер колонки [column] равным размеру заголовка. +*/ void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); -int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); - +/**yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...) + * [EN] + * + * [RU] + * Добвляет [destination] все виджеты, прописанные после [padding]. Добавление происходит с начала контейнера. + * [expand] - расширяемость выделенного для виджетов места + * [fill] - заполнять ли виджетом всё ему выделенное место + * [padding] - отступ од других элементов +*/ int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); +/**yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...) + * [EN] + * + * [RU] + * Добвляет в [destination] все виджеты, прописанные после [padding]. Добавление происходит с конца контейнера. + * [expand] - расширяемость выделенного для виджетов места + * [fill] - заполнять ли виджетом всё ему выделенное место + * [padding] - отступ од других элементов +*/ int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); + +/**yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target) + * [EN] + * + * [RU] + * Выставляет чуствительность виджета [target] в зависимости от состояния комбобокса [toggle]. + * Чувствительность виджета [target] повторяет статус чекбоска. +*/ void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target); + +/**yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target) + * [EN] + * + * [RU] + * Выставляет чуствительность виджета [target] в зависимости от состояния чекбоска [toggle]. + * Если чекбокс вктивен, [target] становится нечувствительным и наоборот. +*/ void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target); + +/**yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); + * [EN] + * + * [RU] + * Выставляет чуствительность виджета [target] в зависимости от состояния комбобокса [toggle]. + * Если выбран первый элемент списка, [target] становится чувствительным, любое другое значение сделает его нечувствительным. +*/ void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); + +/**yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); + * [EN] + * + * [RU] + * Выставляет чуствительность виджета [target] в зависимости от состояния комбобокса [toggle]. + * Если выбран первый элемент списка, [target] становится нечувствительным, любое другое значение сделает его чувствительным. +*/ void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); typedef enum @@ -367,14 +1045,36 @@ int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); */ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); +/**yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter) + * [EN] + * + * [RU] + * Подсвечивает красным цветом [widget] на 5 секунд +*/ void yon_ubl_status_highlight_incorrect(GtkWidget *widget); +/**yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter) + * [EN] + * + * [RU] + * Подсвечивает красным цветом [iter] элемент списка [list] на 5 секунд +*/ void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter); static int status_thread_busy; -void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); -#ifdef __cplusplus +/**yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); + * [EN] + * + * [RU] + * Создаёт статусную строку в контейнере [container], отображая текст [display_text]. + * Строка удаляется через [timeout] секунд. + * [type] - тип сообщения. Может быть: + * BACKGROUND_IMAGE_FAIL_TYPE (красный фон,иконка - восклицательный знак) + * или + * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) +*/ +void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); /**yon_ubl_header_setup(overlay, head, image, imag_path) * [EN] @@ -390,10 +1090,9 @@ void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int ti * [image] - виджет картинки для заднего фона; * [imag_path] - путь до картинки, загружаемой в [image] */ -#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay.gobj()), GTK_WIDGET(head.gobj()), GTK_WIDGET(image.gobj()), (char *)imag_path) -#else +#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(overlay, head, image, imag_path) +/**yon_ubl_header_setup_resource(overlay, head, image, imag_path) * [EN] * Sets up header of app. * [overlay] is overlay for app header; @@ -405,22 +1104,40 @@ void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int ti * [overlay] - оверлей заголовка приложения; * [head] - шапка заголовка, присоединяемая к [overlay] * [image] - виджет картинки для заднего фона; - * [imag_path] - путь до картинки, загружаемой в [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) #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) -#endif 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); +/**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] + * Set up plugs for using with GtkSockets insine ubl-settings-manager. + * [main_window] is container widget, which holds main application functionality. + * [left_window] is container widget, which holds widgets, have to be shown at left part of ubl-settings-manager header. + * [right_window] is container widget, which holds widgets, have to be shown at right part of ubl-settings-manager header. + * [socket_main_id] is id of socket for [main_window]. + * [socket_left_id] is id of socket for [left_window]. + * [socket_right_id] is id of socket for [right_window]. + * [RU] + * Настраивает плаги для работы с сокетами в утилите ubl-settings-manager. + * [main_window] - контейнер основного интерфейса приложения. + * [left_window] - контейнер для виджетов которые должны отображаться в левой части шапки ubl-settings-manager. + * [right_window] - контейнер для виджетов которые должны отображаться в правой части шапки ubl-settings-manager. + * [socket_main_id] - id сокета для [main_window]. + * [socket_left_id] - id сокета для [left_window]. + * [socket_right_id] - id сокета для [right_window]. +*/ 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); -#ifdef WEBKIT_FOUND +/**yon_ubl_browser_window_open(char *link, char *browser_window_name) + * [EN] + * Launches integrated browser window, named [browser_window_name] at header with [link]. + * [RU] + * Открывает встроенный браузер с именем [browser_window_name] и показываемой страницей по ссылке [link] +*/ void yon_ubl_browser_window_open(char *link, char *browser_window_name); -#else -void yon_ubl_browser_window_open(char *link, char *browser_window_name); -#endif #endif #endif \ No newline at end of file