diff --git a/libublsettingsui-gtk3-saving.glade b/libublsettingsui-gtk3-saving.glade index eaa648b..b1b7b1e 100644 --- a/libublsettingsui-gtk3-saving.glade +++ b/libublsettingsui-gtk3-saving.glade @@ -42,6 +42,8 @@ + + @@ -128,6 +130,7 @@ + False True fixed Old value @@ -145,6 +148,7 @@ + False autosize New value @@ -159,6 +163,18 @@ + + + Value +(Old/New) + + + + 7 + + + + diff --git a/libublsettingsui-gtk3.glade b/libublsettingsui-gtk3.glade index 388c719..83bdb4f 100644 --- a/libublsettingsui-gtk3.glade +++ b/libublsettingsui-gtk3.glade @@ -153,6 +153,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True @@ -197,6 +200,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + 800 diff --git a/libublsettingsui-gtk3.pot b/libublsettingsui-gtk3.pot index 5eb71ac..fbdcbf5 100644 --- a/libublsettingsui-gtk3.pot +++ b/libublsettingsui-gtk3.pot @@ -97,62 +97,88 @@ msgstr "" msgid "Nothing were chosen" msgstr "" -#: source/libublsettingsui-gtk3.h:57 -msgid "Global configuration loading succeeded." +#: source/libublsettingsui-gtk3.h:55 +msgid "Copyright © 2022 - 2023, UBSoft LLC" msgstr "" #: source/libublsettingsui-gtk3.h:58 -msgid "Local configuration loading succeeded." +msgid "Global configuration loading succeeded." msgstr "" #: source/libublsettingsui-gtk3.h:59 +msgid "Local configuration loading succeeded." +msgstr "" + +#: source/libublsettingsui-gtk3.h:60 msgid "Config loading failed" msgstr "" -#: source/libublsettingsui-gtk3.h:61 +#: source/libublsettingsui-gtk3.h:62 msgid "Local and global configuration saving succeeded." msgstr "" -#: source/libublsettingsui-gtk3.h:62 +#: source/libublsettingsui-gtk3.h:63 msgid "Global configuration saving succeeded." msgstr "" -#: source/libublsettingsui-gtk3.h:63 +#: source/libublsettingsui-gtk3.h:64 msgid "Local configuration saving succeeded." msgstr "" -#: source/libublsettingsui-gtk3.h:65 +#: source/libublsettingsui-gtk3.h:66 msgid "Parameter" msgstr "" -#: source/libublsettingsui-gtk3.h:66 +#: source/libublsettingsui-gtk3.h:67 msgid "Old value" msgstr "" -#: source/libublsettingsui-gtk3.h:67 +#: source/libublsettingsui-gtk3.h:68 msgid "New value" msgstr "" +#: source/libublsettingsui-gtk3.h:69 +msgid "" +"Value\n" +"(Old/New)" +msgstr "" + +#: source/libublsettingsui-gtk3.h:71 +msgid "Nothing to save" +msgstr "" + #: source/libublsettingsui-gtk3.h:72 -msgid "Full saving mode" +msgid "Saving into local configuration" msgstr "" #: source/libublsettingsui-gtk3.h:73 -msgid "Saving into module" +msgid "Saving into global configuration" msgstr "" #: source/libublsettingsui-gtk3.h:74 +msgid "Saving into global and local configuration" +msgstr "" + +#: source/libublsettingsui-gtk3.h:79 +msgid "Full saving mode" +msgstr "" + +#: source/libublsettingsui-gtk3.h:80 +msgid "Saving into module" +msgstr "" + +#: source/libublsettingsui-gtk3.h:81 msgid "Sandbox mode" msgstr "" -#: source/libublsettingsui-gtk3.h:75 +#: source/libublsettingsui-gtk3.h:82 msgid "Sandbox with profile saving" msgstr "" -#: source/libublsettingsui-gtk3.h:76 +#: source/libublsettingsui-gtk3.h:83 msgid "HDD sandbox" msgstr "" -#: source/libublsettingsui-gtk3.h:77 +#: source/libublsettingsui-gtk3.h:84 msgid "HDD sandbox with profile saving" msgstr "" diff --git a/libublsettingsui-gtk3_ru.po b/libublsettingsui-gtk3_ru.po index b21f321..95e1f03 100644 --- a/libublsettingsui-gtk3_ru.po +++ b/libublsettingsui-gtk3_ru.po @@ -101,62 +101,90 @@ msgstr "Домашняя страница проекта" msgid "Nothing were chosen" msgstr "Ничего не было выбрано" -#: source/libublsettingsui-gtk3.h:57 +#: source/libublsettingsui-gtk3.h:55 +msgid "Copyright © 2022 - 2023, UBSoft LLC" +msgstr "Copyright © 2022 - 2023, ООО «Юбисофт»" + +#: source/libublsettingsui-gtk3.h:58 msgid "Global configuration loading succeeded." msgstr "Успешно загружена глобальная конфигурация" -#: source/libublsettingsui-gtk3.h:58 +#: source/libublsettingsui-gtk3.h:59 msgid "Local configuration loading succeeded." msgstr "Успешно загружена локальная конфигурация" -#: source/libublsettingsui-gtk3.h:59 +#: source/libublsettingsui-gtk3.h:60 msgid "Config loading failed" msgstr "Ошибка загрузки конфига" -#: source/libublsettingsui-gtk3.h:61 +#: source/libublsettingsui-gtk3.h:62 msgid "Local and global configuration saving succeeded." msgstr "Успешно записаны локальная и глобальная конфигурация" -#: source/libublsettingsui-gtk3.h:62 +#: source/libublsettingsui-gtk3.h:63 msgid "Global configuration saving succeeded." msgstr "Успешно записана глобальная конфигурация" -#: source/libublsettingsui-gtk3.h:63 +#: source/libublsettingsui-gtk3.h:64 msgid "Local configuration saving succeeded." msgstr "Успешно записана локальная конфигурация" -#: source/libublsettingsui-gtk3.h:65 +#: source/libublsettingsui-gtk3.h:66 msgid "Parameter" msgstr "Параметр" -#: source/libublsettingsui-gtk3.h:66 +#: source/libublsettingsui-gtk3.h:67 msgid "Old value" msgstr "Старое значение" -#: source/libublsettingsui-gtk3.h:67 +#: source/libublsettingsui-gtk3.h:68 msgid "New value" msgstr "Новое значение" +#: source/libublsettingsui-gtk3.h:69 +msgid "" +"Value\n" +"(Old/New)" +msgstr "" +"Значение\n" +"(Старое/Новое)" + +#: source/libublsettingsui-gtk3.h:71 +msgid "Nothing to save" +msgstr "Нечего сохранять" + #: source/libublsettingsui-gtk3.h:72 +msgid "Saving into local configuration" +msgstr "Сохранение в локальный конфигурационный файл" + +#: source/libublsettingsui-gtk3.h:73 +msgid "Saving into global configuration" +msgstr "Сохранение в глобальный конфигурационный файл" + +#: source/libublsettingsui-gtk3.h:74 +msgid "Saving into global and local configuration" +msgstr "Сохранение в глобальный и локальный конфигурационный файл" + +#: source/libublsettingsui-gtk3.h:79 msgid "Full saving mode" msgstr "Полное сохранение" -#: source/libublsettingsui-gtk3.h:73 +#: source/libublsettingsui-gtk3.h:80 msgid "Saving into module" msgstr "Сохранение в модуль" -#: source/libublsettingsui-gtk3.h:74 +#: source/libublsettingsui-gtk3.h:81 msgid "Sandbox mode" msgstr "Полная песочница в ОЗУ" -#: source/libublsettingsui-gtk3.h:75 +#: source/libublsettingsui-gtk3.h:82 msgid "Sandbox with profile saving" msgstr "Песочница с сохранением профиля пользователя" -#: source/libublsettingsui-gtk3.h:76 +#: source/libublsettingsui-gtk3.h:83 msgid "HDD sandbox" msgstr "Полная песочница на HDD" -#: source/libublsettingsui-gtk3.h:77 +#: source/libublsettingsui-gtk3.h:84 msgid "HDD sandbox with profile saving" msgstr "Полная песочница на HDD с сохранением профиля пользователя" diff --git a/source/libublsettingsui-gtk3.c b/source/libublsettingsui-gtk3.c index 17e4952..a4bc63e 100644 --- a/source/libublsettingsui-gtk3.c +++ b/source/libublsettingsui-gtk3.c @@ -212,19 +212,6 @@ void on_save_parameters(GtkWidget *self, template_saving_window *window){ on_subwindow_close(self); } -// void on_column_resize(GtkTreeVieolumn *self,GParamSpec *pspec,GtkCellRenderer *renderer){ -// GtkWidget *tree = gtk_tree_view_column_get_tree_view(self); -// GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree)); -// // g_object_ref(model); -// // gtk_tree_view_set_model(GTK_TREE_VIEW(tree),NULL); -// int width = gtk_tree_view_column_get_width(self); -// GValue *val=g_malloc0(sizeof(GValue)); -// g_object_get_property(G_OBJECT(renderer),"wrap-width",val); -// g_value_set_int(val,width); -// g_object_set_property(G_OBJECT(renderer),"wrap-width",val); -// gtk_tree_view_set_model(GTK_TREE_VIEW(tree),model);wC -// } - template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ if (((type==YON_CONFIG_LOCAL&& template_config->load_mode==1)||(type==YON_CONFIG_GLOBAL&& template_config->load_mode==0))){ yon_config_save_registered(path); @@ -279,18 +266,23 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ if (!yon_char_is_empty(str)&& strcmp(str,"(null)\n")!=0) { char *final_str = yon_char_new(str); - char *key =yon_char_divide_search(final_str,"=",-1); - if (final_str[strlen(final_str)-1]=='\n')final_str[strlen(final_str)-1]='\0'; + char *key = yon_char_divide_search(final_str,"=",-1); + final_str=yon_char_divide_search(final_str,"\n",-1); + if ((final_str[0]=='\''&&final_str[strlen(final_str)-1]=='\'')||(final_str[0]=='\"'&&final_str[strlen(final_str)-1]=='\"')){ + final_str[strlen(final_str)-1] = '\0'; + free(yon_char_divide(final_str,0)); + } + char *str_copy = yon_char_unite(key,"=",final_str,NULL); dictionary *found=NULL; if (!(found=yon_dictionary_get(&loaded.dict,key))){ yon_dictionary_add_or_create_if_exists_with_data(loaded.dict,NULL,yon_char_new(dct->key)); yon_dictionary_add_or_create_if_exists_with_data(loaded.dict,key,yon_char_new(final_str)); - yon_char_parsed_add_or_create_if_exists(config_compare,&compare_size,yon_char_new(str)); + yon_char_parsed_add_or_create_if_exists(config_compare,&compare_size,yon_char_new(str_copy)); } else{ int element = yon_char_parsed_check_exist(config_compare,compare_size,(char*)loaded.dict->data); if (element>-1){ free(config_compare[element]); - config_compare[element]=yon_char_new(str); + config_compare[element]=yon_char_new(str_copy); loaded.dict->data = yon_char_new(final_str); } } @@ -312,6 +304,17 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ window->OldValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"OldValueCell")); window->NewValueColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"NewValueColumn")); window->NewValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"NewValueCell")); + textdomain(template_ui_LocaleName); + if (type==YON_CONFIG_BOTH){ + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_GLOBAL_LOCAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + } else if (type==YON_CONFIG_GLOBAL){ + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_GLOBAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + + } else if (type==YON_CONFIG_LOCAL){ + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_LOCAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + + } + textdomain(template_app_information.app_locale); window->type=type; window->filteredModel = GTK_TREE_MODEL(gtk_builder_get_object(builder,"listfilter1")); gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(window->filteredModel),5); @@ -375,7 +378,9 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,1,&name,2,&value,-1); if (!yon_char_is_empty(name)&&!strcmp(name,config_keys[i])){ if (!yon_config_check_ignore(name)){ - gtk_list_store_set(window->list,&iter,3,compare_value,4,NULL,6,section,-1); + char *combined = yon_char_unite("",value,"\n",compare_value,NULL); + gtk_list_store_set(window->list,&iter,3,compare_value,4,NULL,6,section,7,combined,-1); + free(combined); if ((value&&!strcmp(value,compare_value))){ //||yon_char_is_empty(compare_value) gtk_list_store_set(window->list,&iter,0,0,3,value,5,0,-1); } else { @@ -390,14 +395,22 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ if (!yon_config_check_ignore(compare_name)&&!yon_char_is_empty(compare_value)){ GtkTreeIter itar; gtk_list_store_append(window->list,&itar); - gtk_list_store_set(window->list,&itar,0,1,1,compare_name,3,compare_value,5,1,6,section,-1); + char *combined = yon_char_append("\n",compare_value); + gtk_list_store_set(window->list,&itar,0,1,1,compare_name,3,compare_value,5,1,6,section,7,combined,-1); + free(combined); } } free(compare_value); free(compare_name); } free(rgba_string); - + if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->filteredModel),&iter)){ + gtk_widget_destroy(window->Window); + textdomain(template_ui_LocaleName); + yon_ubl_status_box_render(NOTHING_TO_SAVE_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + textdomain(template_app_information.app_locale); + return NULL; + } gtk_tree_view_set_model(GTK_TREE_VIEW(window->ParametersTree),window->filteredModel); } @@ -410,7 +423,9 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ } int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data){ + textdomain(template_ui_LocaleName); GtkWidget *dialog = gtk_dialog_new_with_buttons(template_app_information.app_title,GTK_WINDOW(gtk_widget_get_toplevel(self)),GTK_DIALOG_USE_HEADER_BAR,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL); + textdomain(template_app_information.app_locale); gtk_window_set_modal(GTK_WINDOW(dialog),1); gtk_window_set_icon_name(GTK_WINDOW(dialog),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); gtk_window_set_title(GTK_WINDOW(dialog),template_app_information.app_title); @@ -443,6 +458,7 @@ int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data) gtk_widget_set_margin_top(image,20); GtkWidget *label = gtk_label_new(data->action_text); + gtk_widget_set_margin_end(label,20); gtk_widget_show(label); GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); @@ -505,6 +521,22 @@ template_main_window *setup_window(){ widgets->DocumentationMenuItem = yon_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL); widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL); + + + if (template_config->lock_load_global == 1){ + gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); + } + if (template_config->lock_save_global == 1){ + gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); + } + if (template_config->lock_save_local == 1){ + gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); + } + if (template_config->lock_load_system == 1){ + gtk_widget_set_sensitive(widgets->LoadLocalMenuItem,0); + } gtk_window_set_icon_name(GTK_WINDOW(widgets->Window),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); gtk_image_set_from_pixbuf(GTK_IMAGE(HeadImage),gtk_icon_theme_load_icon_for_scale(gtk_icon_theme_get_default(),yon_char_append("com.ublinux.",template_app_information.app_tech_name),32,1,GTK_ICON_LOOKUP_FORCE_SIZE,NULL)); @@ -571,6 +603,91 @@ int yon_ubl_window_init(char *app_title, char *app_description, char *locale, ch template_app_information.app_locale=locale; } +int yon_ubl_setup_arguments(int argc, char *argv[],config_str *unfound_arguments, int *arguments_size, char *additional_options_output){ + (*arguments_size)=0; + 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}, + {"lock-load-local", 0,0, 6}, + {"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 } + }; + config_str unregistered_arguments=NULL; + for (int i=1;isocket_id=atoi(optarg); + break; + case 'e': + if(optarg) + template_config->save_socket_id=atoi(optarg); + break; + case 't': + if(optarg) + template_config->load_socket_id=atoi(optarg); + break; + case 'c': if (system(remove_config_dir_command)){}; + break; + case 1: + template_config->lock_help=1; + break; + case 2: + template_config->lock_save_local=1; + template_config->lock_save_global=1; + break; + case 3: + template_config->lock_save_local=1; + break; + case 4: + template_config->lock_save_global=1; + break; + case 5: + template_config->lock_load_global=1; + break; + case 6: + template_config->lock_load_system=1; + break; + default: + char *unfound = optarg; + yon_char_parsed_add_or_create_if_exists(unregistered_arguments,arguments_size,yon_char_unite(argv[i],!yon_char_is_empty(unfound)?"=":"",!yon_char_is_empty(unfound)?unfound:"",NULL)); + } + } + (*unfound_arguments)=unregistered_arguments; + if (show_help&&!template_config->lock_help){ + printf("%s\n",HELP_LABEL(additional_options_output)); + exit(0); + } + } + + if (getuid()!=0){ + template_config->lock_load_global=1; + template_config->lock_save_global=1; + template_config->lock_save_local=1; + } +} + template_main_window *yon_ubl_window_setup(){ textdomain (template_ui_LocaleName); setlocale(LC_ALL,""); diff --git a/source/libublsettingsui-gtk3.h b/source/libublsettingsui-gtk3.h index 8c6320b..86b8f45 100644 --- a/source/libublsettingsui-gtk3.h +++ b/source/libublsettingsui-gtk3.h @@ -24,7 +24,12 @@ #define ui_CssPath "/com/ublinux/css/libublsettingsui-gtk3.css" #define ui_config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",template_app_information.app_tech_name,"/",template_app_information.app_tech_name,".conf",NULL) +#define remove_config_dir_command yon_char_unite("rm -rfd ", yon_ubl_user_get_home_directory(),"/.config/",template_app_information.app_tech_name,"/",NULL) + #ifndef UBL_UI + #define VERSION_LABEL yon_char_unite(_("Version:")," ",!yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",NULL) + #define HELP_LABEL(rest) yon_char_unite(template_app_information.app_tech_name,_(" version:")," ", !yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",template_app_information.app_title,"\n",_("Usage:"), " ",template_app_information.app_tech_name," ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n\t--clear-config\t\t\t",_("Reset application settings"),"\n",!yon_char_is_empty(rest)?rest:NULL,NULL) + #define template_ui_LocalePath "/usr/share/locale" #define template_ui_LocaleName "libublsettingsui-gtk3" @@ -52,6 +57,7 @@ #define OPEN_HELP_LABEL _("Open documentation") #define PROJECT_HOME_LABEL _("Project Home Page") #define NOTHING_CHOSEN_LABEL _("Nothing were chosen") + #define AUTHORS_LABEL _(L"Copyright © 2022 - 2023, UBSoft LLC") #define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succeeded.") @@ -65,6 +71,12 @@ #define PARAMETER_LABEL _("Parameter") #define OLD_VALUE_LABEL _("Old value") #define NEW_VALUE_LABEL _("New value") + #define COMPARE_VALUE_LABEL _("Value\n(Old/New)") + + #define NOTHING_TO_SAVE_LABEL _("Nothing to save") + #define SAVING_LOCAL_STATE_LABEL _("Saving into local configuration") + #define SAVING_GLOBAL_STATE_LABEL _("Saving into global configuration") + #define SAVING_GLOBAL_LOCAL_STATE_LABEL _("Saving into global and local configuration") #define SYSTEMBOOT_STATEMODE "SYSTEMBOOT_STATEMODE" #define SYSTEMBOOT_STATEMODE_SECTION "[system]" @@ -118,6 +130,7 @@ typedef struct { int lock_save_local; int lock_save_global; int lock_load_global; + int lock_load_system; int load_mode; @@ -256,4 +269,6 @@ void on_open_documentation_confirmation(GtkWidget *self, char *link); * [RU] * Закрывает окно, в котором расположен виджет [self]. */ -void on_subwindow_close(GtkWidget *self); \ No newline at end of file +void on_subwindow_close(GtkWidget *self); + +int yon_ubl_setup_arguments(int argc, char *argv[],config_str *unfound_arguments, int *arguments_size, char *additional_options_output); \ No newline at end of file