diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 43b4b6b..ad66425 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -195,7 +195,8 @@ main_window *setup_window(){ gtk_widget_set_sensitive(widgets->SaveMenuItem,0); } if (main_config.lock_save_global == 1 && main_config.lock_save_local == 1) { - gtk_widget_set_sensitive(widgets->btnSaveCfg,0); + gtk_widget_set_sensitive(widgets->btnSaveCfg,0); + gtk_widget_set_sensitive(widgets->btnAdd,0); } gtk_widget_show_all(widgets->Window); return widgets; @@ -588,7 +589,9 @@ void tree_view_select(GtkWidget *self, main_window *widgets) { gtk_widget_set_sensitive(widgets->btnInfo,1); } else { - gtk_widget_set_sensitive(widgets->btnAdd,1); + if (main_config.lock_save_global == 0 || main_config.lock_save_local == 0) { + gtk_widget_set_sensitive(widgets->btnAdd,1); + } gtk_widget_set_sensitive(widgets->btnDelQuotas,0); gtk_widget_set_sensitive(widgets->btnEdit,0); gtk_widget_set_sensitive(widgets->btnInfo,0); @@ -1075,7 +1078,6 @@ int template_format_str_save(char* source_set_cmd, char* source_remove_cmd) { } char* template_format_str_set_save(char* source_set_cmd) { char* cmd = yon_char_new(source_set_cmd); - int flag_save = 0; for (size_t index = 0; index < main_config.size_tree_view; index++) { char* key = NULL; char* value = NULL; @@ -1083,7 +1085,6 @@ char* template_format_str_set_save(char* source_set_cmd) { value = yon_char_new(save_format_value(index)); if (key != NULL && value != NULL) { cmd = yon_char_unite(cmd, " " , key, "=\"" , value, "\" ", NULL); - flag_save = 1; } if (key != NULL) { free(key); @@ -1093,8 +1094,7 @@ char* template_format_str_set_save(char* source_set_cmd) { } } - if (flag_save && check_save()== 0) { - puts(cmd); + if (strlen(cmd) > 1 && check_save()== 0) { return cmd; } free(cmd); @@ -1257,10 +1257,18 @@ int main(int argc, char *argv[]){ yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); - if (getuid()!=0) - yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - else - yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + if (getuid()!=0) { + yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + } + else { + yon_ubl_status_box_render(LOAD_LOCAL_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + if (main_config.lock_load_global == 0) { + load_global_cfg(); + } + if (main_config.lock_save_local == 0) { + load_system_cfg(); + } + } 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); @@ -1269,8 +1277,7 @@ int main(int argc, char *argv[]){ gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), -1); - load_global_cfg(); - load_system_cfg(); + event_all(widgets); main_event(widgets); gtk_main(); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index f573c04..13a9fa0 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -1,6 +1,6 @@ #define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) #define HELP_LABEL yon_char_unite(_("ubl-settings-resourcequota version:")," ", version_application,"\n",_("CPU and RAM quotas settings"),"\n",_("Usage:"), " ubl-settings-resourcequota ",_("[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",NULL) - +#define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") #define TITLE_LABEL _("CPU and RAM quotas") #define TITLE_INFO_LABEL _("System resource quota settings management") diff --git a/ubl-settings-resourcequota.pot b/ubl-settings-resourcequota.pot index d8be582..f6a7a52 100644 --- a/ubl-settings-resourcequota.pot +++ b/ubl-settings-resourcequota.pot @@ -17,6 +17,11 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +msgid "" +"Warning! Application was launched without root - root-dependent actions are " +"locked" +msgstr "" + msgid "Config loading failed" msgstr "" diff --git a/ubl-settings-resourcequota_ru.po b/ubl-settings-resourcequota_ru.po index 72f0160..6b5307c 100644 --- a/ubl-settings-resourcequota_ru.po +++ b/ubl-settings-resourcequota_ru.po @@ -20,6 +20,11 @@ msgstr "" #: source/ubl-strings.h:8 #: source/ubl-strings.h:1 +msgid "" +"Warning! Application was launched without root - root-dependent actions are " +"locked" +msgstr "Внимание! Приложение было запущено без прав суперпользователя - действия, требующие их наличия заблокированы" + msgid "Config loading failed" msgstr "Не удалось загрузить конфигурацию"