|
|
@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
// dictionary functions
|
|
|
|
// dictionary functions
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_dictionary_create_empty():
|
|
|
|
/**yon_dictionary_new():
|
|
|
|
* [EN]
|
|
|
|
* [EN]
|
|
|
|
* Creates and returns empty dictionary
|
|
|
|
* Creates and returns empty dictionary
|
|
|
|
* [RU]
|
|
|
|
* [RU]
|
|
|
@ -20,7 +20,7 @@ dictionary *yon_dictionary_new()
|
|
|
|
return dict;
|
|
|
|
return dict;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_dictionary_copy_deep(dictionary *dict)
|
|
|
|
/**yon_dictionary_copy(dictionary *dict)
|
|
|
|
* [EN]
|
|
|
|
* [EN]
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* [RU]
|
|
|
|
* [RU]
|
|
|
@ -29,6 +29,7 @@ dictionary *yon_dictionary_new()
|
|
|
|
dictionary *yon_dictinoary_copy(dictionary *dict){
|
|
|
|
dictionary *yon_dictinoary_copy(dictionary *dict){
|
|
|
|
dictionary *dct = yon_dictionary_new_with_data(dict->key,dict->data);
|
|
|
|
dictionary *dct = yon_dictionary_new_with_data(dict->key,dict->data);
|
|
|
|
dct->data_type= dict->data_type;
|
|
|
|
dct->data_type= dict->data_type;
|
|
|
|
|
|
|
|
return dct;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_dictionary_copy_deep(dictionary *dict)
|
|
|
|
/**yon_dictionary_copy_deep(dictionary *dict)
|
|
|
@ -47,22 +48,49 @@ dictionary *yon_dictionary_copy_deep(dictionary *dict){
|
|
|
|
return newone->first;
|
|
|
|
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){
|
|
|
|
int yon_dictionary_set_data(dictionary *dict, void *data){
|
|
|
|
dict->data=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){
|
|
|
|
int yon_dictionary_set_key(dictionary *dict, char *key){
|
|
|
|
dict->key=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){
|
|
|
|
int yon_dictionary_set(dictionary *dict, char *key, void *data){
|
|
|
|
dict->key=key;
|
|
|
|
dict->key=key;
|
|
|
|
dict->data=data;
|
|
|
|
dict->data=data;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**int yon_dictionary_empty(dictionary *dict)
|
|
|
|
|
|
|
|
* [EN]
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Очищает элемент словаря [dict] от данных
|
|
|
|
|
|
|
|
*/
|
|
|
|
int yon_dictionary_empty(dictionary *dict){
|
|
|
|
int yon_dictionary_empty(dictionary *dict){
|
|
|
|
dict->data=NULL;
|
|
|
|
dict->data=NULL;
|
|
|
|
dict->data_type=DICTIONARY_OTHER_TYPE;
|
|
|
|
dict->data_type=DICTIONARY_OTHER_TYPE;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_dictionary_switch_to_last(dictionary **dict)
|
|
|
|
/**yon_dictionary_switch_to_last(dictionary **dict)
|
|
|
@ -409,6 +437,13 @@ dictionary *yon_dictionary_get_nth(dictionary *dict, int place)
|
|
|
|
|
|
|
|
|
|
|
|
// char functions
|
|
|
|
// char functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int yon_char_find_last(char *source, char find){
|
|
|
|
|
|
|
|
int size = strlen(source);
|
|
|
|
|
|
|
|
int i=size;
|
|
|
|
|
|
|
|
for (;source[i]!=find&&i>0;i--);
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**[EN]
|
|
|
|
/**[EN]
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* creates new char string by combining two char strings.
|
|
|
|
* creates new char string by combining two char strings.
|
|
|
@ -445,8 +480,12 @@ char *yon_char_new(char *chr)
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// char *yon_char_unite(char *source, ...)
|
|
|
|
/**yon_char_unite(char *source, ...)
|
|
|
|
|
|
|
|
* [En]
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Объединяет строку [source] со всеми строками, написанными в [...]
|
|
|
|
|
|
|
|
*/
|
|
|
|
char *yon_char_unite(char *source, ...){
|
|
|
|
char *yon_char_unite(char *source, ...){
|
|
|
|
va_list arglist;
|
|
|
|
va_list arglist;
|
|
|
|
char *new_char=NULL;
|
|
|
|
char *new_char=NULL;
|
|
|
@ -494,6 +533,12 @@ char *yon_char_divide(char *source, int dividepos)
|
|
|
|
return cut;
|
|
|
|
return cut;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_char_find_count(char *source, char *find)
|
|
|
|
|
|
|
|
* [EN]
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Считает количество символов [find] в строке [source]
|
|
|
|
|
|
|
|
*/
|
|
|
|
int yon_char_find_count(char *source, char *find){
|
|
|
|
int yon_char_find_count(char *source, char *find){
|
|
|
|
char *working_string=yon_char_new(source);
|
|
|
|
char *working_string=yon_char_new(source);
|
|
|
|
int i=0;
|
|
|
|
int i=0;
|
|
|
@ -535,9 +580,8 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider)
|
|
|
|
cut = yon_char_divide(source, leng);
|
|
|
|
cut = yon_char_divide(source, leng);
|
|
|
|
return cut;
|
|
|
|
return cut;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
return source;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_char_from_int(int int_to_convert)
|
|
|
|
/**yon_char_from_int(int int_to_convert)
|
|
|
@ -569,6 +613,9 @@ char *yon_char_from_int(int int_to_convert)
|
|
|
|
* Заменяет в строке [source] все вхождения строки [find] на [replace]
|
|
|
|
* Заменяет в строке [source] все вхождения строки [find] на [replace]
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
char *yon_char_replace(char *source, char *find, char*replace){
|
|
|
|
char *yon_char_replace(char *source, char *find, char*replace){
|
|
|
|
|
|
|
|
if (!strstr(replace,find)){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *final=NULL;
|
|
|
|
char *final=NULL;
|
|
|
|
char *temp=NULL;
|
|
|
|
char *temp=NULL;
|
|
|
|
if(!strstr(replace,find)){
|
|
|
|
if(!strstr(replace,find)){
|
|
|
@ -579,12 +626,14 @@ char *yon_char_replace(char *source, char *find, char*replace){
|
|
|
|
temp=yon_char_append(temp,replace);
|
|
|
|
temp=yon_char_append(temp,replace);
|
|
|
|
source=yon_char_append(temp,final+1);
|
|
|
|
source=yon_char_append(temp,final+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return source;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**[EN]
|
|
|
|
/**yon_char_parse(char *parameters, int *size, char *divider)
|
|
|
|
* char **yon_char_parse(char *parameters, int *size, char *divider)
|
|
|
|
* [EN]
|
|
|
|
* Parses string [parameters], divided by [divider],
|
|
|
|
* Parses string [parameters], divided by [divider],
|
|
|
|
* then returns parsed string array and sets [size] to
|
|
|
|
* then returns parsed string array and sets [size] to
|
|
|
|
* size of returned array
|
|
|
|
* size of returned array
|
|
|
@ -701,15 +750,19 @@ config_str yon_char_parsed_new (int *size, ...){
|
|
|
|
return new_parsed;
|
|
|
|
return new_parsed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_char_parsed_copy(config_str *source, config_str *to_copy)
|
|
|
|
|
|
|
|
* [EN]
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Копирует массив строк [to_copy] в [source]
|
|
|
|
|
|
|
|
*/
|
|
|
|
void yon_char_parsed_copy(config_str *source, config_str *to_copy){
|
|
|
|
void yon_char_parsed_copy(config_str *source, config_str *to_copy){
|
|
|
|
if (source&&to_copy&&*to_copy){
|
|
|
|
if (source&&!*source&&to_copy&&*to_copy){
|
|
|
|
int size=0;
|
|
|
|
int size=0;
|
|
|
|
config_str new_char = yon_char_parsed_new(&size,(*to_copy)[0],NULL);
|
|
|
|
config_str new_char = yon_char_parsed_new(&size,(*to_copy)[0]);
|
|
|
|
for (int i=1;(*to_copy)[i];i++){
|
|
|
|
for (int i=0;(*to_copy)[i];i++){
|
|
|
|
new_char = yon_char_parsed_append(new_char,&size,yon_char_new((*to_copy)[i]));
|
|
|
|
new_char = yon_char_parsed_append(new_char,&size,yon_char_new((*to_copy)[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
new_char = yon_char_parsed_append(new_char,&size,NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (new_char) *source = new_char;
|
|
|
|
if (new_char) *source = new_char;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -727,12 +780,24 @@ config_str yon_char_parsed_append(config_str parsed, int *size, char *string){
|
|
|
|
return new_parsed;
|
|
|
|
return new_parsed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_ubl_check_root()
|
|
|
|
|
|
|
|
* [EN]
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Возвращает 1 если приложение было запущено от root
|
|
|
|
|
|
|
|
*/
|
|
|
|
int yon_ubl_check_root(){
|
|
|
|
int yon_ubl_check_root(){
|
|
|
|
if (getuid()==0) return 1;
|
|
|
|
if (getuid()==0) return 1;
|
|
|
|
else return 0;
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_ubl_root_user_get()
|
|
|
|
|
|
|
|
* [EN]
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Возвращает имя пользователя.
|
|
|
|
|
|
|
|
* Если пользователь запустил приложение через root, выводится имя пользователя, запустившего приложение через root
|
|
|
|
|
|
|
|
*/
|
|
|
|
char *yon_ubl_root_user_get(){
|
|
|
|
char *yon_ubl_root_user_get(){
|
|
|
|
char *user=NULL;
|
|
|
|
char *user=NULL;
|
|
|
|
if (yon_ubl_check_root()){
|
|
|
|
if (yon_ubl_check_root()){
|
|
|
@ -750,6 +815,14 @@ char *yon_ubl_root_user_get(){
|
|
|
|
return getlogin();
|
|
|
|
return getlogin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *yon_ubl_user_get_home_directory(){
|
|
|
|
|
|
|
|
FILE *path = popen(get_home_dir_command,"r");
|
|
|
|
|
|
|
|
char *ret = g_malloc(4096);
|
|
|
|
|
|
|
|
fgets(ret,4096,path);
|
|
|
|
|
|
|
|
ret=yon_char_divide_search(ret,"\n",-1);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// parsing functions
|
|
|
|
// parsing functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1086,7 +1159,7 @@ config_str yon_config_load(char *command, int *str_len){
|
|
|
|
* Выполняет команду [command], добавляя в конец все записи конфига в таком виде:
|
|
|
|
* Выполняет команду [command], добавляя в конец все записи конфига в таком виде:
|
|
|
|
* [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]"
|
|
|
|
* [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]"
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int yon_config_save(char *command){
|
|
|
|
int yon_config_save_registered(char *command){
|
|
|
|
check_config{
|
|
|
|
check_config{
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
for_dictionaries(dict,__yon__config__strings){
|
|
|
|
for_dictionaries(dict,__yon__config__strings){
|
|
|
@ -1120,18 +1193,6 @@ config_str yon_config_get_all(int *size){
|
|
|
|
} else return NULL;
|
|
|
|
} else return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**[EN]
|
|
|
|
|
|
|
|
* int yon_config_save(char *command)
|
|
|
|
|
|
|
|
* Saves config with [command]
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Выполняет команду [command]
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// int yon_config_save(char *command)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// FILE *output = popen(command, "r");
|
|
|
|
|
|
|
|
// return 1;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**char *yon_config_get_parameter(config parameters, int size, char *param)
|
|
|
|
/**char *yon_config_get_parameter(config parameters, int size, char *param)
|
|
|
|
* [EN]
|
|
|
|
* [EN]
|
|
|
|
* Gets parameter [param] from parameter list [parameters] of size [size];
|
|
|
|
* Gets parameter [param] from parameter list [parameters] of size [size];
|
|
|
@ -1236,7 +1297,7 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi
|
|
|
|
VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL);
|
|
|
|
VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL);
|
|
|
|
vte_terminal_set_pty(VTE_TERMINAL(terminal),pty);
|
|
|
|
vte_terminal_set_pty(VTE_TERMINAL(terminal),pty);
|
|
|
|
gtk_container_add(GTK_CONTAINER(place_to_show),terminal);
|
|
|
|
gtk_container_add(GTK_CONTAINER(place_to_show),terminal);
|
|
|
|
char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ;exit 0","\n",NULL);
|
|
|
|
char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL);
|
|
|
|
printf("%s\n",install_command);
|
|
|
|
printf("%s\n",install_command);
|
|
|
|
if(endwork_function)
|
|
|
|
if(endwork_function)
|
|
|
|
g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument);
|
|
|
|
g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument);
|
|
|
@ -1322,15 +1383,36 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
|
|
|
|
gtk_widget_show_all(terminal);
|
|
|
|
gtk_widget_show_all(terminal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// Window config functions
|
|
|
|
// Window config functions
|
|
|
|
|
|
|
|
|
|
|
|
#define check_window_config_setup if(__yon_window_config_target_window)
|
|
|
|
#define check_window_config_setup if(__yon_window_config_target_window)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
char *parameter_name;
|
|
|
|
|
|
|
|
enum YON_TYPE containing_type;
|
|
|
|
|
|
|
|
GtkWidget *track_widget;
|
|
|
|
|
|
|
|
char *property_name;
|
|
|
|
|
|
|
|
} __yon_listener_parameter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
char *parameter_name;
|
|
|
|
|
|
|
|
char *section;
|
|
|
|
|
|
|
|
enum YON_TYPE containing_type;
|
|
|
|
|
|
|
|
void *property;
|
|
|
|
|
|
|
|
} __yon_custom_parameter;
|
|
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
int x;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int height;
|
|
|
|
int fullscreen;
|
|
|
|
int fullscreen;
|
|
|
|
|
|
|
|
dictionary *custom_listeners;
|
|
|
|
|
|
|
|
dictionary *custom_parameters;
|
|
|
|
|
|
|
|
dictionary *deleted_parameters;
|
|
|
|
} __yon_main_window_config;
|
|
|
|
} __yon_main_window_config;
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWindow *__yon_window_config_target_window = NULL;
|
|
|
|
static GtkWindow *__yon_window_config_target_window = NULL;
|
|
|
|
static GKeyFile *__yon_window_config_file = NULL;
|
|
|
|
static GKeyFile *__yon_window_config_file = NULL;
|
|
|
|
static char *__yon_window_config_path = NULL;
|
|
|
|
static char *__yon_window_config_path = NULL;
|
|
|
@ -1341,15 +1423,62 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width);
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width);
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height);
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height);
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen);
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen);
|
|
|
|
|
|
|
|
dictionary *dict=NULL;
|
|
|
|
|
|
|
|
if (__yon_main_window_config.custom_listeners)
|
|
|
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_listeners){
|
|
|
|
|
|
|
|
__yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*);
|
|
|
|
|
|
|
|
GValue *val = g_malloc0(sizeof(GValue));
|
|
|
|
|
|
|
|
g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
|
|
|
switch(param->containing_type){
|
|
|
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
|
|
|
g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
|
|
|
g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (__yon_main_window_config.custom_parameters)
|
|
|
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_parameters){
|
|
|
|
|
|
|
|
__yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*);
|
|
|
|
|
|
|
|
switch (param->containing_type){
|
|
|
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
|
|
|
g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
|
|
|
g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (__yon_main_window_config.deleted_parameters)
|
|
|
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.deleted_parameters){
|
|
|
|
|
|
|
|
__yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*);
|
|
|
|
|
|
|
|
g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL);
|
|
|
|
g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void yon_get_is_fullscreen(){
|
|
|
|
void yon_get_is_fullscreen(){
|
|
|
|
gtk_window_is_maximized(__yon_window_config_target_window);
|
|
|
|
gtk_window_is_maximized(__yon_window_config_target_window);
|
|
|
|
__yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window);
|
|
|
|
__yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window);
|
|
|
|
|
|
|
|
if (!__yon_main_window_config.fullscreen) gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event)
|
|
|
|
|
|
|
|
* [EN]
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Сохраняет настройки основного окна. Вызывается когда основное окно уничтожается.
|
|
|
|
|
|
|
|
*/
|
|
|
|
void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){
|
|
|
|
void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){
|
|
|
|
check_window_config_setup{
|
|
|
|
check_window_config_setup{
|
|
|
|
yon_get_is_fullscreen();
|
|
|
|
yon_get_is_fullscreen();
|
|
|
@ -1367,6 +1496,12 @@ 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){
|
|
|
|
void yon_window_config_setup(GtkWindow *window){
|
|
|
|
__yon_window_config_target_window = window;
|
|
|
|
__yon_window_config_target_window = window;
|
|
|
|
g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL);
|
|
|
@ -1378,6 +1513,12 @@ 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);
|
|
|
|
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){
|
|
|
|
int yon_window_config_load(char *path){
|
|
|
|
__yon_window_config_file = g_key_file_new();
|
|
|
|
__yon_window_config_file = g_key_file_new();
|
|
|
|
__yon_window_config_path=yon_char_new(path);
|
|
|
|
__yon_window_config_path=yon_char_new(path);
|
|
|
@ -1399,6 +1540,27 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
|
|
|
|
__yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL);
|
|
|
|
__yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL);
|
|
|
|
__yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL);
|
|
|
|
__yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL);
|
|
|
|
__yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL);
|
|
|
|
__yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL);
|
|
|
|
|
|
|
|
dictionary *dict=NULL;
|
|
|
|
|
|
|
|
if (__yon_main_window_config.custom_listeners)
|
|
|
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_listeners){
|
|
|
|
|
|
|
|
__yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*);
|
|
|
|
|
|
|
|
GValue *val = g_malloc0(sizeof(GValue));
|
|
|
|
|
|
|
|
g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
|
|
|
switch(param->containing_type){
|
|
|
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
|
|
|
g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
|
|
|
g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
|
|
|
gboolean res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL);
|
|
|
|
|
|
|
|
g_value_set_boolean(val,res);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:printf("\033[0;31mCannot load %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (__yon_main_window_config.width==0) __yon_main_window_config.width=800;
|
|
|
|
if (__yon_main_window_config.width==0) __yon_main_window_config.width=800;
|
|
|
|
if (__yon_main_window_config.height==0) __yon_main_window_config.height=600;
|
|
|
|
if (__yon_main_window_config.height==0) __yon_main_window_config.height=600;
|
|
|
|
gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height);
|
|
|
|
gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height);
|
|
|
@ -1413,6 +1575,46 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
|
|
|
|
gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y);
|
|
|
|
gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y);
|
|
|
|
gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height);
|
|
|
|
gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config_str yon_window_config_get_section(char *section, gsize *size){
|
|
|
|
|
|
|
|
config_str key = g_key_file_get_keys(__yon_window_config_file,section,size,NULL);
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
param->parameter_name = yon_char_new(param_name);
|
|
|
|
|
|
|
|
param->track_widget = widget;
|
|
|
|
|
|
|
|
param->property_name = yon_char_new(widget_property);
|
|
|
|
|
|
|
|
param->containing_type = val_type;
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_listeners,param->parameter_name,param);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){
|
|
|
|
|
|
|
|
__yon_custom_parameter *param = NULL;
|
|
|
|
|
|
|
|
param = yon_remalloc(param,sizeof(__yon_custom_parameter));
|
|
|
|
|
|
|
|
param->parameter_name = yon_char_new(param_name);
|
|
|
|
|
|
|
|
param->section=section;
|
|
|
|
|
|
|
|
param->property = tracked_value;
|
|
|
|
|
|
|
|
param->containing_type = val_type;
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_parameters,param->parameter_name,param);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void yon_window_config_erase_custom_parameter(char *param_name, char *section){
|
|
|
|
|
|
|
|
__yon_custom_parameter *param = NULL;
|
|
|
|
|
|
|
|
param = yon_remalloc(param,sizeof(__yon_custom_parameter));
|
|
|
|
|
|
|
|
param->parameter_name=param_name;
|
|
|
|
|
|
|
|
param->section=section;
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){
|
|
|
|
GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){
|
|
|
|
GtkWidget *menu_item = gtk_menu_item_new();
|
|
|
|
GtkWidget *menu_item = gtk_menu_item_new();
|
|
|
|
gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom");
|
|
|
|
gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom");
|
|
|
@ -1440,6 +1642,16 @@ GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){
|
|
|
|
gtk_widget_show_all(menu_item);
|
|
|
|
gtk_widget_show_all(menu_item);
|
|
|
|
return menu_item;
|
|
|
|
return menu_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// other Gtk functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size)
|
|
|
|
|
|
|
|
* [EN]
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* [RU]
|
|
|
|
|
|
|
|
* Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size]
|
|
|
|
|
|
|
|
*/
|
|
|
|
int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){
|
|
|
|
int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){
|
|
|
|
if (combo&¶meters){
|
|
|
|
if (combo&¶meters){
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
@ -1450,6 +1662,13 @@ int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**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){
|
|
|
|
int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find){
|
|
|
|
if (combo_box&&text_to_find){
|
|
|
|
if (combo_box&&text_to_find){
|
|
|
|
int active=gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box));
|
|
|
|
int active=gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box));
|
|
|
@ -1467,7 +1686,7 @@ int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find){
|
|
|
|
* [EN]
|
|
|
|
* [EN]
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* [RU]
|
|
|
|
* [RU]
|
|
|
|
* Добвляет в [destination] все виджеты, прописанные после [padding]
|
|
|
|
* Добвляет [destination] все виджеты, прописанные после [padding]. Добавление происходит с начала контейнера.
|
|
|
|
* [expand] - расширяемость выделенного для виджетов места
|
|
|
|
* [expand] - расширяемость выделенного для виджетов места
|
|
|
|
* [fill] - заполнять ли виджетом всё ему выделенное место
|
|
|
|
* [fill] - заполнять ли виджетом всё ему выделенное место
|
|
|
|
* [padding] - отступ од других элементов
|
|
|
|
* [padding] - отступ од других элементов
|
|
|
@ -1483,6 +1702,15 @@ int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**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, ...){
|
|
|
|
int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...){
|
|
|
|
va_list args;
|
|
|
|
va_list args;
|
|
|
|
va_start(args,padding);
|
|
|
|
va_start(args,padding);
|
|
|
@ -1665,7 +1893,7 @@ void yon_ubl_browser_window_open(char *link, char *browser_window_name){
|
|
|
|
if (!user)
|
|
|
|
if (!user)
|
|
|
|
user=getlogin();
|
|
|
|
user=getlogin();
|
|
|
|
char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL);
|
|
|
|
char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL);
|
|
|
|
yon_launch(command);
|
|
|
|
yon_launch_app(command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|