diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 0f52e90..c71eb86 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -13,7 +13,7 @@ include_directories(${VTE291_INCLUDE_DIRS}) link_directories(${VTE291_LIBRARY_DIRS}) add_definitions(${VTE291_CFLAGS_OTHER}) -pkg_check_modules(POLKIT REQUIRED polkit-agent-1) +pkg_check_modules(POLKIT REQUIRED polkit-gobject-1) include_directories(${POLKIT_INCLUDE_DIRS}) link_directories(${POLKIT_LIBRARY_DIRS}) add_definitions(${POLKIT_CFLAGS_OTHER}) @@ -29,10 +29,6 @@ if(WEBKIT_LIBRARIES_FOUND) add_definitions(${WEBKIT_CFLAGS_OTHER}) endif() -configure_file(ubl-cmake.in ubl-cmake.h) - -file(COPY ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h DESTINATION ./) - set(GRESOURCE_C resources.c) set(GRESOURCE_XML gresource.xml) @@ -76,21 +72,21 @@ add_custom_target( DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} ) -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -lm") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ - -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ + -Wformat -Werror=format-security \ -fstack-clash-protection -fcf-protection") - + +string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND) + +if(FORTIFY_FOUND EQUAL -1) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-D_FORTIFY_SOURCE=2") +endif() set(SOURCE_FILES ubl-settings-logging.c ubl-settings-logging.h ubl-strings.h - ubl-utils.h - ubl-utils.c - ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h ) set(LIBRARIES @@ -98,7 +94,10 @@ set(LIBRARIES ${WEBKIT_LIBRARIES} ${VTE291_LIBRARIES} ${POLKIT_LIBRARIES} - pthread) + pthread + ublsettings + ublsettings-gtk3 + ublsettingsui-gtk3) add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) diff --git a/source/ubl-cmake.in b/source/ubl-cmake.in deleted file mode 100644 index d4623a7..0000000 --- a/source/ubl-cmake.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine WEBKIT_FOUND diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 31c5e13..02e72bb 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -4,29 +4,8 @@ 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, char *window){ - if(window) - yon_window_config_custom_window_set(GTK_WINDOW(gtk_widget_get_toplevel(self)),window); - 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); -} - -void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path, saving_window *window){ + +void on_save_window_parameter_switched(GtkCellRendererToggle *, gchar *path, saving_window *window){ GtkTreeIter iter; if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),&iter,path)){ gboolean is_active; @@ -36,295 +15,6 @@ void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path, } -void on_save_parameters(GtkWidget *self, saving_window *window){ - char *append_command = yon_char_unite("ubconfig --target ",main_config.load_mode==1?"global":"system"," set ",NULL); - char *remove_command = yon_char_unite("ubconfig --target ",main_config.load_mode==1?"global":"system"," remove ",NULL); - dictionary *final_append=NULL; - dictionary *final_remove=NULL; - GtkTreeIter iter; - int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter); - for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ - gboolean is_active,can_save; - char *parameter,*old_value,*new_value,*section; - gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&is_active,1,¶meter,2,&old_value,3,&new_value,5,&can_save,6,§ion,-1); - if (is_active&&can_save){ - if(!yon_char_is_empty(parameter)){ - if (yon_char_is_empty(new_value)){ // empty new value - delete - if (yon_dictionary_get(&final_remove,section)){ - final_remove->data = yon_char_unite((char*)final_remove->data," ",parameter,NULL); - } else { - yon_dictionary_add_or_create_if_exists_with_data(final_remove,section, parameter); - } - } else { // non-empty new value - add - if (yon_dictionary_get(&final_append,section)){ - final_append->data=yon_char_unite((char*)final_append->data," ",yon_char_unite(parameter,"=\"",new_value,"\"",NULL),NULL); - } else { - yon_dictionary_add_or_create_if_exists_with_data(final_append,section, yon_char_unite(parameter,"=\"",new_value,"\"",NULL)); - } - } - } - } - } - dictionary *dict = NULL; - if (final_remove){ - for_dictionaries(dict,final_remove){ - char *final_command = yon_char_unite(remove_command," ",dict->key," ",(char*)dict->data,NULL); - system(final_command); - free(final_command); - } - } - if (final_append){ - for_dictionaries(dict,final_append){ - char *final_command = yon_char_unite(append_command," ",dict->key," ",(char*)dict->data,NULL); - system(final_command); - free(final_command); - } - } - if (window->type==YON_CONFIG_BOTH) { - if (main_config.load_mode==1){ - yon_config_save_registered("system"); - } else if (main_config.load_mode==0){ - yon_config_save_registered("global"); - } - } - if (window->type == YON_CONFIG_GLOBAL) - yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - else if (window->type == YON_CONFIG_LOCAL) - yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - else if (window->type == YON_CONFIG_BOTH) - yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - - yon_window_config_custom_window_set(GTK_WINDOW(window->Window),"SaveWindow"); - on_close_subwindow(self,"SavingWindow"); -} - -saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ - if (((type==YON_CONFIG_LOCAL&& main_config.load_mode==1)||(type==YON_CONFIG_GLOBAL&& main_config.load_mode==0))){ - yon_config_save_registered(path); - if (type == YON_CONFIG_GLOBAL) - yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - else if (type == YON_CONFIG_LOCAL) - yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - else if (type == YON_CONFIG_BOTH) - yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - return NULL; - } else { - char *config_to_save = NULL; - if (type==YON_CONFIG_GLOBAL) config_to_save="global"; - else if (type==YON_CONFIG_LOCAL) config_to_save="system"; - else if (type==YON_CONFIG_BOTH) { - if (main_config.load_mode==1){ - config_to_save="global"; - } else if (main_config.load_mode==0){ - config_to_save="system"; - } - } - config_str config_compare=NULL; - int compare_size=0; - va_list args; - va_start(args,type); - char *cur_section = NULL; - dictionary *section_commands=NULL; - while ((cur_section=va_arg(args,char*))){ - char *cur_parameter = va_arg(args,char*); - yon_dictionary_add_or_create_if_exists_with_data(section_commands,cur_section,cur_parameter); - } - struct loaded_config { - dictionary *dict; - char *section; - }; - - struct loaded_config loaded; - loaded.dict = yon_dictionary_new(); - dictionary *dct; - for_dictionaries(dct,section_commands){ - char *command = yon_char_unite(ubconfig_load_command," ", config_to_save," get ", dct->key," ", yon_dictionary_get_data(dct,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 (!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'; - 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)); - } - } - } - GtkBuilder *builder = gtk_builder_new_from_resource(glade_saving_path); - saving_window *window = malloc(sizeof(saving_window)); - window->Window = yon_gtk_builder_get_widget(builder,"Window"); - window->HeaderImage = yon_gtk_builder_get_widget(builder,"HeaderImage"); - window->HeaderTopic = yon_gtk_builder_get_widget(builder,"HeaderTopic"); - window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); - window->ParametersTree = yon_gtk_builder_get_widget(builder,"ParametersTree"); - window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton"); - window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); - window->ToggleCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ToggleCell")); - window->list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); - window->type=type; - yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"SaveWindow"); - yon_window_config_custom_window_get(GTK_WINDOW(window->Window),"SaveWindow"); - gtk_window_set_title(GTK_WINDOW(window->Window),SAVE_TITLE_LABEL); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_save_parameters),window); - g_signal_connect(G_OBJECT(window->ToggleCell),"toggled", G_CALLBACK(on_save_window_parameter_switched),window); - int config_size=0; - config_str config_strings = yon_config_get_all(&config_size); - if (config_strings){ - GtkTreeIter iter; - gtk_tree_view_set_model(GTK_TREE_VIEW(window->ParametersTree),NULL); - config_str compare_keys = NULL; - compare_keys = yon_char_parsed_copy(config_compare,compare_size); - int compare_keys_size=compare_size; - yon_char_parsed_divide_search_full(compare_keys,compare_keys_size,"=",-1); - int config_keys_size=0; - config_str config_keys = yon_config_get_all_keys(&config_keys_size); - int final_size=0; - GdkRGBA rgba; - rgba.alpha=0.8; - rgba.red=1; - rgba.blue=0.3; - rgba.green=0.65; - char *rgba_string = gdk_rgba_to_string(&rgba); - for (int i=0;ilist,&iter); - gtk_list_store_set(window->list,&iter,0,1,1,compare_keys[i],5,1,-1); - for (int j=0;jfirst,compare_keys[i])->prev->data; - gtk_list_store_set(window->list,&iter,2,compare_value,4,rgba_string,6,cur_section,-1); - } - free(compare_value); - free(compare_name); - } - - } - char *name,*value; - for (int i=0;ilist),&iter); - for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ - 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])){ - gtk_list_store_set(window->list,&iter,3,compare_value,4,NULL,6,section,-1); - if (!strcmp(value,compare_value)){ - gtk_list_store_set(window->list,&iter,0,0,5,0,-1); - } - found=1; - break; - } - } - if (!found){ - 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); - } - free(compare_value); - free(compare_name); - } - free(rgba_string); - - gtk_tree_view_set_model(GTK_TREE_VIEW(window->ParametersTree),GTK_TREE_MODEL(window->list)); - } - - gtk_widget_show(window->Window); - return window; - - } - -} - -/**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_window_set_title(GTK_WINDOW(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); -} - char *yon_size_get_letter_from_int(int size){ switch (size){ case 0: return "K"; @@ -334,6 +24,7 @@ char *yon_size_get_letter_from_int(int size){ case 2: return "G"; break; } + return 0; } int yon_size_get_int_from_letter(char size){ @@ -345,13 +36,14 @@ int yon_size_get_int_from_letter(char size){ case 'G': return 2; break; } + return 0; } //functions -void yon_polkit_authorized_action(GCallback *func){ +// void yon_polkit_authorized_action(GCallback *func){ -} +// } void yon_logs_custom_save(main_window *widgets){ GtkTreeIter iter; @@ -360,7 +52,6 @@ void yon_logs_custom_save(main_window *widgets){ char *paths; int standard; int standard_paths; - int size=0; int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->list),&iter); char *final_strings=NULL; for (;valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->list),&iter)){ @@ -404,62 +95,115 @@ void update_loaded_logrotate(){ } int yon_load_proceed(YON_CONFIG_TYPE type){ - if (yon_config_load_register(type,"logging",LOGROTATE("*"),"logging",JOURNALD("*"),NULL)){ + if (type!=YON_CONFIG_CUSTOM){ + yon_config_clean(); + } + + if(!yon_char_is_empty(config_get_default_command)){ + yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); + } + switch (type){ + case YON_CONFIG_GLOBAL: + yon_debug_output("%s\n",yon_char_unite(config_get_command("global"),NULL)); + yon_config_load_config(type,config_get_command("global"),NULL); + update_loaded_logrotate(); + return 1; + break; + case YON_CONFIG_LOCAL: + yon_config_load_config(type,config_get_command("system"),NULL); + yon_config_load_config(YON_CONFIG_GLOBAL,config_get_global_only_parameters,NULL); + update_loaded_logrotate(); + return 1; + break; + case YON_CONFIG_CUSTOM: + char *path = NULL; + path=yon_custom_config_init(); + if (!yon_char_is_empty(path)){ + yon_config_clean(); + yon_config_load_config(type,config_get_command(path),NULL); + yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); + } + break; + default: + } update_loaded_logrotate(); - return 1; - } - + return 1; } void on_load_global(){ yon_load_proceed(YON_CONFIG_GLOBAL); main_config.load_mode=0; - yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); update_loaded_logrotate(); } void on_load_local(){ yon_load_proceed(YON_CONFIG_LOCAL); main_config.load_mode=1; - yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); update_loaded_logrotate(); } -// void yon_save_proceed(char *path,YON_CONFIG_TYPE type){ -// if (((type==YON_CONFIG_LOCAL&& main_config.load_mode==1)||(type==YON_CONFIG_GLOBAL&& main_config.load_mode==0))) -// yon_config_save_registered(path); -// else{ -// if (type==YON_CONFIG_BOTH) -// yon_launch("ubconfig remove logging LOGROTATE[*] JOURNALD[*]"); -// else if (type==YON_CONFIG_LOCAL) -// yon_launch("ubconfig --target system remove logging LOGROTATE[*] JOURNALD[*]"); -// else if (type==YON_CONFIG_GLOBAL) -// yon_launch("ubconfig --target global remove logging LOGROTATE[*] JOURNALD[*]"); -// yon_config_force_save_registered(path); -// } - -// } +void on_config_custom_load(GtkWidget *,main_window *){ + yon_load_proceed(YON_CONFIG_CUSTOM); + main_config.load_mode=3; + // yon_interface_update(widgets); +} void on_save_global_local(){ - yon_save_proceed(NULL,YON_CONFIG_BOTH,"logging", "JOURNALD[*] LOGROTATE[*]",NULL); + main_config.save_config=2; + yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL); } void on_save_global(){ - yon_save_proceed("global",YON_CONFIG_GLOBAL,"logging", "JOURNALD[*] LOGROTATE[*]",NULL); + main_config.save_config=0; + yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL); } void on_save_local(){ - yon_save_proceed("system",YON_CONFIG_LOCAL,"logging", "JOURNALD[*] LOGROTATE[*]",NULL); - + main_config.save_config=1; + yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL); + +} + +void on_config_custom_save(GtkWidget *, main_window *){ + main_config.save_config=3; + yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); +} + +void on_save_done(main_window *, config_str output, int size){ + char *final_output = yon_char_parsed_to_string(output,size,""); + if (final_output){ + printf("%s\n",final_output); + free(final_output); + } + yon_char_parsed_free(output,size); + // yon_interface_update(widgets); + + textdomain(template_ui_LocaleName); + switch (main_config.save_config){ + case 0: + yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case 1: + yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case 2: + yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case 3: + yon_ubl_status_box_render(SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + + } + textdomain(LocaleName); + +} +void on_save_failed(main_window *, config_str , int ){ } - // Inspector functions void on_inspector_jornald_read_async(inspector_window *window){ - FILE *fl; switch(window->last_mode){ case 0: @@ -486,6 +230,8 @@ void on_inspector_jornald_read_async(inspector_window *window){ case 7: fl = popen(get_journal_init_tree_command,"r"); break; + default: fl = popen(get_journal_output_command,"r"); + break; } char *output = g_malloc0(sizeof(char)*4096); GtkTreeIter iter; @@ -563,9 +309,9 @@ void on_inspector_jornald_read_async(inspector_window *window){ } void on_inspector_update(GtkWidget *self, inspector_window *window){ - int size; - GtkTextIter titer,titerend; - config_str output; + // int size; + // GtkTextIter titer; + // config_str output; if (!strcmp(window->journal_name,"journald")){ if(self!=window->UpdateButton){ gtk_style_context_remove_class(gtk_widget_get_style_context(window->ShowKernelButton),"chosenOutline"); @@ -583,7 +329,7 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){ gtk_widget_set_sensitive(window->ShowPriorityButton,1); gtk_widget_set_sensitive(window->ShowSinceBootButton,1); } - GtkWidget *terminal = (GtkWidget*)window->terminals->first->data; + // GtkWidget *terminal = (GtkWidget*)window->terminals->first->data; gtk_widget_hide(window->LoggingNotebook); gtk_widget_show(gtk_widget_get_parent(window->JournaldTree)); if (self==window->ShowSinceBootButton){ @@ -641,7 +387,7 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){ dictionary *dict=NULL; for_dictionaries (dict,window->terminals){ GtkWidget *terminal = (GtkWidget*)dict->data; - yon_terminal_integrated_start(terminal,yon_char_unite("cat ",dict->key," | sed -r \"s/\\x1B\\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g\"",NULL),NULL,NULL); + yon_terminal_integrated_start(terminal,read_log_command(dict->key)); } } } @@ -678,17 +424,17 @@ GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name,i } -void on_inspector_close(GtkWidget *self, inspector_window *window){ +void on_inspector_close(GtkWidget *, inspector_window *window){ main_config.remove_thread++; GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(window->JournaldTree)); - for (int i=0; i< g_list_length(list);i++){ + for (guint i=0; i< g_list_length(list);i++){ int value=gtk_tree_view_column_get_fixed_width((GtkTreeViewColumn*)g_list_nth_data(list,i)); yon_window_config_add_instant_parameter(yon_char_append("inspectorcolumn",yon_char_from_int(i)),"window",&value,YON_TYPE_INT); } } -void on_inspector_open(GtkWidget *self, main_window *widgets){ +void on_inspector_open(GtkWidget *, main_window *widgets){ inspector_window *window = malloc(sizeof(inspector_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_inspector_path); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); @@ -709,7 +455,7 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window)); GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(window->JournaldTree)); - for (int i=0; i< g_list_length(list);i++){ + for (guint i=0; i< g_list_length(list);i++){ int value; yon_window_config_get_parameter("window",yon_char_append("inspectorcolumn",yon_char_from_int(i)),&value,YON_TYPE_INT); if (value) @@ -792,7 +538,7 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ // Logrotate window -void on_logrotate_configuration_path_filechooser_selection_changed(GtkWidget *self, logrotate_filechooser_window *dialog){ +void on_logrotate_configuration_path_filechooser_selection_changed(GtkWidget *, logrotate_filechooser_window *dialog){ GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(dialog->FileChooser)); GFileType type = g_file_query_file_type(file,G_FILE_QUERY_INFO_NONE, NULL); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->FileOrDirCheck))){ @@ -810,11 +556,11 @@ void on_logrotate_configuration_path_filechooser_selection_changed(GtkWidget *se } } -void on_logrotate_filechooser_file_dir_toggled(GtkWidget *self, logrotate_filechooser_window *dialog){ +void on_logrotate_filechooser_file_dir_toggled(GtkWidget *, logrotate_filechooser_window *dialog){ on_logrotate_configuration_path_filechooser_selection_changed(NULL,dialog); } -void on_logrotate_configuration_path_filechooser_save_edit(GtkWidget *self, dictionary *dict){ +void on_logrotate_configuration_path_filechooser_save_edit(GtkWidget *, dictionary *dict){ logrotate_configure_window *window = yon_dictionary_get_data(dict->first,logrotate_configure_window*); logrotate_filechooser_window *dialog = yon_dictionary_get_data(dict->first->next,logrotate_filechooser_window*); GtkTreeIter iter, itar; @@ -839,18 +585,23 @@ void on_logrotate_configuration_path_filechooser_save_edit(GtkWidget *self, dict } if(!deleted){ gtk_list_store_set(window->list,&iter,0,filename,-1); - on_close_subwindow(dialog->FileChooser,"FileDialog"); + on_subwindow_close(dialog->FileChooser); } } } -void on_logrotate_configuration_path_filechooser_save(GtkWidget *self, dictionary *dict){ +void on_logrotate_configuration_path_filechooser_save(GtkWidget *, dictionary *dict){ logrotate_configure_window *window = yon_dictionary_get_data(dict->first,logrotate_configure_window*); logrotate_filechooser_window *dialog = yon_dictionary_get_data(dict->first->next,logrotate_filechooser_window*); char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->FileChooser)); + if (yon_char_is_empty(filename)){ + + yon_ubl_status_box_spawn(GTK_CONTAINER(dialog->StatusBox),NOTHING_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->FileOrDirCheck))){ GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(dialog->FileChooser)); - GFileType type; + GFileType type = G_FILE_TYPE_UNKNOWN; if(file) type = g_file_query_file_type(file,G_FILE_QUERY_INFO_NONE, NULL); if (!filename||(type == G_FILE_TYPE_REGULAR)){ @@ -877,7 +628,7 @@ void on_logrotate_configuration_path_filechooser_save(GtkWidget *self, dictionar if(!deleted){ gtk_list_store_append(window->list,&iter); gtk_list_store_set(window->list,&iter,0,filename,-1); - on_close_subwindow(dialog->FileChooser,"FileDialog"); + on_subwindow_close(dialog->FileChooser); } } @@ -896,47 +647,50 @@ void on_logrotate_configuration_path_filechooser_open(GtkWidget *self, logrotate dialog->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); dialog->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); yon_window_config_custom_window_set(GTK_WINDOW(dialog->FileChooser),"FileDialog"); - gtk_window_set_transient_for(GTK_WINDOW(dialog->FileChooser),GTK_WINDOW(window->MainWindow)); + yon_gtk_window_setup(GTK_WINDOW(dialog->FileChooser),GTK_WINDOW(window->MainWindow),TITLE_LABEL,icon_path,"FileChooser"); GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter,"*log*"); gtk_file_filter_add_pattern(filter,"*log*"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog->FileChooser),filter); dictionary *dict = NULL; - gtk_window_set_title(GTK_WINDOW(dialog->FileChooser),FILECHOOSER_TITLE_LABEL); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog); - g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"FileDialog"); + g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); if (self==window->LogPathAddButton) g_signal_connect(G_OBJECT(dialog->AcceptButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_filechooser_save),dict); - else if (self==window->LogPathEditButton) + else if (self==window->LogPathEditButton){ g_signal_connect(G_OBJECT(dialog->AcceptButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_filechooser_save_edit),dict); + GtkTreeModel *model=NULL; + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ + char *path; + gtk_tree_model_get(model,&iter,0,&path,-1); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->FileChooser),path); + } + } g_signal_connect(G_OBJECT(dialog->FileChooser),"selection-changed",G_CALLBACK(on_logrotate_configuration_path_filechooser_selection_changed),dialog); g_signal_connect(G_OBJECT(dialog->FileOrDirCheck),"toggled",G_CALLBACK(on_logrotate_filechooser_file_dir_toggled),dialog); gtk_widget_show(dialog->FileChooser); } -void on_logrotate_configuration_path_add(GtkWidget *self, logrotate_configure_window *window){ +void on_logrotate_configuration_path_add(GtkWidget *, logrotate_configure_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(window->list); GtkTreeIter iter; gtk_list_store_append(window->list, &iter); GtkTreeViewColumn *column = gtk_tree_view_get_column(GTK_TREE_VIEW(window->LogPathsTree),0); - GList *list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column)); - // GValue *val = g_malloc0(sizeof(GValue)); - // g_object_get_property(G_OBJECT(list->data),"editable",val); - // g_value_set_boolean(val,1); - // g_object_set_property(G_OBJECT(list->data),"editable",val); - // free(val); + // GList *list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column)); gtk_tree_view_set_cursor(GTK_TREE_VIEW(window->LogPathsTree),gtk_tree_model_get_path(model,&iter),column,1); } -void on_path_editing_done(GtkCellRendererText* self,gchar* gtkpath,gchar* new_text,logrotate_configure_window *window){ +void on_path_editing_done(GtkCellRendererText* ,gchar* gtkpath,gchar* new_text,logrotate_configure_window *window){ GtkTreeIter iter, itar; char *cur_path; gtk_tree_model_get_iter(GTK_TREE_MODEL(window->list),&iter,gtk_tree_path_new_from_string(gtkpath)); gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); - int deleted=0; + // int deleted=0; - if (!strcmp(new_text,"")||cur_path&&!strcmp(cur_path,"")) + if (!strcmp(new_text,"")||(cur_path&&!strcmp(cur_path,""))) gtk_list_store_remove(window->list,&iter); else if (new_text&&strcmp(new_text,"")){ int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); @@ -954,14 +708,9 @@ void on_path_editing_done(GtkCellRendererText* self,gchar* gtkpath,gchar* new_te gtk_list_store_set(window->list,&iter,0,new_text,-1); } - // GValue *val = g_malloc0(sizeof(GValue)); - // g_object_get_property(G_OBJECT(self),"editable",val); - // g_value_set_boolean(val,0); - // g_object_set_property(G_OBJECT(self),"editable",val); - // free(val); } -void on_path_editing_cancel(GtkCellRendererText* self,logrotate_configure_window *window){ +void on_path_editing_cancel(GtkCellRendererText* ,logrotate_configure_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(window->list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ @@ -972,22 +721,17 @@ void on_path_editing_cancel(GtkCellRendererText* self,logrotate_configure_window } } -void on_logrotate_configuration_path_edit(GtkWidget *self, logrotate_configure_window *window){ +void on_logrotate_configuration_path_edit(GtkWidget *, logrotate_configure_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(window->list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ GtkTreeViewColumn *column = gtk_tree_view_get_column(GTK_TREE_VIEW(window->LogPathsTree),0); - GList *list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column)); - // GValue *val = g_malloc0(sizeof(GValue)); - // g_object_get_property(G_OBJECT(list->data),"editable",val); - // g_value_set_boolean(val,1); - // g_object_set_property(G_OBJECT(list->data),"editable",val); - // free(val); + // GList *list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column)); gtk_tree_view_set_cursor(GTK_TREE_VIEW(window->LogPathsTree),gtk_tree_model_get_path(model,&iter),column,1); } } -void on_logrotate_configuration_path_remove(GtkWidget *self, logrotate_configure_window *window){ +void on_logrotate_configuration_path_remove(GtkWidget *, logrotate_configure_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(window->list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ @@ -1024,7 +768,7 @@ void on_file_amount_checked(GtkToggleButton *self, logrotate_configure_window *w } } -void on_rules_accept(GtkWidget *self, dictionary *dict){ +void on_rules_accept(GtkWidget *, dictionary *dict){ GtkEntry *entry = yon_dictionary_get_data(dict->first,GtkEntry*); logrotate_rules_window *window = yon_dictionary_get_data(dict->first->next,logrotate_rules_window*); int owner_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserReadCheck)); @@ -1063,10 +807,10 @@ void on_rules_accept(GtkWidget *self, dictionary *dict){ !public_read&&public_write&&public_exec ? 3 : \ 0; gtk_entry_set_text(entry,yon_char_unite(yon_char_from_int(owner),yon_char_from_int(group),yon_char_from_int(public),NULL)); - on_close_subwindow(window->Window,"RulesWindow"); + on_subwindow_close(window->Window); } -void on_rules_update(GtkWidget *self, logrotate_rules_window *window){ +void on_rules_update(GtkWidget *, logrotate_rules_window *window){ int owner_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserReadCheck)); int owner_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserWriteCheck)); int owner_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserExecuteCheck)); @@ -1105,7 +849,7 @@ void on_rules_update(GtkWidget *self, logrotate_rules_window *window){ gtk_entry_set_text(GTK_ENTRY(window->FinalEntry),yon_char_unite(yon_char_from_int(owner),yon_char_from_int(group),yon_char_from_int(public),NULL)); } -void on_rules_open(GtkWidget *self,GtkEntry *entry){ +void on_rules_open(GtkWidget *,GtkEntry *entry){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_rules_path); logrotate_rules_window *window = malloc(sizeof(logrotate_rules_window)); window->Window=yon_gtk_builder_get_widget(builder,"MainWindow"); @@ -1126,7 +870,7 @@ void on_rules_open(GtkWidget *self,GtkEntry *entry){ dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"entry",entry); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"RulesWindow"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_rules_accept),dict); g_signal_connect(G_OBJECT(window->UserReadCheck),"toggled",G_CALLBACK(on_rules_update),window); @@ -1143,22 +887,22 @@ void on_rules_open(GtkWidget *self,GtkEntry *entry){ gtk_widget_show(window->Window); } -void on_filechooser_mode_switch(GtkWidget *self, logrotate_filechooser_window *window){ +void on_filechooser_mode_switch(GtkWidget *, logrotate_filechooser_window *window){ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->FileOrDirCheck))){ gtk_file_chooser_set_action(GTK_FILE_CHOOSER(window->FileChooser),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); } gtk_file_chooser_set_action(GTK_FILE_CHOOSER(window->FileChooser),GTK_FILE_CHOOSER_ACTION_OPEN); } -void on_filechooser_save(GtkWidget *self, dictionary *dict){ +void on_filechooser_save(GtkWidget *, dictionary *dict){ logrotate_configure_window *window = yon_dictionary_get_data(dict->first,logrotate_configure_window*); logrotate_filechooser_window *dialog = yon_dictionary_get_data(dict->first->next,logrotate_filechooser_window*); - char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->FileChooser)); + char *filename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->FileOrDirCheck))?gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->FileChooser)):gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->FileChooser)); gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),filename); - on_close_subwindow(dialog->FileChooser,"FileDialog"); + on_subwindow_close(dialog->FileChooser); } -void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window){ +void on_filechooser_open(GtkWidget *, logrotate_configure_window *window){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_filechooser_path); logrotate_filechooser_window *dialog = malloc(sizeof(logrotate_filechooser_window)); dialog->FileChooser = yon_gtk_builder_get_widget(builder,"FileChooser"); @@ -1166,14 +910,15 @@ void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window){ dialog->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); dialog->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); yon_window_config_custom_window_set(GTK_WINDOW(dialog->FileChooser),"FileDialog"); - gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(window->MainWindow)); + yon_gtk_window_setup(GTK_WINDOW(dialog->FileChooser),GTK_WINDOW(window->MainWindow),TITLE_LABEL,icon_path,"FileChooser"); dictionary *dict = NULL; - gtk_window_set_title(GTK_WINDOW(dialog->FileChooser),FILECHOOSER_TITLE_LABEL); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->FileOrDirCheck),1); + gtk_widget_hide(dialog->FileOrDirCheck); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog); g_signal_connect(G_OBJECT(dialog->FileOrDirCheck),"toggled",G_CALLBACK(on_filechooser_mode_switch),dialog); - g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"FileDialog"); + g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(dialog->AcceptButton),"clicked",G_CALLBACK(on_filechooser_save),dict); gtk_widget_show(dialog->FileChooser); } @@ -1189,7 +934,7 @@ void on_logrotate_period_check_toggled(GtkToggleButton *self,logrotate_configure } } -void on_logrotate_paths_cursor_changed(GtkWidget *self, logrotate_configure_window *window){ +void on_logrotate_paths_cursor_changed(GtkWidget *, logrotate_configure_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(window->list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ @@ -1202,7 +947,7 @@ void on_logrotate_paths_cursor_changed(GtkWidget *self, logrotate_configure_wind } } -int on_logrotate_check_repeats(GtkWidget *self, logrotate_configure_window *window){ +int on_logrotate_check_repeats(GtkWidget *, logrotate_configure_window *window){ GtkTreeIter iter,*itar; GtkTreeModel *model = GTK_TREE_MODEL(window->list); char *chpath=NULL; @@ -1236,7 +981,7 @@ int on_logrotate_check_repeats(GtkWidget *self, logrotate_configure_window *wind return 0; } -void on_logrotate_save(GtkWidget *self, dictionary *dict){ +void on_logrotate_save(GtkWidget *, dictionary *dict){ logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*); logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*); char *log_name=""; @@ -1296,8 +1041,8 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ return; } if (on_logrotate_check_repeats(NULL,window)==1) return; - GtkTreeIter *lastiter; - GtkTreeIter *lastitar; + // GtkTreeIter *lastiter; + // GtkTreeIter *lastitar; for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ char *cur_path; gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); @@ -1306,8 +1051,8 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ } path_amount++; paths = yon_char_unite(paths,strcmp(paths,"") ? "," : "", cur_path,NULL); - lastiter=gtk_tree_iter_copy(&iter); - lastitar=gtk_tree_iter_copy(&iter); + // lastiter=gtk_tree_iter_copy(&iter); + // lastitar=gtk_tree_iter_copy(&iter); } if(!window->paths) { if (matched==path_amount) { @@ -1348,6 +1093,11 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ rotate_count = yon_char_append("rotate ",yon_char_from_long(fileamount)); if (active==2){ const char *text = gtk_entry_get_text(GTK_ENTRY(window->FileAmountEntry)); + if (yon_char_is_empty(text)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->FileAmountEntry); + return; + } olddir=yon_char_unite("olddir ",text,NULL); } } @@ -1420,7 +1170,12 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ int original_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->SaveOriginalCombo)); if (original_active==1){ - char *ext_file = (char*)gtk_entry_get_text(GTK_ENTRY(window->SaveOriginalEntry)); + char *ext_file = (char*)gtk_entry_get_text(GTK_ENTRY(window->SaveOriginalEntry)); + if (yon_char_is_empty(ext_file)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->SaveOriginalEntry); + return; + } extension = yon_char_append("extension ",ext_file); } @@ -1439,8 +1194,15 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ switch(email_active){ case 1: char *adress = (char*)gtk_entry_get_text(GTK_ENTRY(window->EmailEntry)); - if (!yon_char_is_empty(adress)) + char *error = yon_gtk_entry_check_restricted(GTK_ENTRY(window->EmailEntry)); + if (!yon_char_is_empty(error)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),error,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->EmailEntry); + return; + } + if (!yon_char_is_empty(adress)){ mail=yon_char_append("mail ", adress); + } int contents_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->EmailContentsCombo)); if (contents_active==1) mailfirst = "mailfirst"; @@ -1458,37 +1220,109 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ char *before = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandBeforeEntry)); char *after = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandAfterEntry)); char *endwork = (char*)gtk_entry_get_text(GTK_ENTRY(window->EndworkCommandEntry)); + + if (!check_command_is_legit(before_once)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),COMMAND_INVALID_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->CommandBeforeOnceEntry); + return; + } + if (!check_command_is_legit(after_once)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),COMMAND_INVALID_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->CommandAfterOnceEntry); + return; + } + if (!check_command_is_legit(before)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),COMMAND_INVALID_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->CommandBeforeEntry); + return; + } + if (!check_command_is_legit(after)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),COMMAND_INVALID_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->CommandAfterEntry); + return; + } + if (!check_command_is_legit(endwork)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),COMMAND_INVALID_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->EndworkCommandEntry); + return; + } sharedscripts = "sharedscripts"; if (!yon_char_is_empty(before_once)) { - before_once = yon_char_replace(before_once,"\"","=--"); - before_once = yon_char_replace(before_once,"=--","\\\""); firstaction = yon_char_append("firstaction,",before_once); } if (!yon_char_is_empty(after_once)) { - after_once = yon_char_replace(after_once,"\"","=--"); - after_once = yon_char_replace(after_once,"=--","\\\""); lastaction = yon_char_append("lastaction,",after_once); } if (!yon_char_is_empty(before)) { - before = yon_char_replace(before,"\"","=--"); - before = yon_char_replace(before,"=--","\\\""); prerotate = yon_char_append("prerotate,",before); } if (!yon_char_is_empty(after)) { - after = yon_char_replace(after,"\"","=--"); - after = yon_char_replace(after,"=--","\\\""); postrotate = yon_char_append("postrotate,",after); } if (!yon_char_is_empty(endwork)){ - endwork = yon_char_replace(endwork,"\"","=--"); - endwork = yon_char_replace(endwork,"=--","\\\""); preremove = yon_char_append("preremove,",endwork); } if (!yon_char_is_empty(firstaction)||!yon_char_is_empty(after_once)||!yon_char_is_empty(before)||!yon_char_is_empty(after)) endscript = "endscript"; } - - char *commandline = yon_char_unite(period,yon_add_space_if_exists(size),yon_add_space_if_exists(rotate_count),yon_add_space_if_exists(olddir),yon_add_space_if_exists(su),yon_add_space_if_exists(missingok),yon_add_space_if_exists(ifempty),yon_add_space_if_exists(notifempty),yon_add_space_if_exists(minage),yon_add_space_if_exists(maxage),yon_add_space_if_exists(minsize),yon_add_space_if_exists(maxsize),yon_add_space_if_exists(create),yon_add_space_if_exists(copytruncate),yon_add_space_if_exists(compress),yon_add_space_if_exists(delaycompress),yon_add_space_if_exists(extension),yon_add_space_if_exists(dateext),yon_add_space_if_exists(start),yon_add_space_if_exists(mail),yon_add_space_if_exists(mailfirst),yon_add_space_if_exists(sharedscripts),yon_add_space_if_exists(firstaction),yon_add_space_if_exists(lastaction),yon_add_space_if_exists(prerotate),yon_add_space_if_exists(postrotate),yon_add_space_if_exists(preremove),yon_add_space_if_exists(endscript),NULL); + int create_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->CreateLogCombo)); + if (create_active){ + if (create_active==1){ + create = "nocreate"; + } else if (create_active==2){ + char *rule = (char*)gtk_entry_get_text(GTK_ENTRY(window->CreateLogEntry)); + char *rule_user = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->CreateLogUserCombo)); + char *rule_group = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->CreateGroupCombo)); + if (yon_char_is_empty(rule)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->CreateLogEntry); + return; + } + if (yon_char_is_empty(rule_user)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->CreateLogUserCombo); + return; + } + if (yon_char_is_empty(rule_group)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->CreateGroupCombo); + return; + } + create = yon_char_unite("create ", rule," ",rule_user," ",rule_group,NULL); + } else if (create_active==3){ + create = "nocopytruncate"; + } + } + + char *commandline = yon_char_unite(period, + yon_add_space_if_exists(size), + yon_add_space_if_exists(rotate_count), + yon_add_space_if_exists(olddir), + yon_add_space_if_exists(su), + yon_add_space_if_exists(missingok), + yon_add_space_if_exists(ifempty), + yon_add_space_if_exists(notifempty), + yon_add_space_if_exists(minage), + yon_add_space_if_exists(maxage), + yon_add_space_if_exists(minsize), + yon_add_space_if_exists(maxsize), + yon_add_space_if_exists(create), + yon_add_space_if_exists(copytruncate), + yon_add_space_if_exists(compress), + yon_add_space_if_exists(delaycompress), + yon_add_space_if_exists(extension), + yon_add_space_if_exists(dateext), + yon_add_space_if_exists(start), + yon_add_space_if_exists(mail), + yon_add_space_if_exists(mailfirst), + yon_add_space_if_exists(sharedscripts), + yon_add_space_if_exists(firstaction), + yon_add_space_if_exists(lastaction), + yon_add_space_if_exists(prerotate), + yon_add_space_if_exists(postrotate), + yon_add_space_if_exists(preremove), + yon_add_space_if_exists(endscript), + NULL); if (commandline[0]==','){ free(yon_char_divide_search(commandline,",",-1)); } @@ -1508,8 +1342,28 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ } paths=yon_char_replace(paths,",","\n"); gtk_list_store_set(main_config.logrotate_list,&iter,0,log_name,1,paths,2,gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)),-1); - on_close_subwindow(window->MainWindow,"LogrotateWindow"); + on_subwindow_close(window->MainWindow); + } +} + +void on_rules_changed(GtkEditable *editable, const gchar *text, gint length, gint *position){ +gchar *new_text = g_new(gchar, length + 1); + gint i, j = 0; + + for (i = 0; i < length; i++) { + if (text[i]>'0'&&text[i]<'7') { + new_text[j] = text[i]; + j++; + } + } + if (j < length) { + g_signal_handlers_block_by_func(editable, G_CALLBACK(on_rules_changed), NULL); + gtk_editable_insert_text(editable, new_text, j, position); + g_signal_handlers_unblock_by_func(editable, G_CALLBACK(on_rules_changed), NULL); + g_signal_stop_emission_by_name(editable, "insert-text"); } + + g_free(new_text); } logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_window *dialog, char *log_name){ @@ -1577,8 +1431,8 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind window->CommandAfterEntry=yon_gtk_builder_get_widget(builder,"CommandAfterEntry"); window->EndworkCommandEntry=yon_gtk_builder_get_widget(builder,"EndworkCommandEntry"); window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); + g_signal_connect(G_OBJECT(window->CreateLogEntry),"insert-text",G_CALLBACK(on_rules_changed),NULL); - yon_window_config_custom_window_get(GTK_WINDOW(window->MainWindow),"LogrotateWindow"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),LOGROTATE_TITLE_LABEL); if (dialog) gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(dialog->Window)); @@ -1605,10 +1459,17 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),yon_char_append(fin,yon_size_get_letter_from_int(sizenumber))); } + yon_entry_set_entry_type(GTK_ENTRY(window->EmailEntry),GTK_BOX(window->StatusBox)); + yon_entry_set_entry_type(GTK_ENTRY(window->FileAmountEntry),GTK_BOX(window->StatusBox)); + yon_entry_set_entry_type(GTK_ENTRY(window->CommandBeforeOnceEntry),GTK_BOX(window->StatusBox)); + yon_entry_set_entry_type(GTK_ENTRY(window->CommandAfterOnceEntry),GTK_BOX(window->StatusBox)); + yon_entry_set_entry_type(GTK_ENTRY(window->CommandBeforeEntry),GTK_BOX(window->StatusBox)); + yon_entry_set_entry_type(GTK_ENTRY(window->CommandAfterEntry),GTK_BOX(window->StatusBox)); + yon_entry_set_entry_type(GTK_ENTRY(window->EndworkCommandEntry),GTK_BOX(window->StatusBox)); dictionary *dict=NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_logrotate_save),dict); g_signal_connect(G_OBJECT(window->PathCell),"edited",G_CALLBACK(on_path_editing_done),window); g_signal_connect(G_OBJECT(window->PathCell),"editing-canceled",G_CALLBACK(on_path_editing_cancel),window); @@ -1658,12 +1519,14 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind int usize=0; config_str users = yon_ubl_get_all_users(&usize); - yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize); - yon_gtk_combo_box_fill(window->RotationAtUserCombo,users,usize); + for (int i=0;iCreateLogUserCombo),users[i],users[i]); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->RotationAtUserCombo),users[i],users[i]); + } for (int i=0;iRotationAtGroupCombo),main_config.groups[i]); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->CreateGroupCombo),main_config.groups[i]); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->RotationAtGroupCombo),main_config.groups[i],main_config.groups[i]); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->CreateGroupCombo),main_config.groups[i],main_config.groups[i]); } if (paths){ @@ -1678,6 +1541,12 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind if (log_name){ char *parameters = yon_config_get_by_key(LOGROTATE(log_name)); if (parameters){ + char *firstaction = ""; + char *lastaction = ""; + char *prerotate = ""; + char *postrotate = ""; + char *preremove = ""; + char *current_script = NULL; if(parameters[strlen(parameters)-1]=='\"') parameters[strlen(parameters)-1]='\0'; parameters=strstr(parameters,":"); if (parameters) parameters++; @@ -1700,13 +1569,16 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),3); }else if (!strcmp(parsed[i],"yearly")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),4); - }else if (!strcmp(parsed[i],"olddir")){ + }else if (strstr(parsed[i],"olddir")){ char *value = strstr(parsed[i]," "); - if (value) value++; + if (value){ value++; + gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),2); + } else { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),1); + } gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),value); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),1); }else if (!strcmp(parsed[i],"noolddir")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),2); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),0); }else if (strstr(parsed[i],"su")){ char *value = strstr(parsed[i]," "); if (value) value++; @@ -1723,6 +1595,21 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),1); }else if (!strcmp(parsed[i],"notifempty")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),2); + } else if (!strcmp(parsed[i],"nocreate")) { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->CreateLogCombo),1); + } else if (!strcmp(parsed[i],"copytruncate")) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CutCheck),1); + } else if (!strcmp(parsed[i],"nocopytruncate")) { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->CreateLogCombo),3); + } else if (strstr(parsed[i],"create")){ + int parameter_size; + config_str parameter = yon_char_parse(parsed[i],¶meter_size," "); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->CreateLogCombo),2); + gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->CreateLogUserCombo),parameter[2]); + gtk_combo_box_set_active_id(GTK_COMBO_BOX(window->CreateGroupCombo),parameter[3]); + gtk_entry_set_text(GTK_ENTRY(window->CreateLogEntry),parameter[1]); + yon_char_parsed_free(parameter,parameter_size); + }else if (strstr(parsed[i],"minage")){ char *value = strstr(parsed[i]," "); if (value) value++; @@ -1787,32 +1674,56 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind }else if (!strcmp(parsed[i],"sharedscripts")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SharedScenariosCheck),1); }else if (strstr(parsed[i],"firstaction")){ - char *value = parsed[i+1]; - gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); - i++; + current_script = "firstaction"; }else if (strstr(parsed[i],"lastaction")){ - char *value = parsed[i+1]; - gtk_entry_set_text(GTK_ENTRY(window->CommandAfterOnceEntry),value); - i++; + current_script = "lastaction"; }else if (strstr(parsed[i],"prerotate")){ - char *value = parsed[i+1]; - gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),value); - i++; + current_script = "prerotate"; }else if (strstr(parsed[i],"postrotate")){ - char *value = parsed[i+1]; - gtk_entry_set_text(GTK_ENTRY(window->CommandAfterEntry),value); - i++; + current_script = "postrotate"; }else if (!strcmp(parsed[i],"preremove")){ - char *value = parsed[i+1]; - gtk_entry_set_text(GTK_ENTRY(window->EndworkCommandEntry),value); - i++; + current_script = "preremove"; + }else if (!strcmp(parsed[i],"endscript")){ + current_script = NULL; }else if (strstr(parsed[i],"rotate")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck),1); - }else if (!strcmp(parsed[i],"endscript")){ + } else { + if (!yon_char_is_empty(current_script)){ + if (!strcmp(current_script,"firstaction")){ + char *temp = yon_char_unite(firstaction, !yon_char_is_empty(firstaction)?",":"", parsed[i],NULL); + if(!yon_char_is_empty(firstaction)) free(firstaction); + firstaction = temp; + } else if (!strcmp(current_script,"lastaction")){ + char *temp = yon_char_unite(lastaction, !yon_char_is_empty(lastaction)?",":"", parsed[i],NULL); + if(!yon_char_is_empty(lastaction)) free(lastaction); + lastaction = temp; + + } else if (!strcmp(current_script,"prerotate")){ + char *temp = yon_char_unite(prerotate, !yon_char_is_empty(prerotate)?",":"", parsed[i],NULL); + if(!yon_char_is_empty(prerotate)) free(prerotate); + prerotate = temp; + + } else if (!strcmp(current_script,"postrotate")){ + char *temp = yon_char_unite(postrotate, !yon_char_is_empty(postrotate)?",":"", parsed[i],NULL); + if(!yon_char_is_empty(postrotate)) free(postrotate); + postrotate = temp; + + } else if (!strcmp(current_script,"preremove")){ + char *temp = yon_char_unite(preremove, !yon_char_is_empty(preremove)?",":"", parsed[i],NULL); + if(!yon_char_is_empty(preremove)) free(preremove); + preremove = temp; + + } + } } } + if (!yon_char_is_empty(firstaction)) gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),firstaction); + if (!yon_char_is_empty(lastaction)) gtk_entry_set_text(GTK_ENTRY(window->CommandAfterOnceEntry),lastaction); + if (!yon_char_is_empty(prerotate)) gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),prerotate); + if (!yon_char_is_empty(postrotate)) gtk_entry_set_text(GTK_ENTRY(window->CommandAfterEntry),postrotate); + if (!yon_char_is_empty(preremove)) gtk_entry_set_text(GTK_ENTRY(window->EndworkCommandEntry),preremove); } } } @@ -1820,19 +1731,23 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind return window; } -void on_logrotate_add(GtkWidget *self, logrotate_window *dialog){ +void on_logrotate_add(GtkWidget *, logrotate_window *dialog){ logrotate_configure_window *window = yon_logrotate_window_new(NULL,NULL,NULL); gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->MainTree))); - gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(dialog->Window)); + yon_gtk_window_setup(GTK_WINDOW(window->MainWindow),GTK_WINDOW(dialog->Window),TITLE_LABEL,icon_path,"logrotate_add_window"); gtk_widget_show(window->MainWindow); gtk_widget_set_sensitive(window->LogNameEntry,1); gtk_widget_set_sensitive(window->LogDescriptionEntry,1); gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),""); } -void on_logrotate_edit(GtkWidget *self, logrotate_window *window){ +void on_logrotate_edit_activate(GtkWidget*,GtkTreePath*,GtkTreeViewColumn*, logrotate_window *window){ + on_logrotate_edit(NULL,window); +} + +void on_logrotate_edit(GtkWidget *, logrotate_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); - GtkTreeIter iter,itar; + GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){ char *name; int size=0; @@ -1846,6 +1761,7 @@ void on_logrotate_edit(GtkWidget *self, logrotate_window *window){ } gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,-1); logrotate_configure_window *dialog = yon_logrotate_window_new(paths,window,name); + yon_gtk_window_setup(GTK_WINDOW(dialog->MainWindow),GTK_WINDOW(window->Window),TITLE_LABEL,icon_path,"logrotate_edit_window"); gtk_widget_show(dialog->MainWindow); gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name ? name : ""); gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description ? description : ""); @@ -1857,7 +1773,7 @@ void on_logrotate_edit(GtkWidget *self, logrotate_window *window){ } -void on_logrotate_remove(GtkWidget *self, logrotate_window *window){ +void on_logrotate_remove(GtkWidget *, logrotate_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){ @@ -1868,7 +1784,12 @@ void on_logrotate_remove(GtkWidget *self, logrotate_window *window){ } } -void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ +void on_logrotate_apps_configure_activate(GtkWidget *, GtkTreePath*, GtkTreeViewColumn*,logrotate_window *window){ + on_logrotate_apps_configure(NULL,window); +} + + +void on_logrotate_apps_configure(GtkWidget *, logrotate_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_apps_list); GtkTreeIter iter,itar,itor; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->AppsMainTree)),&model,&iter)){ @@ -1902,27 +1823,29 @@ void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ gtk_list_store_set(main_config.logrotate_list,&itar,0,name,1,paths,-1); paths = yon_char_replace(paths,"\n",","); yon_config_register(LOGROTATE(name),"logging",yon_char_unite(paths,":",settings,NULL)); + textdomain(template_ui_LocaleName); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),SUCCESS_LABEL,5,BACKGROUND_IMAGE_SUCCESS_TYPE); + textdomain(LocaleName); } } -void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){ +void on_log_edit_logrotate_settings(GtkWidget *, dictionary *dict){ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); add_log_window *window = yon_dictionary_get_data(dict->first->next,add_log_window*); GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); - GtkTreeIter iter,itar; + GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ char *name; char *description; gtk_tree_model_get(model,&iter,0,&name,2,&description,-1); GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); char *pathse=NULL; - for (int i=0;iMainWindow),GTK_WINDOW(window->MainWindow)); + yon_gtk_window_setup(GTK_WINDOW(dialog->MainWindow),GTK_WINDOW(window->MainWindow),LOGROTATE_TITLE_LABEL,icon_path,"LogrotateWindow"); gtk_widget_show(dialog->MainWindow); gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description); @@ -1938,7 +1861,7 @@ void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){ // Logrotate tab window -void on_logrotate_tab_selection_changed(GtkWidget *self, logrotate_window *window){ +void on_logrotate_tab_selection_changed(GtkWidget *, logrotate_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model,&iter)){ @@ -1952,7 +1875,7 @@ void on_logrotate_tab_selection_changed(GtkWidget *self, logrotate_window *windo } } -void on_logrotate_applications_tab_selection_changed(GtkWidget *self, logrotate_window *window){ +void on_logrotate_applications_tab_selection_changed(GtkWidget *, logrotate_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_apps_list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->AppsMainTree)),&model,&iter)){ @@ -1962,7 +1885,15 @@ void on_logrotate_applications_tab_selection_changed(GtkWidget *self, logrotate_ } } -void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ +void on_logrotate_closed(GtkWidget *self,logrotate_window *window){ + gtk_widget_destroy(window->Menu->menu); + gtk_widget_destroy(window->AppsMenu->menu); + free(window->Menu); + free(window->AppsMenu); + on_subwindow_close(self); +} + +void on_logrotate_tab_open(GtkWidget *, main_window *widgets){ logrotate_window *window = malloc(sizeof(logrotate_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_table_path); window->Window=yon_gtk_builder_get_widget(builder,"MainWindow"); @@ -1983,8 +1914,8 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree),GTK_TREE_MODEL(main_config.logrotate_list)); gtk_tree_view_set_model(GTK_TREE_VIEW(window->AppsMainTree),GTK_TREE_MODEL(main_config.logrotate_apps_list)); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"LogrotateTabWindow"); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_close_subwindow),"LogrotateTabWindow"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_logrotate_closed),window); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_logrotate_closed),window); g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_logrotate_add),window); g_signal_connect(G_OBJECT(window->RemoveButton),"clicked",G_CALLBACK(on_logrotate_remove),window); g_signal_connect(G_OBJECT(window->ConfigureButton),"clicked",G_CALLBACK(on_logrotate_edit),window); @@ -1992,6 +1923,17 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->MainTree),"cursor-changed",G_CALLBACK(on_logrotate_tab_selection_changed),window); g_signal_connect(G_OBJECT(window->AppsMainTree),"cursor-changed",G_CALLBACK(on_logrotate_applications_tab_selection_changed),window); + g_signal_connect(G_OBJECT(window->MainTree),"row-activated",G_CALLBACK(on_logrotate_edit_activate),window); + g_signal_connect(G_OBJECT(window->AppsMainTree),"row-activated",G_CALLBACK(on_logrotate_apps_configure_activate),window); + + window->Menu = yon_rmb_menu_setup(window->MainTree,NULL,NULL, + ADD_CONFIGURATION_LABEL,add_icon_name,G_CALLBACK(on_logrotate_add),window, + REMOVE_CONFIGURATION_LABEL,minus_icon_name,G_CALLBACK(on_logrotate_remove),window, + CONFIGURE_CONFIGURATION_LABEL,settings_icon_name,G_CALLBACK(on_logrotate_edit),window, + NULL); + window->AppsMenu = yon_rmb_menu_setup(window->AppsMainTree,NULL,NULL, + IMPORT_CONFIGURATION_LABEL,import_icon_name,G_CALLBACK(on_logrotate_apps_configure),window, + NULL); gtk_widget_show(window->Window); } @@ -2007,7 +1949,7 @@ void yon_combo_compress_check(GtkComboBox *self, journald_window *window){ } } -void on_journald_reset(GtkWidget *self, journald_window *window){ +void on_journald_reset(GtkWidget *, journald_window *window){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionCombo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RedirectCombo),0); @@ -2037,8 +1979,8 @@ void on_journald_reset(GtkWidget *self, journald_window *window){ gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LowerTimeEntry),0); } -void on_journald_save(GtkWidget *self, journald_window *window){ - char *storage; +void on_journald_save(GtkWidget *, journald_window *window){ + char *storage = ""; int storage_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogStorageCombo)); switch (storage_active){ case 1: storage="volatile"; @@ -2051,7 +1993,7 @@ void on_journald_save(GtkWidget *self, journald_window *window){ break; } - char *compress; + char *compress = ""; int compress_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogCompressionCombo)); if (compress_active==1) compress = "yes"; else if (compress_active==2) compress = "no"; @@ -2070,7 +2012,7 @@ void on_journald_save(GtkWidget *self, journald_window *window){ break; } } - char *splitmode; + char *splitmode = ""; int splitmode_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->DivideJournalFilesCombo)); if (splitmode_active == 1) splitmode = "uid"; else if (splitmode_active == 2 ) splitmode = "none"; @@ -2161,10 +2103,10 @@ void on_journald_save(GtkWidget *self, journald_window *window){ yon_config_register(JOURNALD("MaxLevelConsole"),"logging",yon_char_from_int(forwardempty-1)); else yon_config_remove_by_key(JOURNALD("MaxLevelConsole")); - on_close_subwindow(window->MainWindow,"JournaldWindow"); + on_subwindow_close(window->MainWindow); } -journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ +journald_window *yon_journald_open(GtkWidget *, main_window *widgets){ journald_window *window = malloc(sizeof(journald_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_journald_path); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); @@ -2209,13 +2151,15 @@ journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ { int sz; config_str logsize = yon_config_load(journald_size_command,&sz); - if (logsize) - if (logsize[0][strlen(logsize[0])-1]=='\n') logsize[0][strlen(logsize[0])-1]='\0'; + if (logsize){ + if (logsize[0][strlen(logsize[0])-1]=='\n') + logsize[0][strlen(logsize[0])-1]='\0'; + } gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),logsize[0]); } gtk_window_set_title(GTK_WINDOW(window->MainWindow),JOURNALD_TITLE_LABEL); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"JournaldWindow"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_journald_save),window); g_signal_connect(G_OBJECT(window->ResetButton),"clicked",G_CALLBACK(on_journald_reset),window); @@ -2314,8 +2258,8 @@ void on_journald_open(GtkWidget *self, main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionLabel),description); gtk_entry_set_text(GTK_ENTRY(window->LogNameLabel),name); } - int jsize; - config_str journald_parameters = yon_config_get_all_by_key("JOURNALD[",&jsize); + // int jsize; + // config_str journald_parameters = yon_config_get_all_by_key("JOURNALD[",&jsize); gtk_widget_show(window->MainWindow); } @@ -2326,9 +2270,15 @@ void on_log_save(GtkWidget *self, dictionary *dict){ add_log_window *window = yon_dictionary_get_data(dict->first->next,add_log_window*); GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); char *pathse=NULL; - for (int i=0;iStatusBox),error,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect((GtkWidget*)g_list_nth_data(paths,1)); + return; + } if (strcmp(cur,"")) pathse=yon_char_unite(pathse ? yon_char_append(pathse,"\n"):"",cur,NULL); } @@ -2349,7 +2299,7 @@ void on_log_save(GtkWidget *self, dictionary *dict){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEAT_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; } - GtkTreeIter iter; + // GtkTreeIter iter; char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); char *desc = (char*)gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)); if (!yon_char_is_empty(name)){ @@ -2378,16 +2328,18 @@ void on_log_save(GtkWidget *self, dictionary *dict){ } gtk_list_store_append(widgets->list,&iter); gtk_list_store_set(widgets->list,&iter,3,0,-1); - gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",3,0,-1); + gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,!yon_char_is_empty(desc) ? desc : "",3,0,-1); yon_window_config_custom_window_set(GTK_WINDOW(window->MainWindow),"AddWindow"); } else { yon_window_config_custom_window_set(GTK_WINDOW(window->MainWindow),"EditWindow"); char *nm; - gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,0,&nm,3,&stat,-1); - stat = stat==0?0:stat==1?2:2; + char *paths_old; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,0,&nm,1,&paths_old,3,&stat,-1); + if (strcmp(paths_old,pathse)) + stat = stat==0?0:stat==1?2:2; gtk_list_store_set(widgets->list,&iter,3,stat,-1); } - gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",3,stat,-1); + gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,!yon_char_is_empty(desc) ? desc : "",3,stat,-1); if (stat==2) gtk_widget_set_sensitive(widgets->RemoveButton,1); } else { yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),WRITE_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); @@ -2395,7 +2347,7 @@ void on_log_save(GtkWidget *self, dictionary *dict){ return; } yon_logs_custom_save(widgets); - on_close_subwindow(self,NULL); + on_subwindow_close(self); } add_log_window *on_add_open(main_window *widgets){ @@ -2427,7 +2379,7 @@ add_log_window *on_add_open(main_window *widgets){ void on_log_path_remove(GtkWidget *self, add_log_window *window){ GList *paths = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); - for (int i=0;iFileChooser)); GFileType type = g_file_query_file_type(file,G_FILE_QUERY_INFO_NONE, NULL); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->FileOrDirCheck))){ @@ -2463,17 +2415,21 @@ void on_log_path_filechooser_selection_changed(GtkWidget *self, logrotate_filech } } -void on_log_path_filechooser_toggled(GtkWidget *self, logrotate_filechooser_window *dialog){ +void on_log_path_filechooser_toggled(GtkWidget *, logrotate_filechooser_window *dialog){ on_log_path_filechooser_selection_changed(NULL,dialog); } -void on_log_path_filechooser_save(GtkWidget *self, dictionary *dict){ +void on_log_path_filechooser_save(GtkWidget *, dictionary *dict){ GtkEntry *entry = yon_dictionary_get_data(dict->first,GtkEntry*); logrotate_filechooser_window *dialog = yon_dictionary_get_data(dict->first->next,logrotate_filechooser_window*); char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->FileChooser)); GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(dialog->FileChooser)); if (!file){ filename = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->FileChooser)); + if (yon_char_is_empty(filename)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(dialog->StatusBox),NOTHING_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } if (filename[strlen(filename)-1]=='/') filename = yon_char_append(filename,"*"); else @@ -2490,10 +2446,10 @@ void on_log_path_filechooser_save(GtkWidget *self, dictionary *dict){ } gtk_entry_set_text(entry,filename); - on_close_subwindow(dialog->FileChooser,NULL); + on_subwindow_close(dialog->FileChooser); } -void on_log_path_filechooser_open(GtkWidget *self, GtkEntry *entry){ +void on_log_path_filechooser_open(GtkWidget *, GtkEntry *entry){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_filechooser_path); logrotate_filechooser_window *dialog = malloc(sizeof(logrotate_filechooser_window)); dialog->FileChooser = yon_gtk_builder_get_widget(builder,"FileChooser"); @@ -2509,14 +2465,14 @@ void on_log_path_filechooser_open(GtkWidget *self, GtkEntry *entry){ yon_dictionary_add_or_create_if_exists_with_data(dict,"entry",entry); yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog); - g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),"FileDialog"); + g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(dialog->AcceptButton),"clicked",G_CALLBACK(on_log_path_filechooser_save),dict); g_signal_connect(G_OBJECT(dialog->FileChooser),"selection-changed",G_CALLBACK(on_log_path_filechooser_selection_changed),dialog); g_signal_connect(G_OBJECT(dialog->FileOrDirCheck),"toggled",G_CALLBACK(on_log_path_filechooser_toggled),dialog); gtk_widget_show(dialog->FileChooser); } -void on_log_path_choose(GtkWidget *self,add_log_window *window){ +void on_log_path_choose(GtkWidget *self,add_log_window *){ GtkWidget *parent = gtk_widget_get_parent(self); GList *list = gtk_container_get_children(GTK_CONTAINER(parent)); on_log_path_filechooser_open(NULL,(GtkEntry*)g_list_nth_data(list,1)); @@ -2536,7 +2492,7 @@ void on_log_path_append(GtkWidget *self, add_log_window *window){ return; }else { GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); - for (int i=0;iLogPathsBox),box_path,0,0,5); } -void on_log_add(GtkWidget *self, main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); - GtkTreeIter iter; +void on_log_add(GtkWidget *, main_window *widgets){ + // GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); + // GtkTreeIter iter; add_log_window *window = on_add_open(widgets); yon_window_config_custom_window_get(GTK_WINDOW(window->MainWindow),"AddWindow"); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),"AddWindow"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_subwindow_close),NULL); gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree))); + on_main_window_tree_selection_changed(NULL,widgets); gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); gtk_widget_hide(window->ControlSectionBox); on_log_path_append(NULL,window); } -void on_log_edit(GtkWidget *self,main_window *widgets){ +void on_log_edit_activate(GtkWidget *, GtkTreePath *, GtkTreeViewColumn *, main_window *widgets); +void on_log_edit_activate(GtkWidget *, GtkTreePath *, GtkTreeViewColumn *, main_window *widgets){ + on_log_edit(widgets->ServicesEditButton,widgets); +} + +void on_log_edit(GtkWidget *,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ add_log_window *window = on_add_open(widgets); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),"EditWindow"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_subwindow_close),NULL); yon_window_config_custom_window_get(GTK_WINDOW(window->MainWindow),"EditWindow"); gtk_widget_show(window->MainWindow); - gtk_widget_hide(window->StatisticsFrame); char *name; char *paths; int size; @@ -2618,6 +2579,16 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ float finalsize=0.0; char *temp_paths = yon_char_new(paths); config_str parsed_paths = yon_char_parse(temp_paths,&sz,"\n"); + + int paths_size; + config_str paths_overall_size = yon_config_load(yon_debug_output("%s\n",get_file_folder_size(yon_char_parsed_to_string(parsed_paths,sz," "))),&paths_size); + char *overall = yon_char_divide_search(paths_overall_size[paths_size-1],"\t",-1); + yon_char_parsed_free(paths_overall_size,paths_size); + if (!yon_char_is_empty(overall)&&strcmp(overall,"0")){ + gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),overall); + } else { + gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),NO_FILES_FOUND_LABEL); + } free(temp_paths); temp_paths=NULL; for (int i=0;ilist); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model, &iter)){ @@ -2711,13 +2684,11 @@ void on_log_remove(GtkWidget *self, main_window *widgets){ int stay_paths=0; char *paths; gtk_tree_model_get(model,&iter,1,&paths,4,&stay_paths,-1); - char *stay; - for (int i=0;ilist,&iter,1,paths,3,1,-1); + int size; + config_str parsed = yon_char_parse(paths,&size,"\n"); + char *stay = yon_char_parsed_to_string_for_iters(parsed,size,"\n",stay_paths); + yon_char_parsed_free(parsed,size); + gtk_list_store_set(widgets->list,&iter,1,stay,3,1,-1); gtk_widget_set_sensitive(widgets->RemoveButton,0); } } @@ -2727,6 +2698,12 @@ void on_log_remove(GtkWidget *self, main_window *widgets){ // Main window +void on_service_edit_activate(GtkWidget *, GtkTreePath *, GtkTreeViewColumn *, main_window *widgets); +void on_service_edit_activate(GtkWidget *, GtkTreePath *, GtkTreeViewColumn *, main_window *widgets){ + on_service_edit(NULL,widgets); +} + + void on_service_edit(GtkWidget *self,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); GtkTreeIter iter; @@ -2741,69 +2718,103 @@ void on_service_edit(GtkWidget *self,main_window *widgets){ } } -void on_main_window_tree_selection_changed(GtkWidget *self,main_window *widgets){ +void on_main_window_tree_selection_changed(GtkWidget *,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; + GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->LogsRMBMenu->menu)); + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ gboolean is_standard; gtk_tree_model_get(model,&iter,3,&is_standard,-1); gtk_widget_set_sensitive(widgets->AddButton,1); - if (!is_standard||is_standard==2) + if (!is_standard||is_standard==2){ gtk_widget_set_sensitive(widgets->RemoveButton,1); - else + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,2)),1); + } + else{ gtk_widget_set_sensitive(widgets->RemoveButton,0); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,2)),0); + } gtk_widget_set_sensitive(widgets->InspectButton,1); gtk_widget_set_sensitive(widgets->ConfigureButton,1); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,1)),1); } else { gtk_widget_set_sensitive(widgets->AddButton,1); gtk_widget_set_sensitive(widgets->RemoveButton,0); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,1)),0); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,2)),0); gtk_widget_set_sensitive(widgets->InspectButton,0); gtk_widget_set_sensitive(widgets->ConfigureButton,0); } } -void on_main_window_services_tree_selection_changed(GtkWidget *self,main_window *widgets){ +void on_main_window_services_tree_selection_changed(GtkWidget *,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); GtkTreeIter iter; - if (getuid()!=0){ - gtk_widget_set_sensitive(widgets->ServicesEditButton,0); - gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,0); - gtk_widget_set_sensitive(widgets->ServicesStartStopButton,0); - return; - } if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ gboolean is_active; gboolean is_enabled; char *name; + GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->ServicesRMBMenu->menu)); gtk_tree_model_get(model,&iter,0,&is_active,1,&is_enabled,2,&name,-1); if (is_active){ gtk_widget_set_sensitive(widgets->ServicesEditButton,1); gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,1); gtk_widget_set_sensitive(widgets->ServicesStartStopButton,1); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,0)),1); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,1)),1); gtk_widget_set_tooltip_text(widgets->ServicesEnableDisableButton,AUTOSTART_OFF_LABEL); gtk_widget_set_tooltip_text(widgets->ServicesStartStopButton,STOP_SERVICE_LABEL); gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesStartStopButton))),stop_icon_name,GTK_ICON_SIZE_BUTTON); + GList *item = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(list,0))); + GList *items = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(item,0))); + gtk_image_set_from_icon_name(GTK_IMAGE(g_list_nth_data(items,0)),stop_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_label_set_text(GTK_LABEL(g_list_nth_data(items,1)),STOP_SERVICE_LABEL); + g_list_free(item); + g_list_free(items); } else { gtk_widget_set_sensitive(widgets->ServicesEditButton,0); gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,1); gtk_widget_set_sensitive(widgets->ServicesStartStopButton,1); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,0)),1); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,1)),1); gtk_widget_set_tooltip_text(widgets->ServicesEnableDisableButton,AUTOSTART_ON_LABEL); gtk_widget_set_tooltip_text(widgets->ServicesStartStopButton,START_SERVICE_LABEL); gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesStartStopButton))),start_icon_name,GTK_ICON_SIZE_BUTTON); + GList *item = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(list,0))); + GList *items = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(item,0))); + gtk_image_set_from_icon_name(GTK_IMAGE(g_list_nth_data(items,0)),start_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_label_set_text(GTK_LABEL(g_list_nth_data(items,1)),START_SERVICE_LABEL); + g_list_free(item); + g_list_free(items); } if (is_enabled){ gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesEnableDisableButton))),disable_icon_name,GTK_ICON_SIZE_BUTTON); + GList *item = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(list,1))); + GList *items = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(item,0))); + gtk_image_set_from_icon_name(GTK_IMAGE(g_list_nth_data(items,0)),disable_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_label_set_text(GTK_LABEL(g_list_nth_data(items,1)),AUTOSTART_OFF_LABEL); + g_list_free(item); + g_list_free(items); } else { gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesEnableDisableButton))),enable_icon_name,GTK_ICON_SIZE_BUTTON); - + GList *item = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(list,1))); + GList *items = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(item,0))); + gtk_image_set_from_icon_name(GTK_IMAGE(g_list_nth_data(items,0)),enable_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_label_set_text(GTK_LABEL(g_list_nth_data(items,1)),AUTOSTART_ON_LABEL); + g_list_free(item); + g_list_free(items); } if (!strcmp(name,"journald")){ + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,0)),0); + gtk_widget_set_sensitive(GTK_WIDGET(g_list_nth_data(list,1)),0); gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,0); gtk_widget_set_sensitive(widgets->ServicesStartStopButton,0); gtk_widget_set_tooltip_text(widgets->ServicesEnableDisableButton,AUTOSTART_OFF_LABEL); gtk_widget_set_tooltip_text(widgets->ServicesStartStopButton,STOP_SERVICE_LABEL); } + g_list_free(list); } else { gtk_widget_set_sensitive(widgets->ServicesEditButton,0); gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,0); @@ -2813,31 +2824,45 @@ void on_main_window_services_tree_selection_changed(GtkWidget *self,main_window } } -void on_start_stop_clicked(GtkButton *self, main_window *widgets){ +void on_start_stop_clicked(GtkButton *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); GtkTreeIter iter; + GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->ServicesRMBMenu->buttons->first->data)); + GList *box = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(list,0))); if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ char *start_command; char *stop_command; gboolean is_started; gtk_tree_model_get(model,&iter,0,&is_started,4,&start_command,5,&stop_command,-1); if (is_started){ - yon_launch(stop_command); + g_spawn_command_line_sync(yon_debug_output("%s\n",stop_command),NULL,NULL,NULL,NULL); gtk_list_store_set(widgets->ServicesList,&iter,0,0,-1); - gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),start_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesStartStopButton))),start_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(g_list_nth_data(box,0)),start_icon_name,GTK_ICON_SIZE_BUTTON); gtk_widget_set_tooltip_text(widgets->ServicesStartStopButton,START_SERVICE_LABEL); } else { - yon_launch(start_command); + g_spawn_command_line_sync(yon_debug_output("%s\n",start_command),NULL,NULL,NULL,NULL); gtk_list_store_set(widgets->ServicesList,&iter,0,1,-1); - gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),stop_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesStartStopButton))),stop_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(g_list_nth_data(box,0)),stop_icon_name,GTK_ICON_SIZE_BUTTON); gtk_widget_set_tooltip_text(widgets->ServicesStartStopButton,STOP_SERVICE_LABEL); } } } -void on_enable_disable_clicked(GtkButton *self, main_window *widgets){ +queue_func *yon_queue_add_function(GSourceFunc func,void *data); +queue_func *yon_queue_add_function(GSourceFunc func,void *data){ + queue_func *queue = malloc(sizeof(queue_func)); + queue->func=func; + queue->data=data; + return queue; +} + +void on_enable_disable_clicked(GtkButton *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); GtkTreeIter iter; + GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->ServicesRMBMenu->buttons->first->next->data)); + GList *box = gtk_container_get_children(GTK_CONTAINER(g_list_nth_data(list,0))); if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ char *start_command; char *stop_command; @@ -2846,76 +2871,96 @@ void on_enable_disable_clicked(GtkButton *self, main_window *widgets){ if (is_started){ yon_launch(stop_command); gtk_list_store_set(widgets->ServicesList,&iter,1,0,-1); - gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),enable_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesEnableDisableButton))),enable_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(g_list_nth_data(box,0)),enable_icon_name,GTK_ICON_SIZE_BUTTON); gtk_widget_set_tooltip_text(widgets->ServicesEnableDisableButton,AUTOSTART_ON_LABEL); } else { + /* + g_mutex_lock(&main_config.authorized_mutex); + main_config.queue_size += 1; + main_config.queue = yon_remalloc(main_config.queue,sizeof(queue_func**)*(main_config.queue_size)); + main_config.queue[main_config.queue_size-1] = yon_queue_add_function(G_SOURCE_FUNC(system),start_command); + g_mutex_unlock(&main_config.authorized_mutex);*/ yon_launch(start_command); gtk_list_store_set(widgets->ServicesList,&iter,1,1,-1); - gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),disable_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesEnableDisableButton))),disable_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(g_list_nth_data(box,0)),disable_icon_name,GTK_ICON_SIZE_BUTTON); gtk_widget_set_tooltip_text(widgets->ServicesEnableDisableButton,AUTOSTART_OFF_LABEL); } } } // standard functions - -void on_permissions_changed(){ - if (g_permission_get_allowed(main_config.permissions)){ - PolkitAuthority *auth = polkit_authority_get_sync(NULL,NULL); - PolkitSubject *subject; - pid_t parent_pid; - parent_pid = getppid (); - subject = polkit_unix_process_new_for_owner (parent_pid,0,getuid()); - PolkitDetails *dets = polkit_details_new(); - if (polkit_authority_check_authorization_sync(auth,subject,"com.ublinux.ubl-settings-logging",dets,POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,NULL,NULL)){ - printf("Allowed\n"); - char *command[] = {"/bin/pkexec","/bin/echo","1", NULL}; - gchar *standard_output = NULL; - gchar *standard_error = NULL; - gint exit_status = -1; - - GError *error = NULL; - gboolean success = g_spawn_sync( - NULL, - command, - NULL, - G_SPAWN_DEFAULT, - NULL, - NULL, - &standard_output, - &standard_error, - NULL, - &error - ); - - if (success) { - if (standard_output != NULL) { - printf("Output: %s\n", standard_output); - g_free(standard_output); - } - if (standard_error != NULL) { - printf("Error output: %s\n", standard_error); - g_free(standard_error); - } - printf("Exit status: %d\n", exit_status); - } else { - g_printerr("Error running command: %s\n", error->message); - g_error_free(error); - } - } else { - if (g_permission_get_can_acquire(main_config.permissions)){ - g_permission_acquire(main_config.permissions,NULL,NULL); +gboolean on_unelevate(main_window* widgets); +gboolean on_unelevate(main_window* widgets){ + yon_ubl_status_box_render(UNAUTHTORIZED_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + gtk_widget_set_sensitive(widgets->UpgradePermissionsMenuItem,1); + g_object_unref(main_config.authorization_result); + main_config.authorization_result=NULL; + return G_SOURCE_REMOVE; +} +gboolean yon_timeoutcheck_authtorization(gpointer widgets); +gboolean yon_timeoutcheck_authtorization(gpointer widgets){ + + if (!polkit_authorization_result_get_is_authorized(main_config.authorization_result)){ + gdk_threads_add_idle((GSourceFunc)on_unelevate,widgets); + return G_SOURCE_REMOVE; + } + return G_SOURCE_CONTINUE; +} + +void *yon_authorized_loop(void*); +void *yon_authorized_loop(void*){ + while (polkit_authorization_result_get_is_authorized(main_config.authorization_result)){ + g_mutex_lock(&main_config.authorized_mutex); + if (main_config.queue){ + for (int i=0;ifunc)(main_config.queue[i]->data); } + free(main_config.queue); + main_config.queue=NULL; + main_config.queue_size=0; } + g_mutex_unlock(&main_config.authorized_mutex); + } + return NULL; +} + +void authorize_callback(GObject *source, GAsyncResult *res, main_window *widgets); +void authorize_callback(GObject *source, GAsyncResult *res, main_window *widgets){ + GError *err = NULL; + main_config.authorization_result = polkit_authority_check_authorization_finish(POLKIT_AUTHORITY(source),res,&err); + if (err){ + + } + + g_thread_new("auth_loop",(GThreadFunc)yon_authorized_loop,NULL); + yon_ubl_status_box_render(AUTHTORIZED_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + g_timeout_add(10000, (GSourceFunc)yon_timeoutcheck_authtorization,widgets); + +} + +void on_permissions_changed(GtkMenuItem *,main_window *widgets){ + PolkitAuthority *authority; + GError *error = NULL; + authority = polkit_authority_get_sync(NULL,&error); + if (!authority){ + return; } + polkit_authority_check_authorization( + authority, + main_config.process, + "org.freedesktop.policykit.exec", + NULL, + POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, + NULL, + (GAsyncReadyCallback)authorize_callback, + widgets + ); } 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; @@ -2926,51 +2971,25 @@ void config_init(){ main_config.lock_save_local=0; main_config.remove_thread=-1; main_config.load_mode=1; - - PolkitSubject *subject = NULL; - + main_config.save_config=1; + main_config.queue=NULL; + main_config.queue_size=0; + main_config.process = polkit_unix_process_new_for_owner(getpid(),0,getuid()); pid_t parent_pid; parent_pid = getppid (); if (parent_pid == 1) { g_printerr ("Parent process was reaped by init(1)\n"); } - subject = polkit_unix_process_new_for_owner (parent_pid,0,getuid()); - main_config.permissions = polkit_permission_new_sync("com.ublinux.ubl-settings-logging",subject,NULL,NULL); - g_signal_connect(G_OBJECT(main_config.permissions),"notify::allowed",G_CALLBACK(on_permissions_changed),NULL); } -main_window *setup_window(){ +void yon_main_window_complete(template_main_window **window){ /* Widgets getting | Получение виджетов */ - main_window *widgets = malloc(sizeof(main_window)); + main_window *widgets = realloc(*window,sizeof(main_window)); + (*window) = (template_main_window*)widgets; 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"); + gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"PlugBox"),1,1,0); - 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_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL); - widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL); widgets->InspectButton = yon_gtk_builder_get_widget(builder,"MainInspectButton"); widgets->ConfigureButton = yon_gtk_builder_get_widget(builder,"MainConfigureButton"); @@ -2985,161 +3004,163 @@ main_window *setup_window(){ widgets->ServicesList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ServicesList")); widgets->UpgradePermissionsMenuItem = yon_gtk_builder_get_widget(builder,"UpgradePermissionsMenuItem"); + gtk_menu_shell_prepend(GTK_MENU_SHELL(gtk_widget_get_parent(widgets->AboutMenuItem)),widgets->UpgradePermissionsMenuItem); widgets->MainTree = yon_gtk_builder_get_widget(builder,"MainTree"); gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL); - - GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem); - gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem); - - if (main_config.lock_load_global == 1){ - gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); - } - if (main_config.lock_save_global == 1){ - gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveMenuItem,0); - } - if (main_config.lock_save_local == 1){ - gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveMenuItem,0); - } - int size; - int service_size; - int dirs_size; - char *cname=NULL; - char *cparams=""; - GtkTreeIter iter; - config_str journals = yon_file_open(journals_list_path,&size); - for (int i=1;ilist,&iter); - config_str sfafa = yon_char_parse(log[1],&psize,"\n"); - if (sfafa) - free(sfafa); - gtk_list_store_set(widgets->list,&iter,0,log[0],1,log[1],2,_(log[2]),3,1,4,psize,-1); - } - config_str services = yon_file_open(services_list_path,&service_size); - for (int i=1;iServicesList,&iter); - gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,_(log[1]),4,log[2],5,log[3],6,log[4],7,log[5],8,log[6],-1); - } + + { + + if (main_config.lock_load_global == 1){ + gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); + } + if (main_config.lock_save_global == 1){ + gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); } - config_str dirs = yon_config_load(logrotate_config_command,&dirs_size); - for (int i=0;iSaveLocalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); + } + int size; + int service_size; + int dirs_size; + char *cname=NULL; + char *cparams=""; + GtkTreeIter iter; + config_str journals = yon_file_open(journals_list_path,&size); + for (int i=1;ilist,&iter); + config_str sfafa = yon_char_parse(log[1],&psize,"\n"); + if (sfafa) + free(sfafa); + gtk_list_store_set(widgets->list,&iter,0,log[0],1,log[1],2,_(log[2]),3,1,4,psize,-1); + } + config_str services = yon_file_open(services_list_path,&service_size); + for (int i=1;iServicesList,&iter); + gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,_(log[1]),4,log[2],5,log[3],6,log[4],7,log[5],8,log[6],-1); + } } - if (file[j][0]!='#'&&bracket_found==0&&strcmp(file[j],"")){ - if (strstr(file[j],"{")) { - bracket_found = 1; - yon_char_divide_search_self(file[j],"{",-1); - if (!cname) cname = file[j]; - continue; + config_str dirs = yon_config_load(logrotate_config_command,&dirs_size); + for (int i=0;iMainTree)); + for (guint i=0; iServicesTree)); + for (guint i=0; iMainTree)); - for (int i=0; iServicesTree)); - for (int i=0; ilist),&iter); - for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->list),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,0,&cur_name,-1); - if (!strcmp(cur_name,cur_watcher[0])){ - found=1; - break; + main_config.groups = yon_file_open(group_list_path,&main_config.groups_size); + for (int i=0;ilist),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->list),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(widgets->list),&iter,0,&cur_name,-1); + if (!strcmp(cur_name,cur_watcher[0])){ + found=1; + break; + } } + if (!found) + gtk_list_store_append(widgets->list,&iter); + cur_watcher[1] = yon_char_replace(cur_watcher[1],",","\n"); + gtk_list_store_set(widgets->list,&iter,0,cur_watcher[0],1,cur_watcher[1],2,cur_watcher[2]?cur_watcher[2]:"",3,found ? 2 : 0,-1); + yon_char_parsed_free(cur_watcher,cur_size); } - if (!found) - gtk_list_store_append(widgets->list,&iter); - cur_watcher[1] = yon_char_replace(cur_watcher[1],",","\n"); - gtk_list_store_set(widgets->list,&iter,0,cur_watcher[0],1,cur_watcher[1],2,cur_watcher[2]?cur_watcher[2]:"",3,found ? 2 : 0,-1); - yon_char_parsed_free(cur_watcher,cur_size); } + } else { + if (access(custom_logs_saving_file_path,F_OK)){ + yon_file_create_full_path(custom_logs_saving_file_path,0777); + } + FILE *fl = fopen(custom_logs_saving_file_path,"w"); + fclose(fl); } - } else { - if (access(custom_logs_saving_file_path,F_OK)){ - yon_file_create_full_path(custom_logs_saving_file_path,0777); - } - FILE *fl = fopen(custom_logs_saving_file_path,"w"); - fclose(fl); } /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ // yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); /* Signal connection | Присоединение сигналов */ - 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->InspectButton),"clicked",G_CALLBACK(on_inspector_open),widgets); g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_log_add),widgets); g_signal_connect(G_OBJECT(widgets->ConfigureButton),"clicked",G_CALLBACK(on_log_edit),widgets); + g_signal_connect(G_OBJECT(widgets->MainTree),"row-activated",G_CALLBACK(on_log_edit_activate),widgets); g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_log_remove),widgets); g_signal_connect(G_OBJECT(widgets->ServicesEditButton),"clicked",G_CALLBACK(on_service_edit),widgets); + g_signal_connect(G_OBJECT(widgets->ServicesTree),"row-activated",G_CALLBACK(on_service_edit_activate),widgets); g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_save_global_local),NULL); g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_save_global),NULL); g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_save_local),NULL); + g_signal_connect(G_OBJECT(widgets->SaveCustomMenuItem),"activate",G_CALLBACK(on_config_custom_save),NULL); g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_load_global),NULL); g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_load_local),NULL); + g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(on_config_custom_load),NULL); - g_signal_connect(G_OBJECT(widgets->UpgradePermissionsMenuItem),"activate",G_CALLBACK(on_permissions_changed),NULL); + g_signal_connect(G_OBJECT(widgets->UpgradePermissionsMenuItem),"activate",G_CALLBACK(on_permissions_changed),widgets); g_signal_connect(G_OBJECT(widgets->MainTree),"cursor-changed",G_CALLBACK(on_main_window_tree_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->ServicesTree),"cursor-changed",G_CALLBACK(on_main_window_services_tree_selection_changed),widgets); @@ -3147,118 +3168,66 @@ main_window *setup_window(){ g_signal_connect(G_OBJECT(widgets->ServicesStartStopButton),"clicked",G_CALLBACK(on_start_stop_clicked),widgets); g_signal_connect(G_OBJECT(widgets->ServicesEnableDisableButton),"clicked",G_CALLBACK(on_enable_disable_clicked),widgets); + widgets->LogsRMBMenu = yon_rmb_menu_setup(widgets->MainTree,(RmbCheck)gtk_widget_get_sensitive,widgets->MainTree, + CONFIGURE_LOG_LABEL,settings_icon_name,G_CALLBACK(on_log_edit),widgets, + ADD_LOG_LABEL,add_icon_name,G_CALLBACK(on_log_add),widgets, + REMOVE_LOG_LABEL,remove_icon_name,G_CALLBACK(on_log_remove),widgets, + NULL); + widgets->ServicesRMBMenu = yon_rmb_menu_setup(widgets->ServicesTree,(RmbCheck)gtk_widget_get_sensitive,widgets->ServicesTree, + START_SERVICE_LABEL,start_icon_name,G_CALLBACK(on_start_stop_clicked),widgets, + AUTOSTART_ON_LABEL,enable_icon_name,G_CALLBACK(on_enable_disable_clicked),widgets, + CONFIGURE_SERVICE_LABEL,settings_icon_name,G_CALLBACK(on_service_edit),widgets, + NULL); + // yon_rmb_menu_setup(widgets->ServicesTree,(RmbCheck)gtk_widget_get_sensitive,widgets->MainTree,CONFIGURE_LOG_LABEL,edit_icon_name,G_CALLBACK(on_log_edit),widgets,ADD_LOG_LABEL,add_icon_name,G_CALLBACK(on_log_add),widgets,REMOVE_LOG_LABEL,remove_icon_name,G_CALLBACK(on_log_remove),widgets,NULL); gtk_widget_show(widgets->Window); - return widgets; + + yon_window_config_setup(GTK_WINDOW(widgets->Window)); + yon_window_config_load(config_path); + + { + GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->ServicesTree)); + for (guint i = 0; i < g_list_length(list); i++){ + yon_gtk_tree_view_column_minimal_fixed_size_set((GtkTreeViewColumn*)g_list_nth_data(list,i)); + } + g_list_free(list); + list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); + for (guint i = 0; i < g_list_length(list); i++){ + yon_gtk_tree_view_column_minimal_fixed_size_set((GtkTreeViewColumn*)g_list_nth_data(list,i)); + } + } + yon_save_window_set_postsave_function(on_save_done,widgets); + yon_save_window_set_postsave_failure_function(on_save_failed,widgets); + yon_load_proceed(YON_CONFIG_LOCAL); + update_loaded_logrotate(); } -int main(int argc, char *argv[], char **envp){ +int main(int argc, char *argv[]){ local=setlocale(LC_ALL, ""); textdomain (LocaleName); config_init(); - main_config.envp=envp; - 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;iHeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); - - yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); - if (getuid()!=0) + template_main_window *widgets = yon_ubl_window_setup(); + yon_main_window_complete(&widgets); + + char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL); + yon_window_config_load(path); + main_config.launch_arguments=yon_char_parsed_copy(argv,argc); + main_config.launch_size=argc; + if (getuid()!=0){ + textdomain(template_ui_LocaleName); 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); - GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->ServicesTree)); - for (int i = 0; i < g_list_length(list); i++){ - yon_gtk_column_minimal_fixed_size_set((GtkTreeViewColumn*)g_list_nth_data(list,i)); - } - g_list_free(list); - list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); - for (int i = 0; i < g_list_length(list); i++){ - yon_gtk_column_minimal_fixed_size_set((GtkTreeViewColumn*)g_list_nth_data(list,i)); + textdomain(LocaleName); } - yon_load_proceed(YON_CONFIG_LOCAL); - update_loaded_logrotate(); - 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); gtk_main(); + return 0; } \ No newline at end of file diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 2a20f0a..1e88364 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -1,6 +1,5 @@ #include #include -#include "ubl-utils.h" #include #include #include @@ -12,7 +11,9 @@ #include #include #include -#include "../compile/ubl-cmake.h" +#include +#include +#include #ifdef WEBKIT_FOUND #include #endif @@ -39,16 +40,25 @@ #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) #define journals_list_path "/usr/share/ubl-settings-logging/csv/journals_list.csv" #define services_list_path "/usr/share/ubl-settings-logging/csv/logging_services.csv" +#define icon_path "com.ublinux.ubl-settings-logging" #define logrotate_config_command "ls /etc/logrotate.d/ |sed -e 's/ */\\n/g'" #define journald_size_command "journalctl --disk-usage | grep -oE \"[0-9]{1,}.[0-9]{1,}[A-Z]\"" -#define logrotate_size_command(paths) yon_char_unite("du ",paths," |grep -oE '^[0-9]{1,}'",NULL) +#define logrotate_size_command(paths) yon_debug_output("%s\n",yon_char_unite("du ",paths," |grep -oE '^[0-9]{1,}'",NULL)) #define logrotate_config_path "/etc/logrotate.d/" #define custom_logs_saving_file_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/logwatcher.csv",NULL) +#define read_log_command(command) yon_debug_output("%s\n",yon_char_unite("sed -r \"s/\\x1B\\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g\" ",command,NULL)) + #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-logging" +#define config_get_command(source) yon_char_unite("ubconfig --source ",source," get logging LOGROTATE[*] JOURNALD[*]",NULL) +#define config_get_default_command "" + +#define config_get_global_only_parameters "" +#define config_get_local_only_parameters "" + #define JOURNALD(key) yon_char_unite("JOURNALD[",key,"]",NULL) #define LOGROTATE(key) yon_char_unite("LOGROTATE[",key,"]",NULL) @@ -61,13 +71,25 @@ #define get_journal_all_units_command "clear;systemd-analyze blame --no-pager" #define get_journal_init_tree_command "clear;systemd-analyze critical-chain --no-pager" +#define get_file_folder_size(path) yon_char_append("du -hsc ",path) +#define get_all_files_in_path(path) yon_char_append("find ",path) + #define group_list_path "/etc/group" +#define edit_icon_name "document-edit-symbolic" +#define add_icon_name "com.ublinux.ubl-settings-logging.increase-symbolic" +#define remove_icon_name "com.ublinux.libublsettingsui-gtk3.trash-symbolic" +#define minus_icon_name "com.ublinux.ubl-settings-logging.decrease-symbolic" + +#define import_icon_name "com.ublinux.ubl-settings-logging.back-symbolic" +#define settings_icon_name "com.ublinux.ubl-settings-logging.settings-symbolic" #define start_icon_name "com.ublinux.ubl-settings-logging.play-symbolic" #define stop_icon_name "com.ublinux.ubl-settings-logging.stop-symbolic" #define enable_icon_name "com.ublinux.ubl-settings-logging.check-symbolic" #define disable_icon_name "com.ublinux.ubl-settings-logging.uncheck-symbolic" +#define check_command_is_legit(command) !system(yon_char_unite("bash -c \"set -u; command -v ",command,"\"",NULL)) + #define yon_add_space_if_exists(string) yon_char_is_empty(string) ? "" : yon_char_append(",",string) typedef char* string; string version_application; @@ -75,23 +97,17 @@ string version_application; char *local; typedef struct { + GSourceFunc func; + void *data; +} queue_func; + +typedef struct { + template_config_fields + config_str launch_arguments; + int launch_size; char **envp; - int always_open_documentation; - int win_pos_x; - int win_pos_y; - int win_width; - int win_height; - - 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 load_mode; + int save_config; GtkListStore *logrotate_list; GtkListStore *logrotate_apps_list; @@ -105,37 +121,18 @@ typedef struct { pthread_t inspector_thread; int remove_thread; + PolkitAuthorizationResult *authorization_result; + PolkitSubject *process; + + queue_func** queue; + int queue_size; + + GMutex authorized_mutex; } config; typedef struct { //Standard - GtkWidget *Window; - GtkWidget *HatLabel; - GtkWidget *PlugBox; - - GtkWidget *HeadOverlay; - GtkWidget *HeadImage; - GtkWidget *HeadBox; - GtkWidget *HeadTitleLabel; - GtkWidget *HeadInfoLabel; - - GtkWidget *StatusBox; - 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; + template_window_fields GtkWidget *MainTree; GtkWidget *InspectButton; @@ -154,6 +151,8 @@ typedef struct { GtkWidget *UpgradePermissionsMenuItem; GtkWidget *PermissionsLock; // Custom + rmb_menu_window *LogsRMBMenu; + rmb_menu_window *ServicesRMBMenu; } main_window; @@ -252,6 +251,8 @@ typedef struct { GtkWidget *CancelButton; GtkWidget *SaveButton; GtkWidget *StatusBox; + rmb_menu_window *Menu; + rmb_menu_window *AppsMenu; } logrotate_window; typedef struct { @@ -372,4 +373,89 @@ typedef struct { YON_CONFIG_TYPE type; } saving_window; -main_window *setup_window(); \ No newline at end of file +typedef int (*RmbCheck)(void*); + +main_window *setup_window(); +void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path, saving_window *window); +char *yon_size_get_letter_from_int(int size); +int yon_size_get_int_from_letter(char size); +// void yon_polkit_authorized_action(GCallback *func); +void yon_logs_custom_save(main_window *widgets); +void update_loaded_logrotate(); +int yon_load_proceed(YON_CONFIG_TYPE type); +void on_load_global(); +void on_load_local(); +void on_config_custom_load(GtkWidget *,main_window *widgets); +void on_save_global_local(); +void on_save_global(); +void on_save_local(); +void on_config_custom_save(GtkWidget *, main_window *); +void on_save_done(main_window *widgets, config_str output, int size); +void on_save_failed(main_window *, config_str , int ); +void on_inspector_jornald_read_async(inspector_window *window); +void on_inspector_update(GtkWidget *self, inspector_window *window); +GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name,int mode); +void on_inspector_close(GtkWidget *self, inspector_window *window); +void on_inspector_open(GtkWidget *self, main_window *widgets); +void on_logrotate_configuration_path_filechooser_selection_changed(GtkWidget *self, logrotate_filechooser_window *dialog); +void on_logrotate_filechooser_file_dir_toggled(GtkWidget *self, logrotate_filechooser_window *dialog); +void on_logrotate_configuration_path_filechooser_save_edit(GtkWidget *self, dictionary *dict); +void on_logrotate_configuration_path_filechooser_save(GtkWidget *self, dictionary *dict); +void on_logrotate_configuration_path_filechooser_open(GtkWidget *self, logrotate_configure_window *window); +void on_logrotate_configuration_path_add(GtkWidget *self, logrotate_configure_window *window); +void on_path_editing_done(GtkCellRendererText* self,gchar* gtkpath,gchar* new_text,logrotate_configure_window *window); +void on_path_editing_cancel(GtkCellRendererText* self,logrotate_configure_window *window); +void on_logrotate_configuration_path_edit(GtkWidget *self, logrotate_configure_window *window); +void on_logrotate_configuration_path_remove(GtkWidget *self, logrotate_configure_window *window); +void on_combo_activate_first(GtkComboBox *self, GtkWidget *target); +void on_combo_activate_second(GtkComboBox *self, GtkWidget *target); +void on_file_amount_checked(GtkToggleButton *self, logrotate_configure_window *window); +void on_rules_accept(GtkWidget *self, dictionary *dict); +void on_rules_update(GtkWidget *self, logrotate_rules_window *window); +void on_rules_open(GtkWidget *self,GtkEntry *entry); +void on_filechooser_mode_switch(GtkWidget *self, logrotate_filechooser_window *window); +void on_filechooser_save(GtkWidget *self, dictionary *dict); +void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window); +void on_logrotate_period_check_toggled(GtkToggleButton *self,logrotate_configure_window *window); +void on_logrotate_paths_cursor_changed(GtkWidget *self, logrotate_configure_window *window); +int on_logrotate_check_repeats(GtkWidget *self, logrotate_configure_window *window); +void on_logrotate_save(GtkWidget *self, dictionary *dict); +logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_window *dialog, char *log_name); +void on_logrotate_add(GtkWidget *self, logrotate_window *dialog); +void on_logrotate_edit(GtkWidget *self, logrotate_window *window); +void on_logrotate_remove(GtkWidget *self, logrotate_window *window); +void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window); +void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict); +void on_logrotate_tab_selection_changed(GtkWidget *self, logrotate_window *window); +void on_logrotate_applications_tab_selection_changed(GtkWidget *self, logrotate_window *window); +void on_logrotate_tab_open(GtkWidget *self, main_window *widgets); +void yon_combo_compress_check(GtkComboBox *self, journald_window *window); +void on_journald_reset(GtkWidget *self, journald_window *window); +void on_journald_save(GtkWidget *self, journald_window *window); +journald_window *yon_journald_open(GtkWidget *self, main_window *widgets); +void on_journald_open(GtkWidget *self, main_window *widgets); +void on_log_save(GtkWidget *self, dictionary *dict); +add_log_window *on_add_open(main_window *widgets); +void on_log_path_remove(GtkWidget *self, add_log_window *window); +void on_log_path_filechooser_selection_changed(GtkWidget *self, logrotate_filechooser_window *dialog); +void on_log_path_filechooser_toggled(GtkWidget *self, logrotate_filechooser_window *dialog); +void on_log_path_filechooser_save(GtkWidget *self, dictionary *dict); +void on_log_path_filechooser_open(GtkWidget *self, GtkEntry *entry); +void on_log_path_choose(GtkWidget *self,add_log_window *window); +void on_log_path_append(GtkWidget *self, add_log_window *window); +void on_log_add(GtkWidget *self, main_window *widgets); +void on_log_edit(GtkWidget *self,main_window *widgets); +void on_log_remove(GtkWidget *self, main_window *widgets); +void on_service_edit(GtkWidget *self,main_window *widgets); +void on_main_window_tree_selection_changed(GtkWidget *self,main_window *widgets); +void on_main_window_services_tree_selection_changed(GtkWidget *self,main_window *widgets); +void on_start_stop_clicked(GtkButton *self, main_window *widgets); +void on_enable_disable_clicked(GtkButton *self, main_window *widgets); +void on_permissions_changed(); +void config_init(); +void yon_main_window_complete(template_main_window **window); +void on_logrotate_apps_configure_activate(GtkWidget *, GtkTreePath*, GtkTreeViewColumn*,logrotate_window *window); +void on_logrotate_edit_activate(GtkWidget*,GtkTreePath*,GtkTreeViewColumn*, logrotate_window *window); +void on_logrotate_closed(GtkWidget *,logrotate_window *window); +void on_rules_changed(GtkEditable *editable, const gchar *text, gint length, gint *position); +int main(int argc, char *argv[]); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 0b865a6..e7687a4 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -1,41 +1,14 @@ -#define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) -#define HELP_LABEL yon_char_unite(_("ubl-settings-loggign version:")," ", version_application,"\n",_("Logs and events"),"\n",_("Usage:"), " ubl-settings-logging ",_("[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",_("Clear application configuration"),"\n",NULL) - #define TITLE_LABEL _("Logs and events") #define TITLE_INFO_LABEL _("Logs and events 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 to global and local 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 FILTER_NAME_CONFIG_LABEL yon_char_append(_("Configuration file")," *.ini") +#define CHOOSE_CUSTOM_CONFIG_LABEL _("Choose custom configuration file") -#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 ACCEPT_LABEL _("Accept") #define CHOOSE_DIR_NOT_FILE_LABEL _("Choose directory instead of file") @@ -70,6 +43,7 @@ #define SYSLOG_DESCRIPTION_LABEL _("System log") #define XORG_DESCRIPTION_LABEL _("X.org display server log") #define XSESSION_DESCRIPTION_LABEL _("Graphics X session log") +#define SAVE_LABEL _("Save") //ubl-settings-logging-inspector.glade #define INSPECTOR_TITLE_LABEL _("Logs and events - log inspector") @@ -201,6 +175,7 @@ #define EMPTY_IMPORTANT_LABEL _("Empty important field") #define REPEAT_PATHS_LABEL _("Repeating paths") #define WRITE_IMPORTANT_LABEL _("Write down all important fields") +#define COMMAND_INVALID_LABEL _("Command is invalid") //ubl-settings-logging-logrotate-table.glade #define TABLE_TITLE_LABEL _("Logs and events - logrotate table") @@ -218,6 +193,7 @@ #define LOG_FILE_LABEL _("Log file") #define NAME_LABEL _("Name:") #define TOTAL_LOG_SIZE_LABEL _("Log size:") +#define NO_FILES_FOUND_LABEL _("Journal/log files were not found") //ubl-settings-logging-rules.glade #define RULES_TITLE_LABEL _("Logs and events - rules") @@ -236,4 +212,7 @@ #define NEW_VALUE_LABEL _("New value") #define FILECHOOSER_TITLE_LABEL _("Logs and events - choose a path") -#define SAVE_TITLE_LABEL _("Logs and events - saving") \ No newline at end of file +#define SAVE_TITLE_LABEL _("Logs and events - saving") + +#define AUTHTORIZED_LABEL _("Authorization has been elevated") +#define UNAUTHTORIZED_LABEL _("Authorization has been unelevated") \ No newline at end of file diff --git a/source/ubl-utils.c b/source/ubl-utils.c deleted file mode 100644 index 27002d6..0000000 --- a/source/ubl-utils.c +++ /dev/null @@ -1,2110 +0,0 @@ -#include "ubl-utils.h" - -// dictionary functions - -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; -} - -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; -} - -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){ - dict->data=data; -} - -int yon_dictionary_set_key(dictionary *dict, char *key){ - dict->key=key; - return 1; -} - -int yon_dictionary_set(dictionary *dict, char *key, void *data){ - dict->key=key; - dict->data=data; - return 1; -} - -int yon_dictionary_empty(dictionary *dict){ - dict->data=NULL; - dict->data_type=DICTIONARY_OTHER_TYPE; - return 1; -} - -void yon_dictionary_switch_to_last(dictionary **dict) -{ - dictionary *dct=NULL, *dact=*dict; - for_dictionaries(dct,dact); -} - -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; -} - -dictionary *yon_dictionary_get_last(dictionary *dict) -{ - if (dict->next){ - dictionary *dct = NULL; - for_dictionaries(dct,dict); - return dct; - } else return dict; -} - -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; - } - } - } - } -} - -void yon_dictionary_make_first(dictionary *dict) -{ - for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) - { - dct->first = dict; - } -} - -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; -} - -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_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; -} - -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; -} - -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; -} - -dictionary *yon_dictionary_merge(dictionary *dict1,dictionary *dict2){ - dictionary *dct = NULL; - for_dictionaries(dct,dict2){ - if (!yon_dictionary_get(&dict1,dct->key)) - yon_dictionary_connect(dict1,dct); - } - return dict1; -} - -dictionary *yon_dictionary_get(dictionary **dict, char *key) -{ - dictionary *dct = *dict; - if (dct){ - for (dictionary *pointer = dct->first; pointer != NULL; pointer = pointer->next){ - if (pointer->key&&strcmp(pointer->key, key) == 0){ - *dict = pointer; - return pointer; - } - } - } - return NULL; -} - -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; - } -} - -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; -} - -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; -} - -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; -} - -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; -} - -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; -} - -char *yon_char_divide(char *source, int dividepos) -{ - if (source){ - 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; - } - return NULL; -} - -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 = malloc(i * sizeof(char) + 1); - memset(ch,0,i * sizeof(char) + 1); - sprintf(ch, "%d", int_to_convert); - return ch; -} - -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 = malloc((i + 9)* sizeof(char)); - memset(ch,0,(i + 9)* sizeof(char)); - sprintf(ch, "%.2f", int_to_convert); - return ch; -} - -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 = malloc(i * sizeof(char) + 1); - memset(ch,0,i * sizeof(char) + 1); - sprintf(ch, "%ld", int_to_convert); - return ch; -} - -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; -} - -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; -} - -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; -} - -int yon_char_parsed_check_exist(char **parameters, int size, char *param){ - - for (int i=0;i0){ - int final_size=0; - config_str final = yon_char_parsed_new(&final_size,to_copy[0],NULL); - for (int i=1;i0&&size2>0){ - *final_size=0; - config_str parsed_final = yon_char_parsed_new(final_size,array1[0],NULL); - for (int i=1;i0&&size2>0){ - *final_size=0; - int new_size=0; - config_str parsed_final = yon_char_parsed_new(final_size,array1[0],NULL); - for (int i=1;i0){ - for (int i=0;i0){ - for (int i=0;i0){ - dictionary *dict = NULL; - for (int i=0;i0){ - dictionary *dict = NULL; - for (int i=0;ipw_name,NULL); - else { - user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); - } - } - endpwent(); - return user_list; -} - -// parsing functions - -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; -// }; - -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) dir = yon_char_parsed_append(dir,size,yon_char_new(de->d_name)); - else dir = yon_char_parsed_new(size,yon_char_new(de->d_name),NULL); - } - closedir(directory); - } - return dir; -} - -config_str yon_dir_get_by_mask(char *path, char *mask, int *size){ - (*size)=0; - if (yon_char_find_count(mask,"*")<=1){ - char *lpart; - char *rpart=yon_char_new(mask); - lpart = yon_char_divide_search(rpart,"*",-1); - config_str files = NULL; - int found_size; - config_str found_files = yon_dir_get_contents(path,&found_size); - int found = 1; - int rfound = 0; - for (int i=0;idata=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_dictionaries(temp,(dictionary*)__yon__config__strings) -#define yon_config_parameter_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_config_parameter_new_with_data(key,data); \ - else dict=yon_config_parameter_append_with_data(dict,key,data);} - -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; -} - -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; -} - -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; -} - -void yon_config_set_status(int status){ - check_config{ - for_config{ - ((yon_config_parameter*)temp)->flag1=status; - } - } -} - -void *yon_config_get_by_key(char *key){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict, (dictionary*)__yon__config__strings){ - if (strcmp(dict->key,key)==0&&((yon_config_parameter*)dict)->flag1!=-1){ - return dict->data; - } - } - } - return NULL; -} - -char *yon_config_get_section_for_key(char *key){ - check_config{ - for_config{ - if (!yon_char_is_empty(temp->key)){ - if (!strcmp(temp->key,key)){ - return yon_char_new(((yon_config_parameter*)temp)->section); - } - } - } - } -} - -void *yon_config_get_all_by_key(char *key, int *size){ - check_config{ - config_str ret_data=NULL; - 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; - } -} - -config_str yon_config_get_all_keys(int *size){ - check_config{ - *size=0; - config_str final = NULL; - for_config{ - if (!final) final = yon_char_parsed_new(size,temp->key,NULL); - else final = yon_char_parsed_append(final,size,temp->key); - } - return final; - } - return NULL; -} - -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; -} - -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; -} - -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; -} - -void yon_config_register(char *key, char *config_section, void *data){ - if (!__yon__config__strings||!yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ - yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,data); - __yon__config__strings->flag1=1; - } - else if (yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ - if (data!=__yon__config__strings->data&&strcmp(__yon__config__strings->data,data)){ - __yon__config__strings->data=data; - __yon__config__strings->flag1=1; - } - } - __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; - __yon__config__strings->section=yon_char_new(config_section); -} - -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){ - 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){ - 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; -} - -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_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; - } -} - -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; - } -} - -int yon_file_create_full_path(char *path, int rules){ - if (path){ - if (access(path,F_OK)){ - char *cur_path = yon_char_new(path); - cur_path = yon_char_divide(cur_path,yon_char_find_last(cur_path,'/')); - mkdir(cur_path,0777); - 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 - -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); -}; - -void yon_launch(char *command) -{ - system(command); -} - - - - - - -static render_data render; - -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, 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); - } - -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); - } - - // 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); - } - } - - 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); - } - - 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; - } - - 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,GdkEvent* event, 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),window_name); - g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_window_config_custom_window_destroy),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 - -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; - } -} - -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); - } -} - -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); -} \ No newline at end of file diff --git a/source/ubl-utils.h b/source/ubl-utils.h deleted file mode 100644 index 6c8fa55..0000000 --- a/source/ubl-utils.h +++ /dev/null @@ -1,1145 +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 - -#include "../compile/ubl-cmake.h" -#ifdef WEBKIT_FOUND - #include -#endif -#define DesktopPath "/usr/share/applications/" - -/**for_dictionaries(element, stack) - * [EN] - * - * [RU] - * Работает как for, но нужен для перечисления элементов словаря типа dictioary [stack]. Каждый цикл текущий элемент попадает в [element] -*/ -#define for_dictionaries(element, stack) for (element = stack->first; element != NULL; element = element->next) - -#define new(type) malloc(sizeof(type)) -#define new_arr(type,size) malloc(sizeof(type)*size) - -#define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) - -typedef enum -{ - DICTIONARY_GTK_WIDGETS_TYPE, - DICTIONARY_OTHER_TYPE=0, - DICTIONARY_CHAR_TYPE, - DICTIONARY_INT_TYPE, - DICTIONARY_BOOL_TYPE, - -} DICT_TYPE; - -/** - * Структура именованого списка. - * [key] - ключ элемента - * [data] - хранимое значение - * [next] - следующий элемент списка - * [prev] - предыдущий элемент списка - * [first] - первый элемент списка - * [data_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; - -/**config(key) - * Возвращает элемент конфигурации ubconfig с ключом [key] или NULL если такого нет -*/ -#define config(key) yon_config_get_by_key(key) - -#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) -// 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);} - -/**yon_dictionary_new(): - * [EN] - * Creates and returns empty dictionary - * [RU] - * Создаёт и возвращает пустой словарь. - */ -dictionary *yon_dictionary_new(); - -/**yon_dictionary_copy(dictionary *dict) - * [EN] - * - * [RU] - * Создаёт и возвращает копию элемента словаря [dict] -*/ -dictionary *yon_dictinoary_copy(dictionary *dict); - -/**yon_dictionary_copy_deep(dictionary *dict) - * [EN] - * - * [RU] - * Создаёт полную копию словаря [dict] и возвращает первый элемент -*/ -dictionary *yon_dictionary_copy_deep(dictionary *dict); - -/**int yon_dictionary_set_data(dictionary *dict, void *data) - * [EN] - * - * [RU] - * Установить элементу словаря [dict] значение [data] -*/ -int yon_dictionary_set_data(dictionary *dict, void *data); - -/**int yon_dictionary_set_key(dictionary *dict, char *key) - * [EN] - * - * [RU] - * Изменяет ключ элемента словаря [dict] на [key] -*/ -int yon_dictionary_set_key(dictionary *dict, char *key); - -/** int yon_dictionary_set(dictionary *dict, char *key, void *data) - * [EN] - * - * [RU] -* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] -*/ -int yon_dictionary_set(dictionary *dict, char *key, void *data); - -/**int yon_dictionary_empty(dictionary *dict) - * [EN] - * - * [RU] - * Очищает элемент словаря [dict] от данных -*/ -int yon_dictionary_empty(dictionary *dict); - -/**yon_dictionary_switch_to_last(dictionary **dict) - * [EN] - * - * [RU] - * Переключает словарь [dict] на последний элемент. -*/ -void yon_dictionary_switch_to_last(dictionary **dict); - -/**yon_dictionary_create_conneced(dictionary *targetdict) - * [EN] - * - * [RU] - * Создаёт новый элемент словаря [targetdict] -*/ -dictionary *yon_dictionary_append(dictionary *targetdict); - -/**yon_dictionary_get_last(dictionary *dict) - * [EN] - * - * [RU] - * Возвращает последний элемент словаря [dict]. - * В отличае от yon_dictionary_switch_to_last() - * словарь [dict] остаётся на прежнем элементе. -*/ -dictionary *yon_dictionary_get_last(dictionary *dict); - -/**yon_dictionary_switch_places(dictionary *dict, int aim) - * [EN] - * - * [RU] - * Меняет элемент словаря [dict] местами с другим элементом. - * если [aim]<0 элемент меняется местами с левым элементом; - * если [aim]>0 элемент меняется местами с правым элементом; -*/ -dictionary *yon_dictionary_swap(dictionary *dict, int aim); - -/**yon_dictionary_make_first(dictionary *dict) - * [EN] - * - * [RU] - * Устанавливает указатель первого элемента словаря [dict] - * на текущий элемент. Не использовать. -*/ -void yon_dictionary_make_first(dictionary *dict); - -/**yon_dictionary_make_nth(dictionary *dict, int nth) - * [EN] - * - * [RU] - * Перемещает элемент словаря [dict] на позицию [nth]. -*/ -void yon_dictionary_make_nth(dictionary *dict, int nth); - -/**yon_dictionary_create_with_data(char *key, void *data) - * [EN] - * - * [RU] - * Создаёт новый словарь с ключом [key] и указателем на данные [data] -*/ -dictionary *yon_dictionary_new_with_data(char *key, void *data); - -/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) - * [EN] - * - * [RU] - * Создаёт новый элемент словаря, присоединяемый в конец словаря [dict] - * с ключом [key] и указателем на данные [data] -*/ -dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data); - -/**yon_dictionary_connect(dictionary *old, dictionary *toconnect) - * [EN] - * - * [RU] - * Присоединяет словарь [toconnect] в конец словаря [old]. -*/ -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); - -dictionary *yon_dictionary_merge(dictionary *dict1,dictionary *dict2); - -/**yon_dictionary_get(dictionary **dict, char *key) - * [EN] - * - * [RU] - * Возвращает элемент словаря [dict] с ключом [key]. - * Если такого элемента не было обнаружено, возвращается NULL -*/ -dictionary *yon_dictionary_get(dictionary **dict, char *key); - -/**yon_dictionary_rip(dictionary *dict) - * [EN] - * - * [RU] - * Вырезает элемент из словаря и возвращает вырезанный элемент. -*/ -dictionary *yon_dictionary_rip(dictionary *dict); - -/**yon_dictionary_get_nth(dictionary *dict, int place) - * [EN] - * - * [RU] - * Возвращает [place]-й элемент словаря [dict] -*/ -dictionary *yon_dictionary_get_nth(dictionary *dict, int place); - -/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) - * [EN] - * Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary. - * [RU] - * Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря. -*/ -void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); - -// char functions - -#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); - -/**[EN] - * - * creates new char string by combining two char strings. - */ -char *yon_char_append(char *source, char *append); - -/**[EN] - * - * creates new char string by copying another char. - */ -char *yon_char_new(char *chr); - -/**yon_char_unite(char *source, ...) - * [En] - * - * [RU] - * Объединяет строку [source] со всеми строками, написанными в [...]. Последний элемент должен быть NULL -*/ -char *yon_char_unite(char *source, ...); - -/**yon_cut(char *source, int size, int startpos) - * [EN] - * cuts source string by size length from startpos position. - */ -char *yon_cut(char *source, int size, int startpos); - -/**yon_char_divide(char *source, int dividepos) - * [EN] - * divides source string in dividepos position, - * returning left part of divided string and - * inserting right part to source string. - */ -char *yon_char_divide(char *source, int dividepos); - -/**yon_char_divide_search(char *source, char *dividepos, int delete_divider) - * [EN] - * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) - * searches string [dividepos] in [source] string and divides it, - * returning left part of divided string and - * inserting right part to [source] string. - * if [delete_divider] is 0, left part will contain [delete_divider] substring, else - * if [delete_divider] is 1 it will stay in right part, else - * if [delete_divider] is -1 it will be deleted from string. - * - * [RU] - * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) - * Ищет строку [dividepos] в строке [source] и делит её в этом месте, - * возвращая левую часть разделённой строки и устанавливает в [source] правую часть. - * Если [delete_divider] равен 0, [dividepos] останется в левой строке, иначе - * если [delete_divider] равен 1, [dividepos] останется в правой строке, иначе - * если [delete_divider] равен -1, [dividepos] удаляется из строки. - */ -char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); - -/**yon_char_from_int(int int_to_convert) - * [EN] - * char *yon_char_from_int(int int_to_convert) - * converts int to char*. - * - * [RU] - * char *yon_char_from_int(int int_to_convert) - * Конвертирует int в char* - */ -char *yon_char_from_int(int int_to_convert); - -/**yon_char_from_float(int int_to_convert) - * [EN] - * converts float to char*. - * - * [RU] - * Конвертирует float в char* - */ -char *yon_char_from_float(float int_to_convert); - -/**yon_char_from_long(int int_to_convert) - * [EN] - * converts long to char*. - * - * [RU] - * Конвертирует long в char* - */ -char *yon_char_from_long(long int_to_convert); - -/**yon_char_replace(char *source, char *find, char*replace) - * [EN] - * - * [RU] - * Заменяет в строке [source] все вхождения строки [find] на [replace] -*/ -char *yon_char_replace(char *source, char *find, char*replace); - -/**yon_char_parse(char *parameters, int *size, char *divider) - * [EN] - * Parses string [parameters], divided by [divider], - * then returns parsed string array and sets [size] to - * size of returned array -*/ -char **yon_char_parse(char *parameters, int *size, char *divider); - -#define yon_char_parsed_add_or_create_if_exists(parsed,size,data) {if (!parsed) parsed = yon_char_parsed_new(size,data,NULL);\ - else parsed = yon_char_parsed_append(parsed,size,data);} - -/**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) - * [EN] - * - * [RU] - * Удаляет элемент [item_to_delete] из массива строк [char_string], размера [size] - * Возвращает получившийся массив, в [size] загружается размер нового массива. -*/ -char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); - -/**yon_char_parsed_check_exist(char **parameters, int size, char *param) - * [EN] - * Checks if [parameters] string array of length [size] - * has [param] element; - * [RU] - * Проверяет есть ли в массиве строк [parameters], размера [size] - * элемент [param] -*/ -int yon_char_parsed_check_exist(char **parameters, int size, char *param); - -/**yon_char_parsed_check_repeats(char **parameters, int size) - * [EN] - * Checks if [parameters] string array of length [size] - * has repeated elements; - * [RU] - * Проверяет есть ли в массиве строк [parameters], размера [size] - * повторения -*/ -int yon_char_parsed_check_repeats(char **parameters, int size, int *first_overlap, int *second_overlap); - -/**yon_char_find_count(char *source, char *find) - * [EN] - * - * [RU] - * Считает количество символов [find] в строке [source] -*/ -int yon_char_find_count(char *source, char *find); - -/**yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size) - * [EN] - * - * [RU] - * Проверяет, включает ли в себя [source] размера [source_size] - * массив строк [to_check] размера [check_size] -*/ -int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size); - -/**yon_char_parsed_new (config_str old, int *old_size, ...) - * [EN] - * - * [RU] - * Создаёт новый массив строк. В [size] выгружается его размер - * [...] - неограниченное количество строк. -*/ -config_str yon_char_parsed_new (int *size, ...); - -void yon_char_parsed_free(config_str source, int size); - -/**config_str yon_char_parsed_copy(config_str to_copy, int size) - * [EN] - * - * [RU] - * Возвращает копию массива строк [to_copy] размера [size] -*/ -config_str yon_char_parsed_copy(config_str to_copy, int size); - -/**config_str yon_char_parsed_append(config_str parsed, int *size, char *string) - * [EN] - * Adds [string] at the end of [parsed] string array of [size] length. - * [RU] - * Добавляет строку [string] в конец массива строк [parsed] с длинной [size]. -*/ -config_str yon_char_parsed_append(config_str parsed, int *size, char *string); - -/**yon_char_parsed_merge(config_str array1, int size1, config_str array2, int size2, int *final_size) - * [EN] - * - * [RU] - * Объединяет два массива строк в один. - * [array1] - первый массив строк размера [size1] - * [array2] - второй массив строк размера [size2] - * [final_size] - указатель на целочисленную переменную в которую должен вернуться размер нового массива -*/ -config_str yon_char_parsed_merge(config_str array1, int size1, config_str array2, int size2, int *final_size); - -/**yon_char_parsed_merge_no_repeats(config_str array1, int size1, config_str array2, int size2, int *final_size) - * [EN] - * - * [RU] - * Объединяет два массива строк в один с предотвращением дублей. - * [array1] - первый массив строк размера [size1] - * [array2] - второй массив строк размера [size2] - * [final_size] - указатель на целочисленную переменную в которую должен вернуться размер нового массива -*/ -config_str yon_char_parsed_merge_no_repeats(config_str array1, int size1, config_str array2, int size2, int *final_size); - -int yon_char_parsed_divide_full(config_str parsed,int size,int divide_pos); - -int yon_char_parsed_divide_search_full(config_str parsed,int size,char *divide_pos, int delete_divider); - -dictionary *yon_char_parsed_convert_to_dictionary(config_str parsed, int size); - -dictionary *yon_char_parsed_convert_copy_to_dictionary(config_str parsed, int size); - -/**yon_ubl_check_root() - * [EN] - * - * [RU] - * Возвращает 1 если приложение было запущено от root -*/ -int yon_ubl_check_root(); - -/**yon_ubl_root_user_get() - * [EN] - * - * [RU] - * Возвращает имя пользователя. - * Если пользователь запустил приложение через root, выводится имя пользователя, запустившего приложение через root -*/ -char *yon_ubl_root_user_get(); - -/** yon_ubl_user_get_home_directory() - * [EN] - * - * [RU] - * Возвращает домашний каталог пользователя. - * Если пользователь открыл утилиту с правами суперпользователя, всё равно возвращает каталог пользователя, а не root -*/ -char *yon_ubl_user_get_home_directory(); - -/** yon_ubl_get_all_users(int *user_size) - * [EN] - * - * [RU] - * Возвращает массив всех пользователей в системе и записывает его размер в [user_size] -*/ -config_str yon_ubl_get_all_users(int *user_size); - -// parsing functions - -/** yon_size_convert_automatic(int bytes, int *size) - * [EN] - * - * [RU] - * Делит число [bytes] на 1024 пока оно не станет меньше 1024. - * Возвращает получившееся число и устанавливает [size] равным количеству делений. -*/ -float yon_size_convert_automatic(int bytes, int *size); - -apps *yon_apps_scan_and_parse_desktops(int *sizef); - -void yon_apps_sort(apps *applist, int size); - -apps *yon_apps_get_by_name(apps *applist, char *name, int size); - -/**yon_file_open(char *file_path, int *size) - * [EN] - * - * [RU] - * Открывает файл [file_path], возвращает содержимое в виде массива строк размера [size] -*/ -config_str yon_file_open(char *file_path, int *size); - -/**yon_file_create(char *path, char *name, int rules) - * [EN] - * - * [RU] - * Создать файл с названием [name], находящимся по пути [path] - * С правами доступа [rules] (от 0000 до 0777) -*/ -int yon_file_create(char *path, char *name, int rules); - -/**yon_file_create_full_path(char *path, char *name, int rules) - * [EN] - * - * [RU] - * Создать файл по пути [path] - * С правами доступа [rules] (от 0000 до 0777) -*/ -int yon_file_create_full_path(char *path, int rules); - -/** yon_dir_get_contents(char *dir_path, int *size) - * [EN] - * - * [RU] - * Проверяет существует ли папка [dir_path] и - * возвращает список всех вложенных файлов и папок, - * передавая в [size] длину списка. -*/ -config_str yon_dir_get_contents(char *dir_path, int *size); - -config_str yon_dir_get_by_mask(char *path, char *mask, int *size); - -//config functions - -#define ubconfig_save_command "ubconfig" -#define ubconfig_load_command "ubconfig --source" - -/** - * Типы конфигураций ubconfig-а -*/ -typedef enum { - YON_CONFIG_LOCAL=0, - YON_CONFIG_GLOBAL, - YON_CONFIG_BOTH -} YON_CONFIG_TYPE; - -/**yon_config_load(char *command, int *str_len) - * [EN] - * - * [RU] - * Выполняет команду [command] и возвращает результат выполнения команды, разделяя на строки. - * В [str_len] возвращается длина возвращаемого массива -*/ -config_str yon_config_load(char *command, int *str_len); - -/**int yon_config_save_registered(char *path) - * [EN] - * Saves config at [path] config. - * [path] can be: - * system - * global - * [RU] - * Сохраняет конфигурацию в [path] конфиг. - * [path] может быть - * system - локальный конфиг - * global - глобальный конфиг -*/ -int yon_config_save_registered(char *path); - -/**char *yon_config_get_parameter(config parameters, int size, char *param) - * [EN] - * Gets parameter [param] from parameter list [parameters] of size [size]; - * or NULL if nothing were found - * [RU] - * Возвращает параметр [param] из массива строк [parameters] размером [size] - * или NULL если такой не был найден -*/ -char *yon_config_get_parameter(config_str parameters, int size, char *param); - -/**yon_config_load_register(char *command) - * [EN] - * - * [RU] - * Выполняет команду [command]. - * Полученные данные парсятся и регистрируются в конфиг. -*/ -int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...); - -/**yon_config_remove_by_key(char *key) - * [EN] - * - * [RU] - * Удаляет параметр конфига по ключу [key] -*/ -int yon_config_remove_by_key(char *key); - -/**yon_config_remove_element(char *key, char *deleted) - * [EN] - * - * [RU] - * Удаляет элемент [deleted] из массива параметров с ключом [key] -*/ -int yon_config_remove_element(char *key, char *deleted); - -void yon_config_set_status(int status); - -/**yon_config_get_key_by_key(char *data) - * [EN] - * - * [RU] - * Возвращает значение параметра конфига с ключом [key]. - * Если параметр с таким значением не найден, возвращается NULL -*/ -void *yon_config_get_by_key(char *key); - -char *yon_config_get_section_for_key(char *key); - -/**yon_config_get_all_by_key(char *data) - * [EN] - * - * [RU] - * Возвращает значение всех параметров конфига с ключом включающем строку [key]. - * Если параметр с таким значением не найден, возвращается NULL -*/ -void *yon_config_get_all_by_key(char *key, int *size); - -/**yon_config_get_all_keys(int *size) - * [EN] - * - * [RU] - * Возвращает массив с ключами всех параметров внутреннего конфига -*/ -config_str yon_config_get_all_keys(int *size); - -/**yon_config_set(char *key, void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу и заменяет значение параметра с ключом [key] на новое значение [data]; -*/ -int yon_config_set(char *key, void *data); - -/**yon_config_append(char *key, void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу и дополняет значение параметра с ключом [key] значением [data]; -*/ -int yon_config_append(char *key, char *data); - -/**yon_config_clean() - * [EN] - * Erase all parameters from config; - * [RU] - * Удаляет все параметры из конфига; -*/ -int yon_config_clean(); - -/**yon_config_register(char *key, void *data) - * [EN] - * - * [RU] - * Регистрирует новый параметр конфига. - * [key] - ключ параметра; - * [data] - значение параметра; -*/ -void yon_config_register(char *key, char* config_section, void *data); - -/**int yon_config_force_save_registered(char *path, char *section) - * [EN] - * Force config to save at [path] config ignoring parameter save status. - * [path] can be: - * system - * global - * [RU] - * Принудительно сохраняет конфигурацию в [path] конфиг игнорируя статус параметра. - * [path] может быть - * system - локальный конфиг - * global - глобальный конфиг -*/ -int yon_config_force_save_registered(char *path); - -/**yon_config_get_all(int *size) - * [EN] - * - * [RU] - * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL - * [size] - указатель, в который выгружается длина массива -*/ -config_str yon_config_get_all(int *size); - -// terminal-using functions - -/**yon_launch_app_with_arguments(char *name, char *args) - * [EN] - * Execute [command] in separate thread; - * [RU] - * Выполнить команду [command] в отдельном потоке; -*/ -int yon_launch_app_with_arguments(char *name, char *args); - -/**yon_launch(char *command) - * [EN] - * Execute command [command] - * [RU] - * Выполнить команду [command] -*/ -void yon_launch(char *command); - -#ifdef __GTK_H__ -/** - * void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument) - * [EN] - * launches terminal with specific [command], - * terminal is shown in [place_to_show] container, - * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. - * [RU] - * Запускает терминал с командой [command], - * терминал добавляется в контейнер [place_to_show] виджета, - * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. -*/ -void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument); - -/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument) - * [EN] - * launches terminal with specific [command], - * terminal is shown in [place_to_show] container, - * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. - * [RU] - * Запускает терминал с командой [command], - * терминал добавляется в контейнер [place_to_show] виджета, - * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. -*/ -void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); - -/**YON_TYPE - * [EN] - * - * [RU] - * Типы, поддерживаемые функциями сохранения/загрузки конфигурации утилиты -*/ -enum YON_TYPE{ - YON_TYPE_STRING, - YON_TYPE_STRING_LIST, - YON_TYPE_INT, - YON_TYPE_BOOLEAN, - YON_TYPE_OTHER}; - -/**yon_gtk_builder_get_widget(builder, widget_name) - * [EN] - * Returns GtkWidget from GtkBuilder *[builder]. - * [builder] is GtkBuilder*; - * [widget_name] is id of widget; - * [RU] - * Возвращает виджет GtkWidget c id [widget_name] из [builder] -*/ -#define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name)) - -/**yon_window_config_setup(GtkWindow *window) - * [EN] - * - * [RU] - * Устанавливает указатель на окно для отслеживания его положения и размера -*/ -void yon_window_config_setup(GtkWindow *window); - -/**yon_window_config_load(char *path) - * [EN] - * - * [RU] - * Загружает конфиг окна и инициализирует отслеживание его параметров -*/ -int yon_window_config_load(char *path); - -/**yon_window_config_get_section(char *section, gsize *size) - * [EN] - * - * [RU] - * Возвращает все параметры раздела [section] конфига утилиты и записывает в [size] количество считанных параметров. -*/ -config_str yon_window_config_get_section(char *section, gsize *size); - -/**yon_window_config_add_custom_parameter(GtkWidget *widget, char *param_name, char *widget_property) - * [EN] - * - * [RU] - * Добавляет параметр виджета [widget] по названию [widget_property] для отслеживания и сохраняет его в конфиг под ключом [param_name]. -*/ -void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type); - -/**yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type) - * [EN] - * - * [RU] - * Добавить параметр в конфиг утилиты. - * Параметр [param_name] добавляется в раздел [section] конфига утилиты со значением [tracked value]. - * Тип указывается в [type] -*/ -void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); - -void yon_window_config_add_instant_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); - -/**yon_window_config_erase_custom_parameter(char *param_name, char *section) - * [EN] - * - * [RU] - * Удаляет параметр из конфига утилиты. - * Удаляет параметр [param_name] из раздела [section] конфига утилиты. -*/ -void yon_window_config_erase_custom_parameter(char *param_name, char *section); - -/**yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type) - * [EN] - * - * [RU] - * Возвращает параметр из конфига утилиты. - * Параметр [config_parameter] из раздела [section] возвращается в [return_value] - * Возвращаемый тип указывается в [type] -*/ -int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type); - -/**yon_window_config_custom_window_setup(GtkWindow *window, char *window_name) - * [EN] - * - * [RU] - * Зарегистрировать окно [window] в конфиге утилиты под именем [window_name] -*/ -void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name); - -/**yon_window_config_custom_window_set(GtkWindow *window, char *window_name) - * [EN] - * - * [RU] - * Загрузить и применить параметры окна [window], сохранёнными в конфигурации утилиты под именем [window_name] -*/ -void yon_window_config_custom_window_get(GtkWindow *window, char *window_name); - -/**yon_window_config_custom_window_set(GtkWindow *window, char *window_name) - * [EN] - * - * [RU] - * Сохранить параметры окна [window] в конфигурацию утилиты под именем [window_name] -*/ -void yon_window_config_custom_window_set(GtkWindow *window, char *window_name); - -int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); - -/**yon_ubl_menu_item_documentation_new(char *buttonname) - * [EN] - * - * [RU] - * Создаёт элемент меню GtkMenu с текстом [buttonname]. Кнопка настроена для отображения диалогового окна информации об утилите -*/ -GtkWidget *yon_ubl_menu_item_about_new(char *buttonname); - -/**yon_ubl_menu_item_documentation_new(char *buttonname) - * [EN] - * - * [RU] - * Создаёт элемент меню GtkMenu с текстом [buttonname]. Кнопка настроена для отображения диалогового окна подтверждения перехода на страницу wiki -*/ -GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname); - -// other Gtk functions - -/**yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size) - * [EN] - * - * [RU] - * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] -*/ -int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); - -/**yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find) - * [EN] - * - * [RU] - * Проивзодит поиск по GtkComboBoxText [combo_box] - * возвращает 1 если элемент [text_to_find] найден, иначе возвращает 0 -*/ -int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); - -/**yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column) - * [EN] - * - * [RU] - * Установить минимальный размер колонки [column] равным размеру заголовка. -*/ -void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); - -/**yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...) - * [EN] - * - * [RU] - * Добвляет [destination] все виджеты, прописанные после [padding]. Добавление происходит с начала контейнера. - * [expand] - расширяемость выделенного для виджетов места - * [fill] - заполнять ли виджетом всё ему выделенное место - * [padding] - отступ од других элементов -*/ -int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); - -/**yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...) - * [EN] - * - * [RU] - * Добвляет в [destination] все виджеты, прописанные после [padding]. Добавление происходит с конца контейнера. - * [expand] - расширяемость выделенного для виджетов места - * [fill] - заполнять ли виджетом всё ему выделенное место - * [padding] - отступ од других элементов -*/ -int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); - - - -/**yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target) - * [EN] - * - * [RU] - * Выставляет чуствительность виджета [target] в зависимости от состояния комбобокса [toggle]. - * Чувствительность виджета [target] повторяет статус чекбоска. -*/ -void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target); - -/**yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target) - * [EN] - * - * [RU] - * Выставляет чуствительность виджета [target] в зависимости от состояния чекбоска [toggle]. - * Если чекбокс вктивен, [target] становится нечувствительным и наоборот. -*/ -void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target); - -/**yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); - * [EN] - * - * [RU] - * Выставляет чуствительность виджета [target] в зависимости от состояния комбобокса [toggle]. - * Если выбран первый элемент списка, [target] становится чувствительным, любое другое значение сделает его нечувствительным. -*/ -void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); - -/**yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); - * [EN] - * - * [RU] - * Выставляет чуствительность виджета [target] в зависимости от состояния комбобокса [toggle]. - * Если выбран первый элемент списка, [target] становится нечувствительным, любое другое значение сделает его чувствительным. -*/ -void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); - -typedef enum -{ - 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); - -/**yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter) - * [EN] - * - * [RU] - * Подсвечивает красным цветом [widget] на 5 секунд -*/ -void yon_ubl_status_highlight_incorrect(GtkWidget *widget); - -/**yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter) - * [EN] - * - * [RU] - * Подсвечивает красным цветом [iter] элемент списка [list] на 5 секунд -*/ -void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter); - -static int status_thread_busy; - -/**yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); - * [EN] - * - * [RU] - * Создаёт статусную строку в контейнере [container], отображая текст [display_text]. - * Строка удаляется через [timeout] секунд. - * [type] - тип сообщения. Может быть: - * BACKGROUND_IMAGE_FAIL_TYPE (красный фон,иконка - восклицательный знак) - * или - * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) -*/ -void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); - -/**yon_ubl_header_setup(overlay, head, image, imag_path) - * [EN] - * 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) - -/**yon_ubl_header_setup_resource(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_resource(overlay, head, image, imag_path) _yon_ubl_header_setup_resource(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) - -void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); - -void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); - -/**yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id) - * [EN] - * Set up plugs for using with GtkSockets insine ubl-settings-manager. - * [main_window] is container widget, which holds main application functionality. - * [left_window] is container widget, which holds widgets, have to be shown at left part of ubl-settings-manager header. - * [right_window] is container widget, which holds widgets, have to be shown at right part of ubl-settings-manager header. - * [socket_main_id] is id of socket for [main_window]. - * [socket_left_id] is id of socket for [left_window]. - * [socket_right_id] is id of socket for [right_window]. - * [RU] - * Настраивает плаги для работы с сокетами в утилите ubl-settings-manager. - * [main_window] - контейнер основного интерфейса приложения. - * [left_window] - контейнер для виджетов которые должны отображаться в левой части шапки ubl-settings-manager. - * [right_window] - контейнер для виджетов которые должны отображаться в правой части шапки ubl-settings-manager. - * [socket_main_id] - id сокета для [main_window]. - * [socket_left_id] - id сокета для [left_window]. - * [socket_right_id] - id сокета для [right_window]. -*/ -void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id); - -/**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); -#endif -#endif \ No newline at end of file diff --git a/ubl-settings-logging-add-path.glade b/ubl-settings-logging-add-path.glade index b3f0a35..80f6586 100644 --- a/ubl-settings-logging-add-path.glade +++ b/ubl-settings-logging-add-path.glade @@ -2,6 +2,21 @@ + + True + False + com.ublinux.ubl-settings-logging.increase-symbolic + + + True + False + com.ublinux.ubl-settings-logging.zoom-symbolic + + + True + False + com.ublinux.ubl-settings-logging.decrease-symbolic + True False @@ -23,6 +38,7 @@ True True + url True @@ -78,19 +94,4 @@ - - True - False - com.ublinux.ubl-settings-logging.increase-symbolic - - - True - False - com.ublinux.ubl-settings-logging.zoom-symbolic - - - True - False - com.ublinux.ubl-settings-logging.decrease-symbolic - diff --git a/ubl-settings-logging-add.glade b/ubl-settings-logging-add.glade index 6373ad5..a87b313 100644 --- a/ubl-settings-logging-add.glade +++ b/ubl-settings-logging-add.glade @@ -21,7 +21,7 @@ True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.cancel-symbolic True @@ -59,38 +59,15 @@ False 5 vertical - 5 False end - - Cancel - True - True - True - image1 - - - True - True - 0 - + - - Save - True - True - True - image2 - - - True - True - 1 - + @@ -119,8 +96,8 @@ True False - 5 - 5 + 4 + 4 vertical 5 @@ -499,6 +476,31 @@ com.ublinux.ubl-settings-logging + + + Cancel + True + True + True + image1 + + + 1 + + + + + Save + True + True + True + image2 + + + end + 2 + + diff --git a/ubl-settings-logging-filechooser.glade b/ubl-settings-logging-filechooser.glade index 84db281..94f9a1c 100644 --- a/ubl-settings-logging-filechooser.glade +++ b/ubl-settings-logging-filechooser.glade @@ -1,12 +1,12 @@ - + True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.cancel-symbolic True @@ -101,7 +101,6 @@ True False - True True diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index d448e17..af38e32 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -62,7 +62,7 @@ True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.cancel-symbolic True @@ -86,7 +86,6 @@ 800 - 600 False True com.ublinux.ubl-settings-logging @@ -667,7 +666,7 @@ True False True - alpha + 0 False @@ -965,62 +964,6 @@ 0 - - - True - False - end - 5 - - - Reset - True - True - True - image5 - - - False - True - 0 - - - - - Cancel - True - True - True - image1 - - - True - True - 1 - - - - - Save - True - True - True - image2 - - - True - True - 2 - - - - - False - True - end - 1 - - @@ -1057,6 +1000,43 @@ com.ublinux.ubl-settings-logging + + + Cancel + True + True + True + image1 + + + 1 + + + + + Reset + True + True + True + image5 + + + 2 + + + + + Save + True + True + True + image2 + + + end + 3 + + diff --git a/ubl-settings-logging-logrotate-table.glade b/ubl-settings-logging-logrotate-table.glade index bbc41e5..9d6f8a4 100644 --- a/ubl-settings-logging-logrotate-table.glade +++ b/ubl-settings-logging-logrotate-table.glade @@ -1,5 +1,5 @@ - + @@ -22,7 +22,7 @@ True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.cancel-symbolic True @@ -339,48 +339,6 @@ 0 - - - True - False - end - 5 - True - - - Cancel - True - True - True - image1 - - - False - True - 0 - - - - - Save - True - True - True - image2 - - - False - True - 1 - - - - - False - True - 1 - - True @@ -394,7 +352,6 @@ True False - True True @@ -424,6 +381,31 @@ com.ublinux.ubl-settings-logging + + + Cancel + True + True + True + image1 + + + 1 + + + + + Save + True + True + True + image2 + + + end + 2 + + diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 30ff5a1..169fe5c 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -34,6 +34,7 @@ 10 + 1 999999999 1 10 @@ -81,7 +82,7 @@ True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.cancel-symbolic True @@ -104,7 +105,6 @@ False True com.ublinux.ubl-settings-logging - True True @@ -184,6 +184,7 @@ True False True + name True @@ -220,6 +221,7 @@ True True + name True @@ -1232,6 +1234,7 @@ True False True + 3 False @@ -1470,6 +1473,7 @@ True False True + name False @@ -1667,6 +1671,7 @@ True False True + email False @@ -1784,6 +1789,7 @@ True True + terminal True @@ -1820,6 +1826,7 @@ True True + terminal True @@ -1856,6 +1863,7 @@ True True + terminal True @@ -1892,6 +1900,7 @@ True True + terminal True @@ -1928,6 +1937,7 @@ True True + terminal True @@ -2072,48 +2082,6 @@ 1 - - - True - False - end - 5 - - - Save - True - True - True - image9 - - - True - True - end - 0 - - - - - Cancel - True - True - True - image8 - - - True - True - 1 - - - - - False - True - 2 - - True @@ -2127,7 +2095,6 @@ True False - True True @@ -2157,6 +2124,31 @@ com.ublinux.ubl-settings-logging + + + Cancel + True + True + True + image8 + + + 1 + + + + + Save + True + True + True + image9 + + + end + 2 + + diff --git a/ubl-settings-logging-rules.glade b/ubl-settings-logging-rules.glade index fd0724e..620b09a 100644 --- a/ubl-settings-logging-rules.glade +++ b/ubl-settings-logging-rules.glade @@ -1,12 +1,12 @@ - + True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.cancel-symbolic True diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index c489b60..4a6353a 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -25,172 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - False - False - True - center - com.ublinux.ubl-settings-logging - dialog - True - ubl-settings-logging - 1.1 - Copyright © 2022 - 2023, UBSoft LLC - Logs and events - https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-logging - 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-logging - True - gpl-2-0 - - - True - False - vertical - 2 - - - False - end - - - False - False - 1 - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - Logs and events - - - - - - - - - - True - False - center - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 64 - com.ublinux.ubl-settings-logging - - - False - True - 0 - - - - - True - False - - - True - False - - - True - False - center - vertical - - - 255 - True - False - end - Logs and events - 0 - - - - - - - - True - True - 0 - - - - - 255 - True - False - start - Logs and events configuration - 0 - - - - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - True - 0 - - - - - True - True - 1 - - - @@ -219,6 +53,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + False + Upgrade permissions to root + True False @@ -254,71 +92,64 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False com.ublinux.ubl-settings-logging.settings-symbolic - - True - False - process-stop-symbolic + + + + + + + + + + + + + + + + journald + /var/log/journal/ + System event log + 1 + 1 + + - + True False - emblem-ok-symbolic - - - False - False - 450 - dialog-question-symbolic + True + True + vertical - + True - False - 5 - 5 - 5 - 5 - vertical - 10 + True True False - - - True - False - start - 20 - 20 - dialog-question-symbolic - 6 - - - False - True - 0 - - + 5 + 5 + 5 + 5 + 5 True False vertical + 5 - + True - False - start - 10 - 5 - Would you like to read documentation in the Web? - True - 0 - - - + False + True + True + Inspect log + image1 @@ -328,19 +159,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + 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 + True + Configure log + image2 @@ -350,77 +177,114 @@ translated and supported by community. - - Always redirect to online documentation + True True - False - end - True + True + Add log + image3 False True - end 2 - - - - True - True - 1 - - - - - - True - True - 0 - - - - - True - False - 30 - True - - - Cancel - True - True - True - image8 - + + + True + False + True + True + Remove log + image4 + + + + False + True + 3 + + - True + False True 0 - - Open documentation + True True - True - image9 - + in + + + True + True + liststore1 + 2 + + + True + fixed + 50 + Log/Journal + + + center + end + 100 + + + 0 + + + + + + + True + fixed + 130 + 50 + Path + + + end + 100 + + + 1 + + + + + + + True + fixed + 50 + Description + + + center + end + 100 + + + 2 + + + + + + True @@ -429,159 +293,43 @@ translated and supported by community. - - False - True - 1 - - - - - - True - False - True - - + + True False - Logs and events - - - + Journals + + False + - - - - - - - - - - - - - - - - - - - journald - /var/log/journal/ - System event log - 1 - 1 - - - - - True - False - False - - - True - False - Load global configuration - - - - - - True - False - Load local configuration - - - - - - True - False - False - False - - - False - Upgrade permissions to root - - - - - True - False - False - - - True - False - Save to global and local configuration - - - - - - True - False - Save to global configuration - - - - - - True - False - Save to local configuration - - - - - - 800 - 600 - False - 800 - 600 - com.ublinux.ubl-settings-logging - - - True - False - vertical True False - vertical + 5 + 5 + 5 + 5 + 5 - + True False + vertical + 5 - + True - False - 5 - 5 - 5 - 5 - 5 - 5 - 25 + False + True + True + Start service + image5 + False @@ -590,22 +338,16 @@ translated and supported by community. - + True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - 0 - - - - + False + True + True + Switch autostart on + image6 + False @@ -613,608 +355,128 @@ translated and supported by community. 1 - - - False - True - 0 - - - - - True - False - vertical - - 81 + True - False - - - True - False - start - - - -1 - - + False + True + True + Configure service + image7 + False True - 0 + 2 False True - 1 + 0 - + True - False - 5 - 5 - 5 - 5 - 5 - 5 - True - True - vertical + True + in - + True True + ServicesList - - True - False - 5 - 5 - 5 - 5 - 5 - - - True - False - vertical - 5 - - - True - False - True - True - Inspect log - image1 - - - - False - True - 0 - - - - - True - False - True - True - Configure log - image2 - - - - False - True - 1 - - - - - True - True - True - Add log - image3 - - - - False - True - 2 - - - - - True - False - True - True - Remove log - image4 - - - - False - True - 3 - - - - - False - True - 0 - - + + fixed + 30 + Status - - True - True - in - - - True - True - liststore1 - 2 - - - - - - True - fixed - 50 - Log/Journal - - - center - end - 100 - - - 0 - - - - - - - True - fixed - 130 - 50 - Path - - - end - 100 - - - 1 - - - - - - - True - fixed - 50 - Description - - - center - end - 100 - - - 2 - - - - - - - - - True - True - 1 - + + + 0 + - - - True - False - Journals - - - False - - - - True - False - 5 - 5 - 5 - 5 - 5 - - - True - False - vertical - 5 - - - True - False - True - True - Start service - image5 - - - - False - True - 0 - - - - - True - False - True - True - Switch autostart on - image6 - - - - False - True - 1 - - - - - True - False - True - True - Configure service - image7 - - - - False - True - 2 - - - - - False - True - 0 - - + + fixed + 30 + Autostart - - True - True - in - - - True - True - ServicesList - - - - - - fixed - 30 - Status - - - - 0 - - - - - - - fixed - 30 - Autostart - - - - 1 - - - - - - - True - fixed - 130 - 50 - Service - - - - 2 - - - - - - - True - fixed - 130 - 50 - Description - - - - 3 - - - - - - - - - True - True - 1 - + + + 1 + - - 1 - - - - - True - False - Services - - - 1 - False - - - - True - True - 1 - - - - - False - True - 2 - - - - - True - True - 0 - - - - - - - True - False - 5 - True - - - True - False - 5 - 5 - 5 - 5 - 2 - Logs and events - - - - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 32 - com.ublinux.ubl-settings-logging - - - - - True - False - - - True - True - False - True - menu3 - - - True - False - - True - False - Save + + True + fixed + 130 + 50 + Service + + + + 2 + + - - False - True - 0 - - - True - False - pan-down-symbolic + + True + fixed + 130 + 50 + Description + + + + 3 + + - - False - True - 1 - - False - True - 0 - - - - - True - True - True - False - True - True - menu2 - none - - - - - - - False + True 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 - - + Services - 2 + 1 + False - + + True + True + 1 + diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 768cfad..495bb4e 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -18,887 +18,770 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: source/ubl-strings.h:1 -msgid "Version:" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "ubl-settings-loggign version:" -msgstr "" - -#: source/ubl-strings.h:2 source/ubl-strings.h:4 msgid "Logs and events" msgstr "" #: source/ubl-strings.h:2 -msgid "Usage:" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "[OPTIONS]" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Options:" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Show this help" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Show package version" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock this help menu" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock configuration saving" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock local configration saving" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock global configration saving" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock global configration loading" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Clear application configuration" -msgstr "" - -#: source/ubl-strings.h:5 msgid "Logs and events configuration" msgstr "" -#: source/ubl-strings.h:7 -msgid "Operation succeeded" -msgstr "" - -#: source/ubl-strings.h:8 -msgid "" -"Warning! Application was launched without root - root-dependent actions are " -"locked" -msgstr "" - -#: source/ubl-strings.h:10 -msgid "About" -msgstr "" - -#: source/ubl-strings.h:11 -msgid "Documentation" -msgstr "" - -#: source/ubl-strings.h:13 -msgid "Save to local configuration" -msgstr "" - -#: source/ubl-strings.h:14 -msgid "Save to global configuration" -msgstr "" - -#: source/ubl-strings.h:15 -msgid "Save to global and local configuration" -msgstr "" - -#: source/ubl-strings.h:16 -msgid "Save" -msgstr "" - -#: source/ubl-strings.h:18 -msgid "Load local configuration" -msgstr "" - -#: source/ubl-strings.h:19 -msgid "Load global configuration" -msgstr "" - -#: source/ubl-strings.h:20 -msgid "Load" -msgstr "" - -#: source/ubl-strings.h:22 +#: source/ubl-strings.h:6 msgid "Cancel" msgstr "" -#: source/ubl-strings.h:24 -msgid "Would you like to read documentation in the Web?" -msgstr "" - -#: source/ubl-strings.h:25 -msgid "" -"You will be redirected to documentation website where documentation is\n" -"translated and supported by community." -msgstr "" - -#: source/ubl-strings.h:26 -msgid "Always redirect to online documentation" -msgstr "" - -#: source/ubl-strings.h:27 -msgid "Open documentation" -msgstr "" - -#: source/ubl-strings.h:28 -msgid "Project Home Page" -msgstr "" - -#: source/ubl-strings.h:29 +#: source/ubl-strings.h:7 msgid "Nothing were chosen" msgstr "" -#: source/ubl-strings.h:32 -msgid "Global configuration loading succseeded." +#: source/ubl-strings.h:9 +msgid "Configuration file" msgstr "" -#: source/ubl-strings.h:33 -msgid "Local configuration loading succseeded." -msgstr "" - -#: source/ubl-strings.h:34 -msgid "Config loading failed" -msgstr "" - -#: source/ubl-strings.h:36 -msgid "Local and global configuration saving succseeded." -msgstr "" - -#: source/ubl-strings.h:37 -msgid "Global configuration saving succseeded." -msgstr "" - -#: source/ubl-strings.h:38 -msgid "Local configuration saving succseeded." +#: source/ubl-strings.h:10 +msgid "Choose custom configuration file" msgstr "" -#: source/ubl-strings.h:39 +#: source/ubl-strings.h:12 msgid "Accept" msgstr "" -#: source/ubl-strings.h:41 +#: source/ubl-strings.h:14 msgid "Choose directory instead of file" msgstr "" -#: source/ubl-strings.h:43 +#: source/ubl-strings.h:16 msgid "Journals" msgstr "" -#: source/ubl-strings.h:44 +#: source/ubl-strings.h:17 msgid "Services" msgstr "" -#: source/ubl-strings.h:45 +#: source/ubl-strings.h:18 msgid "Log/Journal" msgstr "" -#: source/ubl-strings.h:46 +#: source/ubl-strings.h:19 msgid "Path" msgstr "" -#: source/ubl-strings.h:47 +#: source/ubl-strings.h:20 msgid "Description" msgstr "" -#: source/ubl-strings.h:48 +#: source/ubl-strings.h:21 msgid "Inspect log" msgstr "" -#: source/ubl-strings.h:49 source/ubl-strings.h:212 +#: source/ubl-strings.h:22 source/ubl-strings.h:186 msgid "Configure log" msgstr "" -#: source/ubl-strings.h:50 +#: source/ubl-strings.h:23 msgid "Add log" msgstr "" -#: source/ubl-strings.h:51 +#: source/ubl-strings.h:24 msgid "Remove log" msgstr "" -#: source/ubl-strings.h:52 +#: source/ubl-strings.h:25 msgid "Stop service" msgstr "" -#: source/ubl-strings.h:53 +#: source/ubl-strings.h:26 msgid "Start service" msgstr "" -#: source/ubl-strings.h:54 +#: source/ubl-strings.h:27 msgid "Configure service" msgstr "" -#: source/ubl-strings.h:55 +#: source/ubl-strings.h:28 msgid "Status" msgstr "" -#: source/ubl-strings.h:56 +#: source/ubl-strings.h:29 msgid "Service" msgstr "" -#: source/ubl-strings.h:57 +#: source/ubl-strings.h:30 msgid "Autostart" msgstr "" -#: source/ubl-strings.h:58 +#: source/ubl-strings.h:31 msgid "Switch autostart off" msgstr "" -#: source/ubl-strings.h:59 +#: source/ubl-strings.h:32 msgid "Switch autostart on" msgstr "" -#: source/ubl-strings.h:60 +#: source/ubl-strings.h:33 msgid "System event log" msgstr "" -#: source/ubl-strings.h:61 +#: source/ubl-strings.h:34 msgid "Log of work and requests to Acpid" msgstr "" -#: source/ubl-strings.h:62 +#: source/ubl-strings.h:35 msgid "Log of work and requests to the web server" msgstr "" -#: source/ubl-strings.h:63 +#: source/ubl-strings.h:36 msgid "Audit log" msgstr "" -#: source/ubl-strings.h:64 +#: source/ubl-strings.h:37 msgid "Log of authorization procedures" msgstr "" -#: source/ubl-strings.h:65 +#: source/ubl-strings.h:38 msgid "Job scheduler log (cron)" msgstr "" -#: source/ubl-strings.h:66 +#: source/ubl-strings.h:39 msgid "Log of work and calls to the print server (cups)" msgstr "" -#: source/ubl-strings.h:67 +#: source/ubl-strings.h:40 msgid "Log of operation and access to system services" msgstr "" -#: source/ubl-strings.h:68 +#: source/ubl-strings.h:41 msgid "Log of work and access to Samba" msgstr "" -#: source/ubl-strings.h:69 +#: source/ubl-strings.h:42 msgid "Postfix mail server log" msgstr "" -#: source/ubl-strings.h:70 +#: source/ubl-strings.h:43 msgid "System log" msgstr "" -#: source/ubl-strings.h:71 +#: source/ubl-strings.h:44 msgid "X.org display server log" msgstr "" -#: source/ubl-strings.h:72 +#: source/ubl-strings.h:45 msgid "Graphics X session log" msgstr "" -#: source/ubl-strings.h:75 +#: source/ubl-strings.h:48 msgid "Logs and events - log inspector" msgstr "" -#: source/ubl-strings.h:76 +#: source/ubl-strings.h:49 msgid "Show messages since the current system boot" msgstr "" -#: source/ubl-strings.h:77 +#: source/ubl-strings.h:50 msgid "Follow for new messages" msgstr "" -#: source/ubl-strings.h:78 +#: source/ubl-strings.h:51 msgid "Show kernel ring buffer" msgstr "" -#: source/ubl-strings.h:79 +#: source/ubl-strings.h:52 msgid "Show only priority error messages, critical messages and warnings" msgstr "" -#: source/ubl-strings.h:80 +#: source/ubl-strings.h:53 msgid "Show all boots" msgstr "" -#: source/ubl-strings.h:81 +#: source/ubl-strings.h:54 msgid "Show a list of all units, ordered by the time of their initialisation" msgstr "" -#: source/ubl-strings.h:82 +#: source/ubl-strings.h:55 msgid "Show tree of time-critical initialization unit chain" msgstr "" -#: source/ubl-strings.h:83 +#: source/ubl-strings.h:56 msgid "Update" msgstr "" -#: source/ubl-strings.h:84 +#: source/ubl-strings.h:57 msgid "Date" msgstr "" -#: source/ubl-strings.h:85 +#: source/ubl-strings.h:58 msgid "Hostname" msgstr "" -#: source/ubl-strings.h:86 +#: source/ubl-strings.h:59 msgid "Process" msgstr "" -#: source/ubl-strings.h:87 +#: source/ubl-strings.h:60 msgid "Log" msgstr "" -#: source/ubl-strings.h:90 +#: source/ubl-strings.h:63 msgid "Logs and events - journald configuration" msgstr "" -#: source/ubl-strings.h:91 +#: source/ubl-strings.h:64 msgid "Description:" msgstr "" -#: source/ubl-strings.h:92 +#: source/ubl-strings.h:65 msgid "Journal storage place:" msgstr "" -#: source/ubl-strings.h:93 source/ubl-strings.h:94 +#: source/ubl-strings.h:66 source/ubl-strings.h:67 msgid "Use compression:" msgstr "" -#: source/ubl-strings.h:95 +#: source/ubl-strings.h:68 msgid "Split journal files:" msgstr "" -#: source/ubl-strings.h:96 +#: source/ubl-strings.h:69 msgid "Log recording journal interval:" msgstr "" -#: source/ubl-strings.h:97 +#: source/ubl-strings.h:70 msgid "Records amount:" msgstr "" -#: source/ubl-strings.h:98 +#: source/ubl-strings.h:71 msgid "Maximum size of all logs:" msgstr "" -#: source/ubl-strings.h:99 +#: source/ubl-strings.h:72 msgid "Maximum size of rotation journal:" msgstr "" -#: source/ubl-strings.h:100 +#: source/ubl-strings.h:73 msgid "Leave free space at storage:" msgstr "" -#: source/ubl-strings.h:101 +#: source/ubl-strings.h:74 msgid "Redirect to console:" msgstr "" -#: source/ubl-strings.h:102 +#: source/ubl-strings.h:75 msgid "TTY:" msgstr "" -#: source/ubl-strings.h:103 +#: source/ubl-strings.h:76 msgid "Type of forwarded messages:" msgstr "" -#: source/ubl-strings.h:104 +#: source/ubl-strings.h:77 msgid "Journal configuration" msgstr "" -#: source/ubl-strings.h:105 +#: source/ubl-strings.h:78 msgid "Total log size:" msgstr "" -#: source/ubl-strings.h:106 +#: source/ubl-strings.h:79 msgid "Lower size to:" msgstr "" -#: source/ubl-strings.h:107 +#: source/ubl-strings.h:80 msgid "Apply" msgstr "" -#: source/ubl-strings.h:108 +#: source/ubl-strings.h:81 msgid "Statistics" msgstr "" -#: source/ubl-strings.h:109 +#: source/ubl-strings.h:82 msgid "Default" msgstr "" -#: source/ubl-strings.h:110 +#: source/ubl-strings.h:83 msgid "RAM" msgstr "" -#: source/ubl-strings.h:111 +#: source/ubl-strings.h:84 msgid "Drive" msgstr "" -#: source/ubl-strings.h:112 +#: source/ubl-strings.h:85 msgid "Auto" msgstr "" -#: source/ubl-strings.h:113 +#: source/ubl-strings.h:86 msgid "None" msgstr "" -#: source/ubl-strings.h:114 +#: source/ubl-strings.h:87 msgid "Yes" msgstr "" -#: source/ubl-strings.h:115 +#: source/ubl-strings.h:88 msgid "No" msgstr "" -#: source/ubl-strings.h:116 +#: source/ubl-strings.h:89 msgid "After" msgstr "" -#: source/ubl-strings.h:117 +#: source/ubl-strings.h:90 msgid "Kb" msgstr "" -#: source/ubl-strings.h:118 +#: source/ubl-strings.h:91 msgid "Mb" msgstr "" -#: source/ubl-strings.h:119 +#: source/ubl-strings.h:92 msgid "Gb" msgstr "" -#: source/ubl-strings.h:120 +#: source/ubl-strings.h:93 msgid "Minutes" msgstr "" -#: source/ubl-strings.h:121 +#: source/ubl-strings.h:94 msgid "Hours" msgstr "" -#: source/ubl-strings.h:122 +#: source/ubl-strings.h:95 msgid "Days" msgstr "" -#: source/ubl-strings.h:123 +#: source/ubl-strings.h:96 msgid "Weeks" msgstr "" -#: source/ubl-strings.h:124 +#: source/ubl-strings.h:97 msgid "Years" msgstr "" -#: source/ubl-strings.h:125 +#: source/ubl-strings.h:98 msgid "Reset" msgstr "" -#: source/ubl-strings.h:128 +#: source/ubl-strings.h:101 msgid "Logs and events - logrotate configuration" msgstr "" -#: source/ubl-strings.h:129 +#: source/ubl-strings.h:102 msgid "Log/Journal:" msgstr "" -#: source/ubl-strings.h:130 +#: source/ubl-strings.h:103 msgid "Paths to log and journals files" msgstr "" -#: source/ubl-strings.h:131 +#: source/ubl-strings.h:104 msgid "On" msgstr "" -#: source/ubl-strings.h:132 +#: source/ubl-strings.h:105 msgid "Off" msgstr "" -#: source/ubl-strings.h:133 source/ubl-strings.h:187 +#: source/ubl-strings.h:106 source/ubl-strings.h:160 msgid "Scenarios" msgstr "" -#: source/ubl-strings.h:134 source/ubl-strings.h:186 +#: source/ubl-strings.h:107 source/ubl-strings.h:159 msgid "Scenarios are running for each rotated journal" msgstr "" -#: source/ubl-strings.h:135 +#: source/ubl-strings.h:108 msgid "Command before rotation (one time):" msgstr "" -#: source/ubl-strings.h:136 +#: source/ubl-strings.h:109 msgid "Command after rotation (one time):" msgstr "" -#: source/ubl-strings.h:137 +#: source/ubl-strings.h:110 msgid "Command before rotation:" msgstr "" -#: source/ubl-strings.h:138 +#: source/ubl-strings.h:111 msgid "Command after rotation:" msgstr "" -#: source/ubl-strings.h:139 +#: source/ubl-strings.h:112 msgid "Rotation period:" msgstr "" -#: source/ubl-strings.h:140 +#: source/ubl-strings.h:113 msgid "Maximum size of file:" msgstr "" -#: source/ubl-strings.h:141 +#: source/ubl-strings.h:114 msgid "Checking frequency configuration" msgstr "" -#: source/ubl-strings.h:142 +#: source/ubl-strings.h:115 msgid "File amount:" msgstr "" -#: source/ubl-strings.h:143 +#: source/ubl-strings.h:116 msgid "Store at:" msgstr "" -#: source/ubl-strings.h:144 +#: source/ubl-strings.h:117 msgid "Rotation as user:" msgstr "" -#: source/ubl-strings.h:145 +#: source/ubl-strings.h:118 msgid "Rotation as group:" msgstr "" -#: source/ubl-strings.h:146 +#: source/ubl-strings.h:119 msgid "Rotation configuration" msgstr "" -#: source/ubl-strings.h:147 +#: source/ubl-strings.h:120 msgid "Error processing:" msgstr "" -#: source/ubl-strings.h:148 +#: source/ubl-strings.h:121 msgid "Rotation of jurnal even when it is empty:" msgstr "" -#: source/ubl-strings.h:149 +#: source/ubl-strings.h:122 msgid "Do not rotate journal younger than" msgstr "" -#: source/ubl-strings.h:150 +#: source/ubl-strings.h:123 msgid "days" msgstr "" -#: source/ubl-strings.h:151 +#: source/ubl-strings.h:124 msgid "Delete rotated journals older than" msgstr "" -#: source/ubl-strings.h:152 +#: source/ubl-strings.h:125 msgid "Rotate journals if size more than" msgstr "" -#: source/ubl-strings.h:153 +#: source/ubl-strings.h:126 msgid "but not earlier than the specified time interval" msgstr "" -#: source/ubl-strings.h:154 +#: source/ubl-strings.h:127 msgid "before specified time interval" msgstr "" -#: source/ubl-strings.h:155 +#: source/ubl-strings.h:128 msgid "File choosing configuration" msgstr "" -#: source/ubl-strings.h:156 +#: source/ubl-strings.h:129 msgid "Create log" msgstr "" -#: source/ubl-strings.h:157 +#: source/ubl-strings.h:130 msgid "as user:" msgstr "" -#: source/ubl-strings.h:158 +#: source/ubl-strings.h:131 msgid "as group:" msgstr "" -#: source/ubl-strings.h:159 +#: source/ubl-strings.h:132 msgid "rules:" msgstr "" -#: source/ubl-strings.h:160 +#: source/ubl-strings.h:133 msgid "" "Cut source journal fileafter copy creating instead of moving old journal " "file and creating new one" msgstr "" -#: source/ubl-strings.h:161 +#: source/ubl-strings.h:134 msgid "Files and directories configuration" msgstr "" -#: source/ubl-strings.h:162 +#: source/ubl-strings.h:135 msgid "Delay compression by one journal in queue:" msgstr "" -#: source/ubl-strings.h:163 +#: source/ubl-strings.h:136 msgid "Compression configuration" msgstr "" -#: source/ubl-strings.h:164 +#: source/ubl-strings.h:137 msgid "Save original log file after rotation if it has specified extension:" msgstr "" -#: source/ubl-strings.h:165 +#: source/ubl-strings.h:138 msgid "Add date of rotation before log header" msgstr "" -#: source/ubl-strings.h:166 +#: source/ubl-strings.h:139 msgid "Number from which numbering of old logs will begin" msgstr "" -#: source/ubl-strings.h:167 +#: source/ubl-strings.h:140 msgid "Filename configuration" msgstr "" -#: source/ubl-strings.h:168 +#: source/ubl-strings.h:141 msgid "Email after rotation:" msgstr "" -#: source/ubl-strings.h:169 +#: source/ubl-strings.h:142 msgid "adress:" msgstr "" -#: source/ubl-strings.h:170 +#: source/ubl-strings.h:143 msgid "contents:" msgstr "" -#: source/ubl-strings.h:171 source/ubl-strings.h:184 +#: source/ubl-strings.h:144 source/ubl-strings.h:157 msgid "Message configuration" msgstr "" -#: source/ubl-strings.h:172 +#: source/ubl-strings.h:145 msgid "Manual input:" msgstr "" -#: source/ubl-strings.h:173 +#: source/ubl-strings.h:146 msgid "Log (-s) size:" msgstr "" -#: source/ubl-strings.h:174 +#: source/ubl-strings.h:147 msgid "Same directory" msgstr "" -#: source/ubl-strings.h:175 +#: source/ubl-strings.h:148 msgid "Separate directory" msgstr "" -#: source/ubl-strings.h:176 +#: source/ubl-strings.h:149 msgid "Output errors if log file does not exist*" msgstr "" -#: source/ubl-strings.h:177 +#: source/ubl-strings.h:150 msgid "Do not output errors if log file does not exist" msgstr "" -#: source/ubl-strings.h:178 +#: source/ubl-strings.h:151 msgid "Do not output" msgstr "" -#: source/ubl-strings.h:179 +#: source/ubl-strings.h:152 msgid "Output errors" msgstr "" -#: source/ubl-strings.h:180 +#: source/ubl-strings.h:153 msgid "Send Email" msgstr "" -#: source/ubl-strings.h:181 +#: source/ubl-strings.h:154 msgid "Don't send Email" msgstr "" -#: source/ubl-strings.h:182 +#: source/ubl-strings.h:155 msgid "First rotated copy" msgstr "" -#: source/ubl-strings.h:183 +#: source/ubl-strings.h:156 msgid "Last rotated copy" msgstr "" -#: source/ubl-strings.h:185 +#: source/ubl-strings.h:158 msgid "Endwork command:" msgstr "" -#: source/ubl-strings.h:188 +#: source/ubl-strings.h:161 msgid "Hourly" msgstr "" -#: source/ubl-strings.h:189 +#: source/ubl-strings.h:162 msgid "Daily" msgstr "" -#: source/ubl-strings.h:190 +#: source/ubl-strings.h:163 msgid "Weekly*" msgstr "" -#: source/ubl-strings.h:191 +#: source/ubl-strings.h:164 msgid "Monthly" msgstr "" -#: source/ubl-strings.h:192 +#: source/ubl-strings.h:165 msgid "Yearly" msgstr "" -#: source/ubl-strings.h:193 +#: source/ubl-strings.h:166 msgid "Monday" msgstr "" -#: source/ubl-strings.h:194 +#: source/ubl-strings.h:167 msgid "Tuesday" msgstr "" -#: source/ubl-strings.h:195 +#: source/ubl-strings.h:168 msgid "Wednesday" msgstr "" -#: source/ubl-strings.h:196 +#: source/ubl-strings.h:169 msgid "Thursday" msgstr "" -#: source/ubl-strings.h:197 +#: source/ubl-strings.h:170 msgid "Friday" msgstr "" -#: source/ubl-strings.h:198 +#: source/ubl-strings.h:171 msgid "Saturday" msgstr "" -#: source/ubl-strings.h:199 +#: source/ubl-strings.h:172 msgid "Sunday*" msgstr "" -#: source/ubl-strings.h:200 +#: source/ubl-strings.h:173 msgid "Same record already exists" msgstr "" -#: source/ubl-strings.h:201 +#: source/ubl-strings.h:174 msgid "Empty important field" msgstr "" -#: source/ubl-strings.h:202 +#: source/ubl-strings.h:175 msgid "Repeating paths" msgstr "" -#: source/ubl-strings.h:203 +#: source/ubl-strings.h:176 msgid "Write down all important fields" msgstr "" -#: source/ubl-strings.h:206 +#: source/ubl-strings.h:177 +msgid "Command is invalid" +msgstr "" + +#: source/ubl-strings.h:180 msgid "Logs and events - logrotate table" msgstr "" -#: source/ubl-strings.h:207 +#: source/ubl-strings.h:181 msgid "System configuration" msgstr "" -#: source/ubl-strings.h:208 +#: source/ubl-strings.h:182 msgid "Applications configuration" msgstr "" -#: source/ubl-strings.h:209 +#: source/ubl-strings.h:183 msgid "Import log configuration" msgstr "" -#: source/ubl-strings.h:210 +#: source/ubl-strings.h:184 msgid "Add log configuration" msgstr "" -#: source/ubl-strings.h:211 +#: source/ubl-strings.h:185 msgid "Remove log configuration" msgstr "" -#: source/ubl-strings.h:215 +#: source/ubl-strings.h:189 msgid "Logs and events - journal configuration" msgstr "" -#: source/ubl-strings.h:216 +#: source/ubl-strings.h:190 msgid "Path (-s):" msgstr "" -#: source/ubl-strings.h:217 +#: source/ubl-strings.h:191 msgid "Control:" msgstr "" -#: source/ubl-strings.h:218 +#: source/ubl-strings.h:192 msgid "Log file" msgstr "" -#: source/ubl-strings.h:219 +#: source/ubl-strings.h:193 msgid "Name:" msgstr "" -#: source/ubl-strings.h:220 +#: source/ubl-strings.h:194 msgid "Log size:" msgstr "" -#: source/ubl-strings.h:223 +#: source/ubl-strings.h:195 +msgid "Journal/log files were not found" +msgstr "" + +#: source/ubl-strings.h:198 msgid "Logs and events - rules" msgstr "" -#: source/ubl-strings.h:224 +#: source/ubl-strings.h:199 msgid "Owner rules" msgstr "" -#: source/ubl-strings.h:225 +#: source/ubl-strings.h:200 msgid "Group rules" msgstr "" -#: source/ubl-strings.h:226 +#: source/ubl-strings.h:201 msgid "Public rules" msgstr "" -#: source/ubl-strings.h:227 +#: source/ubl-strings.h:202 msgid "Read" msgstr "" -#: source/ubl-strings.h:228 +#: source/ubl-strings.h:203 msgid "Write" msgstr "" -#: source/ubl-strings.h:229 +#: source/ubl-strings.h:204 msgid "Execute" msgstr "" -#: source/ubl-strings.h:230 +#: source/ubl-strings.h:205 msgid "Value:" msgstr "" -#: source/ubl-strings.h:233 +#: source/ubl-strings.h:208 msgid ": no such file(s)" msgstr "" -#: source/ubl-strings.h:234 +#: source/ubl-strings.h:209 msgid "Parameter" msgstr "" -#: source/ubl-strings.h:235 +#: source/ubl-strings.h:210 msgid "Old value" msgstr "" -#: source/ubl-strings.h:236 +#: source/ubl-strings.h:211 msgid "New value" msgstr "" -#: source/ubl-strings.h:238 +#: source/ubl-strings.h:213 msgid "Logs and events - choose a path" msgstr "" -#: source/ubl-strings.h:239 +#: source/ubl-strings.h:214 msgid "Logs and events - saving" msgstr "" +#: source/ubl-strings.h:216 +msgid "Authorization has been elevated" +msgstr "" + +#: source/ubl-strings.h:217 +msgid "Authorization has been unelevated" +msgstr "" + msgid "System event log rotation service" -msgstr "Служба ротации системных журналов событий" +msgstr "" msgid "" "Service for collecting messages from system events of active network " "devices" -msgstr "Сервис сбора сообщений системных событий активных сетевых устройств" +msgstr "" + +msgid "Save" +msgstr "" \ No newline at end of file diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 5f21509..2f2f5ee 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -18,622 +18,483 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: source/ubl-strings.h:1 -msgid "Version:" -msgstr "Версия:" - -#: source/ubl-strings.h:2 -msgid "ubl-settings-loggign version:" -msgstr "Версия ubl-settings-logging: " - -#: source/ubl-strings.h:2 source/ubl-strings.h:4 msgid "Logs and events" msgstr "Логи и журналы событий" #: source/ubl-strings.h:2 -msgid "Usage:" -msgstr "Использование:" - -#: source/ubl-strings.h:2 -msgid "[OPTIONS]" -msgstr "[АРГУМЕНТЫ]" - -#: source/ubl-strings.h:2 -msgid "Options:" -msgstr "Аргументы:" - -#: source/ubl-strings.h:2 -msgid "Show this help" -msgstr "Показать параметры справки" - -#: source/ubl-strings.h:2 -msgid "Show package version" -msgstr "Показать текущую версию" - -#: source/ubl-strings.h:2 -msgid "Lock this help menu" -msgstr "Блокировка вызова справки" - -#: source/ubl-strings.h:2 -msgid "Lock configuration saving" -msgstr "Блокировка сохранения локальной и глобальной конфигурации" - -#: source/ubl-strings.h:2 -msgid "Lock local configration saving" -msgstr "Блокировка сохранения локальной конфигурации" - -#: source/ubl-strings.h:2 -msgid "Lock global configration saving" -msgstr "Блокировка сохранения глобальной конфигурации" - -#: source/ubl-strings.h:2 -msgid "Lock global configration loading" -msgstr "Блокировка загрузки глобальной конфигурации" - -#: source/ubl-strings.h:2 -msgid "Clear application configuration" -msgstr "Очистить конфигурацию приложения" - -#: source/ubl-strings.h:5 msgid "Logs and events configuration" msgstr "Настройка и просмотр логов и журналов событий системы" -#: source/ubl-strings.h:7 -msgid "Operation succeeded" -msgstr "Операция завершена" - -#: source/ubl-strings.h:8 -msgid "" -"Warning! Application was launched without root - root-dependent actions are " -"locked" -msgstr "" -"Внимание! Приложение было запущено без прав суперпользователя - действия, " -"требующие их наличия заблокированы" - -#: source/ubl-strings.h:10 -msgid "About" -msgstr "О программе" - -#: source/ubl-strings.h:11 -msgid "Documentation" -msgstr "Справка" - -#: source/ubl-strings.h:13 -msgid "Save to local configuration" -msgstr "Сохранить в локальную конфигурацию" - -#: source/ubl-strings.h:14 -msgid "Save to global configuration" -msgstr "Сохранить в глобальную конфигурацию" - -#: source/ubl-strings.h:15 -msgid "Save to global and local configuration" -msgstr "Сохранить в глобальную и локальную конфигурацию" - -#: source/ubl-strings.h:16 -msgid "Save" -msgstr "Сохранить" - -#: source/ubl-strings.h:18 -msgid "Load local configuration" -msgstr "Загрузить локальную конфигурацию" - -#: source/ubl-strings.h:19 -msgid "Load global configuration" -msgstr "Загрузить глобальную конфигурацию" - -#: source/ubl-strings.h:20 -msgid "Load" -msgstr "Загрузить" - -#: source/ubl-strings.h:22 +#: source/ubl-strings.h:6 msgid "Cancel" msgstr "Отмена" -#: source/ubl-strings.h:24 -msgid "Would you like to read documentation in the Web?" -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 "Всегда перенаправлять" - -#: source/ubl-strings.h:27 -msgid "Open documentation" -msgstr "Прочитать справку" - -#: source/ubl-strings.h:28 -msgid "Project Home Page" -msgstr "Домашняя страница проекта" - -#: source/ubl-strings.h:29 +#: source/ubl-strings.h:7 msgid "Nothing were chosen" msgstr "Ничего не было выбрано" -#: source/ubl-strings.h:32 -msgid "Global configuration loading succseeded." -msgstr "Успешно загружена глобальная конфигурация" - -#: source/ubl-strings.h:33 -msgid "Local configuration loading succseeded." -msgstr "Успешно загружена локальная конфигурация" - -#: source/ubl-strings.h:34 -msgid "Config loading failed" -msgstr "Ошибка загрузки конфигурации" - -#: source/ubl-strings.h:36 -msgid "Local and global configuration saving succseeded." -msgstr "Успешно записаны локальная и глобальная конфигурация" - -#: source/ubl-strings.h:37 -msgid "Global configuration saving succseeded." -msgstr "Успешно записана глобальная конфигурация" +#: source/ubl-strings.h:9 +msgid "Configuration file" +msgstr "Файл конфигурации" -#: source/ubl-strings.h:38 -msgid "Local configuration saving succseeded." -msgstr "Успешно записана локальная конфигурация" +#: source/ubl-strings.h:10 +#, fuzzy +msgid "Choose custom configuration file" +msgstr "Файл конфигурации" -#: source/ubl-strings.h:39 +#: source/ubl-strings.h:12 msgid "Accept" msgstr "Принять" -#: source/ubl-strings.h:41 +#: source/ubl-strings.h:14 msgid "Choose directory instead of file" msgstr "Выбрать папку вместо файла" -#: source/ubl-strings.h:43 +#: source/ubl-strings.h:16 msgid "Journals" msgstr "Журналы" -#: source/ubl-strings.h:44 +#: source/ubl-strings.h:17 msgid "Services" msgstr "Сервисы" -#: source/ubl-strings.h:45 +#: source/ubl-strings.h:18 msgid "Log/Journal" msgstr "Лог/Журнал" -#: source/ubl-strings.h:46 +#: source/ubl-strings.h:19 msgid "Path" msgstr "Путь" -#: source/ubl-strings.h:47 +#: source/ubl-strings.h:20 msgid "Description" msgstr "Описание" -#: source/ubl-strings.h:48 +#: source/ubl-strings.h:21 msgid "Inspect log" msgstr "Просмотреть лог" -#: source/ubl-strings.h:49 source/ubl-strings.h:212 +#: source/ubl-strings.h:22 source/ubl-strings.h:186 msgid "Configure log" msgstr "Настроить лог" -#: source/ubl-strings.h:50 +#: source/ubl-strings.h:23 msgid "Add log" msgstr "Добавить лог" -#: source/ubl-strings.h:51 +#: source/ubl-strings.h:24 msgid "Remove log" msgstr "Удалить лог" -#: source/ubl-strings.h:52 +#: source/ubl-strings.h:25 msgid "Stop service" msgstr "Остановить сервис" -#: source/ubl-strings.h:53 +#: source/ubl-strings.h:26 msgid "Start service" msgstr "Запустить сервис" -#: source/ubl-strings.h:54 +#: source/ubl-strings.h:27 msgid "Configure service" msgstr "Настроить сервис" -#: source/ubl-strings.h:55 +#: source/ubl-strings.h:28 msgid "Status" msgstr "Статус" -#: source/ubl-strings.h:56 +#: source/ubl-strings.h:29 msgid "Service" msgstr "Сервис" -#: source/ubl-strings.h:57 +#: source/ubl-strings.h:30 msgid "Autostart" msgstr "Автозапуск" -#: source/ubl-strings.h:58 +#: source/ubl-strings.h:31 msgid "Switch autostart off" msgstr "Выключить автозапуск" -#: source/ubl-strings.h:59 +#: source/ubl-strings.h:32 msgid "Switch autostart on" msgstr "Включить автозапуск" -#: source/ubl-strings.h:60 +#: source/ubl-strings.h:33 msgid "System event log" msgstr "Системный журнал событий" -#: source/ubl-strings.h:61 +#: source/ubl-strings.h:34 msgid "Log of work and requests to Acpid" msgstr "Журнал работы и обращений к Acpid" -#: source/ubl-strings.h:62 +#: source/ubl-strings.h:35 msgid "Log of work and requests to the web server" msgstr "Журнал работы и обращений к веб-серверу" -#: source/ubl-strings.h:63 +#: source/ubl-strings.h:36 msgid "Audit log" msgstr "Журнал аудита (audit)" -#: source/ubl-strings.h:64 +#: source/ubl-strings.h:37 msgid "Log of authorization procedures" msgstr "Журнал процедур авторизации" -#: source/ubl-strings.h:65 +#: source/ubl-strings.h:38 msgid "Job scheduler log (cron)" msgstr "Журнал работы планировщика заданий (cron)" -#: source/ubl-strings.h:66 +#: source/ubl-strings.h:39 msgid "Log of work and calls to the print server (cups)" msgstr "Журнал работы и обращений к серверу печати (cups)" -#: source/ubl-strings.h:67 +#: source/ubl-strings.h:40 msgid "Log of operation and access to system services" msgstr "Журнал работы и обращения к службам системы" -#: source/ubl-strings.h:68 +#: source/ubl-strings.h:41 msgid "Log of work and access to Samba" msgstr "Журнал работы и обращения к Samba" -#: source/ubl-strings.h:69 +#: source/ubl-strings.h:42 msgid "Postfix mail server log" msgstr "Журнал почтового сервера Postfix" -#: source/ubl-strings.h:70 +#: source/ubl-strings.h:43 msgid "System log" msgstr "Системный журнал" -#: source/ubl-strings.h:71 +#: source/ubl-strings.h:44 msgid "X.org display server log" msgstr "Журнал работы дисплейного сервера X.org" -#: source/ubl-strings.h:72 +#: source/ubl-strings.h:45 msgid "Graphics X session log" msgstr "Журнал сеансов графической системы X" -#: source/ubl-strings.h:75 +#: source/ubl-strings.h:48 msgid "Logs and events - log inspector" msgstr "Логи и журналы событий - просмотр журнала" -#: source/ubl-strings.h:76 +#: source/ubl-strings.h:49 msgid "Show messages since the current system boot" msgstr "Показать сообщения с момента загрузки системы" -#: source/ubl-strings.h:77 +#: source/ubl-strings.h:50 msgid "Follow for new messages" msgstr "Следить за появлением новых сообщений" -#: source/ubl-strings.h:78 +#: source/ubl-strings.h:51 msgid "Show kernel ring buffer" msgstr "Показать кольцевой буфер ядра" -#: source/ubl-strings.h:79 +#: source/ubl-strings.h:52 msgid "Show only priority error messages, critical messages and warnings" msgstr "" "Показать только приоритетные сообщения об ошибках, критических сообщениях и " "предупреждениях" -#: source/ubl-strings.h:80 +#: source/ubl-strings.h:53 msgid "Show all boots" msgstr "Показать все загрузки в журнале" -#: source/ubl-strings.h:81 +#: source/ubl-strings.h:54 msgid "Show a list of all units, ordered by the time of their initialisation" msgstr "" "Показать список всех работающих юнитов, упорядоченных по времени их " "инициализации" -#: source/ubl-strings.h:82 +#: source/ubl-strings.h:55 msgid "Show tree of time-critical initialization unit chain" msgstr "Показать дерево критической по времени цепочки юнитов инициализации" -#: source/ubl-strings.h:83 +#: source/ubl-strings.h:56 msgid "Update" msgstr "Обновить" -#: source/ubl-strings.h:84 +#: source/ubl-strings.h:57 msgid "Date" msgstr "Дата" -#: source/ubl-strings.h:85 +#: source/ubl-strings.h:58 msgid "Hostname" msgstr "Имя хоста" -#: source/ubl-strings.h:86 +#: source/ubl-strings.h:59 msgid "Process" msgstr "Процесс" -#: source/ubl-strings.h:87 +#: source/ubl-strings.h:60 msgid "Log" msgstr "Запись лога" -#: source/ubl-strings.h:90 +#: source/ubl-strings.h:63 msgid "Logs and events - journald configuration" msgstr "Логи и журналы событий - конфигурация сервиса journald" -#: source/ubl-strings.h:91 +#: source/ubl-strings.h:64 msgid "Description:" msgstr "Описание:" -#: source/ubl-strings.h:92 +#: source/ubl-strings.h:65 msgid "Journal storage place:" msgstr "Место хранения журнала:" -#: source/ubl-strings.h:93 source/ubl-strings.h:94 +#: source/ubl-strings.h:66 source/ubl-strings.h:67 msgid "Use compression:" msgstr "Использовать сжатие:" -#: source/ubl-strings.h:95 +#: source/ubl-strings.h:68 msgid "Split journal files:" msgstr "Разделять файлы журнала:" -#: source/ubl-strings.h:96 +#: source/ubl-strings.h:69 msgid "Log recording journal interval:" msgstr "Интервал записи журнала:" -#: source/ubl-strings.h:97 +#: source/ubl-strings.h:70 msgid "Records amount:" msgstr "Количество записей:" -#: source/ubl-strings.h:98 +#: source/ubl-strings.h:71 msgid "Maximum size of all logs:" msgstr "Максимальный размер всех журналов:" -#: source/ubl-strings.h:99 +#: source/ubl-strings.h:72 msgid "Maximum size of rotation journal:" msgstr "Максимальный размер журнала для ротации:" -#: source/ubl-strings.h:100 +#: source/ubl-strings.h:73 msgid "Leave free space at storage:" msgstr "Оставлять в хранилище свободным:" -#: source/ubl-strings.h:101 +#: source/ubl-strings.h:74 msgid "Redirect to console:" msgstr "Перенаправление в консоль:" -#: source/ubl-strings.h:102 +#: source/ubl-strings.h:75 msgid "TTY:" msgstr "TTY:" -#: source/ubl-strings.h:103 +#: source/ubl-strings.h:76 msgid "Type of forwarded messages:" msgstr "Тип перенаправляемых сообщений:" -#: source/ubl-strings.h:104 +#: source/ubl-strings.h:77 msgid "Journal configuration" msgstr "Настройка файла журнала" -#: source/ubl-strings.h:105 +#: source/ubl-strings.h:78 msgid "Total log size:" msgstr "Общий размер журналов:" -#: source/ubl-strings.h:106 +#: source/ubl-strings.h:79 msgid "Lower size to:" msgstr "Уменьшить размер до:" -#: source/ubl-strings.h:107 +#: source/ubl-strings.h:80 msgid "Apply" msgstr "Применить" -#: source/ubl-strings.h:108 +#: source/ubl-strings.h:81 msgid "Statistics" msgstr "Статистика" -#: source/ubl-strings.h:109 +#: source/ubl-strings.h:82 msgid "Default" msgstr "По умолчанию" -#: source/ubl-strings.h:110 +#: source/ubl-strings.h:83 msgid "RAM" msgstr "Оперативная память" -#: source/ubl-strings.h:111 +#: source/ubl-strings.h:84 msgid "Drive" msgstr "Диск" -#: source/ubl-strings.h:112 +#: source/ubl-strings.h:85 msgid "Auto" msgstr "Автоматически" -#: source/ubl-strings.h:113 +#: source/ubl-strings.h:86 msgid "None" msgstr "Нет" -#: source/ubl-strings.h:114 +#: source/ubl-strings.h:87 msgid "Yes" msgstr "Да" -#: source/ubl-strings.h:115 +#: source/ubl-strings.h:88 msgid "No" msgstr "Нет" -#: source/ubl-strings.h:116 +#: source/ubl-strings.h:89 msgid "After" msgstr "После" -#: source/ubl-strings.h:117 +#: source/ubl-strings.h:90 msgid "Kb" msgstr "Кб" -#: source/ubl-strings.h:118 +#: source/ubl-strings.h:91 msgid "Mb" msgstr "Мб" -#: source/ubl-strings.h:119 +#: source/ubl-strings.h:92 msgid "Gb" msgstr "Гб" -#: source/ubl-strings.h:120 +#: source/ubl-strings.h:93 msgid "Minutes" msgstr "Минут" -#: source/ubl-strings.h:121 +#: source/ubl-strings.h:94 msgid "Hours" msgstr "Часов" -#: source/ubl-strings.h:122 +#: source/ubl-strings.h:95 msgid "Days" msgstr "Дней" -#: source/ubl-strings.h:123 +#: source/ubl-strings.h:96 msgid "Weeks" msgstr "Недель" -#: source/ubl-strings.h:124 +#: source/ubl-strings.h:97 msgid "Years" msgstr "Лет" -#: source/ubl-strings.h:125 +#: source/ubl-strings.h:98 msgid "Reset" msgstr "По умолчанию" -#: source/ubl-strings.h:128 +#: source/ubl-strings.h:101 msgid "Logs and events - logrotate configuration" msgstr "Логи и журналы событий - конфигурация сервиса logrotate" -#: source/ubl-strings.h:129 +#: source/ubl-strings.h:102 msgid "Log/Journal:" msgstr "Лог/Журнал:" -#: source/ubl-strings.h:130 +#: source/ubl-strings.h:103 msgid "Paths to log and journals files" msgstr "Пути к файлам лога/журнала" -#: source/ubl-strings.h:131 +#: source/ubl-strings.h:104 msgid "On" msgstr "Включено" -#: source/ubl-strings.h:132 +#: source/ubl-strings.h:105 msgid "Off" msgstr "Выключено" -#: source/ubl-strings.h:133 source/ubl-strings.h:187 +#: source/ubl-strings.h:106 source/ubl-strings.h:160 msgid "Scenarios" msgstr "Сценарии" -#: source/ubl-strings.h:134 source/ubl-strings.h:186 +#: source/ubl-strings.h:107 source/ubl-strings.h:159 msgid "Scenarios are running for each rotated journal" msgstr "Сценарии запускаются для каждого ротируемого журнала" -#: source/ubl-strings.h:135 +#: source/ubl-strings.h:108 msgid "Command before rotation (one time):" msgstr "Команда перед ротацией (один раз):" -#: source/ubl-strings.h:136 +#: source/ubl-strings.h:109 msgid "Command after rotation (one time):" msgstr "Команда после ротации (один раз):" -#: source/ubl-strings.h:137 +#: source/ubl-strings.h:110 msgid "Command before rotation:" msgstr "Команда перед ротацией:" -#: source/ubl-strings.h:138 +#: source/ubl-strings.h:111 msgid "Command after rotation:" msgstr "Команда после ротации:" -#: source/ubl-strings.h:139 +#: source/ubl-strings.h:112 msgid "Rotation period:" msgstr "Период ротации:" -#: source/ubl-strings.h:140 +#: source/ubl-strings.h:113 msgid "Maximum size of file:" msgstr "Максимальный размер файла:" -#: source/ubl-strings.h:141 +#: source/ubl-strings.h:114 msgid "Checking frequency configuration" msgstr "Настройки частоты проверки" -#: source/ubl-strings.h:142 +#: source/ubl-strings.h:115 msgid "File amount:" msgstr "Количество файлов:" -#: source/ubl-strings.h:143 +#: source/ubl-strings.h:116 msgid "Store at:" msgstr "Хранить в:" -#: source/ubl-strings.h:144 +#: source/ubl-strings.h:117 msgid "Rotation as user:" msgstr "Ротация от пользователя:" -#: source/ubl-strings.h:145 +#: source/ubl-strings.h:118 msgid "Rotation as group:" msgstr "Ротация от группы:" -#: source/ubl-strings.h:146 +#: source/ubl-strings.h:119 msgid "Rotation configuration" msgstr "Настройки ротации" -#: source/ubl-strings.h:147 +#: source/ubl-strings.h:120 msgid "Error processing:" msgstr "Обработка ошибок:" -#: source/ubl-strings.h:148 +#: source/ubl-strings.h:121 msgid "Rotation of jurnal even when it is empty:" msgstr "Ротация файла журнала даже если он пуст:" -#: source/ubl-strings.h:149 +#: source/ubl-strings.h:122 msgid "Do not rotate journal younger than" msgstr "Не ротировать журналы, возраст которых меньше" -#: source/ubl-strings.h:150 +#: source/ubl-strings.h:123 msgid "days" msgstr "дней" -#: source/ubl-strings.h:151 +#: source/ubl-strings.h:124 msgid "Delete rotated journals older than" msgstr "Удалить ротированные журналы старше" -#: source/ubl-strings.h:152 +#: source/ubl-strings.h:125 msgid "Rotate journals if size more than" msgstr "Ротация журналов, если размер превышает" -#: source/ubl-strings.h:153 +#: source/ubl-strings.h:126 msgid "but not earlier than the specified time interval" msgstr "но не раньше указанного интервала времени" -#: source/ubl-strings.h:154 +#: source/ubl-strings.h:127 msgid "before specified time interval" msgstr "до истечения указанного интервала времени" -#: source/ubl-strings.h:155 +#: source/ubl-strings.h:128 msgid "File choosing configuration" msgstr "Настройки выбора файла" -#: source/ubl-strings.h:156 +#: source/ubl-strings.h:129 msgid "Create log" msgstr "Создавать лог" -#: source/ubl-strings.h:157 +#: source/ubl-strings.h:130 msgid "as user:" msgstr "от пользователя:" -#: source/ubl-strings.h:158 +#: source/ubl-strings.h:131 msgid "as group:" msgstr "от группы:" -#: source/ubl-strings.h:159 +#: source/ubl-strings.h:132 msgid "rules:" msgstr "права:" -#: source/ubl-strings.h:160 +#: source/ubl-strings.h:133 msgid "" "Cut source journal fileafter copy creating instead of moving old journal " "file and creating new one" @@ -641,268 +502,276 @@ msgstr "" "После создания копии, обрезать исходный файл журнала взамен перемещения " "старого файла журнала и создания нового" -#: source/ubl-strings.h:161 +#: source/ubl-strings.h:134 msgid "Files and directories configuration" msgstr "Настройки файлов и папок" -#: source/ubl-strings.h:162 +#: source/ubl-strings.h:135 msgid "Delay compression by one journal in queue:" msgstr "Отложить сжание на один журнал в очереди:" -#: source/ubl-strings.h:163 +#: source/ubl-strings.h:136 msgid "Compression configuration" msgstr "Настройка сжатия" -#: source/ubl-strings.h:164 +#: source/ubl-strings.h:137 msgid "Save original log file after rotation if it has specified extension:" msgstr "" "Сохранять оригинальный лог после ротации, если у него указано расширение:" -#: source/ubl-strings.h:165 +#: source/ubl-strings.h:138 msgid "Add date of rotation before log header" msgstr "Добавлять дату ротации перед заголовком старого лога:" -#: source/ubl-strings.h:166 +#: source/ubl-strings.h:139 msgid "Number from which numbering of old logs will begin" msgstr "Номер, с которого будет начата нумерация старых логов:" -#: source/ubl-strings.h:167 +#: source/ubl-strings.h:140 msgid "Filename configuration" msgstr "Настройка имени файлов" -#: source/ubl-strings.h:168 +#: source/ubl-strings.h:141 msgid "Email after rotation:" msgstr "Отправка Email после ротации:" -#: source/ubl-strings.h:169 +#: source/ubl-strings.h:142 msgid "adress:" msgstr "на адрес:" -#: source/ubl-strings.h:170 +#: source/ubl-strings.h:143 msgid "contents:" msgstr "содержимое:" -#: source/ubl-strings.h:171 source/ubl-strings.h:184 +#: source/ubl-strings.h:144 source/ubl-strings.h:157 msgid "Message configuration" msgstr "Настройка сообщения" -#: source/ubl-strings.h:172 +#: source/ubl-strings.h:145 msgid "Manual input:" msgstr "Команды настройки" -#: source/ubl-strings.h:173 +#: source/ubl-strings.h:146 msgid "Log (-s) size:" msgstr "Общий размер лога (-ов):" -#: source/ubl-strings.h:174 +#: source/ubl-strings.h:147 msgid "Same directory" msgstr "Той же папке" -#: source/ubl-strings.h:175 +#: source/ubl-strings.h:148 msgid "Separate directory" msgstr "Другой папке" -#: source/ubl-strings.h:176 +#: source/ubl-strings.h:149 msgid "Output errors if log file does not exist*" msgstr "Выводить ошибки, если лог файла не существует*" -#: source/ubl-strings.h:177 +#: source/ubl-strings.h:150 msgid "Do not output errors if log file does not exist" msgstr "Не выводить ошибки, если лог файла не существует" -#: source/ubl-strings.h:178 +#: source/ubl-strings.h:151 msgid "Do not output" msgstr "Не выводить" -#: source/ubl-strings.h:179 +#: source/ubl-strings.h:152 msgid "Output errors" msgstr "Выводить ошибки" -#: source/ubl-strings.h:180 +#: source/ubl-strings.h:153 msgid "Send Email" msgstr "Отправлять Email" -#: source/ubl-strings.h:181 +#: source/ubl-strings.h:154 msgid "Don't send Email" msgstr "Не отправлять Email" -#: source/ubl-strings.h:182 +#: source/ubl-strings.h:155 msgid "First rotated copy" msgstr "Первая ротированная копия" -#: source/ubl-strings.h:183 +#: source/ubl-strings.h:156 msgid "Last rotated copy" msgstr "Последняя ротированная копия" -#: source/ubl-strings.h:185 +#: source/ubl-strings.h:158 msgid "Endwork command:" msgstr "Команда перед удалением файла журнала:" -#: source/ubl-strings.h:188 +#: source/ubl-strings.h:161 msgid "Hourly" msgstr "Час" -#: source/ubl-strings.h:189 +#: source/ubl-strings.h:162 msgid "Daily" msgstr "День" -#: source/ubl-strings.h:190 +#: source/ubl-strings.h:163 msgid "Weekly*" msgstr "Неделя*" -#: source/ubl-strings.h:191 +#: source/ubl-strings.h:164 msgid "Monthly" msgstr "Месяц" -#: source/ubl-strings.h:192 +#: source/ubl-strings.h:165 msgid "Yearly" msgstr "Год" -#: source/ubl-strings.h:193 +#: source/ubl-strings.h:166 msgid "Monday" msgstr "Понедельник" -#: source/ubl-strings.h:194 +#: source/ubl-strings.h:167 msgid "Tuesday" msgstr "Вторник" -#: source/ubl-strings.h:195 +#: source/ubl-strings.h:168 msgid "Wednesday" msgstr "Среда" -#: source/ubl-strings.h:196 +#: source/ubl-strings.h:169 msgid "Thursday" msgstr "Четверг" -#: source/ubl-strings.h:197 +#: source/ubl-strings.h:170 msgid "Friday" msgstr "Пятница" -#: source/ubl-strings.h:198 +#: source/ubl-strings.h:171 msgid "Saturday" msgstr "Суббота" -#: source/ubl-strings.h:199 +#: source/ubl-strings.h:172 msgid "Sunday*" msgstr "Воскресенье*" -#: source/ubl-strings.h:200 +#: source/ubl-strings.h:173 msgid "Same record already exists" msgstr "Такая запись уже существует" -#: source/ubl-strings.h:201 +#: source/ubl-strings.h:174 msgid "Empty important field" msgstr "Важное поле не заполнено" -#: source/ubl-strings.h:202 +#: source/ubl-strings.h:175 msgid "Repeating paths" msgstr "Повторяющиеся пути" -#: source/ubl-strings.h:203 +#: source/ubl-strings.h:176 msgid "Write down all important fields" msgstr "Введите все необходимые поля" -#: source/ubl-strings.h:206 +#: source/ubl-strings.h:177 +msgid "Command is invalid" +msgstr "Неверная команда" + +#: source/ubl-strings.h:180 msgid "Logs and events - logrotate table" msgstr "Логи и журналы событий - таблица журналов logrotate" -#: source/ubl-strings.h:207 +#: source/ubl-strings.h:181 msgid "System configuration" msgstr "Настройки системы" -#: source/ubl-strings.h:208 +#: source/ubl-strings.h:182 msgid "Applications configuration" msgstr "Настройки приложений" -#: source/ubl-strings.h:209 +#: source/ubl-strings.h:183 msgid "Import log configuration" msgstr "Импортировать конфигурацию лога" -#: source/ubl-strings.h:210 +#: source/ubl-strings.h:184 msgid "Add log configuration" msgstr "Добавить конфигурацию лога" -#: source/ubl-strings.h:211 +#: source/ubl-strings.h:185 msgid "Remove log configuration" msgstr "Удалить конфигурацию лога" -#: source/ubl-strings.h:215 +#: source/ubl-strings.h:189 msgid "Logs and events - journal configuration" msgstr "Логи и журналы событий - конфигурация журнала" -#: source/ubl-strings.h:216 +#: source/ubl-strings.h:190 msgid "Path (-s):" msgstr "Путь (-и):" -#: source/ubl-strings.h:217 +#: source/ubl-strings.h:191 msgid "Control:" msgstr "Управление:" -#: source/ubl-strings.h:218 +#: source/ubl-strings.h:192 msgid "Log file" msgstr "Файл лога" -#: source/ubl-strings.h:219 +#: source/ubl-strings.h:193 msgid "Name:" msgstr "Имя:" -#: source/ubl-strings.h:220 +#: source/ubl-strings.h:194 msgid "Log size:" msgstr "Размер лога:" -#: source/ubl-strings.h:223 +#: source/ubl-strings.h:195 +msgid "Journal/log files were not found" +msgstr "Файлы журналов/логов не были найдены" + +#: source/ubl-strings.h:198 msgid "Logs and events - rules" msgstr "Логи и журналы событий - правила" -#: source/ubl-strings.h:224 +#: source/ubl-strings.h:199 msgid "Owner rules" msgstr "Правила владельца" -#: source/ubl-strings.h:225 +#: source/ubl-strings.h:200 msgid "Group rules" msgstr "Правила группы" -#: source/ubl-strings.h:226 +#: source/ubl-strings.h:201 msgid "Public rules" msgstr "Правила остальных" -#: source/ubl-strings.h:227 +#: source/ubl-strings.h:202 msgid "Read" msgstr "Чтение" -#: source/ubl-strings.h:228 +#: source/ubl-strings.h:203 msgid "Write" msgstr "Запись" -#: source/ubl-strings.h:229 +#: source/ubl-strings.h:204 msgid "Execute" msgstr "Исполнение" -#: source/ubl-strings.h:230 +#: source/ubl-strings.h:205 msgid "Value:" msgstr "Значение:" -#: source/ubl-strings.h:233 +#: source/ubl-strings.h:208 msgid ": no such file(s)" msgstr ": файл(ы) не найден(ы)" -#: source/ubl-strings.h:234 +#: source/ubl-strings.h:209 msgid "Parameter" msgstr "Параметр" -#: source/ubl-strings.h:235 +#: source/ubl-strings.h:210 msgid "Old value" msgstr "Старое значение" -#: source/ubl-strings.h:236 +#: source/ubl-strings.h:211 msgid "New value" msgstr "Новое значение" -#: source/ubl-strings.h:238 +#: source/ubl-strings.h:213 msgid "Logs and events - choose a path" msgstr "Логи и журналы событий - Выбор пути" -#: source/ubl-strings.h:239 +#: source/ubl-strings.h:214 msgid "Logs and events - saving" msgstr "Логи и журналы событий - сохранение" @@ -913,3 +782,6 @@ msgid "" "Service for collecting messages from system events of active network " "devices" msgstr "Сервис сбора сообщений системных событий активных сетевых устройств" + +msgid "Save" +msgstr "Сохранить" \ No newline at end of file