From 82fe65376de9d108153dde839b4f9abb0867ccdf Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 29 Nov 2023 09:14:06 +0600 Subject: [PATCH 1/8] Standard libraries update --- .gitignore | 5 +- VERSION.md | 1 - source/ubl-settings-usergroups.c | 169 +-- source/ubl-settings-usergroups.h | 23 +- source/ubl-utils.c | 1091 +++++++++++++++-- source/ubl-utils.h | 104 +- ...tings-usergroups-additional-settings.glade | 364 ++++++ ubl-settings-usergroups-group-creation.glade | 271 ++++ ubl-settings-usergroups-system.glade | 211 ++++ ubl-settings-usergroups-user.glade | 243 +++- ubl-settings-usergroups.glade | 785 ++++++++---- 11 files changed, 2680 insertions(+), 587 deletions(-) delete mode 100644 VERSION.md create mode 100644 ubl-settings-usergroups-additional-settings.glade create mode 100644 ubl-settings-usergroups-group-creation.glade create mode 100644 ubl-settings-usergroups-system.glade diff --git a/.gitignore b/.gitignore index 3a308bb..d82dd62 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ compile/ *# terminal-commands/ source/ubl-cmake.h -vgcore* \ No newline at end of file +vgcore* +.BUILD.md +.updatebuild.sh +.install.sh \ No newline at end of file diff --git a/VERSION.md b/VERSION.md deleted file mode 100644 index 48eea8c..0000000 --- a/VERSION.md +++ /dev/null @@ -1 +0,0 @@ -VERSION 1.3 diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index b149b9c..e38b415 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -107,77 +107,29 @@ void on_toggle_button_switched(GtkToggleButton *self, GtkWidget *widget){ //functions -void on_uid_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->uid = atoi(gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(window->UserUIDEntry)))); -} - -void on_username_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->username = (char*)(gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(window->userUserNameEntry)))); -} - -void on_login_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->login = (char*)(gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(window->userLoginEntry)))); -} - -void on_password_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->password = (char*)(gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(window->userPasswordEntry)))); -} - -void on_group_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->main_group = (char*)(gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(window->userGroupsEntry)))); -} - -void on_hash_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->password_hash = gtk_combo_box_get_active(GTK_COMBO_BOX(window->userPasswordHashAlgorithmCombo)); -} - -void on_extra_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->extra_options = (char*)(gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(window->userExtraOptionsEntry)))); -} - -void on_user_def_password_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->password=NULL; - user_cfg->password_default = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); - on_toggle_button_switched(GTK_TOGGLE_BUTTON(self),window->userPasswordEntry); -} - -void on_auto_uid_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->uid=0; - user_cfg->uid_default = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); - on_toggle_button_switched(GTK_TOGGLE_BUTTON(self),window->UserUIDEntry); -} - -void on_SAMBA_changed(GtkWidget *self, dictionary *dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - user_cfg->sync_SAMBA=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); -} - void on_user_accept(GtkWidget *self, dictionary * dict){ user_window *window = yon_dictionary_get_data(dict->first,user_window*); - user_config *user_cfg = yon_dictionary_get_data(dict->first->next,user_config*); - main_window *widgets = yon_dictionary_get_data(dict->first->next->next,main_window*); + main_window *widgets = yon_dictionary_get_data(dict->first->next,main_window*); GtkTreeIter iter; gtk_list_store_append(main_config.usersListStore,&iter); - gtk_list_store_set(main_config.usersListStore,&iter,(user_cfg->uid_default==0) ? 0 : 1,(user_cfg->uid_default==0) ? user_cfg->uid : 1,2,user_cfg->login, 3,(user_cfg->password_default==0) ? "*******" : _("Default"),5,user_cfg->username,-1); + int auto_id = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDAutoCheck)); + int system_id = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDSystemCheck)); + int unique_id = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDUniqueCheck)); + int user_id = atoi(gtk_entry_get_text(GTK_ENTRY(window->UserUIDEntry))); + const char *user_name = gtk_entry_get_text(GTK_ENTRY(window->userUserNameEntry)); + const char *login = gtk_entry_get_text(GTK_ENTRY(window->userLoginEntry)); + int default_password = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userPasswordDefaultCheck)); + const char *password = gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry)); + int own_group = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userPasswordDefaultCheck)); + const char *groups = gtk_entry_get_text(GTK_ENTRY(window->userGroupsEntry)); + const char *user_shell = NULL; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->userShellCombo))>=0) + user_shell = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->userShellCombo)); + int home_dir_create = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userPasswordDefaultCheck)); + const char *home_dir = gtk_entry_get_text(GTK_ENTRY(window->userHomeFolderEntry)); + int samba = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userPasswordDefaultCheck)); + const char *extra_options = gtk_entry_get_text(GTK_ENTRY(window->userExtraOptionsEntry)); + gtk_list_store_set(main_config.usersListStore,&iter,0,user_id,1,auto_id,2,unique_id,3,system_id,4,user_name,5,login,6,password,7,default_password,8,groups,9,own_group,10,user_shell,11,home_dir,12,home_dir_create,-1); // widgets->MainUserTree; on_close_subwindow(self); } @@ -252,47 +204,42 @@ void on_user_add(GtkWidget *self, main_window *widgets){ window->UserCancelButton = yon_gtk_builder_get_widget(builder,"UserCancelButton"); window->UserOkButton = yon_gtk_builder_get_widget(builder,"UserOkButton"); - window->UserUIDAutoCheck = yon_gtk_builder_get_widget(builder,"userUIDAutoCheck"); + window->userUIDSystemCheck = yon_gtk_builder_get_widget(builder,"userUIDSystemCheck"); + window->userUIDAutoCheck = yon_gtk_builder_get_widget(builder,"userUIDAutoCheck"); + window->userUIDUniqueCheck = yon_gtk_builder_get_widget(builder,"userUIDUniqueCheck"); window->UserUIDEntry = yon_gtk_builder_get_widget(builder,"userUIDEntry"); + window->userUserNameEntry = yon_gtk_builder_get_widget(builder,"userUserNameEntry"); + window->userLoginEntry = yon_gtk_builder_get_widget(builder,"userLoginEntry"); + window->userPasswordDefaultCheck = yon_gtk_builder_get_widget(builder,"userPasswordDefaultCheck"); window->userPasswordEntry = yon_gtk_builder_get_widget(builder,"userPasswordEntry"); + + window->userGroupsCheck = yon_gtk_builder_get_widget(builder,"userGroupsCheck"); window->userGroupsEntry = yon_gtk_builder_get_widget(builder,"userGroupsEntry"); - window->userPasswordHashAlgorithmCombo = yon_gtk_builder_get_widget(builder,"userPasswordHashAlgorithmCombo"); + window->UserAdditionalGroupsButton = yon_gtk_builder_get_widget(builder,"UserAdditionalGroupsButton"); + window->UserAdditionalGroupsMultipleButton = yon_gtk_builder_get_widget(builder,"UserAdditionalGroupsMultipleButton"); + + window->userShellCombo = yon_gtk_builder_get_widget(builder,"userShellCombo"); + + window->userCreateHomeFolderCheck = yon_gtk_builder_get_widget(builder,"userCreateHomeFolderCheck"); + window->userHomeFolderEntry = yon_gtk_builder_get_widget(builder,"userHomeFolderEntry"); + window->userHomeFolderButton = yon_gtk_builder_get_widget(builder,"userHomeFolderButton"); + window->userSyncSAMBACheck = yon_gtk_builder_get_widget(builder,"userSyncSAMBACheck"); window->userExtraOptionsEntry = yon_gtk_builder_get_widget(builder,"userExtraOptionsEntry"); - user_config *user_cfg=malloc(sizeof(user_config)); - user_cfg->username=NULL; - user_cfg->login=NULL; - user_cfg->password=NULL; - user_cfg->main_group=NULL; - user_cfg->additional_groups=NULL; - user_cfg->extra_options=NULL; - user_cfg->uid=-1; - user_cfg->password_default=0; - user_cfg->password_hash=-1; - user_cfg->sync_SAMBA=0; dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window) - yon_dictionary_add_or_create_if_exists_with_data(dict,"config",user_cfg); yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_user_accept),dict); - // g_signal_connect(G_OBJECT(window->UserUIDAutoCheck),"clicked",G_CALLBACK(on_toggle_button_switched),window->UserUIDEntry); - // g_signal_connect(G_OBJECT(window->userPasswordDefaultCheck),"clicked",G_CALLBACK(on_toggle_button_switched),window->UserPasswordEntry); - g_signal_connect(G_OBJECT(window->UserAdditionalGroupsButton),"clicked",G_CALLBACK(on_groups_open),NULL); + g_signal_connect(G_OBJECT(window->UserAdditionalGroupsButton),"clicked",G_CALLBACK(on_def_groups_open),window); - g_signal_connect(G_OBJECT(window->UserUIDAutoCheck),"toggled",G_CALLBACK(on_auto_uid_changed),dict); - g_signal_connect(G_OBJECT(window->UserUIDEntry),"changed",G_CALLBACK(on_uid_changed),dict); - g_signal_connect(G_OBJECT(window->userUserNameEntry),"changed",G_CALLBACK(on_username_changed),dict); - g_signal_connect(G_OBJECT(window->userLoginEntry),"changed",G_CALLBACK(on_login_changed),dict); - g_signal_connect(G_OBJECT(window->userPasswordDefaultCheck),"toggled",G_CALLBACK(on_user_def_password_changed),dict); - g_signal_connect(G_OBJECT(window->userPasswordEntry),"changed",G_CALLBACK(on_password_changed),dict); - g_signal_connect(G_OBJECT(window->userGroupsEntry),"changed",G_CALLBACK(on_group_changed),dict); - g_signal_connect(G_OBJECT(window->userPasswordHashAlgorithmCombo),"changed",G_CALLBACK(on_hash_changed),dict); - g_signal_connect(G_OBJECT(window->userSyncSAMBACheck),"toggled",G_CALLBACK(on_SAMBA_changed),dict); - g_signal_connect(G_OBJECT(window->userExtraOptionsEntry),"changed",G_CALLBACK(on_extra_changed),dict); + + g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"clicked",G_CALLBACK(on_toggle_button_switched),window->UserUIDEntry); + g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"clicked",G_CALLBACK(on_toggle_button_switched),window->userUIDUniqueCheck); gtk_widget_show(window->Window); } @@ -304,34 +251,6 @@ void on_user_delete(){ } -void on_def_groups_edit(GtkCellEditable *self, main_window *widgets){ - main_config.default_groups=(char*)gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(widgets->MainDefaultGroupsEntry))); -} - -void on_def_user_edit(GtkCellEditable *self, main_window *widgets){ - main_config.default_user_name=(char*)gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(widgets->MainDefaultUserNameEntry))); - -} - -void on_def_admin_edit(GtkWidget *self, main_window *widgets){ - main_config.is_1000_administrator=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->MainDefaultUserAdministratorCheck)); - -} - -void on_def_password_edit(GtkCellEditable *self, main_window *widgets){ - main_config.default_password=(char*)gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(widgets->MainDefaultPasswordEntry))); -} - -void on_root_password_edit(GtkCellEditable *self, main_window *widgets){ - main_config.root_password=(char*)gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(widgets->MainRootPasswordEntry))); - -} - -void on_hash_edit(GtkWidget *self, main_window *widgets){ - main_config.hash_alg=gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->MainPasswordHashCombo)); - -} - // standard functions void config_init(){ @@ -426,12 +345,6 @@ main_window *setup_window(){ g_signal_connect(G_OBJECT(widgets->MainEditUserButton),"clicked",G_CALLBACK(on_user_edit),NULL); g_signal_connect(G_OBJECT(widgets->MainDeleteUserButton),"clicked",G_CALLBACK(on_user_delete),NULL); g_signal_connect(G_OBJECT(widgets->MainEditGroupsButton),"clicked",G_CALLBACK(on_def_groups_open),widgets); - g_signal_connect(G_OBJECT(widgets->MainDefaultGroupsEntry),"changed",G_CALLBACK(on_def_groups_edit),widgets); - g_signal_connect(G_OBJECT(widgets->MainDefaultUserNameEntry),"changed",G_CALLBACK(on_def_user_edit),widgets); - g_signal_connect(G_OBJECT(widgets->MainDefaultUserAdministratorCheck),"toggled",G_CALLBACK(on_def_admin_edit),widgets); - g_signal_connect(G_OBJECT(widgets->MainDefaultPasswordEntry),"changed",G_CALLBACK(on_def_password_edit),widgets); - g_signal_connect(G_OBJECT(widgets->MainRootPasswordEntry),"changed",G_CALLBACK(on_root_password_edit),widgets); - g_signal_connect(G_OBJECT(widgets->MainPasswordHashCombo),"changed",G_CALLBACK(on_hash_edit),widgets); gtk_widget_show(widgets->Window); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index c13f3c0..f6eae4e 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -65,6 +65,7 @@ typedef struct { GtkWidget *Window; GtkWidget *HatLabel; GtkWidget *PlugBox; + GtkWidget *MainDefaultGroupsEntry; GtkWidget *HeadOverlay; GtkWidget *HeadImage; @@ -96,7 +97,6 @@ typedef struct { GtkWidget *MainEditGroupsButton; - GtkWidget *MainDefaultGroupsEntry; GtkWidget *MainDefaultUserNameEntry; GtkWidget *MainDefaultUserAdministratorCheck; GtkWidget *MainDefaultPasswordEntry; @@ -171,18 +171,31 @@ typedef struct { typedef struct { GtkWidget *Window; - GtkWidget *UserAdditionalGroupsButton; GtkWidget *UserCancelButton; GtkWidget *UserOkButton; + GtkWidget *userGroupsEntry; - GtkWidget *UserUIDAutoCheck; + GtkWidget *userUIDSystemCheck; + GtkWidget *userUIDAutoCheck; + GtkWidget *userUIDUniqueCheck; GtkWidget *UserUIDEntry; + GtkWidget *userUserNameEntry; GtkWidget *userLoginEntry; + GtkWidget *userPasswordDefaultCheck; GtkWidget *userPasswordEntry; - GtkWidget *userGroupsEntry; - GtkWidget *userPasswordHashAlgorithmCombo; + + GtkWidget *userGroupsCheck; + GtkWidget *UserAdditionalGroupsButton; + GtkWidget *UserAdditionalGroupsMultipleButton; + + GtkWidget *userShellCombo; + + GtkWidget *userCreateHomeFolderCheck; + GtkWidget *userHomeFolderEntry; + GtkWidget *userHomeFolderButton; + GtkWidget *userSyncSAMBACheck; GtkWidget *userExtraOptionsEntry; } user_window; diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 7358272..66ed085 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -2,7 +2,7 @@ // dictionary functions -/**yon_dictionary_create_empty(): +/**yon_dictionary_new(): * [EN] * Creates and returns empty dictionary * [RU] @@ -20,7 +20,7 @@ dictionary *yon_dictionary_new() return dict; } -/**yon_dictionary_copy_deep(dictionary *dict) +/**yon_dictionary_copy(dictionary *dict) * [EN] * * [RU] @@ -29,6 +29,7 @@ dictionary *yon_dictionary_new() 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) @@ -47,22 +48,49 @@ 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) @@ -409,6 +437,13 @@ dictionary *yon_dictionary_get_nth(dictionary *dict, int place) // 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] * * creates new char string by combining two char strings. @@ -420,9 +455,9 @@ char *yon_char_append(char *source, char *append) int size = strlen(source) + strlen(append) + 1; char *final = malloc(size); memset(final, 0, size); - if (strstr(source, "%%")) - sprintf(final, source, append); - else + // if (strstr(source, "%%")) + // sprintf(final, source, append); + // else sprintf(final, "%s%s", source, append); return final; } @@ -445,8 +480,12 @@ char *yon_char_new(char *chr) return NULL; } -// char *yon_char_unite(char *source, ...) - +/**yon_char_unite(char *source, ...) + * [En] + * + * [RU] + * Объединяет строку [source] со всеми строками, написанными в [...] +*/ char *yon_char_unite(char *source, ...){ va_list arglist; char *new_char=NULL; @@ -494,6 +533,12 @@ char *yon_char_divide(char *source, int dividepos) return cut; } +/**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; @@ -536,9 +581,8 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) cut = yon_char_divide(source, leng); return cut; } - else - return source; } + return source; } /**yon_char_from_int(int int_to_convert) @@ -563,52 +607,95 @@ char *yon_char_from_int(int 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; + float convert_check = (float)int_to_convert; + for (i = 1; convert_check >= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0((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; + double convert_check = (double)int_to_convert; + for (i = 1; convert_check >= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0(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){ - char *final=NULL; - char *temp=NULL; - if(!strstr(replace,find)){ - while ((final=strstr(source,find))){ - temp=malloc(strlen(source)-strlen(final)); - memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); - memcpy(temp,source,strlen(source)-strlen(final)); - temp=yon_char_append(temp,replace); - source=yon_char_append(temp,final+1); +char *yon_char_replace(char *source, char *find, char*replace){ + if (!strstr(replace,find)){ + + + char *final=NULL; + char *temp=NULL; + if(!strstr(replace,find)){ + while ((final=strstr(source,find))){ + temp=malloc(strlen(source)-strlen(final)+strlen(replace)); + memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); + memcpy(temp,source,strlen(source)-strlen(final)); + temp=yon_char_append(temp,replace); + source=yon_char_append(temp,final+strlen(find)); + } + } - return source; } + return source; } -/**[EN] - * char **yon_char_parse(char *parameters, int *size, char *divider) +/**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){ - char **string=NULL; - int i=1; - string=malloc(sizeof(char*)); - char *paramline=yon_char_new(parameters); - char *param; - while ((param=yon_char_divide_search(paramline,divider,1))){ - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(param); - i++; - if (strcmp(param,paramline)==0) break; - } - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(paramline); - i++; - // printf("%d\n",i); - *size=i-1; - return string; - + if (parameters){ + char **string=NULL; + *size=0; + char *paramline=yon_char_new(parameters); + char *param = strstr(paramline,divider); + for (;param;param=strstr(paramline,divider)){ + string = yon_remalloc(string,sizeof(char*)*((*size)+1)); + string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param)); + *size=(*size)+1; + } + string = yon_remalloc(string,sizeof(char*)*((*size)+1)); + string[(*size)]=paramline; + (*size)+=1; + return string; + } + return NULL; } /**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) @@ -657,6 +744,30 @@ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ return -1; } +/**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){ + if (parameters){ + *first_overlap=0; + *second_overlap=0; + for ((*first_overlap)=0;(*first_overlap)pw_name,NULL); + else { + user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); + } + } + endpwent(); + return user_list; +} + // parsing functions +/** yon_size_convert_automatic(int bytes, int *size) + * [EN] + * + * [RU] + * +*/ +float yon_size_convert_automatic(int bytes, int *size){ + float byte_float=bytes; + for (*size=-1;byte_float>1024;*size=*size+1){ + byte_float=byte_float/1024; + } + if (*size==-1) { + *size=0; + byte_float=byte_float/1024; + } + return byte_float; +} apps *yon_apps_scan_and_parse_desktops(int *sizef) { @@ -867,8 +1042,73 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size) 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; + if (!access(dir_path,F_OK)){ + DIR *directory = opendir(dir_path); + struct dirent *de; + while ((de = readdir(directory))){ + if (dir) yon_char_parsed_append(dir,size,de->d_name); + else dir = yon_char_parsed_new(size,de->d_name,NULL); + } + closedir(directory); + } + return dir; +} + //config functions +typedef struct yon_config_parameter +{ + char *key; + void *data; + struct yon_config_parameter *next; + struct yon_config_parameter *prev; + struct yon_config_parameter *first; + DICT_TYPE data_type; + int flag1; + char *section; +} yon_config_parameter; + +yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){ + yon_config_parameter *param = yon_remalloc(NULL,sizeof(yon_config_parameter)); + param->data=data; + param->data_type=DICTIONARY_CHAR_TYPE; + param->first=param; + param->flag1=0; + param->key=yon_char_new(key); + param->next=NULL; + param->prev=NULL; + param->section=NULL; + return param; +} + +yon_config_parameter *yon_config_parameter_append_with_data(yon_config_parameter *dict, char *key, void *data){ + yon_config_parameter *param = yon_config_parameter_new_with_data(key,data); + param->first=dict->first; + (param->prev)=(yon_config_parameter*)yon_dictionary_get_last((dictionary*)dict); + dict->next=param; + return param; +} + + +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 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] * @@ -876,28 +1116,48 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size) * Выполняет команду [command]. * Полученные данные парсятся и регистрируются в конфиг. */ -int yon_config_load_register(char *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(__yon__config__strings,NULL); + __yon__config__strings = yon_dictionary_free_all((dictionary*)__yon__config__strings,NULL); } - FILE *output = popen(command, "r"); - char **output_strings = NULL; - output_strings = malloc(sizeof(char)); - int i = 0; - char str[4096]; - memset(str, 0, 4096); - while (fgets(str, 4096, output)) + va_list args; + va_start(args,parameter); + char *arg; + dictionary *sections = NULL; { - if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) + if (sections&&yon_dictionary_get(§ions,section)) sections->data=(void*)yon_char_unite(yon_dictionary_get_data(sections,char*)," ",parameter,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections,section,parameter); + } + while (arg=va_arg(args,char*)){ + char *key = va_arg(args,char*); + if (sections&&yon_dictionary_get(§ions,arg)) sections->data=(void*)yon_char_unite(yon_dictionary_get_data(sections,char*)," ",key,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections,arg,key); + } + char *command=NULL; + dictionary *dict; + for_dictionaries(dict,sections){ + command = yon_char_unite(ubconfig_load_command,config_type==YON_CONFIG_GLOBAL ? " global get " : " system get ", dict->key," ", yon_dictionary_get_data(dict,char*),NULL); + FILE *output = popen(command, "r"); + char **output_strings = NULL; + output_strings = malloc(sizeof(char*)); + int i = 0; + char str[4096]; + memset(str, 0, 4096); + while (fgets(str, 4096, output)) { - char *key = yon_char_divide_search(str,"=",-1); - yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,str); - __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; + if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) + { + char *key = yon_char_divide_search(str,"=",-1); + char *final_str=yon_char_divide_search(str,"\n",-1); + yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,yon_char_new(final_str)); + __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; + __yon__config__strings->section=dict->key; + } } } check_config - return 0; - else return 1; + return 1; + else return 0; } /**yon_config_remove_by_key(char *key) @@ -908,35 +1168,15 @@ int yon_config_load_register(char *command){ */ int yon_config_remove_by_key(char *key){ check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + dictionary *dict = yon_dictionary_get((dictionary**)&__yon__config__strings,key); if (dict){ - yon_dictionary_rip(dict); + ((yon_config_parameter*)dict)->flag1=-1; return 1; }else return 0; } return 0; } -/**yon_config_remove_by_data(void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу на наличие параметра со значением [data] и удаляет найденное значение из конфига. -*/ -int yon_config_remove_by_data(void *data){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ - if (dict->data==data){ - yon_dictionary_rip(dict); - return 1; - } - } - return 0; - } - return 0; -} - /**yon_config_remove_element(char *key, char *deleted) * [EN] * @@ -945,7 +1185,7 @@ int yon_config_remove_by_data(void *data){ */ int yon_config_remove_element(char *key, char *deleted){ check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key); char *data = (char*)dict->data; char *found = strstr(data,deleted); int size=strlen(data)-strlen(found)+1; @@ -959,7 +1199,6 @@ int yon_config_remove_element(char *key, char *deleted){ new_data = yon_char_append(new_data,found+strlen(deleted)); } dict->data=(void*)(new_data); - free(data); dict->flag1=1; return 1; } else return 0; @@ -974,8 +1213,8 @@ int yon_config_remove_element(char *key, char *deleted){ void *yon_config_get_by_key(char *key){ check_config{ dictionary *dict = NULL; - for_dictionaries(dict, __yon__config__strings){ - if (strcmp(dict->key,key)==0){ + for_dictionaries(dict, (dictionary*)__yon__config__strings){ + if (strcmp(dict->key,key)==0&&((yon_config_parameter*)dict)->flag1!=-1){ return dict->data; } } @@ -983,6 +1222,21 @@ void *yon_config_get_by_key(char *key){ return NULL; } +void *yon_config_get_all_by_key(char *key, int *size){ + check_config{ + config_str ret_data=NULL; + dictionary *dict = NULL; + for_dictionaries(dict, (dictionary*)__yon__config__strings){ + if (strstr(dict->key,key)&&((yon_config_parameter*)dict)->flag1!=-1) { + char *ret_string = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); + if (ret_data) ret_data = yon_char_parsed_append(ret_data,size,ret_string); + else ret_data = yon_char_parsed_new(size,ret_string,NULL); + } + } + return ret_data; + } +} + /**yon_config_get_key_by_data(char *data) * [EN] * @@ -993,7 +1247,7 @@ void *yon_config_get_by_key(char *key){ char *yon_config_get_key_by_data(char *data){ check_config{ dictionary *dict = NULL; - for_dictionaries(dict, __yon__config__strings){ + for_dictionaries(dict, (dictionary*)__yon__config__strings){ if (strcmp(((char*)dict->data),data)==0){ return dict->key; } @@ -1010,12 +1264,32 @@ char *yon_config_get_key_by_data(char *data){ */ int yon_config_set(char *key, void *data){ check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key); dict->data=data; + dict->flag1=1; return 1; } 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); + if (strcmp(((char*)dict->data),"")!=0) + dict->data=(void*)(yon_char_unite((char*)dict->data," ",data,NULL)); + else dict->data=(void*)data; + dict->flag1=1; + return 1; + } else return 0; +} + + /**yon_config_clean() * [EN] * Erase all parameters from config; @@ -1024,7 +1298,7 @@ int yon_config_set(char *key, void *data){ */ int yon_config_clean(){ check_config{ - __yon__config__strings = yon_dictionary_free_all(__yon__config__strings, NULL); + __yon__config__strings = (yon_config_parameter*)yon_dictionary_free_all((dictionary*)__yon__config__strings, NULL); return 1; } else return 0; @@ -1038,9 +1312,14 @@ int yon_config_clean(){ * [key] - ключ параметра; * [data] - значение параметра; */ -void yon_config_register(char *key, void *data){ - yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,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); + } + 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) @@ -1062,7 +1341,6 @@ config_str yon_config_load(char *command, int *str_len){ if (strcmp(str, "") != 0) { output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); - // printf("%s\n", str); output_strings[i] = NULL; output_strings[i] = yon_char_new(str); memset(str, 0, 4096); @@ -1078,22 +1356,93 @@ config_str yon_config_load(char *command, int *str_len){ } } -/**int yon_config_save(char *command) +/**int yon_config_save_registered(char *path) * [EN] - * Saves config with [command] + * Saves config at [path] config. + * [path] can be: + * system + * global * [RU] - * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: - * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" + * Сохраняет конфигурацию в [path] конфиг. + * [path] может быть + * system - локальный конфиг + * global - глобальный конфиг */ -int yon_config_save(char *command){ +int yon_config_save_registered(char *path){ check_config{ - dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ - command = yon_char_unite(command, " ", yon_dictionary_get_data(dict,char*), NULL); + dictionary *dct; + dictionary *sections_add=NULL; + dictionary *sections_remove=NULL; + for_dictionaries(dct,(dictionary*)__yon__config__strings){ + if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ + if (((yon_config_parameter*)dct)->flag1==1){ + ((yon_config_parameter*)dct)->flag1=0; + if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); + } else if (((yon_config_parameter*)dct)->flag1==-1){ + ((yon_config_parameter*)dct)->flag1=0; + if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); + yon_dictionary_rip(dct); + } + } } - if (popen(command, "r")) return 1; - else return 0; - } else return 0; + if (sections_add) + for_dictionaries(dct,sections_add){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + if (sections_remove) + for_dictionaries(dct,sections_remove){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + return 1; + } 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; + dictionary *sections_add=NULL; + dictionary *sections_remove=NULL; + for_dictionaries(dct,(dictionary*)__yon__config__strings){ + if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ + if (((yon_config_parameter*)dct)->flag1==1||((yon_config_parameter*)dct)->flag1==0){ + if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); + } else if (((yon_config_parameter*)dct)->flag1==-1){ + if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); + } + } + } + if (sections_add) + for_dictionaries(dct,sections_add){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + if (sections_remove) + for_dictionaries(dct,sections_remove){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + + + return 1; + } else return 1; } /**yon_config_get_all(int *size) @@ -1108,29 +1457,18 @@ config_str yon_config_get_all(int *size){ *size = 1; config_str conf = NULL; dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ + for_dictionaries(dict,(dictionary*)__yon__config__strings){ conf = yon_remalloc(conf,sizeof(char*)*(*size)); conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); - size++; + (*size)++; } - conf = yon_remalloc(conf,sizeof(char*)*(*size+1)); - conf[*size] = NULL; + conf = yon_remalloc(conf,sizeof(char*)*(*size)); + conf[*size-1] = NULL; + (*size)=(*size)-1; return conf; } 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) * [EN] * Gets parameter [param] from parameter list [parameters] of size [size]; @@ -1164,7 +1502,71 @@ char *yon_config_get_parameter(config_str parameters, int size, char *param) return NULL; } +config_str yon_file_open(char *file_path, int *size){ + *size=0; + FILE *file = fopen(file_path,"r"); + if (file){ + char str_loaded[4098]; + config_str final_string = NULL; + while (fgets(str_loaded,4098,file)){ + final_string = final_string ? yon_char_parsed_append(final_string,size,str_loaded) : yon_char_parsed_new(size,str_loaded,NULL); + } + return final_string; + } +} +/**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); + if (access(full_path,F_OK)){ + FILE *fl = fopen(full_path,"w"); + if (fl){ + chmod(full_path,rules); + fclose(fl); + return 1; + } else { + return 0; + } + } else { + return -1; + } + } else { + return 0; + } +} + +/**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)){ + FILE *fl = fopen(path,"w"); + if (fl){ + chmod(path,rules); + fclose(fl); + return 1; + } else { + return 0; + } + } else { + return -1; + } + } else { + return 0; + } +} // terminal-using functions @@ -1235,8 +1637,7 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); gtk_container_add(GTK_CONTAINER(place_to_show),terminal); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - printf("%s\n",install_command); + char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); if(endwork_function) g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); vte_terminal_spawn_async(VTE_TERMINAL(terminal), @@ -1289,7 +1690,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); + char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5; stty -echo; unset PS1","\n",NULL); if(endwork_function) g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); vte_terminal_spawn_async(VTE_TERMINAL(terminal), @@ -1315,21 +1716,42 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end NULL, NULL, NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), 100); + vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); gtk_widget_show_all(terminal); } #endif + // Window config functions + #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 { int x; int y; int width; int height; int fullscreen; + dictionary *custom_listeners; + dictionary *custom_parameters; + dictionary *deleted_parameters; } __yon_main_window_config; + static GtkWindow *__yon_window_config_target_window = NULL; static GKeyFile *__yon_window_config_file = NULL; static char *__yon_window_config_path = NULL; @@ -1340,15 +1762,63 @@ 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","WindowHeight",__yon_main_window_config.height); g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen); + dictionary *dict=NULL; + 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); + } + 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; + } + } + g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); } void yon_get_is_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){ check_window_config_setup{ yon_get_is_fullscreen(); @@ -1366,6 +1836,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){ __yon_window_config_target_window = window; g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); @@ -1377,6 +1853,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); } + /**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); @@ -1390,6 +1872,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end } FILE *fp; fp=fopen(__yon_window_config_path,"w"); + chmod(__yon_window_config_path,0777); fclose(fp); g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); } @@ -1398,6 +1881,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.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); + 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.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); @@ -1413,7 +1917,200 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); } -int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){ + 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); + dictionary *dict=NULL; + if (__yon_main_window_config.deleted_parameters) + for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ + if (strcmp(dict->key,param->parameter_name)) + yon_dictionary_rip(dict); + } + } + + void yon_window_config_add_instant_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ + switch (val_type){ + case YON_TYPE_BOOLEAN: g_key_file_set_boolean(__yon_window_config_file,section,param_name,*((gboolean*)tracked_value)); + break; + case YON_TYPE_INT: g_key_file_set_integer(__yon_window_config_file,section,param_name,*((int*)tracked_value)); + break; + case YON_TYPE_STRING: g_key_file_set_string(__yon_window_config_file,section,param_name,(char*)tracked_value); + break; + } + } + + 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); + } + + int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ + GError *err=NULL; + switch (type){ + case YON_TYPE_BOOLEAN: + *((int*)return_value) = g_key_file_get_boolean(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_INT: + *((int*)return_value) = g_key_file_get_integer(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_STRING: + *((char**)return_value) = g_key_file_get_string(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_STRING_LIST: + gsize size=0; + *((char***)return_value) = g_key_file_get_string_list(__yon_window_config_file,section,config_parameter,&size,&err); + *((char***)return_value)=yon_remalloc(return_value,size+1); + *((char***)return_value)[size]=NULL; + if (err) return 0; else return 1; + break; + } + } + + void yon_on_window_config_custom_window_destroy(GtkWindow *window, char *window_name){ + if (!gtk_window_is_maximized(window)){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + + } + } + + void yon_on_window_config_custom_window_resize(GtkWindow *window, char *window_name){ + if (!gtk_window_is_maximized(window)){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_size(window,&width,&height); + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + } + + } + + void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); + if (width&&height) + gtk_window_resize(window,width,height); + if (X&&Y) + gtk_window_move(window,X,Y); + char *signals_window_name = yon_char_new(window_name); + g_signal_connect(G_OBJECT(window),"check-resize",G_CALLBACK(yon_on_window_config_custom_window_resize),signals_window_name); + g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_window_config_custom_window_destroy),signals_window_name); + } + + void yon_window_config_custom_window_get(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); + if (width&&height) + gtk_window_resize(window,width,height); + if (X&&Y) + gtk_window_move(window,X,Y); + } + + void yon_window_config_custom_window_set(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_size(window,&width,&height); + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + } + +GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ + GtkWidget *menu_item = gtk_menu_item_new(); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + GtkWidget *label = gtk_label_new(buttonname); + GtkWidget *image = gtk_image_new_from_icon_name("dialog-information-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_widget_show_all(menu_item); + return menu_item; +} + +GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ + GtkWidget *menu_item = gtk_menu_item_new(); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemmiddle"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + GtkWidget *label = gtk_label_new(buttonname); + GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_widget_show_all(menu_item); + return menu_item; +} + + +// 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;i0 ? 1 : 0); +} + +void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ + gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>0 ? 0 : 1); +} void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) { @@ -1520,6 +2254,115 @@ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ _yon_ubl_status_box_render(text,type); } +void _yon_ubl_status_highlight_incorrect(GtkWidget *widget){ + gtk_style_context_add_class(gtk_widget_get_style_context(widget),"errorBox"); + sleep(5); + gtk_style_context_remove_class(gtk_widget_get_style_context(widget),"errorBox"); +} + +void yon_ubl_status_highlight_incorrect(GtkWidget *widget){ + GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_highlight_incorrect,widget); +} + +void _yon_ubl_status_list_store_highlight_incorrect(GtkWidget **widget_pack){ + GtkListStore *list = (GtkListStore*)widget_pack[0]; + GtkTreeIter *iter = (GtkTreeIter*)widget_pack[1]; + GdkRGBA rgba,rgba2; + rgba.alpha=1; + rgba.blue=153.0/255.0; + rgba.green=153.0/255.0; + rgba.red=234.0/255.0; + rgba2.alpha=1; + rgba2.blue=0; + rgba2.green=0; + rgba2.red=0; + gtk_list_store_set(list,iter,1,gdk_rgba_to_string(&rgba2),2,gdk_rgba_to_string(&rgba),-1); + sleep(5); + gtk_list_store_set(list,iter,1,NULL,2,NULL,-1); +} + +void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter){ + GtkWidget **pack = malloc(sizeof(GtkWidget *)*2); + pack[0]=(GtkWidget*)list; + pack[1]=(GtkWidget*)iter; + GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_list_store_highlight_incorrect,pack); +} + +struct temp_statusbox { + int times; + GtkWidget *revealer; + }; + +void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ + sleep(statusstruct->times); + if (status_thread_busy){ + gtk_revealer_set_reveal_child(GTK_REVEALER(statusstruct->revealer),0); + sleep(1); + gtk_widget_destroy(statusstruct->revealer); + + } + status_thread_busy=0; +} + +void __yon_ubl_status_box_destroyed(){ + status_thread_busy=0; +} + +void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type){ + if (!status_thread_busy){ + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + GtkWidget *revealer = gtk_revealer_new(); + GtkWidget *label = gtk_label_new(""); + GtkWidget *icon = gtk_image_new(); + gtk_container_add(GTK_CONTAINER(revealer),box); + gtk_box_pack_start(GTK_BOX(box),icon,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(container,revealer); + + gtk_widget_show_all(revealer); + gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1); + g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),NULL); + + gtk_widget_set_margin_bottom(label,9); + gtk_widget_set_margin_top(label,9); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + PangoAttrList *attributes = pango_attr_list_new(); + PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); + pango_attr_list_insert(attributes, boldAttr); + gtk_label_set_attributes(GTK_LABEL(label),attributes); + + GdkRGBA textColor; + gdk_rgba_parse(&textColor, "#4d4d4d4d4d4d"); + PangoAttribute *colorAttr = pango_attr_foreground_new( + (int)(textColor.red * 65535), + (int)(textColor.green * 65535), + (int)(textColor.blue * 65535) + ); + pango_attr_list_insert(attributes, colorAttr); + + GtkIconTheme *ictheme = gtk_icon_theme_get_default(); + if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); + gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + else if (type == BACKGROUND_IMAGE_FAIL_TYPE) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); + gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessError"); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + if (display_text) + gtk_label_set_text(GTK_LABEL(label),display_text); + struct temp_statusbox *statusstruct = malloc(sizeof(struct temp_statusbox)); + statusstruct->revealer = revealer; + statusstruct->times = timeout; + GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); + status_thread_busy=1; + } +} + /**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. diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 01281cd..2fef789 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -9,9 +9,13 @@ #include #include #include +#include +#include #include #include #include +#include +#include #include "../compile/ubl-cmake.h" #ifdef WEBKIT_FOUND @@ -24,7 +28,7 @@ #define new(type) malloc(sizeof(type)) #define new_arr(type,size) malloc(sizeof(type)*size) -#define get_pkexec_user_command "getent passwd $PKEXEC_UID | cut -d: -f1" +#define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) typedef enum { @@ -46,9 +50,11 @@ typedef struct dictionary struct dictionary *prev; struct dictionary *first; DICT_TYPE data_type; - int flag1; } dictionary; + + + typedef struct apps { char *Name; @@ -62,13 +68,8 @@ typedef struct apps typedef char** config_str; -static dictionary *__yon__config__strings = NULL; -#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) - #define config(key) yon_config_get_by_key(key) -#define for_config dictionary temp = NULL; for_dictionary(temp,__yon__config__strings) - #define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) // dictionary functions @@ -122,6 +123,12 @@ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(vo // char functions +#define yon_char_divide_search_self(str,find,delete_divider) {char *temp = str; str = yon_char_divide_search(str,find,delete_divider); free(temp);} + +#define yon_char_is_empty(string) !(string&&strcmp(string,"")) + +int yon_char_find_last(char *source, char find); + char *yon_char_append(char *source, char *append); char *yon_char_new(char *chr); @@ -136,6 +143,10 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); char *yon_char_from_int(int int_to_convert); +char *yon_char_from_float(float int_to_convert); + +char *yon_char_from_long(long int_to_convert); + char *yon_char_replace(char *source, char *find, char*replace); char **yon_char_parse(char *parameters, int *size, char *divider); @@ -144,12 +155,16 @@ char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); int yon_char_parsed_check_exist(char **parameters, int size, char *param); +int yon_char_parsed_check_repeats(char **parameters, int size, int *first_overlap, int *second_overlap); + int yon_char_find_count(char *source, char *find); int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_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_append(config_str parsed, int *size, char *string); @@ -158,8 +173,14 @@ int yon_ubl_check_root(); char *yon_ubl_root_user_get(); +char *yon_ubl_user_get_home_directory(); + +config_str yon_ubl_get_all_users(int *user_size); + // parsing functions +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); @@ -168,13 +189,34 @@ void yon_apps_sort(apps *applist, int size); apps *yon_apps_get_by_name(apps *applist, char *name, int size); +config_str yon_file_open(char *file_path, int *size); + +int yon_file_create(char *path, char *name, int rules); + +int yon_file_create_full_path(char *path, int rules); + +config_str yon_dir_get_contents(char *dir_path, int *size); + +//config functions + +#define ubconfig_save_command "ubconfig" +#define ubconfig_load_command "ubconfig --source" + +typedef enum { + YON_CONFIG_LOCAL=0, + YON_CONFIG_GLOBAL, + YON_CONFIG_BOTH +} YON_CONFIG_TYPE; + config_str yon_config_load(char *command, int *str_len); -int yon_config_save(char *command); +int yon_config_save_registered(char *path); + +int yon_config_force_save_registered(char *path); char *yon_config_get_parameter(config_str parameters, int size, char *param); -int yon_config_load_register(char *command); +int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...); int yon_config_remove_by_key(char *key); @@ -184,13 +226,15 @@ int yon_config_remove_element(char *key, char *deleted); void *yon_config_get_by_key(char *key); +void *yon_config_get_all_by_key(char *key, int *size); + char *yon_config_get_key_by_data(char *data); int yon_config_set(char *key, void *data); int yon_config_clean(); -void yon_config_register(char *key, void *data); +void yon_config_register(char *key, char* config_section, void *data); config_str yon_config_get_all(); @@ -210,6 +254,17 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end #endif +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_gtk_builder_get_widget(builder, widget_name) * [EN] * Returns GtkWidget from GtkBuilder *[builder]. @@ -230,10 +285,28 @@ void yon_window_config_setup(GtkWindow *window); int yon_window_config_load(char *path); +config_str yon_window_config_get_section(char *section, gsize *size); + +void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_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_erase_custom_parameter(char *param_name, char *section); + +int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type); + +void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name); + +void yon_window_config_custom_window_get(GtkWindow *window, char *window_name); + +void yon_window_config_custom_window_set(GtkWindow *window, char *window_name); + int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); +void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); + int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); @@ -241,6 +314,10 @@ int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); +void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); typedef enum { @@ -288,6 +365,13 @@ int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); */ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); +void yon_ubl_status_highlight_incorrect(GtkWidget *widget); + +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_header_setup(overlay, head, image, imag_path) diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade new file mode 100644 index 0000000..6305632 --- /dev/null +++ b/ubl-settings-usergroups-additional-settings.glade @@ -0,0 +1,364 @@ + + + + + + True + False + com.ublinux.ubl-settings-usergroups.cancel-symbolic + + + True + False + com.ublinux.ubl-settings-usergroups.accept-symbolic + + + 600 + 350 + False + False + com.ublinux.ubl-settings-usergroups + + + True + False + 5 + 5 + 5 + vertical + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + 5 + 5 + Default user name (if there's no another): + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 0 + + + + + User with ID 1000 is administrator + True + True + False + True + + + False + True + 1 + + + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + 5 + 5 + Default user password: + 0 + + + False + True + 0 + + + + + True + False + + Default + No password required + Set a password + Endrypted password + + + + True + True + 1 + + + + + True + True + 30 + False + + password + + + True + True + 2 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Root user password: + 0 + + + False + True + 0 + + + + + True + False + + Default + No password required + Set a password + Encrypted password + + + + True + True + 1 + + + + + True + True + 30 + False + + password + + + True + True + end + 2 + + + + + False + True + 3 + + + + + False + True + 3 + + + + + True + False + 5 + + + True + False + 5 + 5 + Password hash algorythm: + 0 + + + False + True + 0 + + + + + True + False + 0 + + md5 + yescrypt + ghost-yescrypt + scrypt + bf + bcrypt + bcrypt-a + sha512crypt + sha256crypt + sunmd5 + md5crypt + bsdicrypt + desctrypt + nt + + + + True + True + 1 + + + + + False + True + 4 + + + + + False + True + 1 + + + + + True + False + end + 5 + + + Deny + True + True + True + image1 + + + False + True + 0 + + + + + Accept + True + True + True + image2 + + + False + True + 1 + + + + + False + True + end + 2 + + + + + + + True + False + True + + + True + False + Users and groups + + + + + + + + + + + + + + + + diff --git a/ubl-settings-usergroups-group-creation.glade b/ubl-settings-usergroups-group-creation.glade new file mode 100644 index 0000000..8b5f35c --- /dev/null +++ b/ubl-settings-usergroups-group-creation.glade @@ -0,0 +1,271 @@ + + + + + + False + False + True + 450 + com.ublinux.ubl-settings-usergroups + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 10 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + UID: + 0 + + + False + True + 0 + + + + + Automatically + True + True + False + True + + + False + True + 2 + + + + + True + True + 1001 + number + + + True + True + 4 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Login: + 0 + + + False + True + 0 + + + + + True + True + login + + + True + True + 1 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Main group: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image1 + + + + False + True + 3 + + + + + False + True + 4 + + + + + False + True + 0 + + + + + True + False + 30 + True + + + Cancel + True + True + True + image4 + + + + True + True + 0 + + + + + Save + True + True + True + image5 + + + + True + True + 1 + + + + + False + True + end + 1 + + + + + + + True + False + + + True + False + Users and groups + + + + + + + + + + + + + + + + + + + + + + True + False + avatar-default-symbolic + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + diff --git a/ubl-settings-usergroups-system.glade b/ubl-settings-usergroups-system.glade new file mode 100644 index 0000000..9936330 --- /dev/null +++ b/ubl-settings-usergroups-system.glade @@ -0,0 +1,211 @@ + + + + + + True + False + gtk-missing-image + + + True + False + gtk-missing-image + + + + + 800 + 600 + False + False + com.ublinux.ubl-settings-usergroups + + + True + False + 5 + 5 + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + True + True + image1 + + + + False + True + 0 + + + + + True + True + True + image2 + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + True + + + True + True + liststore2 + + + + + + Blocked + + + + + UID + + + + + Login + + + + + Username + + + + + Primary group + + + + + Additional groups + + + + + Home directory + + + + + + + True + False + Users + + + False + + + + + True + True + liststore1 + + + + + + UID + + + + + + + + Group + + + + + + + + Group users + + + + + + + + 1 + + + + + True + False + Groups + + + 1 + False + + + + + True + True + 1 + + + + + + + True + False + True + + + True + False + Users and groups + + + + + + + + + diff --git a/ubl-settings-usergroups-user.glade b/ubl-settings-usergroups-user.glade index 8719198..566a9f3 100644 --- a/ubl-settings-usergroups-user.glade +++ b/ubl-settings-usergroups-user.glade @@ -2,11 +2,27 @@ + + + True + False + avatar-default-symbolic + True False emblem-ok-symbolic + + True + False + document-edit-symbolic + + + True + False + gtk-missing-image + True False @@ -54,6 +70,20 @@ 0 + + + System + True + True + False + True + + + False + True + 1 + + Automatically @@ -65,7 +95,21 @@ False True - 1 + 2 + + + + + Unique + True + True + False + True + + + False + True + 3 @@ -78,7 +122,7 @@ True True - 2 + 4 @@ -236,6 +280,20 @@ 0 + + + Own groups + True + True + False + True + + + False + True + 1 + + True @@ -244,20 +302,39 @@ True True - 1 + 2 - Additional groups True True True + image1 + False True - 2 + 3 + + + + + True + True + True + image3 + + + + False + True + 4 @@ -273,10 +350,10 @@ False 5 - + True False - Password hash algorythm: + User shell: 0 @@ -286,21 +363,14 @@ - + True False - 0 - - sha256 - AIX md5 - md5 (apache variant) - md5 - True True - 1 + 2 @@ -310,6 +380,72 @@ 5 + + + True + False + 5 + + + True + False + Home directory: + 0 + + + False + True + 0 + + + + + Create + True + True + False + True + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image2 + + + + False + True + 3 + + + + + False + True + 6 + + Sync with SAMBA user @@ -321,7 +457,7 @@ False True - 6 + 8 @@ -357,7 +493,7 @@ False True - 7 + 9 @@ -371,47 +507,58 @@ True False - 30 - True - - Cancel + True - True - True - image7 - + False + 5 + True + + + Cancel + True + True + True + image7 + + + + False + True + 0 + + + + + Save + True + True + True + image10 + + + + False + True + 1 + + - True + False True + end 0 - - - Save - True - True - True - image10 - - - - True - True - 1 - - False True - end 1 @@ -443,6 +590,8 @@ + + diff --git a/ubl-settings-usergroups.glade b/ubl-settings-usergroups.glade index 1645544..b05fbee 100644 --- a/ubl-settings-usergroups.glade +++ b/ubl-settings-usergroups.glade @@ -204,16 +204,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + + + + + - - + + + + + + + + @@ -221,6 +233,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False value-increase-symbolic + + True + False + value-increase-symbolic + + + True + False + value-increase-symbolic + + + True + False + value-increase-symbolic + + + True + False + value-increase-symbolic + True False @@ -236,6 +268,246 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False document-edit-symbolic + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + 5 + Default user groups: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image4 + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + 5 + Default user name (if there's no another): + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 1 + + + + + User with ID 1000 is administrator + True + True + False + True + + + False + True + 2 + + + + + True + False + 5 + + + True + False + 5 + Default user password: + 0 + + + False + True + 0 + + + + + True + True + 30 + False + + password + + + False + True + 1 + + + + + True + True + end + 30 + False + + password + + + False + True + end + 2 + + + + + True + False + Root user password: + + + False + True + end + 3 + + + + + False + True + 3 + + + + + True + False + 5 + + + True + False + 5 + Password hash algorythm: + 0 + + + False + True + 0 + + + + + True + False + 0 + + md5 + yescrypt + ghost-yescrypt + scrypt + bf + bcrypt + bcrypt-a + sha512crypt + sha256crypt + sunmd5 + md5crypt + bsdicrypt + desctrypt + nt + + + + True + True + 1 + + + + + False + True + 4 + + + + + + + + + + + True False @@ -640,7 +912,6 @@ translated and supported by community. 5 True True - vertical 5 @@ -649,48 +920,14 @@ translated and supported by community. vertical 5 - + True - False - 5 - - - True - False - 5 - Default user groups: - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - True - True - True - image4 - - - False - True - 2 - - + True + True + image12 + False @@ -699,35 +936,14 @@ translated and supported by community. - + True - False - 5 - - - True - False - 5 - Default user name (if there's no another): - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - + True + True + image11 + False @@ -736,12 +952,14 @@ translated and supported by community. - - User with ID 1000 is administrator + True True - False - True + True + image10 + False @@ -750,69 +968,14 @@ translated and supported by community. - + True - False - 5 - - - True - False - 5 - Default user password: - 0 - - - False - True - 0 - - - - - True - True - 30 - False - - password - - - False - True - 1 - - - - - True - True - end - 30 - False - - password - - - False - True - end - 2 - - - - - True - False - Root user password: - - - False - True - end - 3 - - + True + True + image1 + False @@ -821,42 +984,14 @@ translated and supported by community. - + True - False - 5 - - - True - False - 5 - Password hash algorythm: - 0 - - - False - True - 0 - - - - - True - False - 0 - - sha256 - AIX md5 - md5 (apache variant) - md5 - - - - True - True - 1 - - + True + True + image2 + False @@ -864,6 +999,38 @@ translated and supported by community. 4 + + + True + True + True + image3 + + + + False + True + 5 + + + + + True + True + True + image13 + + + + False + True + 6 + + False @@ -872,138 +1039,222 @@ translated and supported by community. - + True - False - 5 + True - + True - True - external - in + False + 5 + 5 + 5 + 5 + 5 - + True True - UserList - - - + external + in - - UID + + True + True + UserList + 0 + + + - - - 0 - + + Block + - - - - - Login - - - 2 - + + UID + + + + 0 + + + - - - - - Password - - - 3 - + + Login + + + + 5 + + + + + + + User name + + + + 4 + + + - - - - - User name - - - 5 - + + Main group + + + + + + + + Additional groups + + + + + + + + Additional parameters + + + + + + + + Password status + + + True + True + 1 + + + + + True + False + Users + - True - True - 0 + False True False - vertical + 5 + 5 + 5 + 5 5 - + True True - True - image1 - + external + in + + + True + True + UserList + 0 + + + + + + GID + + + + 0 + + + + + + + Group name + + + + 2 + + + + + + + Group users + + + + 3 + + + + + + + Additional parameters + + + + 5 + + + + + + + Password status + + + + + + + - False + True True 0 - - - True - True - True - image2 - - - - False - True - 1 - - - - - True - True - True - image3 - - - - False - True - 2 - - - False - True 1 + + + True + False + Groups + + + 1 + False + + True @@ -1197,12 +1448,4 @@ translated and supported by community. - - - - - - - - -- 2.35.1 From ba1f25ddfc57e040e6e68a6fa0a6a43044e9998a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 29 Nov 2023 09:15:53 +0600 Subject: [PATCH 2/8] Makefile revert --- Makefile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ecee835..120e355 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,10 @@ MAKEFILE_PATH := $(dir $(MAKEFILE_FILEPATH)) CMAKE_COMMAND = cmake CMAKE_SOURCE_DIR = $(MAKEFILE_PATH)source CMAKE_BUILD_DIR = $(MAKEFILE_PATH)compile -DEPENDS = /usr/bin/cmake +DEPENDS = /bin/cmake PREFIX ?= /usr/local PKGNAME = $(MAKEFILE_DIR) FILE_VER = source/${PKGNAME}.h -PKGIDENT = $(subst /,-,$(subst /usr,,${PREFIX})) default_target: all @@ -90,7 +89,7 @@ uninstall: @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}" @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop" @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg" - @$(RM) "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy" + @$(RM) "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ @@ -113,12 +112,12 @@ install: check uninstall rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ done @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.policy" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" - @install -Dm644 "com.ublinux.${PKGNAME}.policy" "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy" - @sed -e '\|annotate key=|s|/usr/bin|${PREFIX}/bin|' -e '/action id=/s/\.run/${PKGIDENT}\.run/' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" + @sed -e 's+/usr/bin+${PREFIX}/bin+g' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ @@ -141,7 +140,7 @@ help: echo "... init"; \ echo "... debug"; \ echo "... prepare"; \ - echo "... build"; \ + echo "... compile"; \ echo "... install"; \ echo "... uninstall"; \ echo "... clean" \ No newline at end of file -- 2.35.1 From e82f3e5f2a734e1a73f2c0ce9a7152f7dac99a64 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 29 Nov 2023 09:19:22 +0600 Subject: [PATCH 3/8] gitignore revert --- .gitignore | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.gitignore b/.gitignore index d82dd62..1d74e21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1 @@ .vscode/ -ubl-settings-usergroups -*~ -build/ -compile/ -*# -terminal-commands/ -source/ubl-cmake.h -vgcore* -.BUILD.md -.updatebuild.sh -.install.sh \ No newline at end of file -- 2.35.1 From 90adeb3bca29edb6f265c67a93f4c7a87db8235a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 29 Nov 2023 09:21:06 +0600 Subject: [PATCH 4/8] gitignore revert --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 1d74e21..3a308bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,9 @@ .vscode/ +ubl-settings-usergroups +*~ +build/ +compile/ +*# +terminal-commands/ +source/ubl-cmake.h +vgcore* \ No newline at end of file -- 2.35.1 From c6ed130169c98b6c0ecb56db52da60ae1bc0e439 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 6 Dec 2023 17:59:06 +0600 Subject: [PATCH 5/8] Interface reworking process --- .gitignore | 4 +- Makefile | 38 +- gresource.xml | 4 + ...-settings-usergroups.calendar-symbolic.svg | 47 + ...blinux.ubl-settings-usergroups.checked.svg | 0 ...-settings-usergroups.decrease-symbolic.svg | 40 + ....ubl-settings-usergroups.edit-symbolic.svg | 4 + ...ubl-settings-usergroups.group-symbolic.svg | 47 + ...-settings-usergroups.increase-symbolic.svg | 40 + ...s-usergroups.profile-settings-symbolic.svg | 53 + ...l-settings-usergroups.profile-symbolic.svg | 49 + ...-settings-usergroups.settings-symbolic.svg | 1 + ....ubl-settings-usergroups.sync-symbolic.svg | 1 + ...ubl-settings-usergroups.trash-symbolic.svg | 1 + ....ubl-settings-usergroups.view-symbolic.svg | 1 + ...blinux.ubl-settings-usergroups.warning.svg | 0 ....ubl-settings-usergroups.zoom-symbolic.svg | 160 ++ source/CMakeLists.txt | 18 +- source/ubl-settings-usergroups.c | 450 +-- source/ubl-settings-usergroups.h | 201 +- source/ubl-strings.h | 33 - source/ubl-utils.c | 2488 ----------------- source/ubl-utils.h | 424 --- ...tings-usergroups-additional-settings.glade | 26 +- ubl-settings-usergroups-group-creation.glade | 208 +- ubl-settings-usergroups-group.glade | 402 +-- ubl-settings-usergroups-password.glade | 310 ++ ubl-settings-usergroups-user.glade | 1390 ++++++--- ubl-settings-usergroups.glade | 1420 ++-------- 29 files changed, 2591 insertions(+), 5269 deletions(-) create mode 100644 icons/com.ublinux.ubl-settings-usergroups.calendar-symbolic.svg rename com.ublinux.ubl-settings-usergroups.checked.svg => icons/com.ublinux.ubl-settings-usergroups.checked.svg (100%) create mode 100644 icons/com.ublinux.ubl-settings-usergroups.decrease-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.edit-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.group-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.increase-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.profile-settings-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.profile-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.settings-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.sync-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.trash-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.view-symbolic.svg rename com.ublinux.ubl-settings-usergroups.warning.svg => icons/com.ublinux.ubl-settings-usergroups.warning.svg (100%) create mode 100644 icons/com.ublinux.ubl-settings-usergroups.zoom-symbolic.svg delete mode 100644 source/ubl-utils.c delete mode 100644 source/ubl-utils.h create mode 100644 ubl-settings-usergroups-password.glade diff --git a/.gitignore b/.gitignore index 3a308bb..90cb1f3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ compile/ *# terminal-commands/ source/ubl-cmake.h -vgcore* \ No newline at end of file +vgcore* +.install.sh +ubl-settings-generator \ No newline at end of file diff --git a/Makefile b/Makefile index 120e355..739bf18 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ DEPENDS = /bin/cmake PREFIX ?= /usr/local PKGNAME = $(MAKEFILE_DIR) FILE_VER = source/${PKGNAME}.h +PKGIDENT=$(subst /,-,${PREFIX}) default_target: all @@ -23,6 +24,11 @@ init: @echo "Initialize ..."; \ if [ -d ".git" ]; then \ LATEST_TAG=$$(git describe --abbrev=0 --tags | sed 's/^v//'); \ + if [ -z "$${LATEST_TAG}" ]; \ + then \ + LATEST_TAG=$$"0.0"; \ + echo "$${LATEST_TAG} is empty"; \ + fi; \ else \ LATEST_TAG="Development"; \ fi; \ @@ -74,7 +80,7 @@ uninstall: @for FILE_PO in $(wildcard *.po); do \ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ - PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ + PATH_FILE_MO="${DESTDIR}/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ $(RM) "$${PATH_FILE_MO}"; \ done @for SIZE in 16x16 32x32 48x48 scalable; do \ @@ -89,7 +95,7 @@ uninstall: @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}" @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop" @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg" - @$(RM) "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy" + @$(RM) "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ @@ -101,9 +107,9 @@ install: check uninstall @echo "Install ..." @for FILE_PO in $(wildcard *.po); do \ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ - install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \ + install -dm755 "${DESTDIR}/usr/share/locale/$${LANG}/LC_MESSAGES"; \ FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ - PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ + PATH_FILE_MO="${DESTDIR}/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ echo "$${FILE_PO}"; \ msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \ done @@ -112,16 +118,28 @@ install: check uninstall rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ done @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" - @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.policy" + @cp ./com.ublinux.${PKGNAME}.policy ./compile/com.ublinux.${PKGNAME}${PKGIDENT}.policy + @sed -e 's+/usr/bin+${PREFIX}/bin+' -e 's+.run+${PKGIDENT}.run+g' ./compile/com.ublinux.${PKGNAME}${PKGIDENT}.policy -i @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" - @sed -e 's+/usr/bin+${PREFIX}/bin+g' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.checked.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.warning.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.increase-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.profile-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.settings-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.sync-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.trash-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.view-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.edit-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.group-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.zoom-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.calendar-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.profile-settings-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy" @if [ -z ${DESTDIR} ]; then \ - [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ + [ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ - [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \ + [ -d "${DESTDIR}$/usr/share/applications" ] && touch "${DESTDIR}/usr/share/applications" &>/dev/null || true; \ fi @echo "Install: OK" diff --git a/gresource.xml b/gresource.xml index 09b2fec..081a63f 100644 --- a/gresource.xml +++ b/gresource.xml @@ -2,8 +2,12 @@ ubl-settings-usergroups.glade + ubl-settings-usergroups-group-creation.glade + ubl-settings-usergroups-additional-settings.glade + ubl-settings-usergroups-password.glade ubl-settings-usergroups-group.glade ubl-settings-usergroups-user.glade + ubl-settings-usergroups-system.glade ubl-settings-usergroups.css diff --git a/icons/com.ublinux.ubl-settings-usergroups.calendar-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.calendar-symbolic.svg new file mode 100644 index 0000000..78715dc --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.calendar-symbolic.svg @@ -0,0 +1,47 @@ + + + + + + + + + + diff --git a/com.ublinux.ubl-settings-usergroups.checked.svg b/icons/com.ublinux.ubl-settings-usergroups.checked.svg similarity index 100% rename from com.ublinux.ubl-settings-usergroups.checked.svg rename to icons/com.ublinux.ubl-settings-usergroups.checked.svg diff --git a/icons/com.ublinux.ubl-settings-usergroups.decrease-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.decrease-symbolic.svg new file mode 100644 index 0000000..1413e10 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.decrease-symbolic.svg @@ -0,0 +1,40 @@ + + + + + + diff --git a/icons/com.ublinux.ubl-settings-usergroups.edit-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.edit-symbolic.svg new file mode 100644 index 0000000..baba3f9 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.edit-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/icons/com.ublinux.ubl-settings-usergroups.group-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.group-symbolic.svg new file mode 100644 index 0000000..7cd4139 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.group-symbolic.svg @@ -0,0 +1,47 @@ + + + + + + + + + + diff --git a/icons/com.ublinux.ubl-settings-usergroups.increase-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.increase-symbolic.svg new file mode 100644 index 0000000..800b264 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.increase-symbolic.svg @@ -0,0 +1,40 @@ + + + + + + diff --git a/icons/com.ublinux.ubl-settings-usergroups.profile-settings-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.profile-settings-symbolic.svg new file mode 100644 index 0000000..1879618 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.profile-settings-symbolic.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + diff --git a/icons/com.ublinux.ubl-settings-usergroups.profile-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.profile-symbolic.svg new file mode 100644 index 0000000..4bc7b0c --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.profile-symbolic.svg @@ -0,0 +1,49 @@ + + + + + + + + + + diff --git a/icons/com.ublinux.ubl-settings-usergroups.settings-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.settings-symbolic.svg new file mode 100644 index 0000000..67d3487 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.settings-symbolic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/com.ublinux.ubl-settings-usergroups.sync-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.sync-symbolic.svg new file mode 100644 index 0000000..13651dd --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.sync-symbolic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/com.ublinux.ubl-settings-usergroups.trash-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.trash-symbolic.svg new file mode 100644 index 0000000..03ca715 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.trash-symbolic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/com.ublinux.ubl-settings-usergroups.view-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.view-symbolic.svg new file mode 100644 index 0000000..8e6a1ed --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.view-symbolic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/com.ublinux.ubl-settings-usergroups.warning.svg b/icons/com.ublinux.ubl-settings-usergroups.warning.svg similarity index 100% rename from com.ublinux.ubl-settings-usergroups.warning.svg rename to icons/com.ublinux.ubl-settings-usergroups.warning.svg diff --git a/icons/com.ublinux.ubl-settings-usergroups.zoom-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.zoom-symbolic.svg new file mode 100644 index 0000000..c5011ec --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.zoom-symbolic.svg @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 56e4492..33d015f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -8,10 +8,10 @@ include_directories(${GTK_INCLUDE_DIRS}) link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) -#pkg_check_modules(VTE291 REQUIRED vte-2.91) -#include_directories(${VTE291_INCLUDE_DIRS}) -#link_directories(${VTE291_LIBRARY_DIRS}) -#add_definitions(${VTE291_CFLAGS_OTHER}) +pkg_check_modules(VTE291 REQUIRED vte-2.91) +include_directories(${VTE291_INCLUDE_DIRS}) +link_directories(${VTE291_LIBRARY_DIRS}) +add_definitions(${VTE291_CFLAGS_OTHER}) find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) @@ -36,6 +36,10 @@ add_custom_target(GLADE ubl-settings-usergroups.glade) set(DEPENDFILES ../ubl-settings-usergroups.glade + ../ubl-settings-usergroups-additional-settings.glade + ../ubl-settings-usergroups-group-creation.glade + ../ubl-settings-usergroups-password.glade + ../ubl-settings-usergroups-system.glade ../ubl-settings-usergroups-user.glade ../ubl-settings-usergroups-group.glade ../gresource.xml @@ -75,15 +79,15 @@ set(SOURCE_FILES ubl-settings-usergroups.c ubl-settings-usergroups.h ubl-strings.h - ubl-utils.h - ubl-utils.c ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h ) set(LIBRARIES ${GTK_LIBRARIES} ${WEBKIT_LIBRARIES} -# ${VTE291_LIBRARIES} + ${VTE291_LIBRARIES} + ubl-utils + ublsettings-ui pthread) diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index e38b415..c0f627e 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -2,245 +2,102 @@ config main_config; -//signal emmit handlers - no header initialization - -/**on_close_subwindow(GtkWidget *self) - * [EN] - * Closes window in which [self] is contained. - * [RU] - * Закрывает окно, в котором расположен виджет [self]. -*/ -void on_close_subwindow(GtkWidget *self){ - gtk_widget_destroy(gtk_widget_get_toplevel(self)); -} - -/**yon_open_browser(GtkWidget *self, char *link) - * [EN] - * Opens browser with [link] link. - * [RU] - * Открывает браузер с [link] ссылкой. -*/ -void yon_open_browser(GtkWidget *self, char *link){ - yon_ubl_browser_window_open(link,TITLE_LABEL); -} - -/**on_open_documentation_confirmation(GtkWidget *self, char *link) - * [EN] - * Opens confirmation window for [link] link. - * [RU] - * Открывает окно подтверждение перехода по ссылке [link]. -*/ -void on_open_documentation_confirmation(GtkWidget *self, char *link){ - if (main_config.always_open_documentation==0){ - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - documentation_confirmation_window *widgets = malloc(sizeof(documentation_confirmation_window)); - widgets->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); - widgets->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); - widgets->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); - widgets->HatText = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); - widgets->HeaderText = yon_gtk_builder_get_widget(builder,"helpHeader"); - widgets->InfoText = yon_gtk_builder_get_widget(builder,"helpText"); - widgets->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); - gtk_label_set_text(GTK_LABEL(widgets->HatText),TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->HeaderText),HELP_TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->InfoText),HELP_INFO_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->AcceptButton),OPEN_HELP_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->AlwaysOpenCheck),HELP_ALWAYS_OPEN_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->CloseButton),CANCEL_LABEL); - gtk_widget_show_all(widgets->Window); - g_signal_connect(G_OBJECT(widgets->CloseButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); - g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - - - } else { - yon_open_browser(self,link); - } -} - -/**on_link(GtkWidget *self, char* uri, gpointer user_data) - * [EN] - * Signal for hadnling AboutDialog links. - * Connect to "activate-link" signal. - * [self] is AboutDialog window; - * [uri] is activated link; - * [user_data] is pointer for user data, hasn't used in standard handler; - * [RU] - * Функция для обработки сигнала нажатия на ссылку окна AboutDialog. - * Присоединять к сигналу "activate-link". - * [self] - окно AboutDialog; - * [uri] - ссылка, по которой совершается переход; - * [user_data] - указатель на любые другие данные, не используется в стандартном обработчике; -*/ -void on_link(GtkWidget *self, char* uri, gpointer user_data){ - gtk_widget_destroy(self); - on_open_documentation_confirmation(self,uri); -} - -/**on_about() - * [EN] - * Function for setting up and showing AboutDialog. - * Connect it to "activate" signal of Documentation MenuItem. - * [RU] - * Функиця для настройки и показа окна AboutDialog. - * Присоединять к сигналу "activate" кнопки справки типа MenuItem. -*/ -void on_about(){ - GtkBuilder *builder=gtk_builder_new_from_resource(glade_path); - GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow"); - GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic"); - GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); - gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); - gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(window),PROJECT_HOME_LABEL); - gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); - g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); - gtk_widget_set_visible(hideButtonBox,0); - gtk_widget_destroy(hideButtonBox); - gtk_widget_show(window); -} - -void on_toggle_button_switched(GtkToggleButton *self, GtkWidget *widget){ - gtk_widget_set_sensitive(widget,!gtk_toggle_button_get_active(self)); - -} - //functions -void on_user_accept(GtkWidget *self, dictionary * dict){ - user_window *window = yon_dictionary_get_data(dict->first,user_window*); - main_window *widgets = yon_dictionary_get_data(dict->first->next,main_window*); - GtkTreeIter iter; - gtk_list_store_append(main_config.usersListStore,&iter); - int auto_id = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDAutoCheck)); - int system_id = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDSystemCheck)); - int unique_id = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDUniqueCheck)); - int user_id = atoi(gtk_entry_get_text(GTK_ENTRY(window->UserUIDEntry))); - const char *user_name = gtk_entry_get_text(GTK_ENTRY(window->userUserNameEntry)); - const char *login = gtk_entry_get_text(GTK_ENTRY(window->userLoginEntry)); - int default_password = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userPasswordDefaultCheck)); - const char *password = gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry)); - int own_group = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userPasswordDefaultCheck)); - const char *groups = gtk_entry_get_text(GTK_ENTRY(window->userGroupsEntry)); - const char *user_shell = NULL; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->userShellCombo))>=0) - user_shell = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->userShellCombo)); - int home_dir_create = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userPasswordDefaultCheck)); - const char *home_dir = gtk_entry_get_text(GTK_ENTRY(window->userHomeFolderEntry)); - int samba = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userPasswordDefaultCheck)); - const char *extra_options = gtk_entry_get_text(GTK_ENTRY(window->userExtraOptionsEntry)); - gtk_list_store_set(main_config.usersListStore,&iter,0,user_id,1,auto_id,2,unique_id,3,system_id,4,user_name,5,login,6,password,7,default_password,8,groups,9,own_group,10,user_shell,11,home_dir,12,home_dir_create,-1); - // widgets->MainUserTree; - on_close_subwindow(self); -} - void yon_load_proceed(char *command){ - if (yon_config_load_register(command)) - yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - else - yon_ubl_status_box_render(LOAD_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } -void on_def_groups_accept(GtkWidget *self, dictionary *windowes){ - char *groups_string = ""; - main_window *widgets = yon_dictionary_get_data(windowes->first->next,main_window*); - groups_window *window = yon_dictionary_get_data(windowes->first,groups_window*); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsAdmCheck))==1) groups_string = yon_char_append(groups_string,"adm,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsAudioCheck))==1) groups_string = yon_char_append(groups_string,"audio,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsAutologinCheck))==1) groups_string = yon_char_append(groups_string,"autologin,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsAvahiCheck))==1) groups_string = yon_char_append(groups_string,"avahi,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsBinCheck))==1) groups_string = yon_char_append(groups_string,"bin,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsBrlapiCheck))==1) groups_string = yon_char_append(groups_string,"brlapi,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsBrittyCheck))==1) groups_string = yon_char_append(groups_string,"britty,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsBumblbeeCheck))==1) groups_string = yon_char_append(groups_string,"bumblbee,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsChronyCheck))==1) groups_string = yon_char_append(groups_string,"chrony,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsClamavCheck))==1) groups_string = yon_char_append(groups_string,"clamav,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsCockpitWsCheck))==1) groups_string = yon_char_append(groups_string,"cockpit-ws,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsCockpitWsinstanceCheck))==1) groups_string = yon_char_append(groups_string,"cockpit-wsinstance,"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupsColordCheck))==1) groups_string = yon_char_append(groups_string,"colord,"); - if (strcmp(groups_string,"")!=0) groups_string[strlen(groups_string)-1]='\0'; - gtk_entry_buffer_set_text(gtk_entry_get_buffer(GTK_ENTRY(widgets->MainDefaultGroupsEntry)),groups_string,strlen(groups_string)); - on_close_subwindow(self); +void yon_save_proceed(char *section,YON_CONFIG_TYPE type){ } -void on_groups_open(GtkWidget *self, main_window *widgets){ +additional_config_window *yon_additional_config_window_new(){ + additional_config_window *window = malloc(sizeof(additional_config_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_additional); +window->Window=yon_gtk_builder_get_widget(builder,"Window"); +window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); +window->DefaultUserNameEntry=yon_gtk_builder_get_widget(builder,"DefaultUserNameEntry"); +window->DefaultUserAdministratorCheck=yon_gtk_builder_get_widget(builder,"DefaultUserAdministratorCheck"); +window->DefaultPasswordCombo=yon_gtk_builder_get_widget(builder,"DefaultPasswordCombo"); +window->DefaultPasswordEntry=yon_gtk_builder_get_widget(builder,"DefaultPasswordEntry"); +window->RootPasswordCombo=yon_gtk_builder_get_widget(builder,"RootPasswordCombo"); +window->RootPasswordEntry=yon_gtk_builder_get_widget(builder,"RootPasswordEntry"); +window->PasswordHashCombo=yon_gtk_builder_get_widget(builder,"PasswordHashCombo"); +window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); +window->AcceptButton=yon_gtk_builder_get_widget(builder,"AcceptButton"); } -void on_def_groups_open(GtkWidget *self, main_window *widgets){ - GtkBuilder *builder = gtk_builder_new_from_resource(glade_groups_path); +groups_window *yon_groups_window_new(){ groups_window *window = malloc(sizeof(groups_window)); - window->Window = yon_gtk_builder_get_widget(builder,"GroupsWindow"); - window->GroupsCancelButton = yon_gtk_builder_get_widget(builder,"GroupsCancelButton"); - window->GroupsOkButton = yon_gtk_builder_get_widget(builder,"GroupsOkButton"); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_groups); + window->GroupsWindow=yon_gtk_builder_get_widget(builder,"GroupsWindow"); + window->GroupsTree=yon_gtk_builder_get_widget(builder,"GroupsTree"); + window->GroupsCancelButton=yon_gtk_builder_get_widget(builder,"GroupsCancelButton"); + window->GroupsOkButton=yon_gtk_builder_get_widget(builder,"GroupsOkButton"); + + g_signal_connect(G_OBJECT(window->GroupsCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + return window; +} - window->GroupsAdmCheck = yon_gtk_builder_get_widget(builder,"groupsAdmGroupCheck"); - window->GroupsAudioCheck = yon_gtk_builder_get_widget(builder,"groupsAudioGroupCheck"); - window->GroupsAutologinCheck = yon_gtk_builder_get_widget(builder,"groupsAutologinGroupCheck"); - window->GroupsAvahiCheck = yon_gtk_builder_get_widget(builder,"groupsAvahiGroupCheck"); - window->GroupsBinCheck = yon_gtk_builder_get_widget(builder,"groupsBinGroupCheck"); - window->GroupsBrlapiCheck = yon_gtk_builder_get_widget(builder,"groupsBrlapiGroupCheck"); - window->GroupsBrittyCheck = yon_gtk_builder_get_widget(builder,"groupsBrittyGroupCheck"); - window->GroupsBumblbeeCheck = yon_gtk_builder_get_widget(builder,"groupsBumblbeeGroupCheck"); - window->GroupsChronyCheck = yon_gtk_builder_get_widget(builder,"groupsChronyGroupCheck"); - window->GroupsClamavCheck = yon_gtk_builder_get_widget(builder,"groupsClamavGroupCheck"); - window->GroupsCockpitWsCheck = yon_gtk_builder_get_widget(builder,"groupsCockpitWsGroupCheck"); - window->GroupsCockpitWsinstanceCheck = yon_gtk_builder_get_widget(builder,"groupsCockpitWsinstanceGroupCheck"); - window->GroupsColordCheck = yon_gtk_builder_get_widget(builder,"groupsColordGroupCheck"); - dictionary *windgets=NULL; - yon_dictionary_add_or_create_if_exists_with_data(windgets,"window",window); - yon_dictionary_add_or_create_if_exists_with_data(windgets,"widgets",widgets); - g_signal_connect(G_OBJECT(window->GroupsCancelButton),"clicked",G_CALLBACK(on_close_subwindow),window); - g_signal_connect(G_OBJECT(window->GroupsOkButton),"clicked",G_CALLBACK(on_def_groups_accept),windgets); - gtk_widget_show(window->Window); +void on_standard_groups_open(GtkWidget *self, main_window *widgets){ + groups_window *window = yon_groups_window_new(); + g_signal_connect(G_OBJECT(window->GroupsOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_window_set_transient_for(GTK_WINDOW(window->GroupsWindow),GTK_WINDOW(widgets->Window)); + gtk_widget_show(window->GroupsWindow); } -void on_user_add(GtkWidget *self, main_window *widgets){ - GtkBuilder *builder = gtk_builder_new_from_resource(glade_user_path); +user_window *yon_user_window_new(){ user_window *window = malloc(sizeof(user_window)); - window->Window = yon_gtk_builder_get_widget(builder,"CreateUserWindow"); - window->UserAdditionalGroupsButton = yon_gtk_builder_get_widget(builder,"UserAdditionalGroupsButton"); - window->UserCancelButton = yon_gtk_builder_get_widget(builder,"UserCancelButton"); - window->UserOkButton = yon_gtk_builder_get_widget(builder,"UserOkButton"); - - window->userUIDSystemCheck = yon_gtk_builder_get_widget(builder,"userUIDSystemCheck"); - window->userUIDAutoCheck = yon_gtk_builder_get_widget(builder,"userUIDAutoCheck"); - window->userUIDUniqueCheck = yon_gtk_builder_get_widget(builder,"userUIDUniqueCheck"); - window->UserUIDEntry = yon_gtk_builder_get_widget(builder,"userUIDEntry"); - - window->userUserNameEntry = yon_gtk_builder_get_widget(builder,"userUserNameEntry"); - - window->userLoginEntry = yon_gtk_builder_get_widget(builder,"userLoginEntry"); - - window->userPasswordDefaultCheck = yon_gtk_builder_get_widget(builder,"userPasswordDefaultCheck"); - window->userPasswordEntry = yon_gtk_builder_get_widget(builder,"userPasswordEntry"); - - window->userGroupsCheck = yon_gtk_builder_get_widget(builder,"userGroupsCheck"); - window->userGroupsEntry = yon_gtk_builder_get_widget(builder,"userGroupsEntry"); - window->UserAdditionalGroupsButton = yon_gtk_builder_get_widget(builder,"UserAdditionalGroupsButton"); - window->UserAdditionalGroupsMultipleButton = yon_gtk_builder_get_widget(builder,"UserAdditionalGroupsMultipleButton"); - - window->userShellCombo = yon_gtk_builder_get_widget(builder,"userShellCombo"); - - window->userCreateHomeFolderCheck = yon_gtk_builder_get_widget(builder,"userCreateHomeFolderCheck"); - window->userHomeFolderEntry = yon_gtk_builder_get_widget(builder,"userHomeFolderEntry"); - window->userHomeFolderButton = yon_gtk_builder_get_widget(builder,"userHomeFolderButton"); - - window->userSyncSAMBACheck = yon_gtk_builder_get_widget(builder,"userSyncSAMBACheck"); - window->userExtraOptionsEntry = yon_gtk_builder_get_widget(builder,"userExtraOptionsEntry"); - dictionary *dict = NULL; - yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window) - yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_user); + window->CreateUserWindow=yon_gtk_builder_get_widget(builder,"CreateUserWindow"); + window->userUIDAutoCheck=yon_gtk_builder_get_widget(builder,"userUIDAutoCheck"); + window->userUIDEntry=yon_gtk_builder_get_widget(builder,"userUIDEntry"); + window->userLoginEntry=yon_gtk_builder_get_widget(builder,"userLoginEntry"); + window->userPasswordCombo=yon_gtk_builder_get_widget(builder,"userPasswordCombo"); + window->userPasswordEntry=yon_gtk_builder_get_widget(builder,"userPasswordEntry"); + window->userPasswordButton=yon_gtk_builder_get_widget(builder,"userPasswordButton"); + window->userUserNameEntry=yon_gtk_builder_get_widget(builder,"userUserNameEntry"); + window->userGroupsCheck=yon_gtk_builder_get_widget(builder,"userGroupsCheck"); + window->userGroupsEntry=yon_gtk_builder_get_widget(builder,"userGroupsEntry"); + window->UserGroupsButton=yon_gtk_builder_get_widget(builder,"UserGroupsButton"); + window->userCreateHomeFolderCheck=yon_gtk_builder_get_widget(builder,"userCreateHomeFolderCheck"); + window->userHomeFolderEntry=yon_gtk_builder_get_widget(builder,"userHomeFolderEntry"); + window->userHomeFolderButton=yon_gtk_builder_get_widget(builder,"userHomeFolderButton"); + window->userAdditionalGroupsEntry=yon_gtk_builder_get_widget(builder,"userAdditionalGroupsEntry"); + window->userAdditionalGroupsButton=yon_gtk_builder_get_widget(builder,"userAdditionalGroupsButton"); + window->userPasswordChangedEntry=yon_gtk_builder_get_widget(builder,"userPasswordChangedEntry"); + window->userPasswordExpirationEntry=yon_gtk_builder_get_widget(builder,"userPasswordExpirationEntry"); + window->userPasswordExpirationButton=yon_gtk_builder_get_widget(builder,"userPasswordExpirationButton"); + window->userPasswordChangeDelayMinimumSpin=yon_gtk_builder_get_widget(builder,"userPasswordChangeDelayMinimumSpin"); + window->userPasswordChangeDelayMaximumSpin=yon_gtk_builder_get_widget(builder,"userPasswordChangeDelayMaximumSpin"); + window->userWarningSpin=yon_gtk_builder_get_widget(builder,"userWarningSpin"); + window->userActivitySpin=yon_gtk_builder_get_widget(builder,"userActivitySpin"); + window->userForceChangeCheck=yon_gtk_builder_get_widget(builder,"userForceChangeCheck"); + window->userShellCombo=yon_gtk_builder_get_widget(builder,"userShellCombo"); + window->userShellEntry=yon_gtk_builder_get_widget(builder,"userShellEntry"); + window->userHomeCombo=yon_gtk_builder_get_widget(builder,"userHomeCombo"); + window->userHomeEntry=yon_gtk_builder_get_widget(builder,"userHomeEntry"); + window->userHomeButton=yon_gtk_builder_get_widget(builder,"userHomeButton"); + window->userCreateSystemCheck=yon_gtk_builder_get_widget(builder,"userCreateSystemCheck"); + window->userCreateUnuniqueCheck=yon_gtk_builder_get_widget(builder,"userCreateUnuniqueCheck"); + window->userDontCheckCheck=yon_gtk_builder_get_widget(builder,"userDontCheckCheck"); + window->userSyncSAMBACheck=yon_gtk_builder_get_widget(builder,"userSyncSAMBACheck"); + window->userDeactivatedCheck=yon_gtk_builder_get_widget(builder,"userDeactivatedCheck"); + window->userExtraOptionsEntry=yon_gtk_builder_get_widget(builder,"userExtraOptionsEntry"); + window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); + window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); + window->userTitleNameLabel=yon_gtk_builder_get_widget(builder,"userTitleNameLabel"); + g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + return window; +} - g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_user_accept),dict); - g_signal_connect(G_OBJECT(window->UserAdditionalGroupsButton),"clicked",G_CALLBACK(on_def_groups_open),window); +void on_user_add(GtkWidget *self, main_window *widgets){ + user_window *window = yon_user_window_new(); + g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); - - g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"clicked",G_CALLBACK(on_toggle_button_switched),window->UserUIDEntry); - g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"clicked",G_CALLBACK(on_toggle_button_switched),window->userUIDUniqueCheck); - gtk_widget_show(window->Window); + gtk_window_set_transient_for(GTK_WINDOW(window->CreateUserWindow),GTK_WINDOW(widgets->Window)); + gtk_widget_show(window->CreateUserWindow); } void on_user_edit(){ @@ -251,78 +108,52 @@ void on_user_delete(){ } +void on_def_groups_open(){ + +} + // standard functions +/**config_init() + * [EN] + * + * [RU] + * Функция инициализации всех параметров конфигурации +*/ void config_init(){ - main_config.always_open_documentation = 0; - main_config.win_height = 0; - main_config.win_width = 0; - main_config.win_pos_x = 0; - main_config.win_pos_y = 0; - main_config.socket_id = -1; - main_config.save_socket_id = -1; - main_config.load_socket_id = -1; - main_config.lock_help = 0; - main_config.lock_help = 0; - main_config.lock_load_global = 0; - main_config.lock_save_global = 0; - main_config.lock_save_local = 0; - main_config.default_groups = NULL; - main_config.default_groups_config = NULL; - main_config.default_password = NULL; - main_config.default_user_name = NULL; - main_config.is_1000_administrator=0; - main_config.hash_alg=0; - main_config.root_password=NULL; + main_config.always_open_documentation=0; + main_config.socket_id=-1; + main_config.save_socket_id=-1; + main_config.load_socket_id=-1; + main_config.lock_help=0; + main_config.lock_help=0; + main_config.lock_load_global=0; + main_config.lock_save_global=0; + main_config.lock_save_local=0; } -main_window *setup_window(){ - /* Widgets getting | Получение виджетов */ - main_window *widgets = malloc(sizeof(main_window)); +/**yon_main_window_complete(main_window *widgets) + * [EN] + * + * [RU] + * Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом. +*/ +void yon_main_window_complete(main_window *widgets){ + widgets = realloc(widgets,sizeof(main_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); - widgets->HatLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); - widgets->PlugBox = yon_gtk_builder_get_widget(builder,"plugBox"); - - widgets->HeadOverlay = yon_gtk_builder_get_widget(builder,"HeadOverlay"); - widgets->HeadImage = yon_gtk_builder_get_widget(builder,"HeadBackgroundImage"); - widgets->HeadBox = yon_gtk_builder_get_widget(builder,"HeaderBox"); - widgets->HeadTitleLabel = yon_gtk_builder_get_widget(builder,"HeaderTitleLabel"); - widgets->HeadInfoLabel = yon_gtk_builder_get_widget(builder,"HeaderInfoLabel"); - - widgets->StatusBox = yon_gtk_builder_get_widget(builder,"mainStatusBox"); - widgets->StatusIcon = yon_gtk_builder_get_widget(builder,"mainStatusIcon"); - widgets->StatusLabel = yon_gtk_builder_get_widget(builder,"mainStatusLabel"); - - widgets->SaveLabel = yon_gtk_builder_get_widget(builder,"headerSaveConfigLabel"); - widgets->SaveMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalLocalConfigurationMenuItem"); - widgets->SaveGlobalMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalConfigurationMenuItem"); - widgets->SaveLocalMenuItem = yon_gtk_builder_get_widget(builder,"SaveLocalConfigurationMenuItem"); - widgets->RightBox = yon_gtk_builder_get_widget(builder,"HeaderRightBox"); - - widgets->LoadLabel = yon_gtk_builder_get_widget(builder,"headerLoadConfigLabel"); - widgets->LoadGlobalMenuItem = yon_gtk_builder_get_widget(builder,"LoadGlobalConfigurationMenuItem"); - widgets->LoadLocalMenuItem = yon_gtk_builder_get_widget(builder,"LoadLocalConfigurationMenuItem"); - widgets->LeftBox = yon_gtk_builder_get_widget(builder,"HeaderLeftBox"); - - widgets->DocumentationMenuItem = yon_gtk_builder_get_widget(builder,"DocumentationMenuItem"); - widgets->AboutMenuItem = yon_gtk_builder_get_widget(builder,"AboutMenuItem"); - - widgets->MainAddUserButton = yon_gtk_builder_get_widget(builder,"MainAddUserButton"); - widgets->MainEditUserButton = yon_gtk_builder_get_widget(builder,"MainEditUserButton"); - widgets->MainDeleteUserButton = yon_gtk_builder_get_widget(builder,"MainDeleteUserButton"); - - widgets->MainEditGroupsButton = yon_gtk_builder_get_widget(builder,"MainEditGroupsButton"); - - widgets->MainDefaultGroupsEntry = yon_gtk_builder_get_widget(builder,"mainDefaultGroupsEntry"); - widgets->MainDefaultUserNameEntry = yon_gtk_builder_get_widget(builder,"mainDefaultUserNameEntry"); - widgets->MainDefaultUserAdministratorCheck = yon_gtk_builder_get_widget(builder,"mainDefaultUserAdministratorCheck"); - widgets->MainDefaultPasswordEntry = yon_gtk_builder_get_widget(builder,"mainDefaultPasswordEntry"); - widgets->MainRootPasswordEntry = yon_gtk_builder_get_widget(builder,"mainRootPasswordEntry"); - widgets->MainUserTree = yon_gtk_builder_get_widget(builder,"mainUserTree"); - widgets->MainPasswordHashCombo = yon_gtk_builder_get_widget(builder,"mainPasswordHashCombo"); - - main_config.usersListStore = GTK_LIST_STORE(gtk_builder_get_object(builder,"UserList")); + gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"PlugBox"),1,1,0); + widgets->button1 = yon_gtk_builder_get_widget(builder,"button1"); + widgets->button2 = yon_gtk_builder_get_widget(builder,"button2"); + widgets->button3 = yon_gtk_builder_get_widget(builder,"button3"); + widgets->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); + widgets->EditButton = yon_gtk_builder_get_widget(builder,"EditButton"); + widgets->DeleteButton = yon_gtk_builder_get_widget(builder,"DeleteButton"); + widgets->UpdateButton = yon_gtk_builder_get_widget(builder,"UpdateButton"); + widgets->UsersTree = yon_gtk_builder_get_widget(builder,"UsersTree"); + widgets->GroupsTree = yon_gtk_builder_get_widget(builder,"GroupsTree"); + + main_config.usersListStore = GTK_LIST_STORE(gtk_builder_get_object(builder,"UsersList")); + main_config.groupsListStore = GTK_LIST_STORE(gtk_builder_get_object(builder,"GroupsList")); if (main_config.lock_load_global == 1){ @@ -338,17 +169,14 @@ main_window *setup_window(){ } /* Signal connection | Присоединение сигналов */ - g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(gtk_main_quit), NULL); - g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),WIKI_LINK); - g_signal_connect(G_OBJECT(widgets->AboutMenuItem),"activate",G_CALLBACK(on_about),NULL); - g_signal_connect(G_OBJECT(widgets->MainAddUserButton),"clicked",G_CALLBACK(on_user_add),widgets); - g_signal_connect(G_OBJECT(widgets->MainEditUserButton),"clicked",G_CALLBACK(on_user_edit),NULL); - g_signal_connect(G_OBJECT(widgets->MainDeleteUserButton),"clicked",G_CALLBACK(on_user_delete),NULL); - g_signal_connect(G_OBJECT(widgets->MainEditGroupsButton),"clicked",G_CALLBACK(on_def_groups_open),widgets); + g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_user_add),widgets); + g_signal_connect(G_OBJECT(widgets->EditButton),"clicked",G_CALLBACK(on_user_edit),widgets); + g_signal_connect(G_OBJECT(widgets->DeleteButton),"clicked",G_CALLBACK(on_user_delete),widgets); + g_signal_connect(G_OBJECT(widgets->button3),"clicked",G_CALLBACK(on_standard_groups_open),widgets); + // g_signal_connect(G_OBJECT(widgets->),"clicked",G_CALLBACK(on_def_groups_open),widgets); gtk_widget_show(widgets->Window); - return widgets; } int main(int argc, char *argv[]){ @@ -370,11 +198,11 @@ int main(int argc, char *argv[]){ {"socket-id", 1, 0, 's'}, {"socket-ext-id", 1,0, 'e'}, {"socket-trd-id", 1,0, 't'}, - {"debug", 0,0, 'd'}, + {"clear-config", 0,0, 'c'}, { NULL, 0, NULL, 0 } }; for (int i=0;iHeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); - - yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); - if (getuid()!=0) - yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - else - yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); - yon_window_config_setup(GTK_WINDOW(widgets->Window)); - yon_window_config_load(config_path); - GtkCssProvider *css=gtk_css_provider_new(); - gtk_css_provider_load_from_resource(css,CssPath); - gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), - GTK_STYLE_PROVIDER(css), - -1); + yon_ubl_connect_config((_template_config*)&main_config); + yon_ubl_window_init(TITLE_LABEL,TITLE_INFO_LABEL,LocaleName,CssPath,LocaleName,version_application,WIKI_LINK); + template_main_window *widgets = yon_ubl_window_setup(); + yon_main_window_complete((main_window*)widgets); gtk_main(); } \ No newline at end of file diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index f6eae4e..2197896 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -1,6 +1,5 @@ #include #include -#include "ubl-utils.h" #include #include #include @@ -8,6 +7,8 @@ #include #include #include +#include +#include #include "../compile/ubl-cmake.h" #ifdef WEBKIT_FOUND #include @@ -19,11 +20,22 @@ #define _(String) gettext(String) #define glade_path "/com/ublinux/ui/ubl-settings-usergroups.glade" -#define glade_user_path "/com/ublinux/ui/ubl-settings-usergroups-user.glade" -#define glade_groups_path "/com/ublinux/ui/ubl-settings-usergroups-group.glade" +#define glade_path_user "/com/ublinux/ui/ubl-settings-usergroups-user.glade" +#define glade_path_groups "/com/ublinux/ui/ubl-settings-usergroups-group.glade" +#define glade_path_additional "/com/ublinux/ui/ubl-settings-usergroups-additional-settings.glade" +#define glade_path_group_creation "/com/ublinux/ui/ubl-settings-usergroups-group-creation.glade" +#define glade_path_password "/com/ublinux/ui/ubl-settings-usergroups-password.glade" +#define glade_path_system "/com/ublinux/ui/ubl-settings-usergroups-system.glade" #define banner_path "/com/ublinux/images/ubl-settings-usergroups-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-usergroups.css" -#define config_path yon_char_unite("/home/",yon_ubl_root_user_get(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) +#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) + +#define LocalePath "/usr/share/locale" +#define LocaleName "ubl-settings-usergroups" + +#define clear_config_both_command "ubconfig remove TEMP_SECTION TEMP_PATAMETER" +#define clear_config_global_command "ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER" +#define clear_config_local_command "ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER" #define yon_col(mean) yon_char_append(mean,":") @@ -35,12 +47,7 @@ string version_application; char *local; typedef struct { - int always_open_documentation; - int win_pos_x; - int win_pos_y; - int win_width; - int win_height; - +// Standard config. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_config STRUCT { int socket_id; int load_socket_id; int save_socket_id; @@ -49,23 +56,19 @@ typedef struct { int lock_save_local; int lock_save_global; int lock_load_global; - - // Custom - char *default_groups; - char *default_user_name; - char *default_password; - char *root_password; - int hash_alg; - gboolean is_1000_administrator; - struct groups_config *default_groups_config; + + int always_open_documentation; +// } Standard config. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_config STRUCT +// Type custom parameters below: GtkListStore *usersListStore; + GtkListStore *groupsListStore; } config; typedef struct { + // Standard widgets. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_main_window STRUCT { GtkWidget *Window; - GtkWidget *HatLabel; + GtkWidget *HeadLabel; GtkWidget *PlugBox; - GtkWidget *MainDefaultGroupsEntry; GtkWidget *HeadOverlay; GtkWidget *HeadImage; @@ -77,52 +80,34 @@ typedef struct { GtkWidget *StatusIcon; GtkWidget *StatusLabel; - GtkWidget *SaveLabel; GtkWidget *SaveMenuItem; GtkWidget *SaveGlobalMenuItem; GtkWidget *SaveLocalMenuItem; GtkWidget *RightBox; - GtkWidget *LoadLabel; GtkWidget *LoadGlobalMenuItem; GtkWidget *LoadLocalMenuItem; GtkWidget *LeftBox; GtkWidget *DocumentationMenuItem; GtkWidget *AboutMenuItem; - // Custom - GtkWidget *MainAddUserButton; - GtkWidget *MainEditUserButton; - GtkWidget *MainDeleteUserButton; - GtkWidget *MainEditGroupsButton; + GtkWidget *InterfaceBox; +// } Standard widgets. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_main_window STRUCT +// Type custom parameters below: + GtkWidget *button1; + GtkWidget *button2; + GtkWidget *button3; + GtkWidget *AddButton; + GtkWidget *EditButton; + GtkWidget *DeleteButton; + GtkWidget *UpdateButton; - GtkWidget *MainDefaultUserNameEntry; - GtkWidget *MainDefaultUserAdministratorCheck; - GtkWidget *MainDefaultPasswordEntry; - GtkWidget *MainRootPasswordEntry; - GtkWidget *MainPasswordHashCombo; - - GtkWidget *MainUserTree; + GtkWidget *UsersTree; + GtkWidget *GroupsTree; } main_window; -typedef struct { - gboolean adm; - gboolean audio; - gboolean autologin; - gboolean avahi; - gboolean bin; - gboolean brlapi; - gboolean britty; - gboolean bumblbee; - gboolean chrony; - gboolean clamav; - gboolean cockpit_ws; - gboolean cockpit_wsinstance; - gboolean colord; -} groups_config; - typedef struct { GtkWidget *Window; @@ -136,68 +121,66 @@ typedef struct { } documentation_confirmation_window; typedef struct { - GtkWidget *Window; - GtkWidget *GroupsCancelButton; - GtkWidget *GroupsOkButton; - - GtkWidget *GroupsAdmCheck; - GtkWidget *GroupsAudioCheck; - GtkWidget *GroupsAutologinCheck; - GtkWidget *GroupsAvahiCheck; - GtkWidget *GroupsBinCheck; - GtkWidget *GroupsBrlapiCheck; - GtkWidget *GroupsBrittyCheck; - GtkWidget *GroupsBumblbeeCheck; - GtkWidget *GroupsChronyCheck; - GtkWidget *GroupsClamavCheck; - GtkWidget *GroupsCockpitWsCheck; - GtkWidget *GroupsCockpitWsinstanceCheck; - GtkWidget *GroupsColordCheck; +GtkWidget *GroupsWindow; +GtkWidget *GroupsTree; +GtkWidget *GroupsCancelButton; +GtkWidget *GroupsOkButton; } groups_window; typedef struct { - int uid; - gboolean uid_default; - char *username; - char *login; - char *password; - gboolean password_default; - char *main_group; - struct groups_config *additional_groups; - int password_hash; - gboolean sync_SAMBA; - char *extra_options; -} user_config; +GtkWidget *CreateUserWindow; +GtkWidget *userUIDAutoCheck; +GtkWidget *userUIDEntry; +GtkWidget *userLoginEntry; +GtkWidget *userPasswordCombo; +GtkWidget *userPasswordEntry; +GtkWidget *userPasswordButton; +GtkWidget *userUserNameEntry; +GtkWidget *userGroupsCheck; +GtkWidget *userGroupsEntry; +GtkWidget *UserGroupsButton; +GtkWidget *userCreateHomeFolderCheck; +GtkWidget *userHomeFolderEntry; +GtkWidget *userHomeFolderButton; +GtkWidget *userAdditionalGroupsEntry; +GtkWidget *userAdditionalGroupsButton; +GtkWidget *userPasswordChangedEntry; +GtkWidget *userPasswordExpirationEntry; +GtkWidget *userPasswordExpirationButton; +GtkWidget *userPasswordChangeDelayMinimumSpin; +GtkWidget *userPasswordChangeDelayMaximumSpin; +GtkWidget *userWarningSpin; +GtkWidget *userActivitySpin; +GtkWidget *userForceChangeCheck; +GtkWidget *userShellCombo; +GtkWidget *userShellEntry; +GtkWidget *userHomeCombo; +GtkWidget *userHomeEntry; +GtkWidget *userHomeButton; +GtkWidget *userCreateSystemCheck; +GtkWidget *userCreateUnuniqueCheck; +GtkWidget *userDontCheckCheck; +GtkWidget *userSyncSAMBACheck; +GtkWidget *userDeactivatedCheck; +GtkWidget *userExtraOptionsEntry; +GtkWidget *UserCancelButton; +GtkWidget *UserOkButton; +GtkWidget *userTitleNameLabel; +} user_window; typedef struct { - GtkWidget *Window; - GtkWidget *UserCancelButton; - GtkWidget *UserOkButton; - GtkWidget *userGroupsEntry; - - GtkWidget *userUIDSystemCheck; - GtkWidget *userUIDAutoCheck; - GtkWidget *userUIDUniqueCheck; - GtkWidget *UserUIDEntry; - - GtkWidget *userUserNameEntry; - GtkWidget *userLoginEntry; - - GtkWidget *userPasswordDefaultCheck; - GtkWidget *userPasswordEntry; - - GtkWidget *userGroupsCheck; - GtkWidget *UserAdditionalGroupsButton; - GtkWidget *UserAdditionalGroupsMultipleButton; - - GtkWidget *userShellCombo; - - GtkWidget *userCreateHomeFolderCheck; - GtkWidget *userHomeFolderEntry; - GtkWidget *userHomeFolderButton; - - GtkWidget *userSyncSAMBACheck; - GtkWidget *userExtraOptionsEntry; -} user_window; +GtkWidget *Window; +GtkWidget *StatusBox; +GtkWidget *DefaultUserNameEntry; +GtkWidget *DefaultUserAdministratorCheck; +GtkWidget *DefaultPasswordCombo; +GtkWidget *DefaultPasswordEntry; +GtkWidget *RootPasswordCombo; +GtkWidget *RootPasswordEntry; +GtkWidget *PasswordHashCombo; +GtkWidget *CancelButton; +GtkWidget *AcceptButton; + +} additional_config_window; main_window *setup_window(); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 56da4ea..d3e9e90 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -4,39 +4,6 @@ #define TITLE_LABEL _("Users and groups") #define TITLE_INFO_LABEL _("System users and groups configuration") -#define SUCCESS_LABEL _("Operation succeeded") -#define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") - -#define ABOUT_LABEL _("About") -#define DOCUMENTATION_LABEL _("Documentation") - -#define SAVE_LOCAL_LABEL _("Save to local configuration") -#define SAVE_GLOBAL_LABEL _("Save to global configuration") -#define SAVE_CONFIGURATION_LABEL _("Save configuration") -#define SAVE_LABEL _("Save") - -#define LOAD_LOCAL_LABEL _("Load local configuration") -#define LOAD_GLOBAL_LABEL _("Load global configuration") -#define LOAD_LABEL _("Load") - -#define CANCEL_LABEL _("Cancel") - -#define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?") -#define HELP_INFO_LABEL _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.") -#define HELP_ALWAYS_OPEN_LABEL _("Always redirect to online documentation") -#define OPEN_HELP_LABEL _("Open documentation") -#define PROJECT_HOME_LABEL _("Project Home Page") -#define NOTHING_CHOSEN_LABEL _("Nothing were chosen") - - -#define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succseeded.") -#define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succseeded.") -#define LOAD_FAILED_LABEL _("Config loading failed") - -#define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.") -#define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.") -#define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.") - #define DEFAULT_USER_GROUPS_LABEL _("Default user groups:") #define DEFAULT_USER_NAME_LABEL _("Default user name (if there's no another):") #define USER_1000_IS_ADMIN_LABEL _("User with ID 1000 is administrator") diff --git a/source/ubl-utils.c b/source/ubl-utils.c deleted file mode 100644 index 66ed085..0000000 --- a/source/ubl-utils.c +++ /dev/null @@ -1,2488 +0,0 @@ -#include "ubl-utils.h" - -// dictionary functions - -/**yon_dictionary_new(): - * [EN] - * Creates and returns empty dictionary - * [RU] - * Создаёт и возвращает пустой словарь. - */ -dictionary *yon_dictionary_new() -{ - dictionary *dict = malloc(sizeof(dictionary)); - dict->data = NULL; - dict->key = NULL; - dict->next = NULL; - dict->prev = NULL; - dict->first = dict; - dict->data_type = DICTIONARY_OTHER_TYPE; - 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; - for_dictionaries(dct,dict){ - yon_dictionary_add_or_create_if_exists_with_data(newone,dct->key,dct->data); - newone->data_type=dct->data_type; - } - 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); - targetdict->next = yon_dictionary_new(); - targetdict->next->prev = targetdict; - targetdict->next->first = targetdict->first; - targetdict->next->data_type = DICTIONARY_OTHER_TYPE; - 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){ - dictionary *dct = NULL; - for_dictionaries(dct,dict); - return dct; - } 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) - { - if (dict->prev) - { - if (dict->prev->prev) - { - dictionary *next = dict->next, *prev = dict->prev, *preprev = prev->prev; - if (next) - { - preprev->next = dict; - dict->prev = preprev; - dict->next = prev; - prev->prev = dict; - prev->next = next; - next->prev = prev; - } - else - { - preprev->next = dict; - dict->prev = preprev; - dict->next = prev; - prev->prev = dict; - prev->next = NULL; - } - return prev; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - if (next) - { - yon_dictionary_make_first(dict); - dict->prev = NULL; - dict->next = prev; - prev->prev = dict; - prev->next = next; - next->prev = prev; - } - else - { - dict->prev = NULL; - dict->next = prev; - prev->prev = dict; - prev->next = NULL; - } - return prev; - } - } - } - else if (aim > 0) - { - if (dict->next) - { - if (dict->next->next) - { - dictionary *next = dict->next, *prev = dict->prev, *afnext = next->next; - if (prev) - { - prev->next = next; - next->prev = prev; - next->next = dict; - dict->prev = next; - dict->next = afnext; - afnext->prev = dict; - } - else - { - yon_dictionary_make_first(next); - next->prev = NULL; - next->next = dict; - dict->prev = next; - dict->next = afnext; - afnext->prev = dict; - } - return next; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - if (prev) - { - prev->next = next; - next->prev = prev; - next->next = dict; - dict->prev = next; - dict->next = NULL; - } - else - { - next->prev = NULL; - next->next = dict; - dict->prev = next; - dict->next = NULL; - } - } - } - } -} - -/**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) - { - dct->first = 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; - for (int i = 0; i < nth; i++) - { - if (dct == NULL) - return; - else - dct = dct->next; - } - yon_dictionary_rip(dict); - dictionary *prev = dct->prev; - prev->next = dict; - dict->prev = prev; - dict->next = dct; - 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(); - dct->key = yon_char_new(key); - dct->data = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - 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){ - if(data_manipulation) - data_manipulation(dict->data); - if(dict->prev) - free(dict->prev); - } - free(dict); - 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); - dct->key = yon_char_new(key); - dct->data = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - 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); - dict->next = toconnect; - toconnect->prev = dict; - toconnect->first = dict->first; - return toconnect; -} - -/**yon_dictionary_get(dictionary **dict, char *key) - * [EN] - * - * [RU] - * Возвращает элемент словаря [dict] с ключом [key]. - * Если такого элемента не было обнаружено, возвращается NULL -*/ -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; - } - } - return NULL; -} - -/**yon_dictionary_rip(dictionary *dict) - * [EN] - * - * [RU] - * Вырезает элемент из словаря и возвращает вырезанный элемент. -*/ -dictionary *yon_dictionary_rip(dictionary *dict) -{ - if (!dict->next&&!dict->prev) return NULL; - else if (!dict->next) - { - dictionary *prev = dict->prev; - if (prev) - { - prev->next = NULL; - return prev; - } - else - return dict; - } - else if (!dict->prev) - { - dictionary *next = dict->next; - if (next) - { - yon_dictionary_make_first(next); - next->prev = NULL; - return next; - } - else - return dict; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - next->prev = prev; - prev->next = next; - return next; - } -} - -/**yon_dictionary_get_nth(dictionary *dict, int place) - * [EN] - * - * [RU] - * Возвращает [place]-й элемент словаря [dict] -*/ -dictionary *yon_dictionary_get_nth(dictionary *dict, int place) -{ - if (dict){ - dict = dict->first; - int i = 0; - for (i = 0; i < place; i++) - if (dict->next) - dict = dict->next; - else - break; - if (i == place) - return dict; - else - return NULL; - } else return NULL; -} - -// 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] - * - * creates new char string by combining two char strings. - */ -char *yon_char_append(char *source, char *append) -{ - if (source && append) - { - int size = strlen(source) + strlen(append) + 1; - char *final = malloc(size); - memset(final, 0, size); - // if (strstr(source, "%%")) - // sprintf(final, source, append); - // else - sprintf(final, "%s%s", source, append); - return final; - } - else - return NULL; -} - -/**[EN] - * - * creates new char string by copying another char. - */ -char *yon_char_new(char *chr) -{ - if (chr){ - char *newchar = malloc(strlen(chr) + 1); - memset(newchar, 0, strlen(chr) + 1); - memcpy(newchar, chr, strlen(chr)); - return newchar; - } else - return NULL; -} - -/**yon_char_unite(char *source, ...) - * [En] - * - * [RU] - * Объединяет строку [source] со всеми строками, написанными в [...] -*/ -char *yon_char_unite(char *source, ...){ - va_list arglist; - char *new_char=NULL; - char *unite_char=NULL; - new_char=yon_char_new(source); - va_start(arglist,source); - unite_char = va_arg(arglist,char*); - while(unite_char){ - new_char = yon_char_append(new_char,unite_char); - unite_char = va_arg(arglist,char*); - } - va_end(arglist); - 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; - cut = malloc(size + 1); - memset(cut, 0, size + 1); - memcpy(cut, source + startpos, size); - 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) -{ - char *cut = malloc(dividepos + 1); - memset(cut, 0, dividepos + 1); - memcpy(cut, source, dividepos); - char *left = malloc(strlen(source) - strlen(cut)); - memset(left, 0, strlen(source) - strlen(cut)); - memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); - memset(source, 0, strlen(source)); - memcpy(source, left, strlen(left)); - return cut; -} - -/**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; - int size=0; - int pos=0; - config_str rtn = yon_char_parse(working_string,&size,"\n"); - for (int j=0;j= 10; i++) - { - convert_check = convert_check / 10; - } - char *ch = g_malloc0(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; - float convert_check = (float)int_to_convert; - for (i = 1; convert_check >= 10; i++) - { - convert_check = convert_check / 10; - } - char *ch = g_malloc0((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; - double convert_check = (double)int_to_convert; - for (i = 1; convert_check >= 10; i++) - { - convert_check = convert_check / 10; - } - char *ch = g_malloc0(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)){ - - - char *final=NULL; - char *temp=NULL; - if(!strstr(replace,find)){ - while ((final=strstr(source,find))){ - temp=malloc(strlen(source)-strlen(final)+strlen(replace)); - memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); - memcpy(temp,source,strlen(source)-strlen(final)); - temp=yon_char_append(temp,replace); - source=yon_char_append(temp,final+strlen(find)); - } - - } - } - 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; - *size=0; - char *paramline=yon_char_new(parameters); - char *param = strstr(paramline,divider); - for (;param;param=strstr(paramline,divider)){ - string = yon_remalloc(string,sizeof(char*)*((*size)+1)); - string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param)); - *size=(*size)+1; - } - string = yon_remalloc(string,sizeof(char*)*((*size)+1)); - string[(*size)]=paramline; - (*size)+=1; - return string; - } - 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)); - int flag = 0; - for (int i=0;i < (*size);i++){ - if (i==item_to_delete) { - flag = 1; - } - if (flag == 0) { - new_char_parsed[i]=yon_char_new(char_string[i]); - } - else if (flag == 1 && i!=item_to_delete) { - new_char_parsed[i-1]=yon_char_new(char_string[i]); - } - } - (*size)=(*size)-1; - 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;ipw_name,NULL); - else { - user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); - } - } - endpwent(); - return user_list; -} - -// parsing functions - -/** yon_size_convert_automatic(int bytes, int *size) - * [EN] - * - * [RU] - * -*/ -float yon_size_convert_automatic(int bytes, int *size){ - float byte_float=bytes; - for (*size=-1;byte_float>1024;*size=*size+1){ - byte_float=byte_float/1024; - } - if (*size==-1) { - *size=0; - byte_float=byte_float/1024; - } - 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; -}; - - -/** - * 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; - if (!access(dir_path,F_OK)){ - DIR *directory = opendir(dir_path); - struct dirent *de; - while ((de = readdir(directory))){ - if (dir) yon_char_parsed_append(dir,size,de->d_name); - else dir = yon_char_parsed_new(size,de->d_name,NULL); - } - closedir(directory); - } - return dir; -} - -//config functions - -typedef struct yon_config_parameter -{ - char *key; - void *data; - struct yon_config_parameter *next; - struct yon_config_parameter *prev; - struct yon_config_parameter *first; - DICT_TYPE data_type; - int flag1; - char *section; -} yon_config_parameter; - -yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){ - yon_config_parameter *param = yon_remalloc(NULL,sizeof(yon_config_parameter)); - param->data=data; - param->data_type=DICTIONARY_CHAR_TYPE; - param->first=param; - param->flag1=0; - param->key=yon_char_new(key); - param->next=NULL; - param->prev=NULL; - param->section=NULL; - return param; -} - -yon_config_parameter *yon_config_parameter_append_with_data(yon_config_parameter *dict, char *key, void *data){ - yon_config_parameter *param = yon_config_parameter_new_with_data(key,data); - param->first=dict->first; - (param->prev)=(yon_config_parameter*)yon_dictionary_get_last((dictionary*)dict); - dict->next=param; - return param; -} - - -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 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); - } - va_list args; - va_start(args,parameter); - char *arg; - dictionary *sections = NULL; - { - if (sections&&yon_dictionary_get(§ions,section)) sections->data=(void*)yon_char_unite(yon_dictionary_get_data(sections,char*)," ",parameter,NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections,section,parameter); - } - while (arg=va_arg(args,char*)){ - char *key = va_arg(args,char*); - if (sections&&yon_dictionary_get(§ions,arg)) sections->data=(void*)yon_char_unite(yon_dictionary_get_data(sections,char*)," ",key,NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections,arg,key); - } - char *command=NULL; - dictionary *dict; - for_dictionaries(dict,sections){ - command = yon_char_unite(ubconfig_load_command,config_type==YON_CONFIG_GLOBAL ? " global get " : " system get ", dict->key," ", yon_dictionary_get_data(dict,char*),NULL); - FILE *output = popen(command, "r"); - char **output_strings = NULL; - output_strings = malloc(sizeof(char*)); - int i = 0; - char str[4096]; - memset(str, 0, 4096); - while (fgets(str, 4096, output)) - { - if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) - { - char *key = yon_char_divide_search(str,"=",-1); - char *final_str=yon_char_divide_search(str,"\n",-1); - yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,yon_char_new(final_str)); - __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; - __yon__config__strings->section=dict->key; - } - } - } - check_config - return 1; - 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); - if (dict){ - ((yon_config_parameter*)dict)->flag1=-1; - return 1; - }else return 0; - } - 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); - char *data = (char*)dict->data; - char *found = strstr(data,deleted); - int size=strlen(data)-strlen(found)+1; - char *new_data = malloc(size); - memset(new_data,0,size); - if (strlen(found)!=strlen(deleted)){ - memcpy(new_data,data,size-1); - new_data = yon_char_append(new_data,found+strlen(deleted)+1); - } else { - memcpy(new_data,data,size-2); - new_data = yon_char_append(new_data,found+strlen(deleted)); - } - dict->data=(void*)(new_data); - dict->flag1=1; - return 1; - } else return 0; -} - -/**yon_config_get_by_key(char *key) - * [EN] - * - * [RU] - * Возвращает значение параметра конфига с ключом [key] -*/ -void *yon_config_get_by_key(char *key){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict, (dictionary*)__yon__config__strings){ - if (strcmp(dict->key,key)==0&&((yon_config_parameter*)dict)->flag1!=-1){ - return dict->data; - } - } - } - return NULL; -} - -void *yon_config_get_all_by_key(char *key, int *size){ - check_config{ - config_str ret_data=NULL; - dictionary *dict = NULL; - for_dictionaries(dict, (dictionary*)__yon__config__strings){ - if (strstr(dict->key,key)&&((yon_config_parameter*)dict)->flag1!=-1) { - char *ret_string = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); - if (ret_data) ret_data = yon_char_parsed_append(ret_data,size,ret_string); - else ret_data = yon_char_parsed_new(size,ret_string,NULL); - } - } - return ret_data; - } -} - -/**yon_config_get_key_by_data(char *data) - * [EN] - * - * [RU] - * Возвращает ключ параметра конфига со значением [data]. - * Если параметр с таким значением не найден, возвращается NULL -*/ -char *yon_config_get_key_by_data(char *data){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict, (dictionary*)__yon__config__strings){ - if (strcmp(((char*)dict->data),data)==0){ - return dict->key; - } - } - } - 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); - dict->data=data; - dict->flag1=1; - return 1; - } 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); - if (strcmp(((char*)dict->data),"")!=0) - dict->data=(void*)(yon_char_unite((char*)dict->data," ",data,NULL)); - else dict->data=(void*)data; - dict->flag1=1; - return 1; - } 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); - return 1; - } - 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); - } - 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; - output_strings = malloc(sizeof(char)); - int i = 0; - char str[4096]; - memset(str, 0, 4096); - while (fgets(str, 4096, output)) - { - if (strcmp(str, "") != 0) - { - output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); - output_strings[i] = NULL; - output_strings[i] = yon_char_new(str); - memset(str, 0, 4096); - i++; - } - } - if (i>0){ - *str_len = i; - return output_strings; - } else{ - *str_len=-1; - return NULL; - } -} - -/**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; - dictionary *sections_add=NULL; - dictionary *sections_remove=NULL; - for_dictionaries(dct,(dictionary*)__yon__config__strings){ - if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ - if (((yon_config_parameter*)dct)->flag1==1){ - ((yon_config_parameter*)dct)->flag1=0; - if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); - } else if (((yon_config_parameter*)dct)->flag1==-1){ - ((yon_config_parameter*)dct)->flag1=0; - if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); - yon_dictionary_rip(dct); - } - } - } - if (sections_add) - for_dictionaries(dct,sections_add){ - char *command = yon_dictionary_get_data(dct,char*); - yon_launch(command); - } - if (sections_remove) - for_dictionaries(dct,sections_remove){ - char *command = yon_dictionary_get_data(dct,char*); - yon_launch(command); - } - return 1; - } 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; - dictionary *sections_add=NULL; - dictionary *sections_remove=NULL; - for_dictionaries(dct,(dictionary*)__yon__config__strings){ - if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ - if (((yon_config_parameter*)dct)->flag1==1||((yon_config_parameter*)dct)->flag1==0){ - if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); - } else if (((yon_config_parameter*)dct)->flag1==-1){ - if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); - } - } - } - if (sections_add) - for_dictionaries(dct,sections_add){ - char *command = yon_dictionary_get_data(dct,char*); - yon_launch(command); - } - if (sections_remove) - for_dictionaries(dct,sections_remove){ - char *command = yon_dictionary_get_data(dct,char*); - yon_launch(command); - } - - - return 1; - } 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; - config_str conf = NULL; - dictionary *dict = NULL; - for_dictionaries(dict,(dictionary*)__yon__config__strings){ - conf = yon_remalloc(conf,sizeof(char*)*(*size)); - conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); - (*size)++; - } - conf = yon_remalloc(conf,sizeof(char*)*(*size)); - conf[*size-1] = NULL; - (*size)=(*size)-1; - return conf; - } 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]==' ') - yon_char_divide_search(param," ",-1); - param=yon_char_divide_search(yon_char_new(param)," ",-1); - - char *str = NULL; - for (int j = 0; j < size; j++) - { - char *name = yon_char_divide_search(yon_char_new(parameters[j]), "=", 1); - if (name) - { - if (strcmp(name, param) == 0) - { - str = yon_char_divide_search(yon_char_new(parameters[j]), "\n", 1); - if (strcmp(str, "") != 0 && strcmp(str, "(null)") != 0) - return str; - else - return NULL; - } - } - } - return NULL; -} - -config_str yon_file_open(char *file_path, int *size){ - *size=0; - FILE *file = fopen(file_path,"r"); - if (file){ - char str_loaded[4098]; - config_str final_string = NULL; - while (fgets(str_loaded,4098,file)){ - final_string = final_string ? yon_char_parsed_append(final_string,size,str_loaded) : yon_char_parsed_new(size,str_loaded,NULL); - } - return final_string; - } -} - -/**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); - if (access(full_path,F_OK)){ - FILE *fl = fopen(full_path,"w"); - if (fl){ - chmod(full_path,rules); - fclose(fl); - return 1; - } else { - return 0; - } - } else { - return -1; - } - } else { - return 0; - } -} - -/**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)){ - FILE *fl = fopen(path,"w"); - if (fl){ - chmod(path,rules); - fclose(fl); - return 1; - } else { - return 0; - } - } else { - return -1; - } - } else { - return 0; - } -} - -// 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); - pthread_t thread_id; - char *command = NULL; - command = path; - 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 void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) -{ - if (!terminal) return; - if (pid == -1) printf("Error\n\n\n"); - 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(); - commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); - commands[1]=NULL; - char **env=new_arr(char*,2); - env[0]=""; - env[1]=NULL; - GtkWidget *terminal = vte_terminal_new(); - vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); - VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); - vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - gtk_container_add(GTK_CONTAINER(place_to_show),terminal); - char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - if(endwork_function) - g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); - vte_terminal_spawn_async(VTE_TERMINAL(terminal), - VTE_PTY_DEFAULT, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - child_ready, - install_command); - vte_pty_spawn_async(pty, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - NULL, - NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); - vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); - vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); - 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(); - commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); - commands[1]=NULL; - char **env=new_arr(char*,2); - env[0]=""; - env[1]=NULL; - vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); - VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); - vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5; stty -echo; unset PS1","\n",NULL); - if(endwork_function) - g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); - vte_terminal_spawn_async(VTE_TERMINAL(terminal), - VTE_PTY_DEFAULT, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - child_ready, - install_command); - vte_pty_spawn_async(pty, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - NULL, - NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); - vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); - vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); - gtk_widget_show_all(terminal); - } -#endif - - // Window config functions - - #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 { - int x; - int y; - int width; - int height; - int fullscreen; - dictionary *custom_listeners; - dictionary *custom_parameters; - dictionary *deleted_parameters; - } __yon_main_window_config; - - static GtkWindow *__yon_window_config_target_window = NULL; - static GKeyFile *__yon_window_config_file = NULL; - static char *__yon_window_config_path = NULL; - - void yon_window_config_save(){ - g_key_file_set_integer(__yon_window_config_file,"window","WindowPosX",__yon_main_window_config.x); - g_key_file_set_integer(__yon_window_config_file,"window","WindowPosY",__yon_main_window_config.y); - 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","fullscreen",__yon_main_window_config.fullscreen); - dictionary *dict=NULL; - 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); - } - 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; - } - } - - g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); - } - - void yon_get_is_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){ - check_window_config_setup{ - yon_get_is_fullscreen(); - yon_window_config_save(); - } - gtk_main_quit(); - } - - void __yon_window_config_on_resize(){ - int max=0; - max=gtk_window_is_maximized(__yon_window_config_target_window); - if(max==0){ - gtk_window_get_size(__yon_window_config_target_window,&__yon_main_window_config.width,&__yon_main_window_config.height); - gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); - } - } - - /**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); - g_signal_connect(G_OBJECT(window),"check-resize"/*"configure-event"*/,G_CALLBACK(__yon_window_config_on_resize),NULL); - } - - void _yon_maximize(void *data){ - g_usleep(G_USEC_PER_SEC/10); - 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); - if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){ - struct stat st; - int size; - config_str conf = yon_char_parse(yon_char_new(__yon_window_config_path),&size,"/"); - char *path = yon_char_unite(conf[0],"/",conf[1],"/",conf[2],"/",conf[3],"/",conf[4],"/",NULL); - if (stat(path, &st) == -1) { - mkdir(path, 0777); - } - FILE *fp; - fp=fopen(__yon_window_config_path,"w"); - chmod(__yon_window_config_path,0777); - fclose(fp); - g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); - } - __yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL); - __yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",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.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.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_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); - pthread_t tid; - pthread_create(&tid,NULL,(void *)_yon_maximize,NULL); - return 1; - } - - void yon_window_config_apply(){ - dictionary *dict=NULL; - 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); - } - - 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); - dictionary *dict=NULL; - if (__yon_main_window_config.deleted_parameters) - for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ - if (strcmp(dict->key,param->parameter_name)) - yon_dictionary_rip(dict); - } - } - - void yon_window_config_add_instant_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ - switch (val_type){ - case YON_TYPE_BOOLEAN: g_key_file_set_boolean(__yon_window_config_file,section,param_name,*((gboolean*)tracked_value)); - break; - case YON_TYPE_INT: g_key_file_set_integer(__yon_window_config_file,section,param_name,*((int*)tracked_value)); - break; - case YON_TYPE_STRING: g_key_file_set_string(__yon_window_config_file,section,param_name,(char*)tracked_value); - break; - } - } - - 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); - } - - int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ - GError *err=NULL; - switch (type){ - case YON_TYPE_BOOLEAN: - *((int*)return_value) = g_key_file_get_boolean(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_INT: - *((int*)return_value) = g_key_file_get_integer(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_STRING: - *((char**)return_value) = g_key_file_get_string(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_STRING_LIST: - gsize size=0; - *((char***)return_value) = g_key_file_get_string_list(__yon_window_config_file,section,config_parameter,&size,&err); - *((char***)return_value)=yon_remalloc(return_value,size+1); - *((char***)return_value)[size]=NULL; - if (err) return 0; else return 1; - break; - } - } - - void yon_on_window_config_custom_window_destroy(GtkWindow *window, char *window_name){ - if (!gtk_window_is_maximized(window)){ - int height=0; - int width=0; - int X=0; - int Y=0; - gtk_window_get_position(window,&X,&Y); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); - - } - } - - void yon_on_window_config_custom_window_resize(GtkWindow *window, char *window_name){ - if (!gtk_window_is_maximized(window)){ - int height=0; - int width=0; - int X=0; - int Y=0; - gtk_window_get_size(window,&width,&height); - gtk_window_get_position(window,&X,&Y); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); - } - - } - - void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name){ - int height=0; - int width=0; - int X=0; - int Y=0; - yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); - yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); - yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); - yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); - if (width&&height) - gtk_window_resize(window,width,height); - if (X&&Y) - gtk_window_move(window,X,Y); - char *signals_window_name = yon_char_new(window_name); - g_signal_connect(G_OBJECT(window),"check-resize",G_CALLBACK(yon_on_window_config_custom_window_resize),signals_window_name); - g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_window_config_custom_window_destroy),signals_window_name); - } - - void yon_window_config_custom_window_get(GtkWindow *window, char *window_name){ - int height=0; - int width=0; - int X=0; - int Y=0; - yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); - yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); - yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); - yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); - if (width&&height) - gtk_window_resize(window,width,height); - if (X&&Y) - gtk_window_move(window,X,Y); - } - - void yon_window_config_custom_window_set(GtkWindow *window, char *window_name){ - int height=0; - int width=0; - int X=0; - int Y=0; - gtk_window_get_size(window,&width,&height); - gtk_window_get_position(window,&X,&Y); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); - yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); - } - -GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ - GtkWidget *menu_item = gtk_menu_item_new(); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); - GtkWidget *label = gtk_label_new(buttonname); - GtkWidget *image = gtk_image_new_from_icon_name("dialog-information-symbolic",GTK_ICON_SIZE_BUTTON); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - gtk_box_pack_start(GTK_BOX(box),image,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(GTK_CONTAINER(menu_item),box); - gtk_widget_show_all(menu_item); - return menu_item; -} - -GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ - GtkWidget *menu_item = gtk_menu_item_new(); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemmiddle"); - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); - GtkWidget *label = gtk_label_new(buttonname); - GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - gtk_box_pack_start(GTK_BOX(box),image,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(GTK_CONTAINER(menu_item),box); - gtk_widget_show_all(menu_item); - return menu_item; -} - - -// 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;i0 ? 1 : 0); -} - -void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ - gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>0 ? 0 : 1); -} - -void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) -{ - gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); - gtk_image_set_from_file(GTK_IMAGE(Image), image_path); -} - -void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) -{ - gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); - gtk_image_set_from_resource(GTK_IMAGE(Image), image_path); -} - -int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label) -{ - if(icon&&box&&label){ - render.icon=icon; - render.box=box; - render.label=label; - return 1; - } else return 0; -} - -void _yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type) -{ - render_data data = render; - GtkIconTheme *ictheme = gtk_icon_theme_get_default(); - GError *err = NULL; - if (err) - { - printf("%s\n", err->message); - g_error_free(err); - } - if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); - gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); - gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); - } - else if (type == BACKGROUND_IMAGE_FAIL_TYPE) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); - gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); - gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); - } - if (text) - gtk_label_set_text(GTK_LABEL(data.label), text); -} - -void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ - _yon_ubl_status_box_render(text,type); -} - -void _yon_ubl_status_highlight_incorrect(GtkWidget *widget){ - gtk_style_context_add_class(gtk_widget_get_style_context(widget),"errorBox"); - sleep(5); - gtk_style_context_remove_class(gtk_widget_get_style_context(widget),"errorBox"); -} - -void yon_ubl_status_highlight_incorrect(GtkWidget *widget){ - GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_highlight_incorrect,widget); -} - -void _yon_ubl_status_list_store_highlight_incorrect(GtkWidget **widget_pack){ - GtkListStore *list = (GtkListStore*)widget_pack[0]; - GtkTreeIter *iter = (GtkTreeIter*)widget_pack[1]; - GdkRGBA rgba,rgba2; - rgba.alpha=1; - rgba.blue=153.0/255.0; - rgba.green=153.0/255.0; - rgba.red=234.0/255.0; - rgba2.alpha=1; - rgba2.blue=0; - rgba2.green=0; - rgba2.red=0; - gtk_list_store_set(list,iter,1,gdk_rgba_to_string(&rgba2),2,gdk_rgba_to_string(&rgba),-1); - sleep(5); - gtk_list_store_set(list,iter,1,NULL,2,NULL,-1); -} - -void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter){ - GtkWidget **pack = malloc(sizeof(GtkWidget *)*2); - pack[0]=(GtkWidget*)list; - pack[1]=(GtkWidget*)iter; - GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_list_store_highlight_incorrect,pack); -} - -struct temp_statusbox { - int times; - GtkWidget *revealer; - }; - -void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ - sleep(statusstruct->times); - if (status_thread_busy){ - gtk_revealer_set_reveal_child(GTK_REVEALER(statusstruct->revealer),0); - sleep(1); - gtk_widget_destroy(statusstruct->revealer); - - } - status_thread_busy=0; -} - -void __yon_ubl_status_box_destroyed(){ - status_thread_busy=0; -} - -void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type){ - if (!status_thread_busy){ - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - GtkWidget *revealer = gtk_revealer_new(); - GtkWidget *label = gtk_label_new(""); - GtkWidget *icon = gtk_image_new(); - gtk_container_add(GTK_CONTAINER(revealer),box); - gtk_box_pack_start(GTK_BOX(box),icon,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(container,revealer); - - gtk_widget_show_all(revealer); - gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1); - g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),NULL); - - gtk_widget_set_margin_bottom(label,9); - gtk_widget_set_margin_top(label,9); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - PangoAttrList *attributes = pango_attr_list_new(); - PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); - pango_attr_list_insert(attributes, boldAttr); - gtk_label_set_attributes(GTK_LABEL(label),attributes); - - GdkRGBA textColor; - gdk_rgba_parse(&textColor, "#4d4d4d4d4d4d"); - PangoAttribute *colorAttr = pango_attr_foreground_new( - (int)(textColor.red * 65535), - (int)(textColor.green * 65535), - (int)(textColor.blue * 65535) - ); - pango_attr_list_insert(attributes, colorAttr); - - GtkIconTheme *ictheme = gtk_icon_theme_get_default(); - if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); - gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); - } - else if (type == BACKGROUND_IMAGE_FAIL_TYPE) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); - gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessError"); - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); - } - if (display_text) - gtk_label_set_text(GTK_LABEL(label),display_text); - struct temp_statusbox *statusstruct = malloc(sizeof(struct temp_statusbox)); - statusstruct->revealer = revealer; - statusstruct->times = timeout; - GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); - status_thread_busy=1; - } -} - -/**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){ - if (main_window&&socket_main_id>-1){ - gtk_widget_hide(gtk_widget_get_toplevel(main_window)); - GtkWidget *plug_main=gtk_plug_new(socket_main_id); - GtkWidget *plug_left=NULL; - GtkWidget *plug_right=NULL; - GtkWidget *box=NULL; - g_signal_connect(G_OBJECT(plug_main), "destroy", G_CALLBACK(gtk_main_quit),NULL); - if (socket_left_id>-1&&left_window){ - plug_left=gtk_plug_new(socket_left_id); - g_object_ref(left_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); - gtk_container_add(GTK_CONTAINER(plug_left),left_window); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"primary-toolbar"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"button"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"opacited"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"color"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"noborder"); - gtk_widget_show(plug_left); - } - else if (left_window){ - if (box==NULL){ - box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); - gtk_box_reorder_child(GTK_BOX(main_window),box,0); - gtk_widget_show(box); - } - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"inherited"); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); - gtk_box_pack_end(GTK_BOX(box),left_window,0,0,5); - } - if (socket_right_id>-1&&right_window){ - plug_right=gtk_plug_new(socket_right_id); - g_object_ref(right_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); - gtk_container_add(GTK_CONTAINER(plug_right),right_window); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"primary-toolbar"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"button"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"opacited"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"color"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"noborder"); - gtk_widget_show(plug_right); - } - else if (right_window){ - if (box==NULL){ - box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); - gtk_box_reorder_child(GTK_BOX(main_window),box,0); - gtk_widget_show(box); - } - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"inherited"); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); - gtk_box_pack_start(GTK_BOX(box),right_window,0,0,5); - } - g_object_ref(main_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(main_window)),main_window); - gtk_container_add(GTK_CONTAINER(plug_main),main_window); - gtk_widget_show(plug_main); - } -} - -#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); - GtkWidget *header=gtk_header_bar_new(); - GtkWidget *header_label=gtk_label_new(browser_window_name); - GtkWidget *WebView=webkit_web_view_new(); - gtk_container_add(GTK_CONTAINER(browser),web_place); - gtk_window_set_titlebar(GTK_WINDOW(browser),header); - gtk_window_set_title(GTK_WINDOW(browser),browser_window_name); - gtk_widget_set_size_request(browser,800,600); - gtk_header_bar_set_custom_title(GTK_HEADER_BAR(header),header_label); - gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),1); - 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 diff --git a/source/ubl-utils.h b/source/ubl-utils.h deleted file mode 100644 index 2fef789..0000000 --- a/source/ubl-utils.h +++ /dev/null @@ -1,424 +0,0 @@ -#ifndef UBL_UTILS -#define UBL_UTILS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../compile/ubl-cmake.h" -#ifdef WEBKIT_FOUND - #include -#endif -#define DesktopPath "/usr/share/applications/" - -#define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) - -#define new(type) malloc(sizeof(type)) -#define new_arr(type,size) malloc(sizeof(type)*size) - -#define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) - -typedef enum -{ - #ifdef __GTK_H__ - DICTIONARY_GTK_WIDGETS_TYPE, - #endif - DICTIONARY_OTHER_TYPE=0, - DICTIONARY_CHAR_TYPE, - DICTIONARY_INT_TYPE, - DICTIONARY_BOOL_TYPE, - -} DICT_TYPE; - -typedef struct dictionary -{ - char *key; - void *data; - struct dictionary *next; - struct dictionary *prev; - struct dictionary *first; - DICT_TYPE data_type; -} dictionary; - - - - -typedef struct apps -{ - char *Name; - int Type; - char *Categories; - char *Exec; - char *Icon; - int Pluggable; - int DualPluggable; -} apps; - -typedef char** config_str; - -#define config(key) yon_config_get_by_key(key) - -#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) -// dictionary functions - -/**yon_dictionary_get_data(dictionary, type) - * [EN] - * Gets data from dictionary. - * [dictionary] is dictionary, from which data should be extracted; - * [type] is type of data, [dictionary] contains. - * [RU] - * Возвращает данные из словаря. - * [dictionary] - словарь из которого достаются данные. - * [type] - тип данных, хранящихся в словаре [dictionary]. -*/ -#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) - -/**yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) - * [EN] - * - * [RU] - * Добавляет элемент словаря в конец словаря [dict] c ключом [key] и данными [data]. - * Если словарь не существует, создаёт его -*/ -#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);} - -dictionary *yon_dictionary_new(); - -dictionary *yon_dictionary_append(dictionary *targetdict); - -dictionary *yon_dictionary_get_last(dictionary *dict); - -dictionary *yon_dictionary_swap(dictionary *dict, int aim); - -void yon_dictionary_make_first(dictionary *dict); - -void yon_dictionary_make_nth(dictionary *dict, int nth); - -dictionary *yon_dictionary_new_with_data(char *key, void *data); - -dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data); - -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); - -dictionary *yon_dictionary_get(dictionary **dict, char *key); - -dictionary *yon_dictionary_rip(dictionary *dict); - -dictionary *yon_dictionary_get_nth(dictionary *dict, int place); - -void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); - -// char functions - -#define yon_char_divide_search_self(str,find,delete_divider) {char *temp = str; str = yon_char_divide_search(str,find,delete_divider); free(temp);} - -#define yon_char_is_empty(string) !(string&&strcmp(string,"")) - -int yon_char_find_last(char *source, char find); - -char *yon_char_append(char *source, char *append); - -char *yon_char_new(char *chr); - -char *yon_char_unite(char *source, ...); - -char *yon_cut(char *source, int size, int startpos); - -char *yon_char_divide(char *source, int dividepos); - -char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); - -char *yon_char_from_int(int int_to_convert); - -char *yon_char_from_float(float int_to_convert); - -char *yon_char_from_long(long int_to_convert); - -char *yon_char_replace(char *source, char *find, char*replace); - -char **yon_char_parse(char *parameters, int *size, char *divider); - -char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); - -int yon_char_parsed_check_exist(char **parameters, int size, char *param); - -int yon_char_parsed_check_repeats(char **parameters, int size, int *first_overlap, int *second_overlap); - -int yon_char_find_count(char *source, char *find); - -int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_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_append(config_str parsed, int *size, char *string); - -int yon_ubl_check_root(); - -char *yon_ubl_root_user_get(); - -char *yon_ubl_user_get_home_directory(); - -config_str yon_ubl_get_all_users(int *user_size); - -// parsing functions - -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); - -config_str yon_file_open(char *file_path, int *size); - -int yon_file_create(char *path, char *name, int rules); - -int yon_file_create_full_path(char *path, int rules); - -config_str yon_dir_get_contents(char *dir_path, int *size); - -//config functions - -#define ubconfig_save_command "ubconfig" -#define ubconfig_load_command "ubconfig --source" - -typedef enum { - YON_CONFIG_LOCAL=0, - YON_CONFIG_GLOBAL, - YON_CONFIG_BOTH -} YON_CONFIG_TYPE; - -config_str yon_config_load(char *command, int *str_len); - -int yon_config_save_registered(char *path); - -int yon_config_force_save_registered(char *path); - -char *yon_config_get_parameter(config_str parameters, int size, char *param); - -int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...); - -int yon_config_remove_by_key(char *key); - -int yon_config_remove_by_data(void *data); - -int yon_config_remove_element(char *key, char *deleted); - -void *yon_config_get_by_key(char *key); - -void *yon_config_get_all_by_key(char *key, int *size); - -char *yon_config_get_key_by_data(char *data); - -int yon_config_set(char *key, void *data); - -int yon_config_clean(); - -void yon_config_register(char *key, char* config_section, void *data); - -config_str yon_config_get_all(); - -// terminal-using functions - -int yon_launch_app_with_arguments(char *name, char *args); - -void yon_launch(char *command); - -// Gtk functions - -#ifdef __GTK_H__ -#ifdef VTE_TERMINAL -void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument); - -void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); - -#endif - -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_gtk_builder_get_widget(builder, widget_name) - * [EN] - * Returns GtkWidget from GtkBuilder *[builder]. - * [builder] is GtkBuilder*; - * [widget_name] is id of widget; -*/ -#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; - -void yon_window_config_setup(GtkWindow *window); - -int yon_window_config_load(char *path); - -config_str yon_window_config_get_section(char *section, gsize *size); - -void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_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_erase_custom_parameter(char *param_name, char *section); - -int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type); - -void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name); - -void yon_window_config_custom_window_get(GtkWindow *window, char *window_name); - -void yon_window_config_custom_window_set(GtkWindow *window, char *window_name); - -int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); - -int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); - -void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); - -int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); - -int yon_dictionary_gtk_pack_start_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, ...); - - -void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target); -void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target); -void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); -void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); - -typedef enum -{ - BACKGROUND_IMAGE_SUCCESS_TYPE, - BACKGROUND_IMAGE_FAIL_TYPE -} BACKGROUND_IMAGE_TYPE; - -typedef struct { - BACKGROUND_IMAGE_TYPE type; - GtkWidget *icon; - GtkWidget *box; - GtkWidget *label; - char* text_to_render; -} render_data; - - -/**yon_ubl_status_box_setup(render,icon,box,label) - * [EN] - * Sets up [render] structure of type render_data. - * [icon] is GtkImage widget of status box for showing status icons; - * [box] is GtkBox widget of status box for showing status color; - * [label] is GtkLabel widget of status box for showing status text; - * [RU] - * Настраивает структуру [render] типа render_data. - * [icon] - виджет типа GtkIcon в котором будут отображаться статусные иконки; - * [box] - виджет типа GtkBox в котором будет отображаться цвет статуса; - * [label] - виджет типа GtkLabel в котором будет отображаться текст статусного сообщения; -*/ -int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); - -/**yon_ubl_status_box_render(render,text,type) - * [EN] - * Renders message in status box; - * [render] is render_data structure of status box; - * [text] is text to be shown in status box; - * [type] if type of message. Can be BACKGROUND_IMAGE_FAIL_TYPE or BACKGROUND_IMAGE_SUCCESS_TYPE - * [RU] - * Отображает сообщение в статусном окне. - * [render] - структура типа render_data для нужного статусного окна; - * [text] - текст, отображаемый в статусном окне; - * [type] - тип сообщения. Может быть: - * BACKGROUND_IMAGE_FAIL_TYPE (красный фон,иконка - восклицательный знак) - * или - * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) -*/ -void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); - -void yon_ubl_status_highlight_incorrect(GtkWidget *widget); - -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_header_setup(overlay, head, image, imag_path) - * [EN] - * Sets up header of app. - * [overlay] is overlay for app header; - * [head] is box of header, which connects to [overlay] - * [image] is header background image; - * [imag_path] is path of image, shown in [image] - * [RU] - * Настраивает заголовок приложения. - * [overlay] - оверлей заголовка приложения; - * [head] - шапка заголовка, присоединяемая к [overlay] - * [image] - виджет картинки для заднего фона; - * [imag_path] - путь до картинки, загружаемой в [image] -*/ -#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay.gobj()), GTK_WIDGET(head.gobj()), GTK_WIDGET(image.gobj()), (char *)imag_path) -#else - -/**yon_ubl_header_setup(overlay, head, image, imag_path) - * [EN] - * Sets up header of app. - * [overlay] is overlay for app header; - * [head] is box of header, which connects to [overlay] - * [image] is header background image; - * [imag_path] is path of image, shown in [image] - * [RU] - * Настраивает заголовок приложения. - * [overlay] - оверлей заголовка приложения; - * [head] - шапка заголовка, присоединяемая к [overlay] - * [image] - виджет картинки для заднего фона; - * [imag_path] - путь до картинки, загружаемой в [image] -*/ -#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) -#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); - -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 - -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 diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index 6305632..53e190c 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -12,7 +12,7 @@ False com.ublinux.ubl-settings-usergroups.accept-symbolic - + 600 350 False @@ -69,7 +69,7 @@ - + True True @@ -87,7 +87,7 @@ - + User with ID 1000 is administrator True True @@ -127,7 +127,7 @@ - + True False @@ -144,7 +144,7 @@ - + True True 30 @@ -184,7 +184,7 @@ - + True False @@ -201,7 +201,7 @@ - + True True 30 @@ -251,7 +251,7 @@ - + True False 0 @@ -299,8 +299,8 @@ end 5 - - Deny + + Cancel True True True @@ -313,7 +313,7 @@ - + Accept True True @@ -337,12 +337,12 @@ - + True False True - + True False Users and groups diff --git a/ubl-settings-usergroups-group-creation.glade b/ubl-settings-usergroups-group-creation.glade index 8b5f35c..e3d234c 100644 --- a/ubl-settings-usergroups-group-creation.glade +++ b/ubl-settings-usergroups-group-creation.glade @@ -2,7 +2,27 @@ - + + True + False + avatar-default-symbolic + + + True + False + gtk-missing-image + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + False False True @@ -12,18 +32,29 @@ True False - 5 - 5 - 5 - 5 - 5 - 5 vertical - 10 + 5 + + + True + False + vertical + + + + + + False + True + 0 + + True False + 5 + 5 vertical 5 @@ -35,7 +66,7 @@ True False - UID: + Group Id: 0 @@ -62,7 +93,7 @@ True True - 1001 + 1007 number @@ -87,7 +118,7 @@ True False - Login: + Group name: 0 @@ -124,7 +155,7 @@ True False - Main group: + Group users: 0 @@ -171,14 +202,19 @@ False True - 0 + 1 True False - 30 + end + 5 + 5 + 5 + 5 + 5 True @@ -222,6 +258,130 @@ 1 + + + True + False + 5 + 5 + 0 + in + + + True + False + 12 + + + True + False + vertical + 5 + + + Allow creation of groups with ununique GID + True + True + False + True + + + False + True + 0 + + + + + Create system group + True + True + False + True + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Password: + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + True + True + + + False + True + 2 + + + + + True + True + True + image2 + + + False + True + 3 + + + + + False + True + 2 + + + + + + + + + True + False + Additional settings + + + + + False + True + 2 + + @@ -244,28 +404,8 @@ - - - - - - - True - False - avatar-default-symbolic - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - diff --git a/ubl-settings-usergroups-group.glade b/ubl-settings-usergroups-group.glade index ac621cb..60e8937 100644 --- a/ubl-settings-usergroups-group.glade +++ b/ubl-settings-usergroups-group.glade @@ -2,6 +2,193 @@ + + True + False + vertical + + + adm + True + True + False + True + + + False + True + 0 + + + + + audio + True + True + False + True + + + False + True + 1 + + + + + autologin + True + True + False + True + + + False + True + 2 + + + + + avahi + True + True + False + True + + + False + True + 3 + + + + + bin + True + True + False + True + + + False + True + 4 + + + + + brlapi + True + True + False + True + + + False + True + 5 + + + + + britty + True + True + False + True + + + False + True + 6 + + + + + bumblbee + True + True + False + True + + + False + True + 7 + + + + + chrony + True + True + False + True + + + False + True + 8 + + + + + clamav + True + True + False + True + + + False + True + 9 + + + + + cockpit-ws + True + True + False + True + + + False + True + 10 + + + + + cockpit-wsinstance + True + True + False + True + + + False + True + 11 + + + + + colord + True + True + False + True + + + False + True + 12 + + + True False @@ -13,6 +200,8 @@ emblem-ok-symbolic + 250 + 385 False False True @@ -30,191 +219,39 @@ vertical 10 - + True - False - vertical - - - adm - True - True - False - True - - - False - True - 0 - - - - - audio - True - True - False - True - - - False - True - 1 - - - - - autologin - True - True - False - True - - - False - True - 2 - - - - - avahi - True - True - False - True - - - False - True - 3 - - - - - bin - True - True - False - True - - - False - True - 4 - - + True + in - - brlapi + True True - False - True + + + + + + + + + 0 + + + + + + + Group + + + + 1 + + + + - - False - True - 5 - - - - - britty - True - True - False - True - - - False - True - 6 - - - - - bumblbee - True - True - False - True - - - False - True - 7 - - - - - chrony - True - True - False - True - - - False - True - 8 - - - - - clamav - True - True - False - True - - - False - True - 9 - - - - - cockpit-ws - True - True - False - True - - - False - True - 10 - - - - - cockpit-wsinstance - True - True - False - True - - - False - True - 11 - - - - - colord - True - True - False - True - - - False - True - 12 - @@ -227,7 +264,8 @@ True False - 30 + end + 5 True @@ -278,7 +316,7 @@ False True - + True False Users and groups diff --git a/ubl-settings-usergroups-password.glade b/ubl-settings-usergroups-password.glade new file mode 100644 index 0000000..666a39c --- /dev/null +++ b/ubl-settings-usergroups-password.glade @@ -0,0 +1,310 @@ + + + + + + True + False + gtk-missing-image + + + True + False + gtk-missing-image + + + True + False + gtk-missing-image + + + False + False + True + 450 + com.ublinux.ubl-settings-usergroups + + + True + False + vertical + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + end + 5 + 5 + 5 + 5 + 5 + 5 + 5 + True + + + Cancel + True + True + True + image4 + + + + True + True + 0 + + + + + Save + True + True + True + image5 + + + + True + True + 1 + + + + + False + True + end + 1 + + + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Parrword: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image3 + + + False + True + 2 + + + + + True + True + 0 + + + + + True + False + 5 + + + True + False + Repeat password: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + False + True + 2 + + + + + True + True + 1 + + + + + True + False + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Password hash: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image2 + + + False + True + 2 + + + + + True + True + 3 + + + + + True + True + 2 + + + + + + + True + False + True + + + True + False + Users and groups + + + + + + + + + + + + + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + diff --git a/ubl-settings-usergroups-user.glade b/ubl-settings-usergroups-user.glade index 566a9f3..1b04071 100644 --- a/ubl-settings-usergroups-user.glade +++ b/ubl-settings-usergroups-user.glade @@ -3,10 +3,11 @@ + True False - avatar-default-symbolic + com.ublinux.ubl-settings-usergroups.profile-symbolic True @@ -16,12 +17,22 @@ True False - document-edit-symbolic + com.ublinux.ubl-settings-usergroups.zoom-symbolic True False - gtk-missing-image + com.ublinux.ubl-settings-usergroups.edit-symbolic + + + True + False + com.ublinux.ubl-settings-usergroups.group-symbolic + + + True + False + com.ublinux.ubl-settings-usergroups.calendar-symbolic True @@ -29,484 +40,954 @@ process-stop-symbolic + 500 False False True - 450 com.ublinux.ubl-settings-usergroups True False - 5 - 5 - 5 - 5 - 5 - 5 vertical 10 - + True False - vertical - 5 - - - True - False - 5 - - - True - False - UID: - 0 - - - False - True - 0 - - - - - System - True - True - False - True - - - False - True - 1 - - - - - Automatically - True - True - False - True - - - False - True - 2 - - - - - Unique - True - True - False - True - - - False - True - 3 - - - - - True - True - 1001 - number - - - True - True - 4 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - User name: - 0 - - - False - True - 0 - - - - - True - True - username - - - True - True - 1 - - - - - False - True - 1 - - - - True - False - 5 - - - True - False - Login: - 0 - - - False - True - 0 - - - - - True - True - login - - - True - True - 1 - - - - - False - True - 2 - - - - - True - False - 5 - - - True - False - Password: - 0 - - - False - True - 0 - - - - - Default - True - True - False - True - - - False - True - 1 - - - - - True - True - False - * - False - False - ****** - password - - - True - True - 2 - - - - - False - True - 3 - - - - - True - False - 5 - - - True - False - Main group: - 0 - - - False - True - 0 - - - - - Own groups - True - True - False - True - - - False - True - 1 - - - - - True - True - - - True - True - 2 - - - - - True - True - True - image1 - - - - False - True - 3 - - - - - True - True - True - image3 - - - - False - True - 4 - - - - - False - True - 4 - - - - - True - False - 5 - - - True - False - User shell: - 0 - - - False - True - 0 - - - - - True - False - - - True - True - 2 - - - - - False - True - 5 - - - - - True - False - 5 - - - True - False - Home directory: - 0 - - - False - True - 0 - - - - - Create - True - True - False - True - - - False - True - 1 - - - - - True - True - - - True - True - 2 - - - - - True - True - True - image2 - - - - False - True - 3 - - - - - False - True - 6 - - - - - Sync with SAMBA user - True - True - False - True - - - False - True - 8 - + + + + False + True + 0 + + + + + True + True + never + in - + True False - 5 + 5 + 5 + 5 + 5 - + True False - Extra options: - 0 + vertical + 5 + + + True + False + 5 + + + True + False + UID: + 0 + + + False + True + 0 + + + + + Automatically + True + True + False + True + + + False + True + 2 + + + + + True + True + 1001 + number + + + True + True + 4 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Login: + 0 + + + False + True + 0 + + + + + True + True + login + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Password: + 0 + + + False + True + 0 + + + + + True + False + + Default + + + + False + True + 1 + + + + + True + True + False + * + False + False + ****** + password + + + True + True + 2 + + + + + True + True + True + image3 + + + + False + True + 3 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + User name: + 0 + + + False + True + 0 + + + + + True + True + username + + + True + True + 1 + + + + + False + True + 3 + + + + + True + False + 5 + + + True + False + Main group: + 0 + + + False + True + 0 + + + + + Login name + True + True + False + True + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image1 + + + + False + True + 3 + + + + + False + True + 4 + + + + + True + False + 5 + + + True + False + Additional group: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image4 + + + + False + True + 2 + + + + + False + True + 7 + + + + + True + False + 0 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Password has been changed: + + + False + True + 0 + + + + + True + True + + + False + True + 1 + + + + + True + False + expiration date: + + + False + True + 2 + + + + + True + True + + + False + True + 3 + + + + + True + True + True + image5 + + + + False + True + 4 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Password change interval: minimum + + + False + True + 0 + + + + + True + True + + + False + True + 1 + + + + + True + False + days, maximum + + + False + True + 2 + + + + + True + True + + + False + True + 3 + + + + + True + False + days + + + False + True + 4 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Days until warning: + + + False + True + 0 + + + + + True + True + + + False + True + 1 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Days without activity: + + + False + True + 0 + + + + + True + True + + + False + True + 1 + + + + + False + True + 3 + + + + + True + False + 5 + + + Force change at next login + True + True + False + True + + + False + True + 0 + + + + + False + True + 4 + + + + + + + + + True + False + Password configuration + + + + + False + True + 8 + + + + + True + False + 0 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + User shell: + + + False + True + 0 + + + + + True + False + + Default + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Home directory: + + + False + True + 0 + + + + + True + False + + Default + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image2 + + + + False + True + 3 + + + + + False + True + 1 + + + + + True + False + 5 + + + Create system user + True + True + False + True + + + False + True + 0 + + + + + False + True + 2 + + + + + True + False + 5 + + + Create user with ununique (repeating) UID + True + True + False + True + + + False + True + 0 + + + + + False + True + 3 + + + + + True + False + 5 + + + Do not check login for compliance with character rules + True + True + False + True + + + False + True + 0 + + + + + False + True + 4 + + + + + + + + + True + False + Additional configuration + + + + + False + True + 9 + + + + + Sync with SAMBA user + True + True + False + True + + + False + True + 10 + + + + + Temporary deactivation + True + True + False + True + + + False + True + 11 + + + + + True + False + 5 + + + True + False + Extra options: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 13 + + - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - False - True - 9 - - False + True True - 0 + 1 True False + 5 + 5 + 5 True @@ -559,7 +1040,8 @@ False True - 1 + end + 2 @@ -582,16 +1064,4 @@ - - - - - - - - - - - - diff --git a/ubl-settings-usergroups.glade b/ubl-settings-usergroups.glade index b05fbee..75af7f9 100644 --- a/ubl-settings-usergroups.glade +++ b/ubl-settings-usergroups.glade @@ -25,180 +25,43 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - False - False - True - center - com.ublinux.ubl-settings-usergroups - dialog - True - ubl-settings-usergroups - 1.1 - Copyright © 2022 - 2023, UBSoft LLC - Users and groups - https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-usergroups - Project Home Page - Это приложение распространяется без каких-либо гарантий. -Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. - UBGroup - UBGroup - com.ublinux.ubl-settings-usergroups - True - gpl-2-0 - - - True - False - vertical - 2 - - - False - end - - - False - False - 1 - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - Users and groups - - - - - - - - - - True - False - center - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 64 - com.ublinux.ubl-settings-usergroups - - - False - True - 0 - - - - - True - False - - - True - False - - - True - False - center - vertical - - - 255 - True - False - end - Users and groups - 0 - - - - - - - - True - True - 0 - - - - - 255 - True - False - start - System users and groups configuration - True - 0 - - - - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - True - 0 - - - - - True - True - 1 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -231,60 +94,65 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False - value-increase-symbolic + com.ublinux.ubl-settings-usergroups.increase-symbolic True False - value-increase-symbolic + com.ublinux.ubl-settings-usergroups.group-symbolic True False - value-increase-symbolic + com.ublinux.ubl-settings-usergroups.profile-settings-symbolic True False - value-increase-symbolic + com.ublinux.ubl-settings-usergroups.settings-symbolic True False - value-increase-symbolic + com.ublinux.ubl-settings-usergroups.sync-symbolic True False - document-edit-symbolic + com.ublinux.ubl-settings-usergroups.edit-symbolic True False - user-trash-symbolic - - - True - False - document-edit-symbolic + com.ublinux.ubl-settings-usergroups.trash-symbolic - + True False - vertical + 5 + 5 + 5 + 5 + 5 + 5 + True + True 5 True False + vertical 5 - + True - False - 5 - Default user groups: - 0 + True + True + image12 + False @@ -293,22 +161,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True True + True + image11 + - True + False True 1 - + True True True - image4 + image10 + False @@ -316,1136 +192,298 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 2 - - - False - True - 0 - - - - - True - False - 5 - - - True - False - 5 - Default user name (if there's no another): - 0 - - - False - True - 0 - - - + True True - - - True - True - 1 - - - - - False - True - 1 - - - - - User with ID 1000 is administrator - True - True - False - True - - - False - True - 2 - - - - - True - False - 5 - - - True - False - 5 - Default user password: - 0 + True + image1 + False True - 0 + 3 - + True True - 30 - False - - password + True + image2 + False True - 1 + 4 - + True True - end - 30 - False - - password - - - False - True - end - 2 - - - - - True - False - Root user password: + True + image3 + False True - end - 3 + 5 - - - False - True - 3 - - - - - True - False - 5 - + True - False - 5 - Password hash algorythm: - 0 + True + True + image13 + False True - 0 - - - - - True - False - 0 - - md5 - yescrypt - ghost-yescrypt - scrypt - bf - bcrypt - bcrypt-a - sha512crypt - sha256crypt - sunmd5 - md5crypt - bsdicrypt - desctrypt - nt - - - - True - True - 1 + 6 False True - 4 + 0 - - - - - - - - - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - - False - False - 450 - dialog-question-symbolic - + True - False - 5 - 5 - 5 - 5 - vertical - 10 - - - True - False - - - True - False - start - 20 - 20 - dialog-question-symbolic - 6 - - - False - True - 0 - - - - - True - False - vertical - - - True - False - start - 10 - 5 - Would you like to read documentation in the Web? - True - 0 - - - - - - - False - True - 0 - - - - - True - False - start - start - 10 - 10 - You will be redirected to documentation website where documentation is -translated and supported by community. - True - 0 - - - - False - True - 1 - - - - - Always redirect to online documentation - True - True - False - end - True - - - - False - True - end - 2 - - - - - - True - True - 1 - - - - - - True - True - 0 - - + True True False - 30 - True - - - Cancel - True - True - True - image8 - - - - True - True - 0 - - + 5 + 5 + 5 + 5 + 5 - - Open documentation + True True - True - image9 - - - - True - True - 1 - - - - - False - True - 1 - - - - - - - True - False - True - - - True - False - Users and groups - - - - - - - - - - True - False - False - - - True - False - Load global configuration - - - - - - True - False - Load local configuration - - - - - - True - False - False - False - - - True - False - Documentation - True - - - - - - True - False - About - - - - - - True - False - False - - - True - False - Save configuration - - - - - - True - False - Save to global configuration - - - - - - True - False - Save to local configuration - - - - - - 800 - 600 - False - 800 - 600 - com.ublinux.ubl-settings-usergroups - - - True - False - vertical - - - True - False - vertical - - - True - False + external - + True - False - 5 - 5 - 5 - 5 - 5 - 5 - 25 - - - False - True - 0 - - - - - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - - - 81 - True - False - - - True - False - start - - - -1 - - - - - False - True - 0 - - - - - False - True - 1 - - - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - True - True - 5 - - - True - False - vertical - 5 - - - True - True - True - image12 - - - - False - True - 0 - - - - - True - True - True - image11 - - - - False - True - 1 - + True + UsersList + 0 + + - - True - True - True - image10 - + + Block - - False - True - 2 - - - True - True - True - image1 - + + UID + + + + 0 + + - - False - True - 3 - - - True - True - True - image2 - + + Login + + + + 5 + + - - False - True - 4 - - - True - True - True - image3 - + + User name + + + + 4 + + - - False - True - 5 - - - True - True - True - image13 - + + Main group + + + - - False - True - 6 - - - - False - True - 0 - - - - - True - True - - True - False - 5 - 5 - 5 - 5 - 5 + + Additional groups - - True - True - external - in - - - True - True - UserList - 0 - - - - - - Block - - - - - UID - - - - 0 - - - - - - - Login - - - - 5 - - - - - - - User name - - - - 4 - - - - - - - Main group - - - - - - - - Additional groups - - - - - - - - Additional parameters - - - - - - - - Password status - - - - - - - True - True - 1 - + - - - True - False - Users - - - False - - - - True - False - 5 - 5 - 5 - 5 - 5 + + Additional parameters - - True - True - external - in - - - True - True - UserList - 0 - - - - - - GID - - - - 0 - - - - - - - Group name - - - - 2 - - - - - - - Group users - - - - 3 - - - - - - - Additional parameters - - - - 5 - - - - - - - Password status - - - - - - - - - - True - True - 0 - + - - 1 - - - - True - False - Groups + + + Password status - - 1 - False - - - True - True - 1 - - False + True True - 2 + 1 - - True - True - 0 - - - - - - True - False - True - - + + True False - 5 - 5 - 5 - 5 - 2 - Users and groups - - - + Users + + False + - + True False - 5 - 5 5 5 - 6 - 6 - 32 - com.ublinux.ubl-settings-usergroups - - - - - True - False + 5 + 5 + 5 - + True True - False - True - menu3 + external - + True - False + True + UsersList + 0 + + + + + + GID + + + + 0 + + + + + + + Group name + + + + 2 + + + + + + + Group users + + + + 3 + + + + - - True - False - Save + + Additional parameters + + + + 5 + + - - False - True - 0 - - - True - False - pan-down-symbolic + + Password status + + + - - False - True - 1 - - False + True True 0 - - - True - True - True - False - True - True - menu2 - none - - - - - - - False - True - 1 - - - end 1 - - + + True False - - - True - True - False - True - menu1 - - - True - False - - - True - False - Load - - - False - True - 0 - - - - - True - False - pan-down-symbolic - - - False - True - 1 - - - - - - - False - True - 0 - - + Groups - 2 + 1 + False - + + True + True + 1 + -- 2.35.1 From 561937b921bb204e31406c3474268e04bc78bac3 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 7 Dec 2023 12:14:30 +0600 Subject: [PATCH 6/8] Window constructors are done, L2 windows are connected to interface --- Makefile | 2 + README.md | 1 + ...bl-settings-usergroups.funnel-symbolic.svg | 45 ++ ...x.ubl-settings-usergroups.key-symbolic.svg | 60 ++ source/ubl-settings-usergroups.c | 575 +++++++++++------- source/ubl-settings-usergroups.h | 394 ++++++------ ...tings-usergroups-additional-settings.glade | 15 +- ubl-settings-usergroups-group-creation.glade | 40 +- ubl-settings-usergroups-group.glade | 3 +- ubl-settings-usergroups-password.glade | 54 +- ubl-settings-usergroups-system.glade | 9 +- ubl-settings-usergroups-user.glade | 6 + ubl-settings-usergroups.glade | 2 +- 13 files changed, 779 insertions(+), 427 deletions(-) create mode 100644 icons/com.ublinux.ubl-settings-usergroups.funnel-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.key-symbolic.svg diff --git a/Makefile b/Makefile index 739bf18..6e816e2 100644 --- a/Makefile +++ b/Makefile @@ -134,6 +134,8 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.group-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.zoom-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.calendar-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.key-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.funnel-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.profile-settings-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy" @if [ -z ${DESTDIR} ]; then \ diff --git a/README.md b/README.md index 006bbe3..f17b7ad 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ In order to build ubl-ubl-settings-usergroups you will need: - C compiler - GTK+ 3 & dependencies - webkit2gtk (optional) +- [libublsettings-ui](https://gitea.ublinux.ru/Applications/libublsettings-ui) Once you have all the necessary dependencies, you can use: ```sh diff --git a/icons/com.ublinux.ubl-settings-usergroups.funnel-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.funnel-symbolic.svg new file mode 100644 index 0000000..4aec04a --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.funnel-symbolic.svg @@ -0,0 +1,45 @@ + + + + + + + + + + diff --git a/icons/com.ublinux.ubl-settings-usergroups.key-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.key-symbolic.svg new file mode 100644 index 0000000..a11cbf1 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.key-symbolic.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index c0f627e..c9374b7 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -1,158 +1,316 @@ -#include "ubl-settings-usergroups.h" +#include "ubl-settings-usergroups.h" + +config main_config; + +//functions + +void yon_load_proceed(char *command){ + +} + +void yon_save_proceed(char *section,YON_CONFIG_TYPE type){ +} + +void on_filechooser_open(GtkWidget *self, GtkEntry *output_target){ -config main_config; +} -//functions +void on_groups_clicked(GtkWidget *self, GtkEntry *output_target){ -void yon_load_proceed(char *command){ - } -void yon_save_proceed(char *section,YON_CONFIG_TYPE type){ +void on_password_change(GtkWidget *self, GtkEntry *output_target){ + +} + +void on_additional_groups_clicked(GtkWidget *self, GtkEntry *output_target){ + +} + +void on_expiration_clicked(GtkWidget *self, GtkEntry *output_target){ + +} + +// standard functions + + + +ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new(){ + ubl_settings_usergroups_additional_settings_window *window = malloc(sizeof(ubl_settings_usergroups_additional_settings_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_additional_settings); + window->Window=yon_gtk_builder_get_widget(builder,"Window"); + window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); + window->DefaultUserNameEntry=yon_gtk_builder_get_widget(builder,"DefaultUserNameEntry"); + window->DefaultUserAdministratorCheck=yon_gtk_builder_get_widget(builder,"DefaultUserAdministratorCheck"); + window->DefaultPasswordCombo=yon_gtk_builder_get_widget(builder,"DefaultPasswordCombo"); + window->DefaultPasswordEntry=yon_gtk_builder_get_widget(builder,"DefaultPasswordEntry"); + window->RootPasswordCombo=yon_gtk_builder_get_widget(builder,"RootPasswordCombo"); + window->RootPasswordEntry=yon_gtk_builder_get_widget(builder,"RootPasswordEntry"); + window->PasswordHashCombo=yon_gtk_builder_get_widget(builder,"PasswordHashCombo"); + window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); + window->AcceptButton=yon_gtk_builder_get_widget(builder,"AcceptButton"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); +return window; } -additional_config_window *yon_additional_config_window_new(){ - additional_config_window *window = malloc(sizeof(additional_config_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_additional); -window->Window=yon_gtk_builder_get_widget(builder,"Window"); -window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); -window->DefaultUserNameEntry=yon_gtk_builder_get_widget(builder,"DefaultUserNameEntry"); -window->DefaultUserAdministratorCheck=yon_gtk_builder_get_widget(builder,"DefaultUserAdministratorCheck"); -window->DefaultPasswordCombo=yon_gtk_builder_get_widget(builder,"DefaultPasswordCombo"); -window->DefaultPasswordEntry=yon_gtk_builder_get_widget(builder,"DefaultPasswordEntry"); -window->RootPasswordCombo=yon_gtk_builder_get_widget(builder,"RootPasswordCombo"); -window->RootPasswordEntry=yon_gtk_builder_get_widget(builder,"RootPasswordEntry"); -window->PasswordHashCombo=yon_gtk_builder_get_widget(builder,"PasswordHashCombo"); -window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); -window->AcceptButton=yon_gtk_builder_get_widget(builder,"AcceptButton"); + +void on_ubl_settings_usergroups_additional_settings_open(GtkWidget *self, main_window *widgets){ + ubl_settings_usergroups_additional_settings_window *window = yon_ubl_settings_usergroups_additional_settings_new(); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + + gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window)); + gtk_widget_show(window->Window); } -groups_window *yon_groups_window_new(){ - groups_window *window = malloc(sizeof(groups_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_groups); - window->GroupsWindow=yon_gtk_builder_get_widget(builder,"GroupsWindow"); - window->GroupsTree=yon_gtk_builder_get_widget(builder,"GroupsTree"); - window->GroupsCancelButton=yon_gtk_builder_get_widget(builder,"GroupsCancelButton"); - window->GroupsOkButton=yon_gtk_builder_get_widget(builder,"GroupsOkButton"); - g_signal_connect(G_OBJECT(window->GroupsCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); - return window; +ubl_settings_usergroups_group_creation_window *yon_ubl_settings_usergroups_group_creation_new(){ + ubl_settings_usergroups_group_creation_window *window = malloc(sizeof(ubl_settings_usergroups_group_creation_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_group_creation); + window->CreateGroupWindow=yon_gtk_builder_get_widget(builder,"CreateGroupWindow"); + window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); + window->userUIDAutoCheck=yon_gtk_builder_get_widget(builder,"userUIDAutoCheck"); + window->userUIDEntry=yon_gtk_builder_get_widget(builder,"userUIDEntry"); + window->userLoginEntry=yon_gtk_builder_get_widget(builder,"userLoginEntry"); + window->userGroupsEntry=yon_gtk_builder_get_widget(builder,"userGroupsEntry"); + window->UserAdditionalGroupsButton=yon_gtk_builder_get_widget(builder,"UserAdditionalGroupsButton"); + window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); + window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); + g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); +return window; +} + + + +ubl_settings_usergroups_group_window *yon_ubl_settings_usergroups_group_new(){ + ubl_settings_usergroups_group_window *window = malloc(sizeof(ubl_settings_usergroups_group_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_group); + window->groupsAdmGroupCheck=yon_gtk_builder_get_widget(builder,"groupsAdmGroupCheck"); + window->groupsAudioGroupCheck=yon_gtk_builder_get_widget(builder,"groupsAudioGroupCheck"); + window->groupsAutologinGroupCheck=yon_gtk_builder_get_widget(builder,"groupsAutologinGroupCheck"); + window->groupsAvahiGroupCheck=yon_gtk_builder_get_widget(builder,"groupsAvahiGroupCheck"); + window->groupsBinGroupCheck=yon_gtk_builder_get_widget(builder,"groupsBinGroupCheck"); + window->groupsBrlapiGroupCheck=yon_gtk_builder_get_widget(builder,"groupsBrlapiGroupCheck"); + window->groupsBrittyGroupCheck=yon_gtk_builder_get_widget(builder,"groupsBrittyGroupCheck"); + window->groupsBumblbeeGroupCheck=yon_gtk_builder_get_widget(builder,"groupsBumblbeeGroupCheck"); + window->groupsChronyGroupCheck=yon_gtk_builder_get_widget(builder,"groupsChronyGroupCheck"); + window->groupsClamavGroupCheck=yon_gtk_builder_get_widget(builder,"groupsClamavGroupCheck"); + window->groupsCockpitWsGroupCheck=yon_gtk_builder_get_widget(builder,"groupsCockpitWsGroupCheck"); + window->groupsCockpitWsinstanceGroupCheck=yon_gtk_builder_get_widget(builder,"groupsCockpitWsinstanceGroupCheck"); + window->groupsColordGroupCheck=yon_gtk_builder_get_widget(builder,"groupsColordGroupCheck"); + window->GroupsWindow=yon_gtk_builder_get_widget(builder,"GroupsWindow"); + window->GroupsTree=yon_gtk_builder_get_widget(builder,"GroupsTree"); + window->GroupsCancelButton=yon_gtk_builder_get_widget(builder,"GroupsCancelButton"); + window->GroupsOkButton=yon_gtk_builder_get_widget(builder,"GroupsOkButton"); + g_signal_connect(G_OBJECT(window->GroupsCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); +return window; } void on_standard_groups_open(GtkWidget *self, main_window *widgets){ - groups_window *window = yon_groups_window_new(); + ubl_settings_usergroups_group_window *window = yon_ubl_settings_usergroups_group_new(); g_signal_connect(G_OBJECT(window->GroupsOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_window_set_transient_for(GTK_WINDOW(window->GroupsWindow),GTK_WINDOW(widgets->Window)); gtk_widget_show(window->GroupsWindow); } -user_window *yon_user_window_new(){ - user_window *window = malloc(sizeof(user_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_user); - window->CreateUserWindow=yon_gtk_builder_get_widget(builder,"CreateUserWindow"); - window->userUIDAutoCheck=yon_gtk_builder_get_widget(builder,"userUIDAutoCheck"); - window->userUIDEntry=yon_gtk_builder_get_widget(builder,"userUIDEntry"); - window->userLoginEntry=yon_gtk_builder_get_widget(builder,"userLoginEntry"); - window->userPasswordCombo=yon_gtk_builder_get_widget(builder,"userPasswordCombo"); - window->userPasswordEntry=yon_gtk_builder_get_widget(builder,"userPasswordEntry"); - window->userPasswordButton=yon_gtk_builder_get_widget(builder,"userPasswordButton"); - window->userUserNameEntry=yon_gtk_builder_get_widget(builder,"userUserNameEntry"); - window->userGroupsCheck=yon_gtk_builder_get_widget(builder,"userGroupsCheck"); - window->userGroupsEntry=yon_gtk_builder_get_widget(builder,"userGroupsEntry"); - window->UserGroupsButton=yon_gtk_builder_get_widget(builder,"UserGroupsButton"); - window->userCreateHomeFolderCheck=yon_gtk_builder_get_widget(builder,"userCreateHomeFolderCheck"); - window->userHomeFolderEntry=yon_gtk_builder_get_widget(builder,"userHomeFolderEntry"); - window->userHomeFolderButton=yon_gtk_builder_get_widget(builder,"userHomeFolderButton"); - window->userAdditionalGroupsEntry=yon_gtk_builder_get_widget(builder,"userAdditionalGroupsEntry"); - window->userAdditionalGroupsButton=yon_gtk_builder_get_widget(builder,"userAdditionalGroupsButton"); - window->userPasswordChangedEntry=yon_gtk_builder_get_widget(builder,"userPasswordChangedEntry"); - window->userPasswordExpirationEntry=yon_gtk_builder_get_widget(builder,"userPasswordExpirationEntry"); - window->userPasswordExpirationButton=yon_gtk_builder_get_widget(builder,"userPasswordExpirationButton"); - window->userPasswordChangeDelayMinimumSpin=yon_gtk_builder_get_widget(builder,"userPasswordChangeDelayMinimumSpin"); - window->userPasswordChangeDelayMaximumSpin=yon_gtk_builder_get_widget(builder,"userPasswordChangeDelayMaximumSpin"); - window->userWarningSpin=yon_gtk_builder_get_widget(builder,"userWarningSpin"); - window->userActivitySpin=yon_gtk_builder_get_widget(builder,"userActivitySpin"); - window->userForceChangeCheck=yon_gtk_builder_get_widget(builder,"userForceChangeCheck"); - window->userShellCombo=yon_gtk_builder_get_widget(builder,"userShellCombo"); - window->userShellEntry=yon_gtk_builder_get_widget(builder,"userShellEntry"); - window->userHomeCombo=yon_gtk_builder_get_widget(builder,"userHomeCombo"); - window->userHomeEntry=yon_gtk_builder_get_widget(builder,"userHomeEntry"); - window->userHomeButton=yon_gtk_builder_get_widget(builder,"userHomeButton"); - window->userCreateSystemCheck=yon_gtk_builder_get_widget(builder,"userCreateSystemCheck"); - window->userCreateUnuniqueCheck=yon_gtk_builder_get_widget(builder,"userCreateUnuniqueCheck"); - window->userDontCheckCheck=yon_gtk_builder_get_widget(builder,"userDontCheckCheck"); - window->userSyncSAMBACheck=yon_gtk_builder_get_widget(builder,"userSyncSAMBACheck"); - window->userDeactivatedCheck=yon_gtk_builder_get_widget(builder,"userDeactivatedCheck"); - window->userExtraOptionsEntry=yon_gtk_builder_get_widget(builder,"userExtraOptionsEntry"); - window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); - window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); - window->userTitleNameLabel=yon_gtk_builder_get_widget(builder,"userTitleNameLabel"); - g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); - return window; + + +ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_new(){ + ubl_settings_usergroups_password_window *window = malloc(sizeof(ubl_settings_usergroups_password_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_password); + window->CreateGroupWindow=yon_gtk_builder_get_widget(builder,"CreateGroupWindow"); + window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); + window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); + window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); + g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); +return window; +} + + + +ubl_settings_usergroups_system_window *yon_ubl_settings_usergroups_system_new(){ + ubl_settings_usergroups_system_window *window = malloc(sizeof(ubl_settings_usergroups_system_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_system); + window->liststore1=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + window->liststore2=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore2")); + window->MonitorWindow=yon_gtk_builder_get_widget(builder,"MonitorWindow"); + window->SettingsBar=yon_gtk_builder_get_widget(builder,"SettingsBar"); +return window; } -void on_user_add(GtkWidget *self, main_window *widgets){ - user_window *window = yon_user_window_new(); - g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); +void on_settings_usergroups_system_open(GtkWidget *self, main_window *widgets){ + ubl_settings_usergroups_system_window *window = yon_ubl_settings_usergroups_system_new(); - gtk_window_set_transient_for(GTK_WINDOW(window->CreateUserWindow),GTK_WINDOW(widgets->Window)); - gtk_widget_show(window->CreateUserWindow); + gtk_window_set_transient_for(GTK_WINDOW(window->MonitorWindow),GTK_WINDOW(widgets->Window)); + gtk_widget_show(window->MonitorWindow); } -void on_user_edit(){ + + + + + + +ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){ + ubl_settings_usergroups_user_window *window = malloc(sizeof(ubl_settings_usergroups_user_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_user); + window->CreateUserWindow=yon_gtk_builder_get_widget(builder,"CreateUserWindow"); + window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); + window->userUIDAutoCheck=yon_gtk_builder_get_widget(builder,"userUIDAutoCheck"); + window->userUIDEntry=yon_gtk_builder_get_widget(builder,"userUIDEntry"); + window->userLoginEntry=yon_gtk_builder_get_widget(builder,"userLoginEntry"); + window->userPasswordCombo=yon_gtk_builder_get_widget(builder,"userPasswordCombo"); + window->userPasswordEntry=yon_gtk_builder_get_widget(builder,"userPasswordEntry"); + window->userPasswordButton=yon_gtk_builder_get_widget(builder,"userPasswordButton"); + window->userUserNameEntry=yon_gtk_builder_get_widget(builder,"userUserNameEntry"); + window->userGroupsCheck=yon_gtk_builder_get_widget(builder,"userGroupsCheck"); + window->userGroupsEntry=yon_gtk_builder_get_widget(builder,"userGroupsEntry"); + window->UserGroupsButton=yon_gtk_builder_get_widget(builder,"UserGroupsButton"); + window->userAdditionalGroupsEntry=yon_gtk_builder_get_widget(builder,"userAdditionalGroupsEntry"); + window->userAdditionalGroupsButton=yon_gtk_builder_get_widget(builder,"userAdditionalGroupsButton"); + window->userPasswordChangedEntry=yon_gtk_builder_get_widget(builder,"userPasswordChangedEntry"); + window->userPasswordExpirationEntry=yon_gtk_builder_get_widget(builder,"userPasswordExpirationEntry"); + window->userPasswordExpirationButton=yon_gtk_builder_get_widget(builder,"userPasswordExpirationButton"); + window->userPasswordChangeDelayMinimumSpin=yon_gtk_builder_get_widget(builder,"userPasswordChangeDelayMinimumSpin"); + window->userPasswordChangeDelayMaximumSpin=yon_gtk_builder_get_widget(builder,"userPasswordChangeDelayMaximumSpin"); + window->userWarningSpin=yon_gtk_builder_get_widget(builder,"userWarningSpin"); + window->userActivitySpin=yon_gtk_builder_get_widget(builder,"userActivitySpin"); + window->userForceChangeCheck=yon_gtk_builder_get_widget(builder,"userForceChangeCheck"); + window->userShellCombo=yon_gtk_builder_get_widget(builder,"userShellCombo"); + window->userShellEntry=yon_gtk_builder_get_widget(builder,"userShellEntry"); + window->userHomeCombo=yon_gtk_builder_get_widget(builder,"userHomeCombo"); + window->userHomeEntry=yon_gtk_builder_get_widget(builder,"userHomeEntry"); + window->userHomeButton=yon_gtk_builder_get_widget(builder,"userHomeButton"); + window->userCreateSystemCheck=yon_gtk_builder_get_widget(builder,"userCreateSystemCheck"); + window->userCreateUnuniqueCheck=yon_gtk_builder_get_widget(builder,"userCreateUnuniqueCheck"); + window->userDontCheckCheck=yon_gtk_builder_get_widget(builder,"userDontCheckCheck"); + window->userSyncSAMBACheck=yon_gtk_builder_get_widget(builder,"userSyncSAMBACheck"); + window->userDeactivatedCheck=yon_gtk_builder_get_widget(builder,"userDeactivatedCheck"); + window->userExtraOptionsEntry=yon_gtk_builder_get_widget(builder,"userExtraOptionsEntry"); + window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); + window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); + + g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->userUIDEntry); + g_signal_connect(G_OBJECT(window->userHomeButton),"clicked",G_CALLBACK(on_filechooser_open),window->userHomeEntry); + g_signal_connect(G_OBJECT(window->UserGroupsButton),"clicked",G_CALLBACK(on_groups_clicked),window->userGroupsEntry); + g_signal_connect(G_OBJECT(window->userPasswordButton),"clicked",G_CALLBACK(on_password_change),window->userPasswordEntry); + g_signal_connect(G_OBJECT(window->userAdditionalGroupsButton),"clicked",G_CALLBACK(on_additional_groups_clicked),window->userAdditionalGroupsEntry); + g_signal_connect(G_OBJECT(window->userPasswordExpirationButton),"clicked",G_CALLBACK(on_expiration_clicked),window->userPasswordExpirationEntry); +return window; } -void on_user_delete(){ +void on_main_add(GtkWidget *self, main_window *widgets){ + GtkTreeModel *model; + GtkWidget *cur_tree; + GtkTreeIter iter; + if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))==0){ + model = GTK_TREE_MODEL(widgets->UsersList); + ubl_settings_usergroups_user_window *window = yon_ubl_settings_usergroups_user_new(); + g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + + gtk_window_set_transient_for(GTK_WINDOW(window->CreateUserWindow),GTK_WINDOW(widgets->Window)); + gtk_widget_show(window->CreateUserWindow); + } else { + model = GTK_TREE_MODEL(widgets->GroupsList); + ubl_settings_usergroups_group_creation_window *window = yon_ubl_settings_usergroups_group_creation_new(); + g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + + gtk_window_set_transient_for(GTK_WINDOW(window->CreateGroupWindow),GTK_WINDOW(widgets->Window)); + gtk_widget_show(window->CreateGroupWindow); + } } -void on_def_groups_open(){ +void on_main_edit(GtkWidget *self, main_window *widgets){ + GtkTreeModel *model; + GtkWidget *cur_tree; + GtkTreeIter iter; + if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))==0){ + model = GTK_TREE_MODEL(widgets->UsersList); + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->UsersTree)),&model,&iter)){ + ubl_settings_usergroups_user_window *window = yon_ubl_settings_usergroups_user_new(); + g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + + gtk_window_set_transient_for(GTK_WINDOW(window->CreateUserWindow),GTK_WINDOW(widgets->Window)); + gtk_widget_show(window->CreateUserWindow); + } + } else { + model = GTK_TREE_MODEL(widgets->GroupsList); + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->GroupsTree)),&model,&iter)){ + ubl_settings_usergroups_group_creation_window *window = yon_ubl_settings_usergroups_group_creation_new(); + g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + + gtk_window_set_transient_for(GTK_WINDOW(window->CreateGroupWindow),GTK_WINDOW(widgets->Window)); + gtk_widget_show(window->CreateGroupWindow); + } + } } -// standard functions - -/**config_init() - * [EN] - * - * [RU] - * Функция инициализации всех параметров конфигурации -*/ -void config_init(){ - main_config.always_open_documentation=0; - main_config.socket_id=-1; - main_config.save_socket_id=-1; - main_config.load_socket_id=-1; - main_config.lock_help=0; - main_config.lock_help=0; - main_config.lock_load_global=0; - main_config.lock_save_global=0; - main_config.lock_save_local=0; +void on_main_delete(GtkWidget *self, main_window *widgets){ + GtkTreeModel *model; + GtkWidget *cur_tree; + GtkTreeIter iter; + if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))==0){ + model = GTK_TREE_MODEL(widgets->UsersList); + cur_tree=widgets->UsersTree; + } else { + model = GTK_TREE_MODEL(widgets->GroupsList); + cur_tree=widgets->GroupsTree; + } + if(gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(cur_tree)),&model,&iter)){ + gtk_list_store_remove(GTK_LIST_STORE(model),&iter); + } } -/**yon_main_window_complete(main_window *widgets) - * [EN] - * - * [RU] - * Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом. -*/ -void yon_main_window_complete(main_window *widgets){ - widgets = realloc(widgets,sizeof(main_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"PlugBox"),1,1,0); - widgets->button1 = yon_gtk_builder_get_widget(builder,"button1"); - widgets->button2 = yon_gtk_builder_get_widget(builder,"button2"); - widgets->button3 = yon_gtk_builder_get_widget(builder,"button3"); - widgets->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); - widgets->EditButton = yon_gtk_builder_get_widget(builder,"EditButton"); - widgets->DeleteButton = yon_gtk_builder_get_widget(builder,"DeleteButton"); - widgets->UpdateButton = yon_gtk_builder_get_widget(builder,"UpdateButton"); - widgets->UsersTree = yon_gtk_builder_get_widget(builder,"UsersTree"); - widgets->GroupsTree = yon_gtk_builder_get_widget(builder,"GroupsTree"); - - main_config.usersListStore = GTK_LIST_STORE(gtk_builder_get_object(builder,"UsersList")); + +/**config_init() + * [EN] + * + * [RU] + * Функция инициализации всех параметров конфигурации +*/ +void config_init(){ + main_config.always_open_documentation=0; + main_config.socket_id=-1; + main_config.save_socket_id=-1; + main_config.load_socket_id=-1; + main_config.lock_help=0; + main_config.lock_help=0; + main_config.lock_load_global=0; + main_config.lock_save_global=0; + main_config.lock_save_local=0; +} + +/**yon_main_window_complete(main_window *widgets) + * [EN] + * + * [RU] + * Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом. +*/ +void yon_main_window_complete(main_window *widgets){ + widgets = yon_remalloc(widgets,sizeof(main_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); + gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"PlugBox"),1,1,0); + // Custom widgets configuration + + widgets->CacheAlgList=GTK_LIST_STORE(gtk_builder_get_object(builder,"CacheAlgList")); + widgets->GroupsList=GTK_LIST_STORE(gtk_builder_get_object(builder,"GroupsList")); + widgets->UsersList=GTK_LIST_STORE(gtk_builder_get_object(builder,"UsersList")); + widgets->PlugBox=yon_gtk_builder_get_widget(builder,"PlugBox"); + widgets->button1=yon_gtk_builder_get_widget(builder,"button1"); + widgets->button2=yon_gtk_builder_get_widget(builder,"button2"); + widgets->button3=yon_gtk_builder_get_widget(builder,"button3"); + widgets->AddButton=yon_gtk_builder_get_widget(builder,"AddButton"); + widgets->EditButton=yon_gtk_builder_get_widget(builder,"EditButton"); + widgets->DeleteButton=yon_gtk_builder_get_widget(builder,"DeleteButton"); + widgets->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton"); + widgets->UsersTree=yon_gtk_builder_get_widget(builder,"UsersTree"); + widgets->GroupsTree=yon_gtk_builder_get_widget(builder,"GroupsTree"); + widgets->MainNotebook=yon_gtk_builder_get_widget(builder,"MainNotebook"); + + main_config.usersListStore = GTK_LIST_STORE(gtk_builder_get_object(builder,"UsersList")); main_config.groupsListStore = GTK_LIST_STORE(gtk_builder_get_object(builder,"GroupsList")); @@ -169,96 +327,97 @@ void yon_main_window_complete(main_window *widgets){ } /* Signal connection | Присоединение сигналов */ - g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_user_add),widgets); - g_signal_connect(G_OBJECT(widgets->EditButton),"clicked",G_CALLBACK(on_user_edit),widgets); - g_signal_connect(G_OBJECT(widgets->DeleteButton),"clicked",G_CALLBACK(on_user_delete),widgets); + g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_main_add),widgets); + g_signal_connect(G_OBJECT(widgets->EditButton),"clicked",G_CALLBACK(on_main_edit),widgets); + g_signal_connect(G_OBJECT(widgets->DeleteButton),"clicked",G_CALLBACK(on_main_delete),widgets); g_signal_connect(G_OBJECT(widgets->button3),"clicked",G_CALLBACK(on_standard_groups_open),widgets); - // g_signal_connect(G_OBJECT(widgets->),"clicked",G_CALLBACK(on_def_groups_open),widgets); + g_signal_connect(G_OBJECT(widgets->button2),"clicked",G_CALLBACK(on_ubl_settings_usergroups_additional_settings_open),widgets); + g_signal_connect(G_OBJECT(widgets->button1),"clicked",G_CALLBACK(on_settings_usergroups_system_open),widgets); gtk_widget_show(widgets->Window); -} - -int main(int argc, char *argv[]){ - local=setlocale(LC_ALL, ""); - textdomain (LocaleName); - config_init(); - int option_index=0; - int show_help=0; - int debug_mode=0; - { - struct option long_options[] = { - {"help", 0, 0, 'h'}, - {"version", 0, 0, 'V'}, - {"lock-help", 0,0, 1}, - {"lock-save", 0,0, 2}, - {"lock-save-local", 0,0, 3}, - {"lock-save-global", 0,0, 4}, - {"lock-load-global", 0,0, 5}, - {"socket-id", 1, 0, 's'}, - {"socket-ext-id", 1,0, 'e'}, - {"socket-trd-id", 1,0, 't'}, - {"clear-config", 0,0, 'c'}, - { NULL, 0, NULL, 0 } - }; - for (int i=0;i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../compile/ubl-cmake.h" -#ifdef WEBKIT_FOUND - #include -#endif -#include "ubl-strings.h" - -#define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-usergroups" - -#define _(String) gettext(String) - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../compile/ubl-cmake.h" +#ifdef WEBKIT_FOUND + #include +#endif +#include "ubl-strings.h" + +#define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-usergroups" + +#define _(String) gettext(String) + #define glade_path "/com/ublinux/ui/ubl-settings-usergroups.glade" -#define glade_path_user "/com/ublinux/ui/ubl-settings-usergroups-user.glade" -#define glade_path_groups "/com/ublinux/ui/ubl-settings-usergroups-group.glade" -#define glade_path_additional "/com/ublinux/ui/ubl-settings-usergroups-additional-settings.glade" -#define glade_path_group_creation "/com/ublinux/ui/ubl-settings-usergroups-group-creation.glade" -#define glade_path_password "/com/ublinux/ui/ubl-settings-usergroups-password.glade" -#define glade_path_system "/com/ublinux/ui/ubl-settings-usergroups-system.glade" +#define glade_path_ubl_settings_usergroups_additional_settings "/com/ublinux/ui/ubl-settings-usergroups-additional-settings.glade" +#define glade_path_ubl_settings_usergroups_group_creation "/com/ublinux/ui/ubl-settings-usergroups-group-creation.glade" +#define glade_path_ubl_settings_usergroups_group "/com/ublinux/ui/ubl-settings-usergroups-group.glade" +#define glade_path_ubl_settings_usergroups_password "/com/ublinux/ui/ubl-settings-usergroups-password.glade" +#define glade_path_ubl_settings_usergroups_system "/com/ublinux/ui/ubl-settings-usergroups-system.glade" +#define glade_path_ubl_settings_usergroups_user "/com/ublinux/ui/ubl-settings-usergroups-user.glade" + #define banner_path "/com/ublinux/images/ubl-settings-usergroups-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-usergroups.css" -#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) - -#define LocalePath "/usr/share/locale" -#define LocaleName "ubl-settings-usergroups" - -#define clear_config_both_command "ubconfig remove TEMP_SECTION TEMP_PATAMETER" -#define clear_config_global_command "ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER" -#define clear_config_local_command "ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER" - -#define yon_col(mean) yon_char_append(mean,":") - -#define LocalePath "/usr/share/locale" -#define LocaleName "ubl-settings-usergroups" -typedef char* string; +#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) + +#define LocalePath "/usr/share/locale" +#define LocaleName "ubl-settings-usergroups" + +#define clear_config_both_command "ubconfig remove TEMP_SECTION TEMP_PATAMETER" +#define clear_config_global_command "ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER" +#define clear_config_local_command "ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER" + +typedef char* string; string version_application; - -char *local; - -typedef struct { -// Standard config. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_config STRUCT { - int socket_id; - int load_socket_id; - int save_socket_id; - - int lock_help; - int lock_save_local; - int lock_save_global; - int lock_load_global; - - int always_open_documentation; -// } Standard config. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_config STRUCT -// Type custom parameters below: + +char *local; + +typedef struct { +// Standard config. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_config STRUCT { + int socket_id; + int load_socket_id; + int save_socket_id; + + int lock_help; + int lock_save_local; + int lock_save_global; + int lock_load_global; + + int always_open_documentation; +// } Standard config. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_config STRUCT +// Type custom parameters below: : GtkListStore *usersListStore; GtkListStore *groupsListStore; - } config; - -typedef struct { - // Standard widgets. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_main_window STRUCT { - GtkWidget *Window; - GtkWidget *HeadLabel; - GtkWidget *PlugBox; - - GtkWidget *HeadOverlay; - GtkWidget *HeadImage; - GtkWidget *HeadBox; - GtkWidget *HeadTitleLabel; - GtkWidget *HeadInfoLabel; - - GtkWidget *StatusBox; - GtkWidget *StatusIcon; - GtkWidget *StatusLabel; - - GtkWidget *SaveMenuItem; - GtkWidget *SaveGlobalMenuItem; - GtkWidget *SaveLocalMenuItem; - GtkWidget *RightBox; - - GtkWidget *LoadGlobalMenuItem; - GtkWidget *LoadLocalMenuItem; - GtkWidget *LeftBox; - - GtkWidget *DocumentationMenuItem; - GtkWidget *AboutMenuItem; - - GtkWidget *InterfaceBox; -// } Standard widgets. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_main_window STRUCT -// Type custom parameters below: - GtkWidget *button1; - GtkWidget *button2; - GtkWidget *button3; - GtkWidget *AddButton; - GtkWidget *EditButton; - GtkWidget *DeleteButton; - GtkWidget *UpdateButton; - - GtkWidget *UsersTree; - GtkWidget *GroupsTree; - -} main_window; - -typedef struct { - GtkWidget *Window; - - GtkWidget *HatText; - GtkWidget *HeaderText; - GtkWidget *InfoText; - GtkWidget *AlwaysOpenCheck; - - GtkWidget *CloseButton; - GtkWidget *AcceptButton; -} documentation_confirmation_window; - -typedef struct { -GtkWidget *GroupsWindow; -GtkWidget *GroupsTree; -GtkWidget *GroupsCancelButton; -GtkWidget *GroupsOkButton; -} groups_window; - -typedef struct { -GtkWidget *CreateUserWindow; -GtkWidget *userUIDAutoCheck; -GtkWidget *userUIDEntry; -GtkWidget *userLoginEntry; -GtkWidget *userPasswordCombo; -GtkWidget *userPasswordEntry; -GtkWidget *userPasswordButton; -GtkWidget *userUserNameEntry; -GtkWidget *userGroupsCheck; -GtkWidget *userGroupsEntry; -GtkWidget *UserGroupsButton; -GtkWidget *userCreateHomeFolderCheck; -GtkWidget *userHomeFolderEntry; -GtkWidget *userHomeFolderButton; -GtkWidget *userAdditionalGroupsEntry; -GtkWidget *userAdditionalGroupsButton; -GtkWidget *userPasswordChangedEntry; -GtkWidget *userPasswordExpirationEntry; -GtkWidget *userPasswordExpirationButton; -GtkWidget *userPasswordChangeDelayMinimumSpin; -GtkWidget *userPasswordChangeDelayMaximumSpin; -GtkWidget *userWarningSpin; -GtkWidget *userActivitySpin; -GtkWidget *userForceChangeCheck; -GtkWidget *userShellCombo; -GtkWidget *userShellEntry; -GtkWidget *userHomeCombo; -GtkWidget *userHomeEntry; -GtkWidget *userHomeButton; -GtkWidget *userCreateSystemCheck; -GtkWidget *userCreateUnuniqueCheck; -GtkWidget *userDontCheckCheck; -GtkWidget *userSyncSAMBACheck; -GtkWidget *userDeactivatedCheck; -GtkWidget *userExtraOptionsEntry; -GtkWidget *UserCancelButton; -GtkWidget *UserOkButton; -GtkWidget *userTitleNameLabel; -} user_window; - -typedef struct { -GtkWidget *Window; -GtkWidget *StatusBox; -GtkWidget *DefaultUserNameEntry; -GtkWidget *DefaultUserAdministratorCheck; -GtkWidget *DefaultPasswordCombo; -GtkWidget *DefaultPasswordEntry; -GtkWidget *RootPasswordCombo; -GtkWidget *RootPasswordEntry; -GtkWidget *PasswordHashCombo; -GtkWidget *CancelButton; -GtkWidget *AcceptButton; - -} additional_config_window; - -main_window *setup_window(); \ No newline at end of file + +} config; + +typedef struct { +// Standard widgets. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_main_window STRUCT { + GtkWidget *Window; + GtkWidget *HeadLabel; + GtkWidget *PlugBox; + + GtkWidget *HeadOverlay; + GtkWidget *HeadImage; + GtkWidget *HeadBox; + GtkWidget *HeadTitleLabel; + GtkWidget *HeadInfoLabel; + + GtkWidget *StatusBox; + GtkWidget *StatusIcon; + GtkWidget *StatusLabel; + + GtkWidget *SaveMenuItem; + GtkWidget *SaveGlobalMenuItem; + GtkWidget *SaveLocalMenuItem; + GtkWidget *RightBox; + + GtkWidget *LoadGlobalMenuItem; + GtkWidget *LoadLocalMenuItem; + GtkWidget *LeftBox; + + GtkWidget *DocumentationMenuItem; + GtkWidget *AboutMenuItem; + + GtkWidget *InterfaceBox; +// } Standard widgets. DO NOT EDIT - MUST BE SAME AS ublsettings-ui's template_main_window STRUCT +// Type custom parameters below: + GtkListStore *CacheAlgList; + GtkListStore *GroupsList; + GtkListStore *UsersList; + GtkWidget *button1; + GtkWidget *button2; + GtkWidget *button3; + GtkWidget *AddButton; + GtkWidget *EditButton; + GtkWidget *DeleteButton; + GtkWidget *UpdateButton; + GtkWidget *UsersTree; + GtkWidget *GroupsTree; + GtkWidget *MainNotebook; + +} main_window; + + +typedef struct { + GtkWidget *Window; + + GtkWidget *AlwaysOpenCheck; + + GtkWidget *CloseButton; + GtkWidget *AcceptButton; +} documentation_confirmation_window; + +typedef struct{ + GtkWidget *Window; + GtkWidget *StatusBox; + GtkWidget *DefaultUserNameEntry; + GtkWidget *DefaultUserAdministratorCheck; + GtkWidget *DefaultPasswordCombo; + GtkWidget *DefaultPasswordEntry; + GtkWidget *RootPasswordCombo; + GtkWidget *RootPasswordEntry; + GtkWidget *PasswordHashCombo; + GtkWidget *CancelButton; + GtkWidget *AcceptButton; +} ubl_settings_usergroups_additional_settings_window; + +typedef struct{ + GtkWidget *CreateGroupWindow; + GtkWidget *StatusBox; + GtkWidget *userUIDAutoCheck; + GtkWidget *userUIDEntry; + GtkWidget *userLoginEntry; + GtkWidget *userGroupsEntry; + GtkWidget *UserAdditionalGroupsButton; + GtkWidget *UserCancelButton; + GtkWidget *UserOkButton; +} ubl_settings_usergroups_group_creation_window; + +typedef struct{ + GtkWidget *groupsAdmGroupCheck; + GtkWidget *groupsAudioGroupCheck; + GtkWidget *groupsAutologinGroupCheck; + GtkWidget *groupsAvahiGroupCheck; + GtkWidget *groupsBinGroupCheck; + GtkWidget *groupsBrlapiGroupCheck; + GtkWidget *groupsBrittyGroupCheck; + GtkWidget *groupsBumblbeeGroupCheck; + GtkWidget *groupsChronyGroupCheck; + GtkWidget *groupsClamavGroupCheck; + GtkWidget *groupsCockpitWsGroupCheck; + GtkWidget *groupsCockpitWsinstanceGroupCheck; + GtkWidget *groupsColordGroupCheck; + GtkWidget *GroupsWindow; + GtkWidget *GroupsTree; + GtkWidget *GroupsCancelButton; + GtkWidget *GroupsOkButton; +} ubl_settings_usergroups_group_window; + +typedef struct{ + GtkWidget *CreateGroupWindow; + GtkWidget *StatusBox; + GtkWidget *UserCancelButton; + GtkWidget *UserOkButton; +} ubl_settings_usergroups_password_window; + +typedef struct{ + GtkListStore *liststore1; + GtkListStore *liststore2; + GtkWidget *MonitorWindow; + GtkWidget *SettingsBar; +} ubl_settings_usergroups_system_window; + +typedef struct{ + GtkWidget *CreateUserWindow; + GtkWidget *StatusBox; + GtkWidget *userUIDAutoCheck; + GtkWidget *userUIDEntry; + GtkWidget *userLoginEntry; + GtkWidget *userPasswordCombo; + GtkWidget *userPasswordEntry; + GtkWidget *userPasswordButton; + GtkWidget *userUserNameEntry; + GtkWidget *userGroupsCheck; + GtkWidget *userGroupsEntry; + GtkWidget *UserGroupsButton; + GtkWidget *userAdditionalGroupsEntry; + GtkWidget *userAdditionalGroupsButton; + GtkWidget *userPasswordChangedEntry; + GtkWidget *userPasswordExpirationEntry; + GtkWidget *userPasswordExpirationButton; + GtkWidget *userPasswordChangeDelayMinimumSpin; + GtkWidget *userPasswordChangeDelayMaximumSpin; + GtkWidget *userWarningSpin; + GtkWidget *userActivitySpin; + GtkWidget *userForceChangeCheck; + GtkWidget *userShellCombo; + GtkWidget *userShellEntry; + GtkWidget *userHomeCombo; + GtkWidget *userHomeEntry; + GtkWidget *userHomeButton; + GtkWidget *userCreateSystemCheck; + GtkWidget *userCreateUnuniqueCheck; + GtkWidget *userDontCheckCheck; + GtkWidget *userSyncSAMBACheck; + GtkWidget *userDeactivatedCheck; + GtkWidget *userExtraOptionsEntry; + GtkWidget *UserCancelButton; + GtkWidget *UserOkButton; +} ubl_settings_usergroups_user_window; + + diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index 53e190c..d5a324f 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -72,6 +72,7 @@ True True + com.ublinux.ubl-settings-usergroups.profile-symbolic True @@ -130,6 +131,7 @@ True False + 0 Default No password required @@ -138,7 +140,7 @@ - True + False True 1 @@ -149,7 +151,9 @@ True 30 False - + * + com.ublinux.ubl-settings-usergroups.key-symbolic + ******** password @@ -187,6 +191,7 @@ True False + 0 Default No password required @@ -195,7 +200,7 @@ - True + False True 1 @@ -206,7 +211,9 @@ True 30 False - + * + com.ublinux.ubl-settings-usergroups.key-symbolic + ******** password diff --git a/ubl-settings-usergroups-group-creation.glade b/ubl-settings-usergroups-group-creation.glade index e3d234c..b078dda 100644 --- a/ubl-settings-usergroups-group-creation.glade +++ b/ubl-settings-usergroups-group-creation.glade @@ -1,16 +1,17 @@ - + + True False - avatar-default-symbolic + com.ublinux.ubl-settings-usergroups.profile-settings-symbolic True False - gtk-missing-image + com.ublinux.ubl-settings-usergroups.edit-symbolic True @@ -32,6 +33,7 @@ True False + 5 vertical 5 @@ -131,6 +133,7 @@ True True + com.ublinux.ubl-settings-usergroups.profile-symbolic login @@ -212,8 +215,6 @@ end 5 5 - 5 - 5 5 True @@ -270,7 +271,9 @@ True False - 12 + 5 + 5 + 5 True @@ -279,7 +282,7 @@ 5 - Allow creation of groups with ununique GID + Create group with ununique GID True True False @@ -326,9 +329,16 @@ True False + 0 + + Default + No password required + Set a password + Encrypted password + - False + True True 1 @@ -337,9 +347,13 @@ True True + False + * + com.ublinux.ubl-settings-usergroups.key-symbolic + ******** - False + True True 2 @@ -350,6 +364,9 @@ True True image2 + False @@ -372,14 +389,14 @@ True False - Additional settings + Additional configuration False True - 2 + 3 @@ -388,6 +405,7 @@ True False + True True diff --git a/ubl-settings-usergroups-group.glade b/ubl-settings-usergroups-group.glade index 60e8937..c9dd9a1 100644 --- a/ubl-settings-usergroups-group.glade +++ b/ubl-settings-usergroups-group.glade @@ -2,6 +2,7 @@ + True False @@ -217,7 +218,7 @@ 5 5 vertical - 10 + 5 True diff --git a/ubl-settings-usergroups-password.glade b/ubl-settings-usergroups-password.glade index 666a39c..48ad22c 100644 --- a/ubl-settings-usergroups-password.glade +++ b/ubl-settings-usergroups-password.glade @@ -1,21 +1,32 @@ - + + True False - gtk-missing-image + com.ublinux.ubl-settings-usergroups.view-symbolic True False - gtk-missing-image + com.ublinux.ubl-settings-usergroups.view-symbolic True False - gtk-missing-image + com.ublinux.ubl-settings-usergroups.view-symbolic + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic False @@ -27,6 +38,7 @@ True False + 5 vertical 5 @@ -51,10 +63,7 @@ end 5 5 - 5 5 - 5 - 5 5 True @@ -103,6 +112,8 @@ True False + 5 + 5 vertical 5 @@ -127,6 +138,10 @@ True True + False + * + com.ublinux.ubl-settings-usergroups.key-symbolic + ******** True @@ -140,6 +155,9 @@ True True image3 + False @@ -176,6 +194,10 @@ True True + False + * + com.ublinux.ubl-settings-usergroups.key-symbolic + ******** True @@ -189,6 +211,9 @@ True True image1 + False @@ -249,6 +274,9 @@ True True image2 + False @@ -265,7 +293,7 @@ - True + False True 2 @@ -297,14 +325,4 @@ - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - diff --git a/ubl-settings-usergroups-system.glade b/ubl-settings-usergroups-system.glade index 9936330..0403f40 100644 --- a/ubl-settings-usergroups-system.glade +++ b/ubl-settings-usergroups-system.glade @@ -1,20 +1,21 @@ - + + True False - gtk-missing-image + com.ublinux.ubl-settings-usergroups.funnel-symbolic True False - gtk-missing-image + com.ublinux.ubl-settings-usergroups.sync-symbolic - + 800 600 False diff --git a/ubl-settings-usergroups-user.glade b/ubl-settings-usergroups-user.glade index 1b04071..fc66ccf 100644 --- a/ubl-settings-usergroups-user.glade +++ b/ubl-settings-usergroups-user.glade @@ -159,6 +159,7 @@ True True + com.ublinux.ubl-settings-usergroups.profile-symbolic login @@ -196,8 +197,12 @@ True False + 0 Default + No password required + Set a password + Encrypted password @@ -212,6 +217,7 @@ True False * + com.ublinux.ubl-settings-usergroups.key-symbolic False False ****** diff --git a/ubl-settings-usergroups.glade b/ubl-settings-usergroups.glade index 75af7f9..c7b056e 100644 --- a/ubl-settings-usergroups.glade +++ b/ubl-settings-usergroups.glade @@ -264,7 +264,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True True -- 2.35.1 From aa2930608d2ba2ec5653aef9132fdb236f35444f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 7 Dec 2023 12:50:07 +0600 Subject: [PATCH 7/8] Version 1 without localisation --- README.md | 2 +- source/ubl-settings-usergroups.c | 36 +++++++++++++++++-- source/ubl-settings-usergroups.h | 23 ++++++++++++ ...tings-usergroups-additional-settings.glade | 1 + ubl-settings-usergroups-group-creation.glade | 14 ++++---- 5 files changed, 66 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f17b7ad..5a8ac35 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ In order to build ubl-ubl-settings-usergroups you will need: - CMake - C compiler - GTK+ 3 & dependencies -- webkit2gtk (optional) +- webkit2gtk - [libublsettings-ui](https://gitea.ublinux.ru/Applications/libublsettings-ui) Once you have all the necessary dependencies, you can use: diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index c9374b7..1843f6e 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -12,18 +12,38 @@ void yon_save_proceed(char *section,YON_CONFIG_TYPE type){ } void on_filechooser_open(GtkWidget *self, GtkEntry *output_target){ + // ubl_settings_usergroups_additional_settings_window *window = yon_ubl_settings_usergroups_additional_settings_new(); + // g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + // gtk_widget_show(window->Window); } void on_groups_clicked(GtkWidget *self, GtkEntry *output_target){ + ubl_settings_usergroups_group_window *window = yon_ubl_settings_usergroups_group_new(); + gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(window->GroupsTree),0),0); + g_signal_connect(G_OBJECT(window->GroupsOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->GroupsWindow); + +} + +void on_groups_multiple_clicked(GtkWidget *self, GtkEntry *output_target){ + ubl_settings_usergroups_group_window *window = yon_ubl_settings_usergroups_group_new(); + g_signal_connect(G_OBJECT(window->GroupsOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->GroupsWindow); } void on_password_change(GtkWidget *self, GtkEntry *output_target){ + ubl_settings_usergroups_password_window *window = yon_ubl_settings_usergroups_password_new(); + g_signal_connect(G_OBJECT(window->UserOkButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->CreateGroupWindow); } -void on_additional_groups_clicked(GtkWidget *self, GtkEntry *output_target){ +void on_additional_settings_clicked(GtkWidget *self, GtkEntry *output_target){ + ubl_settings_usergroups_additional_settings_window *window = yon_ubl_settings_usergroups_additional_settings_new(); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->Window); } @@ -76,6 +96,16 @@ ubl_settings_usergroups_group_creation_window *yon_ubl_settings_usergroups_group window->UserAdditionalGroupsButton=yon_gtk_builder_get_widget(builder,"UserAdditionalGroupsButton"); window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); + window->AdditionalGroupsButton=yon_gtk_builder_get_widget(builder,"AdditionalGroupsButton"); + window->UnuniqueGIDCheck=yon_gtk_builder_get_widget(builder,"UnuniqueGIDCheck"); + window->SystemGroupCheck=yon_gtk_builder_get_widget(builder,"SystemGroupCheck"); + window->PasswordCombo=yon_gtk_builder_get_widget(builder,"PasswordCombo"); + window->PasswordEntry=yon_gtk_builder_get_widget(builder,"PasswordEntry"); + window->ChangePasswordButton=yon_gtk_builder_get_widget(builder,"ChangePasswordButton"); + + g_signal_connect(G_OBJECT(window->UnuniqueGIDCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->userLoginEntry); + g_signal_connect(G_OBJECT(window->AdditionalGroupsButton),"clicked",G_CALLBACK(on_groups_multiple_clicked),window->userGroupsEntry); + g_signal_connect(G_OBJECT(window->ChangePasswordButton),"clicked",G_CALLBACK(on_password_change),window->PasswordEntry); g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); return window; } @@ -102,6 +132,7 @@ ubl_settings_usergroups_group_window *yon_ubl_settings_usergroups_group_new(){ window->GroupsTree=yon_gtk_builder_get_widget(builder,"GroupsTree"); window->GroupsCancelButton=yon_gtk_builder_get_widget(builder,"GroupsCancelButton"); window->GroupsOkButton=yon_gtk_builder_get_widget(builder,"GroupsOkButton"); + g_signal_connect(G_OBJECT(window->GroupsCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); return window; } @@ -191,11 +222,12 @@ ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){ window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); + g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->userUIDEntry); g_signal_connect(G_OBJECT(window->userHomeButton),"clicked",G_CALLBACK(on_filechooser_open),window->userHomeEntry); g_signal_connect(G_OBJECT(window->UserGroupsButton),"clicked",G_CALLBACK(on_groups_clicked),window->userGroupsEntry); g_signal_connect(G_OBJECT(window->userPasswordButton),"clicked",G_CALLBACK(on_password_change),window->userPasswordEntry); - g_signal_connect(G_OBJECT(window->userAdditionalGroupsButton),"clicked",G_CALLBACK(on_additional_groups_clicked),window->userAdditionalGroupsEntry); + g_signal_connect(G_OBJECT(window->userAdditionalGroupsButton),"clicked",G_CALLBACK(on_groups_multiple_clicked),window->userAdditionalGroupsEntry); g_signal_connect(G_OBJECT(window->userPasswordExpirationButton),"clicked",G_CALLBACK(on_expiration_clicked),window->userPasswordExpirationEntry); return window; } diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index e85cc5b..4ee3e97 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -143,6 +143,12 @@ typedef struct{ GtkWidget *UserAdditionalGroupsButton; GtkWidget *UserCancelButton; GtkWidget *UserOkButton; + GtkWidget *AdditionalGroupsButton; + GtkWidget *UnuniqueGIDCheck; + GtkWidget *SystemGroupCheck; + GtkWidget *PasswordCombo; + GtkWidget *PasswordEntry; + GtkWidget *ChangePasswordButton; } ubl_settings_usergroups_group_creation_window; typedef struct{ @@ -218,3 +224,20 @@ typedef struct{ } ubl_settings_usergroups_user_window; +ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new(); + +void on_ubl_settings_usergroups_additional_settings_open(GtkWidget *self, main_window *widgets); + +ubl_settings_usergroups_group_creation_window *yon_ubl_settings_usergroups_group_creation_new(); + +ubl_settings_usergroups_group_window *yon_ubl_settings_usergroups_group_new(); + +void on_standard_groups_open(GtkWidget *self, main_window *widgets); + +ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_new(); + +ubl_settings_usergroups_system_window *yon_ubl_settings_usergroups_system_new(); + +void on_settings_usergroups_system_open(GtkWidget *self, main_window *widgets); + +ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(); \ No newline at end of file diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index d5a324f..3ff73e0 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -17,6 +17,7 @@ 350 False False + True com.ublinux.ubl-settings-usergroups diff --git a/ubl-settings-usergroups-group-creation.glade b/ubl-settings-usergroups-group-creation.glade index b078dda..65f806f 100644 --- a/ubl-settings-usergroups-group-creation.glade +++ b/ubl-settings-usergroups-group-creation.glade @@ -78,7 +78,7 @@ - + Automatically True True @@ -179,7 +179,7 @@ - + True True True @@ -281,7 +281,7 @@ vertical 5 - + Create group with ununique GID True True @@ -295,7 +295,7 @@ - + Create system group True True @@ -326,7 +326,7 @@ - + True False 0 @@ -344,7 +344,7 @@ - + True True False @@ -359,7 +359,7 @@ - + True True True -- 2.35.1 From 973fb80f5f1d5bef6fc2c743fcc36ec1466a37c0 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 7 Dec 2023 15:39:46 +0600 Subject: [PATCH 8/8] Version 1 --- Makefile | 2 + ...bl-settings-usergroups.accept-symbolic.svg | 4 + ...bl-settings-usergroups.cancel-symbolic.svg | 50 ++++ source/ubl-strings.h | 63 ++++- ...tings-usergroups-additional-settings.glade | 3 +- ubl-settings-usergroups-group-creation.glade | 4 +- ubl-settings-usergroups-group.glade | 4 +- ubl-settings-usergroups-password.glade | 4 +- ubl-settings-usergroups-user.glade | 28 ++- ubl-settings-usergroups.pot | 148 +++++------ ubl-settings-usergroups_ru.po | 233 +++++++++--------- 11 files changed, 345 insertions(+), 198 deletions(-) create mode 100644 icons/com.ublinux.ubl-settings-usergroups.accept-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-usergroups.cancel-symbolic.svg diff --git a/Makefile b/Makefile index 6e816e2..435c5d1 100644 --- a/Makefile +++ b/Makefile @@ -136,6 +136,8 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.calendar-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.key-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.funnel-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.accept-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.cancel-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.profile-settings-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy" @if [ -z ${DESTDIR} ]; then \ diff --git a/icons/com.ublinux.ubl-settings-usergroups.accept-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.accept-symbolic.svg new file mode 100644 index 0000000..79e0fdc --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.accept-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/icons/com.ublinux.ubl-settings-usergroups.cancel-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.cancel-symbolic.svg new file mode 100644 index 0000000..c045b0b --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.cancel-symbolic.svg @@ -0,0 +1,50 @@ + + + + + + + + + + diff --git a/source/ubl-strings.h b/source/ubl-strings.h index d3e9e90..cfe1e13 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -25,4 +25,65 @@ #define ADDITIONAL_GROUPS_USER_LABEL _("Additional groups") #define PASSWORD_HASH_USER_LABEL _("Password hash algorythm:") #define SYNC_SAMBA_USER_LABEL _("Sync with SAMBA user") -#define EXTRA_OPTIONS_USER_LABEL _("Extra options:") \ No newline at end of file +#define EXTRA_OPTIONS_USER_LABEL _("Extra options:") +#define CANCEL_LABEL _("Cancel") +#define OK_LABEL _("Ok") + +#define BLOCK_LABEL _("Block") +#define MAIN_GROUP_LABEL _("Main group") +#define ADDITIONAL_PARAMETERS_LABEL _("Additional parameters") +#define PASSWORD_STATUS_LABEL _("Password status") +#define USERS_LABEL _("Users") +#define GID_LABEL _("GID") +#define GROUP_NAME_LABEL _("Group name") +#define GROUPS_USERS_LABEL _("Group users") +#define GROUPS_LABEL _("Groups") + +//ubl-settings-usergroups-additional-settings.glade +#define SET_PASSWORD_LABEL _("Set a password") +#define ENDRYPTED_LABEL _("Endrypted password") +#define MD5_LABEL "md5" +#define YESCRYPT_LABEL "yescrypt" +#define NO_PASSWORD_LABEL _("No password required") +#define SCRYPT_LABEL "scrypt" +#define BF_LABEL "bf" +#define BCRYPT_LABEL "bcrypt" +#define SHA512_LABEL "sha512crypt" +#define SHA256_LABEL "sha256crypt" +#define SUNMD_LABEL "sunmd5" +#define MD5CRYPT_LABEL "md5crypt" +#define BSDICRYPT_LABEL "bsdicrypt" +#define DESCTRYPT_LABEL "desctrypt" +#define NT_LABEL "nt" +#define ACCEPT_LABEL _("Accept") + +//ubl-settings-usergroups-group-creation.glade +#define AUTOMATICALLY_LABEL _("Automatically") +#define LOGIN_GROUP_LABEL _("login") +#define CREATE_GROUP_UNUNIQUE_LABEL _("Create group with ununique GID") +#define CREATE_SYSTEM_GROUP_LABEL _("Create system group") +#define ENCRYPTED_PASSWORD_LABEL _("Encrypted password") +#define ADDITIONAL_CONFIGURATION_LABEL _("Additional configuration") + +//ubl-settings-usergroups-group.glade +#define ADM_LABEL "adm" +#define AUDIO_LABEL "audio" +#define AUTOLIGIN_LABEL "autologin" +#define AVAHI_LABEL "avahi" +#define BIN_LABEL "bin" +#define BRLAPI_LABEL "brlapi" +#define BRITTY_LABEL "britty" +#define BUMBLBEE_LABEL "bumblbee" +#define CHRONY_LABEL "chrony" +#define CLAMAV_LABEL "clamav" +#define COLORD_LABEL "colord" + +//ubl-settings-usergroups-system.glade +#define BLOCKED_LABEL _("Blocked") +#define USERNAME_LABEL _("Username") +#define PRIMARY_GROUP_LABEL _("Primary group") +#define HOME_DIRECTORY_LABEL _("Home directory") +#define GROUP_LABEL _("Group") + +#define GROUP_LABEL _("Group") +#define GROUP_LABEL _("Group") \ No newline at end of file diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index 3ff73e0..d088cc7 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -1,7 +1,8 @@ - + + True False diff --git a/ubl-settings-usergroups-group-creation.glade b/ubl-settings-usergroups-group-creation.glade index 65f806f..3d1a328 100644 --- a/ubl-settings-usergroups-group-creation.glade +++ b/ubl-settings-usergroups-group-creation.glade @@ -16,12 +16,12 @@ True False - process-stop-symbolic + com.ublinux.ubl-settings-usergroups.cancel-symbolic True False - emblem-ok-symbolic + com.ublinux.ubl-settings-usergroups.accept-symbolic False diff --git a/ubl-settings-usergroups-group.glade b/ubl-settings-usergroups-group.glade index c9dd9a1..ee79aea 100644 --- a/ubl-settings-usergroups-group.glade +++ b/ubl-settings-usergroups-group.glade @@ -193,12 +193,12 @@ True False - process-stop-symbolic + com.ublinux.ubl-settings-usergroups.cancel-symbolic True False - emblem-ok-symbolic + com.ublinux.ubl-settings-usergroups.accept-symbolic 250 diff --git a/ubl-settings-usergroups-password.glade b/ubl-settings-usergroups-password.glade index 48ad22c..cbe7be8 100644 --- a/ubl-settings-usergroups-password.glade +++ b/ubl-settings-usergroups-password.glade @@ -21,12 +21,12 @@ True False - process-stop-symbolic + com.ublinux.ubl-settings-usergroups.cancel-symbolic True False - emblem-ok-symbolic + com.ublinux.ubl-settings-usergroups.accept-symbolic False diff --git a/ubl-settings-usergroups-user.glade b/ubl-settings-usergroups-user.glade index fc66ccf..a6c6d20 100644 --- a/ubl-settings-usergroups-user.glade +++ b/ubl-settings-usergroups-user.glade @@ -4,6 +4,26 @@ + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + True False @@ -12,7 +32,7 @@ True False - emblem-ok-symbolic + com.ublinux.ubl-settings-usergroups.accept-symbolic True @@ -37,7 +57,7 @@ True False - process-stop-symbolic + com.ublinux.ubl-settings-usergroups.cancel-symbolic 500 @@ -520,6 +540,7 @@ True True + adjustment1 False @@ -543,6 +564,7 @@ True True + adjustment2 False @@ -590,6 +612,7 @@ True True + adjustment3 False @@ -625,6 +648,7 @@ True True + adjustment4 False diff --git a/ubl-settings-usergroups.pot b/ubl-settings-usergroups.pot index 559f905..7b13235 100644 --- a/ubl-settings-usergroups.pot +++ b/ubl-settings-usergroups.pot @@ -74,177 +74,181 @@ msgid "System users and groups configuration" msgstr "" #: source/ubl-strings.h:7 -msgid "Operation succeeded" +msgid "Default user groups:" msgstr "" #: source/ubl-strings.h:8 -msgid "" -"Warning! Application was launched without root - root-dependent actions are " -"locked" +msgid "Default user name (if there's no another):" +msgstr "" + +#: source/ubl-strings.h:9 +msgid "User with ID 1000 is administrator" msgstr "" #: source/ubl-strings.h:10 -msgid "About" +msgid "Default user password:" msgstr "" #: source/ubl-strings.h:11 -msgid "Documentation" +msgid "Root user password:" msgstr "" -#: source/ubl-strings.h:13 -msgid "Save to local configuration" +#: source/ubl-strings.h:12 source/ubl-strings.h:26 +msgid "Password hash algorythm:" msgstr "" #: source/ubl-strings.h:14 -msgid "Save to global configuration" +msgid "UID" msgstr "" #: source/ubl-strings.h:15 -msgid "Save configuration" +msgid "Login" msgstr "" #: source/ubl-strings.h:16 -msgid "Save" +msgid "Password" msgstr "" -#: source/ubl-strings.h:18 -msgid "Load local configuration" +#: source/ubl-strings.h:17 +msgid "User name" msgstr "" #: source/ubl-strings.h:19 -msgid "Load global configuration" +msgid "UID:" msgstr "" #: source/ubl-strings.h:20 -msgid "Load" +msgid "User name:" +msgstr "" + +#: source/ubl-strings.h:21 +msgid "Login:" msgstr "" #: source/ubl-strings.h:22 -msgid "Cancel" +msgid "Password:" msgstr "" -#: source/ubl-strings.h:24 -msgid "Would you like to read documentation in the Web?" +#: source/ubl-strings.h:23 +msgid "Default" msgstr "" -#: source/ubl-strings.h:25 -msgid "" -"You will be redirected to documentation website where documentation is\n" -"translated and supported by community." +#: source/ubl-strings.h:24 +msgid "Main group:" msgstr "" -#: source/ubl-strings.h:26 -msgid "Always redirect to online documentation" +#: source/ubl-strings.h:25 +msgid "Additional groups" msgstr "" #: source/ubl-strings.h:27 -msgid "Open documentation" +msgid "Sync with SAMBA user" msgstr "" #: source/ubl-strings.h:28 -msgid "Project Home Page" +msgid "Extra options:" msgstr "" #: source/ubl-strings.h:29 -msgid "Nothing were chosen" +msgid "Cancel" +msgstr "" + +#: source/ubl-strings.h:30 +msgid "Ok" msgstr "" #: source/ubl-strings.h:32 -msgid "Global configuration loading succseeded." +msgid "Block" msgstr "" #: source/ubl-strings.h:33 -msgid "Local configuration loading succseeded." +msgid "Main group" msgstr "" #: source/ubl-strings.h:34 -msgid "Config loading failed" +msgid "Additional parameters" +msgstr "" + +#: source/ubl-strings.h:35 +msgid "Password status" msgstr "" #: source/ubl-strings.h:36 -msgid "Local and global configuration saving succseeded." +msgid "Users" msgstr "" #: source/ubl-strings.h:37 -msgid "Global configuration saving succseeded." +msgid "GID" msgstr "" #: source/ubl-strings.h:38 -msgid "Local configuration saving succseeded." -msgstr "" - -#: source/ubl-strings.h:40 -msgid "Default user groups:" +msgid "Group name" msgstr "" -#: source/ubl-strings.h:41 -msgid "Default user name (if there's no another):" +#: source/ubl-strings.h:39 +msgid "Group users" msgstr "" -#: source/ubl-strings.h:42 -msgid "User with ID 1000 is administrator" +#: source/ubl-strings.h:40 +msgid "Groups" msgstr "" #: source/ubl-strings.h:43 -msgid "Default user password:" +msgid "Set a password" msgstr "" #: source/ubl-strings.h:44 -msgid "Root user password:" -msgstr "" - -#: source/ubl-strings.h:45 source/ubl-strings.h:59 -msgid "Password hash algorythm:" +msgid "Endrypted password" msgstr "" #: source/ubl-strings.h:47 -msgid "UID" +msgid "No password required" msgstr "" -#: source/ubl-strings.h:48 -msgid "Login" +#: source/ubl-strings.h:58 +msgid "Accept" msgstr "" -#: source/ubl-strings.h:49 -msgid "Password" +#: source/ubl-strings.h:61 +msgid "Automatically" msgstr "" -#: source/ubl-strings.h:50 -msgid "User name" +#: source/ubl-strings.h:62 +msgid "login" msgstr "" -#: source/ubl-strings.h:52 -msgid "UID:" +#: source/ubl-strings.h:63 +msgid "Create group with ununique GID" msgstr "" -#: source/ubl-strings.h:53 -msgid "User name:" +#: source/ubl-strings.h:64 +msgid "Create system group" msgstr "" -#: source/ubl-strings.h:54 -msgid "Login:" +#: source/ubl-strings.h:65 +msgid "Encrypted password" msgstr "" -#: source/ubl-strings.h:55 -msgid "Password:" +#: source/ubl-strings.h:66 +msgid "Additional configuration" msgstr "" -#: source/ubl-strings.h:56 -msgid "Default" +#: source/ubl-strings.h:82 +msgid "Blocked" msgstr "" -#: source/ubl-strings.h:57 -msgid "Main group:" +#: source/ubl-strings.h:83 +msgid "Username" msgstr "" -#: source/ubl-strings.h:58 -msgid "Additional groups" +#: source/ubl-strings.h:84 +msgid "Primary group" msgstr "" -#: source/ubl-strings.h:60 -msgid "Sync with SAMBA user" +#: source/ubl-strings.h:85 +msgid "Home directory" msgstr "" -#: source/ubl-strings.h:61 -msgid "Extra options:" +#: source/ubl-strings.h:86 source/ubl-strings.h:88 source/ubl-strings.h:89 +msgid "Group" msgstr "" diff --git a/ubl-settings-usergroups_ru.po b/ubl-settings-usergroups_ru.po index 609c4ff..9bae460 100644 --- a/ubl-settings-usergroups_ru.po +++ b/ubl-settings-usergroups_ru.po @@ -77,181 +77,182 @@ msgstr "" "конфигурационный файл)" #: source/ubl-strings.h:7 -msgid "Operation succeeded" -msgstr "Операция завершена" +msgid "Default user groups:" +msgstr "Группы пользователей по умлочанию:" #: source/ubl-strings.h:8 -msgid "" -"Warning! Application was launched without root - root-dependent actions are " -"locked" -msgstr "" -"Внимание! Приложение было запущено без прав суперпользователя - действия, " -"требующие их наличия заблокированы" +msgid "Default user name (if there's no another):" +msgstr "Имя пользователя по умолчанию (если нет других):" + +#: source/ubl-strings.h:9 +msgid "User with ID 1000 is administrator" +msgstr "Пользователь с ID 1000 является администратором" #: source/ubl-strings.h:10 -msgid "About" -msgstr "О программе" +msgid "Default user password:" +msgstr "Пароль для пользователя по умолчанию" #: source/ubl-strings.h:11 -msgid "Documentation" -msgstr "Справка" +msgid "Root user password:" +msgstr "Пароль пользователя root" -#: source/ubl-strings.h:13 -msgid "Save to local configuration" -msgstr "Сохранить в локальную конфигурацию" +#: source/ubl-strings.h:12 source/ubl-strings.h:26 +msgid "Password hash algorythm:" +msgstr "Алгоритм хэширования пароля" #: source/ubl-strings.h:14 -msgid "Save to global configuration" -msgstr "Сохранить в глобальную конфигурацию" +msgid "UID" +msgstr "UID" #: source/ubl-strings.h:15 -msgid "Save configuration" -msgstr "Сохранить конфигурацию" +msgid "Login" +msgstr "Логин" #: source/ubl-strings.h:16 -msgid "Save" -msgstr "Сохранить" +msgid "Password" +msgstr "Пароль" -#: source/ubl-strings.h:18 -msgid "Load local configuration" -msgstr "Загрузить локальную конфигуруцию" +#: source/ubl-strings.h:17 +msgid "User name" +msgstr "Имя пользователя" #: source/ubl-strings.h:19 -msgid "Load global configuration" -msgstr "Загрузить глобальную конфигурацию" +msgid "UID:" +msgstr "UID:" #: source/ubl-strings.h:20 -msgid "Load" -msgstr "Загрузить" +msgid "User name:" +msgstr "Имя пользователя:" + +#: source/ubl-strings.h:21 +msgid "Login:" +msgstr "Логин:" #: source/ubl-strings.h:22 -msgid "Cancel" -msgstr "Отмена" +msgid "Password:" +msgstr "Пароль:" + +#: source/ubl-strings.h:23 +msgid "Default" +msgstr "По умолчанию" #: source/ubl-strings.h:24 -msgid "Would you like to read documentation in the Web?" -msgstr "Вы хотите прочитать справку в Сети?" +msgid "Main group:" +msgstr "Основная группа:" #: source/ubl-strings.h:25 -msgid "" -"You will be redirected to documentation website where documentation is\n" -"translated and supported by community." -msgstr "" -"Вы будете перенаправлены на сайт с документацией где страницы помощи\n" -"переводятся и поддерживаются сообществом." - -#: source/ubl-strings.h:26 -msgid "Always redirect to online documentation" -msgstr "Всегда перенаправлять" +msgid "Additional groups" +msgstr "Дополнительные группы" #: source/ubl-strings.h:27 -msgid "Open documentation" -msgstr "Прочитать справку" +msgid "Sync with SAMBA user" +msgstr "Синхронизировать с пользователем SAMBA" #: source/ubl-strings.h:28 -msgid "Project Home Page" -msgstr "Домашняя страница проекта" +msgid "Extra options:" +msgstr "Дополнительный опции:" #: source/ubl-strings.h:29 -msgid "Nothing were chosen" -msgstr "Ничего не было выбрано" +msgid "Cancel" +msgstr "Отменить" + +#: source/ubl-strings.h:30 +msgid "Ok" +msgstr "Ок" #: source/ubl-strings.h:32 -msgid "Global configuration loading succseeded." -msgstr "Успешно загружена глобальная конфигурация" +msgid "Block" +msgstr "Блок" #: source/ubl-strings.h:33 -msgid "Local configuration loading succseeded." -msgstr "Успешно загружена локальная конфигурация" +msgid "Main group" +msgstr "Основная группа" #: source/ubl-strings.h:34 -msgid "Config loading failed" -msgstr "Ошибка загрузки конфигурации" +msgid "Additional parameters" +msgstr "Дополнительные группы" + +#: source/ubl-strings.h:35 +msgid "Password status" +msgstr "Статус пароля" #: source/ubl-strings.h:36 -msgid "Local and global configuration saving succseeded." -msgstr "Успешно записаны локальная и глобальная конфигурация" +msgid "Users" +msgstr "Пользователи" #: source/ubl-strings.h:37 -msgid "Global configuration saving succseeded." -msgstr "Успешно записана глобальная конфигурация" +msgid "GID" +msgstr "GID" #: source/ubl-strings.h:38 -msgid "Local configuration saving succseeded." -msgstr "Успешно записана локальная конфигурация" +#, fuzzy +msgid "Group name" +msgstr "Имя группы" -#: source/ubl-strings.h:40 -msgid "Default user groups:" -msgstr "Группы пользователей по умлочанию:" +#: source/ubl-strings.h:39 +msgid "Group users" +msgstr "Пользователи группы" -#: source/ubl-strings.h:41 -msgid "Default user name (if there's no another):" -msgstr "Имя пользователя по умолчанию (если нет других):" - -#: source/ubl-strings.h:42 -msgid "User with ID 1000 is administrator" -msgstr "Пользователь с ID 1000 является администратором" +#: source/ubl-strings.h:40 +msgid "Groups" +msgstr "Группы" #: source/ubl-strings.h:43 -msgid "Default user password:" -msgstr "Пароль для пользователя по умолчанию" +msgid "Set a password" +msgstr "Установать пароль" #: source/ubl-strings.h:44 -msgid "Root user password:" -msgstr "Пароль пользователя root" - -#: source/ubl-strings.h:45 source/ubl-strings.h:59 -msgid "Password hash algorythm:" -msgstr "Алгоритм хэширования пароля" +msgid "Endrypted password" +msgstr "Зашифрованный пароль" #: source/ubl-strings.h:47 -msgid "UID" -msgstr "UID" +msgid "No password required" +msgstr "Пароль не требуется" -#: source/ubl-strings.h:48 -msgid "Login" -msgstr "Логин" +#: source/ubl-strings.h:58 +msgid "Accept" +msgstr "Принять" -#: source/ubl-strings.h:49 -msgid "Password" -msgstr "Пароль" +#: source/ubl-strings.h:61 +msgid "Automatically" +msgstr "Автоматически" -#: source/ubl-strings.h:50 -msgid "User name" -msgstr "Имя пользователя" +#: source/ubl-strings.h:62 +msgid "login" +msgstr "логин" -#: source/ubl-strings.h:52 -msgid "UID:" -msgstr "UID:" +#: source/ubl-strings.h:63 +msgid "Create group with ununique GID" +msgstr "Создать группу с повторяющимися (не уникальными) GID" -#: source/ubl-strings.h:53 -msgid "User name:" -msgstr "Имя пользователя:" +#: source/ubl-strings.h:64 +msgid "Create system group" +msgstr "Создать системную группу" -#: source/ubl-strings.h:54 -msgid "Login:" -msgstr "Логин:" +#: source/ubl-strings.h:65 +msgid "Encrypted password" +msgstr "Зашифрованный пароль" -#: source/ubl-strings.h:55 -msgid "Password:" -msgstr "Пароль:" +#: source/ubl-strings.h:66 +msgid "Additional configuration" +msgstr "Загрузить локальную конфигуруцию" -#: source/ubl-strings.h:56 -msgid "Default" -msgstr "По умолчанию" +#: source/ubl-strings.h:82 +msgid "Blocked" +msgstr "Заблокировано" -#: source/ubl-strings.h:57 -msgid "Main group:" -msgstr "Основная группа:" +#: source/ubl-strings.h:83 +msgid "Username" +msgstr "Имя пользователя" -#: source/ubl-strings.h:58 -msgid "Additional groups" -msgstr "Дополнительные группы" +#: source/ubl-strings.h:84 +msgid "Primary group" +msgstr "Основная группа" -#: source/ubl-strings.h:60 -msgid "Sync with SAMBA user" -msgstr "Синхронизировать с пользователем SAMBA" +#: source/ubl-strings.h:85 +msgid "Home directory" +msgstr "Домашний каталог" -#: source/ubl-strings.h:61 -msgid "Extra options:" -msgstr "Дополнительный опции:" +#: source/ubl-strings.h:86 source/ubl-strings.h:88 source/ubl-strings.h:89 +msgid "Group" +msgstr "Группа" -- 2.35.1