From c54b834d630247806ddfd2c717dd1d12f8a81c2d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 7 Mar 2024 10:33:16 +0600 Subject: [PATCH] Updating for new libraries version --- source/ubl-settings-services.c | 30 ++++++++++++++++++++++-------- source/ubl-settings-services.h | 14 ++++++++++++++ ubl-settings-services.desktop | 2 +- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/source/ubl-settings-services.c b/source/ubl-settings-services.c index 9e072ef..1cc2867 100644 --- a/source/ubl-settings-services.c +++ b/source/ubl-settings-services.c @@ -5,8 +5,14 @@ config main_config; //functions void yon_load_proceed(YON_CONFIG_TYPE type){ - if (yon_config_load_register(type,"system","SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK",NULL)){ - + yon_config_clean(); + if (!yon_char_is_empty(config_get_default_command)) + yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); + if (type==YON_CONFIG_GLOBAL){ + yon_config_load_config(type,config_get_global_command,NULL); + } + if (type==YON_CONFIG_LOCAL){ + yon_config_load_config(type,config_get_local_command,NULL); } } @@ -34,17 +40,21 @@ void on_config_global_load(GtkWidget *self,main_window *widgets){ } +void on_service_constant_update(){ + +} + void on_config_global_local_save(){ - yon_save_proceed(NULL,YON_CONFIG_BOTH,"system","SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK",NULL); + yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL); } void on_config_local_save(){ - yon_save_proceed("system",YON_CONFIG_LOCAL,"system","SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK",NULL); + yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_local_command,NULL); } void on_config_global_save(){ - yon_save_proceed("global",YON_CONFIG_GLOBAL,"system","SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK",NULL); + yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL); } @@ -121,7 +131,7 @@ void on_config_autostart_clicked(GtkWidget *self, main_window *widgets){ if (status==0){ if (place ==-1){ if (!yon_config_append("SERVICES_ENABLE",name,",")){ - yon_config_register("SERVICES_ENABLE","[system]",name); + yon_config_register("SERVICES_ENABLE",SERVICES_ENABLE_get_command,name); } } } else { @@ -155,7 +165,7 @@ void on_config_autostop_clicked(GtkWidget *self, main_window *widgets){ if (status==0){ if (place ==-1){ if (!yon_config_append("SERVICES_DISABLE",name,",")){ - yon_config_register("SERVICES_DISABLE","[system]",name); + yon_config_register("SERVICES_DISABLE",SERVICES_DISABLE_get_command,name); } } } else { @@ -190,7 +200,7 @@ void on_config_block_clicked(GtkWidget *self, main_window *widgets){ if (status==0){ if (place ==-1){ if (!yon_config_append("SERVICES_MASK",name,",")){ - yon_config_register("SERVICES_MASK","[system]",name); + yon_config_register("SERVICES_MASK",SERVICES_MASK_get_command,name); } } } else { @@ -734,9 +744,11 @@ void on_tree_selection_changed(GtkWidget *self, main_window *widgets){ if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ switch_status=1; } + if (getuid()==0){ gtk_widget_set_sensitive(widgets->ConfigAutostartButton,switch_status); gtk_widget_set_sensitive(widgets->ConfigAutostopButton,switch_status); gtk_widget_set_sensitive(widgets->ConfigBlockButton,switch_status); + } gtk_widget_set_sensitive(widgets->SystemAutostartButton,switch_status); gtk_widget_set_sensitive(widgets->SystemLaunchButton,switch_status); gtk_widget_set_sensitive(widgets->InfoButton,switch_status); @@ -833,6 +845,8 @@ int main(int argc, char *argv[]){ gtk_init(&argc,&argv); template_main_window *widgets = yon_ubl_window_setup(); yon_main_window_complete((main_window*)widgets); + if (getuid()!=0) + yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); gtk_main(); return 0; } \ No newline at end of file diff --git a/source/ubl-settings-services.h b/source/ubl-settings-services.h index a98cd69..f453bde 100644 --- a/source/ubl-settings-services.h +++ b/source/ubl-settings-services.h @@ -48,6 +48,18 @@ #define start_log_command(target) yon_char_append("journalctl --all --no-pager --unit ",target) +#define config_get_local_command "ubconfig --source system get system SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK" +#define config_get_global_command "ubconfig --source global get system SERVICES_ENABLE SERVICES_DISABLE SERVICES_MASK" +#define config_get_default_command "" + +#define config_get_global_only_parameters "" +#define config_get_local_only_parameters "" + +#define SERVICES_ENABLE_get_command "ubconfig --source global get [system] SERVICES_ENABLE" +#define SERVICES_DISABLE_get_command "ubconfig --source global get [system] SERVICES_DISABLE" +#define SERVICES_MASK_get_command "ubconfig --source global get [system] SERVICES_MASK" +#define CONSOLE_FONT_get_command "ubconfig --source global get [locale] CONSOLE_FONT" + typedef char* string; string version_application; @@ -200,6 +212,8 @@ void on_config_local_save(); void on_config_global_save(); +void on_service_constant_update(); + log_window *yon_log_window_new(); gboolean yon_interface_update(main_window *widgets); diff --git a/ubl-settings-services.desktop b/ubl-settings-services.desktop index 3df33d6..494dca1 100644 --- a/ubl-settings-services.desktop +++ b/ubl-settings-services.desktop @@ -7,7 +7,7 @@ GenericName[ru]=Службы и процесссы systemd Comment=System cervices and processes configuration Comment[ru]=Настройка работы служб и процессов системы Type=Application -Exec=pkexec ubl-settings-services +Exec=ubl-settings-services Icon=com.ublinux.ubl-settings-services Terminal=false X-XfcePluggable=true