From 1fc100f2bd016333747c51cb1a3563f6fe891447 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 18 Apr 2024 15:46:13 +0600 Subject: [PATCH 1/3] Fixes --- source/ubl-settings-services.c | 51 ++++++- source/ubl-settings-services.h | 9 ++ source/ubl-strings.h | 13 +- systemd_conf.csv | 17 +++ ubl-settings-services.glade | 8 +- ubl-settings-services.pot | 237 ++++++++++++++++--------------- ubl-settings-services_ru.po | 246 ++++++++++++++++++--------------- 7 files changed, 346 insertions(+), 235 deletions(-) create mode 100644 systemd_conf.csv diff --git a/source/ubl-settings-services.c b/source/ubl-settings-services.c index dc93d96..62843f5 100644 --- a/source/ubl-settings-services.c +++ b/source/ubl-settings-services.c @@ -117,7 +117,7 @@ void on_config_global_save(){ void on_config_custom_save(GtkWidget *self, main_window *widgets){ if (self&&widgets){} main_config.save_config=1; - template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); + template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,yon_config_get_custom_command("system"),NULL); if (window){}; } @@ -339,6 +339,11 @@ void on_config_block_clicked(GtkCellRenderer *self, char *path, main_window *wid } +void on_system_autostart_confirmed(GtkWidget *self,char *service_command){ + if (self){}; + yon_launch_app_with_arguments(service_command,""); +} + void on_system_autostart_clicked(GtkCellRenderer *self, char *path, main_window *widgets){ if (self){}; GtkTreeIter filter_iter; @@ -359,9 +364,15 @@ void on_system_autostart_clicked(GtkCellRenderer *self, char *path, main_window gboolean status = 0; char *service_name; gtk_tree_model_get(model,&iter,3,&status,5,&service_name,-1); + dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); + data->action_text=(!status)==0 ?SERVICE_DISABLE_WARNING_LABEL(service_name):SERVICE_ENABLE_WARNING_LABEL(service_name); + data->data=(!status)==1 ? service_enable_command(service_name) : \ + service_disable_command(service_name); + data->function=(void*)(void*)on_system_autostart_confirmed; + int responce = yon_confirmation_dialog_call(widgets->Window,data); + if (responce == GTK_RESPONSE_ACCEPT){ gtk_list_store_set(GTK_LIST_STORE(model),&iter,3,!status,-1); - yon_launch((!status)==1 ? service_enable_command(service_name) : \ - service_disable_command(service_name)); + } } } @@ -441,7 +452,7 @@ void on_filter_changed(GtkWidget *self, main_window *widgets){ void on_system_kill_confirmed(GtkWidget *self,char *service_name){ if (self){}; char *command = service_kill_command(service_name); - yon_launch(command); + yon_launch_app_with_arguments(command,""); } void on_system_launch_clicked(GtkWidget *self, char *path, main_window *widgets){ @@ -494,8 +505,36 @@ void on_system_launch_clicked(GtkWidget *self, char *path, main_window *widgets) } +void on_service_restart_confirmed(GtkWidget *self,char *service_name){ + if (self){}; + char *command = restart_command(service_name); + yon_launch_app_with_arguments(command,""); +} + void on_system_restart_clicked(GtkWidget *self, main_window *widgets){ if (self&&widgets){}; + GtkWidget *target_tree; + switch(gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){ + case 0:target_tree=widgets->SystemUnitsTree; + break; + case 1: target_tree = widgets->UserUnitsTree; + break; + default: return; + } + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(target_tree)); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(target_tree)),&model,&iter)){ + char *target; + gtk_tree_model_get(model,&iter,5,&target,-1); + dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); + data->action_text=REEXEC_SERVICE_WARMING_LABEL(target); + data->data=target; + data->function=(void*)(void*)on_service_restart_confirmed; + int responce = yon_confirmation_dialog_call(widgets->Window,data); + if (responce == GTK_RESPONSE_ACCEPT){ + yon_ubl_status_box_render(SERVICE_RELOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + } + } } void yon_sessions_update(main_window *widgets){ @@ -1430,6 +1469,7 @@ void yon_main_window_complete(main_window *widgets){ widgets->UserSystemLaunchedCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"UserSystemLaunchedCell")); widgets->SystemMenu = yon_rmb_menu_setup(widgets->SystemUnitsTree,NULL,NULL, RESTART_LABEL,update_icon_path,G_CALLBACK(on_system_restart_clicked),widgets, + RELAUNCH_SYSTEMCTL_LABEL,relaunch_icon_path,G_CALLBACK(yon_system_systemd_restart),widgets, STATUS_LABEL,status_icon_path,on_system_info_clicked,widgets, SHOW_LOG_LABEL,log_icon_path,on_system_log_clicked,widgets, SHOW_SOURCE_LABEL,source_icon_path,on_system_edit_clicked,widgets, @@ -1452,6 +1492,7 @@ void yon_main_window_complete(main_window *widgets){ widgets->UserDescriptionLabel=yon_gtk_builder_get_widget(builder,"UserDescriptionLabel"); widgets->UserMenu = yon_rmb_menu_setup(widgets->UserUnitsTree,NULL,NULL, RESTART_LABEL,update_icon_path,G_CALLBACK(on_system_restart_clicked),widgets, + RELAUNCH_SYSTEMCTL_LABEL,relaunch_icon_path,G_CALLBACK(yon_system_systemd_restart),widgets, STATUS_LABEL,status_icon_path,on_user_info_clicked,widgets, SHOW_LOG_LABEL,log_icon_path,on_user_log_clicked,widgets, SHOW_SOURCE_LABEL,source_icon_path,on_user_edit_clicked,widgets, @@ -1473,11 +1514,13 @@ void yon_main_window_complete(main_window *widgets){ { GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->SystemMenu->menu)); gtk_style_context_add_class(gtk_widget_get_style_context(g_list_nth_data(list,1)),"separatorTop"); + gtk_style_context_add_class(gtk_widget_get_style_context(g_list_nth_data(list,1)),"separatorBottom"); g_list_free(list); } { GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->UserMenu->menu)); gtk_style_context_add_class(gtk_widget_get_style_context(g_list_nth_data(list,1)),"separatorTop"); + gtk_style_context_add_class(gtk_widget_get_style_context(g_list_nth_data(list,1)),"separatorBottom"); g_list_free(list); } widgets->SystemServiceLabel=yon_gtk_builder_get_widget(builder,"SystemServiceLabel"); diff --git a/source/ubl-settings-services.h b/source/ubl-settings-services.h index b49aa1a..8fb44ab 100644 --- a/source/ubl-settings-services.h +++ b/source/ubl-settings-services.h @@ -101,6 +101,9 @@ #define source_icon_path "com.ublinux.ubl-settings-services.source-symbolic" #define properties_icon_path "com.ublinux.ubl-settings-services.properties-symbolic" #define status_icon_path "com.ublinux.ubl-settings-services.important-symbolic" +#define relaunch_icon_path "com.ublinux.ubl-settings-services.sync-time-symbolic" + +#define restart_command(target) yon_char_append("systemctl restart ",target) #define reload_systemd_root_command "systemctl daemon-reload" #define reexec_systemd_root_command "systemctl daemon-reexec" @@ -325,6 +328,12 @@ void on_source_show(); void on_properties_show(); +void on_system_autostart_confirmed(GtkWidget *self,char *service_command); + +void on_service_restart_confirmed(GtkWidget *self,char *service_name); + +void on_system_system_restart_clicked(GtkWidget *self, main_window *widgets); + void yon_sessions_update(main_window *widgets); void on_session_activate(); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index f394e9b..62bc354 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -16,6 +16,8 @@ #define SYSTEM_SERVICES_LABEL _("System services only") #define USER_SERVICES_LABEL _("User services only") +#define SAVE_PROCESS_LABEL _("Saving...") + #define ALL_LABEL _("All") #define SERVICES_LABEL _("Services") #define SOCKETS_LABEL _("Sockets") @@ -44,7 +46,7 @@ #define LAUNCHED_LABEL _("Launched") #define LIST_LOAD_LABEL _("Service list is loading") #define STATUS_LABEL _("Status") -#define RESTART_LABEL _("Restart with new configuration") +#define RESTART_LABEL _("Restart") #define SHOW_LOG_LABEL _("Show log") #define SHOW_SOURCE_LABEL _("Show source") #define PROPERTIES_LABEL _("Properties") @@ -61,8 +63,11 @@ #define SWITCH_OFF_ERROR_LABEL _("Service were not stopped") #define SERVICE_STOP_WARNING_LABEL(target) yon_char_unite(_("Are you sure want to stop "),target,"?\n",_("The system may become unstable."),NULL) +#define SERVICE_SART_WARNING_LABEL(target) yon_char_unite(_("Are you sure want to start "),target,"?\n",_("The system may become unstable."),NULL) #define REEXEC_SERVICE_WARMING_LABEL(target) yon_char_unite(_("Are you sure want to restart "),target,"?\n",_("The system may become unstable."),NULL) #define RELOAD_SERVICE_WARMING_LABEL(target) yon_char_unite(_("Are you sure want to reload "),target,"?\n",_("The system may become unstable."),NULL) +#define SERVICE_ENABLE_WARNING_LABEL(target) yon_char_unite(_("Are you sure want to enable "),target,"?\n",_("The system may become unstable."),NULL) +#define SERVICE_DISABLE_WARNING_LABEL(target) yon_char_unite(_("Are you sure want to disable "),target,"?\n",_("The system may become unstable."),NULL) #define DAYS_LABEL _("Days") #define HOURS_LABEL _("Hours") #define MINUTES_LABEL _("Minutes") @@ -86,8 +91,8 @@ #define UNIT_LABEL _("Unit") -#define RELAUNCH_SYSTEMCTL_LABEL _("Relaunch systemctl") -#define REEXEC_SYSTEMCTL_LABEL _("Reexec systemctl") +#define RELAUNCH_SYSTEMCTL_LABEL _("Relaunch with new configuration") +#define REEXEC_SYSTEMCTL_LABEL _("Reexec systemd") #define SHOW_SERVICE_INFO_LABEL _("Show service information") #define SHOW_SERVICE_LOG_LABEL _("Show service log") #define SHOW_SERVICE_SOURCE_LABEL _("Show service source file") @@ -140,4 +145,6 @@ #define SYSTEMD_REEXEC_SUCCESS_LABEL _("Systemd has been re-executed") #define SYSTEMD_RELAUNCH_SUCCESS_LABEL _("Systemd has been relaunched") +#define SERVICE_RELOAD_SUCCESS_LABEL _("Service has been successfully restarted") + #define SAVE_LABEL _("Save") \ No newline at end of file diff --git a/systemd_conf.csv b/systemd_conf.csv new file mode 100644 index 0000000..66b8146 --- /dev/null +++ b/systemd_conf.csv @@ -0,0 +1,17 @@ +config_name;description +ubconfig*.conf;UBLinux OS configuration files +coredump*.conf;System Debug Dump Configuration +journald*.conf;Configuring various systemd log service options +journal-upload*.conf;Configuring various systemd-journal-upload.service parameters +networkd*.conf;Configuring Global Network Settings +pstore*.conf;Configuration file for systemd-pstore, a tool for archiving the contents of the pstore persistent storage file system +sleep*.conf;Workstation hibernation options +system*.conf;Systemd configuration +user*.conf;User Configuration +homed*.conf;Settings management configuration for user account home directories created and managed by systemd-homed.service +journal-remote*.conf;Configuration files for various systemd-journal-remote.service parameters +logind*.conf;Configuration files for various systemd login manager options +oomd*.conf;Configuration files for various out-of-memory (OOM) killer parameters in systemd user space +resolved*.conf;Local DNS and LLMNR name resolution management configuration files +swap*.conf;System swap file management configuration files +timesyncd*.conf;Configuration file controlling NTP network time synchronization \ No newline at end of file diff --git a/ubl-settings-services.glade b/ubl-settings-services.glade index 0726e48..1b5f3a0 100644 --- a/ubl-settings-services.glade +++ b/ubl-settings-services.glade @@ -387,7 +387,7 @@ True True True - Relaunch systemctl + Relaunch with new cnfiguration image1 + + + False + True + 3 + + True @@ -442,7 +470,7 @@ False True - 3 + 4 @@ -460,7 +488,7 @@ False True - 4 + 5 @@ -478,7 +506,7 @@ False True - 5 + 6 @@ -496,7 +524,7 @@ False True - 6 + 7 @@ -507,7 +535,7 @@ False True - 7 + 8 @@ -532,7 +560,7 @@ False True - 8 + 9 @@ -985,6 +1013,24 @@ 2 + + + True + False + True + True + Reexec systemd + image2 + + + + False + True + 3 + + True @@ -1000,7 +1046,7 @@ False True - 3 + 4 @@ -1018,7 +1064,7 @@ False True - 4 + 5 @@ -1036,7 +1082,7 @@ False True - 5 + 6 @@ -1054,7 +1100,7 @@ False True - 6 + 7 @@ -1065,7 +1111,7 @@ False True - 7 + 8 @@ -1090,7 +1136,7 @@ False True - 8 + 9 -- 2.35.1 From 88ffdb3784b81bfee452677393e180aa1b51cd48 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 18 Apr 2024 16:16:12 +0600 Subject: [PATCH 3/3] Confirmation window for service launching --- source/ubl-settings-services.c | 29 ++++++++++++++++++++++------- source/ubl-settings-services.h | 8 ++++---- source/ubl-strings.h | 2 +- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/source/ubl-settings-services.c b/source/ubl-settings-services.c index 2e41ed2..45e6a7c 100644 --- a/source/ubl-settings-services.c +++ b/source/ubl-settings-services.c @@ -451,8 +451,7 @@ void on_filter_changed(GtkWidget *self, main_window *widgets){ void on_system_kill_confirmed(GtkWidget *self,char *service_name){ if (self){}; - char *command = service_kill_command(service_name); - yon_launch_app_with_arguments(command,""); + yon_launch_app_with_arguments(service_name,""); } void on_system_launch_clicked(GtkWidget *self, char *path, main_window *widgets){ @@ -477,7 +476,7 @@ void on_system_launch_clicked(GtkWidget *self, char *path, main_window *widgets) if (status){ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); data->action_text=SERVICE_STOP_WARNING_LABEL(service_name); - data->data=service_name; + data->data=service_stop_command(service_name); data->function=(void*)(void*)on_system_kill_confirmed; int size; config_str result = yon_config_load(service_check_active_command(service_name),&size); @@ -491,15 +490,31 @@ void on_system_launch_clicked(GtkWidget *self, char *path, main_window *widgets) } yon_char_parsed_free(result,size); } else { - yon_launch(service_start_command(service_name)); + dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); + data->action_text=SERVICE_START_WARNING_LABEL(service_name); + data->data=service_start_command(service_name); + data->function=(void*)(void*)on_system_kill_confirmed; int size; config_str result = yon_config_load(service_check_active_command(service_name),&size); yon_char_remove_last_symbol(result[0],'\n'); if (size>0&&!strcmp(result[0],"active")){ - gtk_list_store_set(GTK_LIST_STORE(model),&iter,4,1,-1); - } else { - yon_ubl_status_box_render(SERVICE_START_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + int responce = yon_confirmation_dialog_call(widgets->Window,data); + if (responce == GTK_RESPONSE_ACCEPT){ + gtk_list_store_set(GTK_LIST_STORE(model),&iter,4,1,-1); + + } } + + // yon_char_parsed_free(result,size); + // yon_launch(service_start_command(service_name)); + // int size; + // config_str result = yon_config_load(service_check_active_command(service_name),&size); + // yon_char_remove_last_symbol(result[0],'\n'); + // if (size>0&&!strcmp(result[0],"active")){ + // gtk_list_store_set(GTK_LIST_STORE(model),&iter,4,1,-1); + // } else { + // yon_ubl_status_box_render(SERVICE_START_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + // } } } diff --git a/source/ubl-settings-services.h b/source/ubl-settings-services.h index e73afd7..f2cab65 100644 --- a/source/ubl-settings-services.h +++ b/source/ubl-settings-services.h @@ -38,10 +38,10 @@ #define load_system_services_command "systemctl --system list-units --no-pager --all |grep -E \"^ \" |grep -v \"UNIT\" |sed -e 's/ */;/g' -e 's/^;//g' |cut -f1 -d';'" #define load_enabled_command "systemctl list-unit-files --no-pager --state=enabled --all |sed -e 's/ */:/g' -e 's/ *: */:/g'|cut -f1 -d:" #define load_launched_command "systemctl list-units --no-pager --state=active --all --no-legend|sed -e 's/^ //g' -e 's/ */:/g' |cut -f1 -d:" -#define service_start_command(target) yon_char_append("systemctl start --no-pager ",target) -#define service_stop_command(target) yon_char_append("systemctl stop --no-pager ",target) -#define service_enable_command(target) yon_char_append("systemctl enable --no-pager ",target) -#define service_disable_command(target) yon_char_append("systemctl disable --no-pager ",target) +#define service_start_command(target) yon_char_append("systemctl start ",target) +#define service_stop_command(target) yon_char_append("systemctl stop ",target) +#define service_enable_command(target) yon_char_append("systemctl enable ",target) +#define service_disable_command(target) yon_char_append("systemctl disable ",target) #define service_kill_command(target) yon_char_append("systemctl kill ",target) #define service_check_active_command(target) yon_char_append("systemctl is-active ",target) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 62bc354..2bcb8af 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -63,7 +63,7 @@ #define SWITCH_OFF_ERROR_LABEL _("Service were not stopped") #define SERVICE_STOP_WARNING_LABEL(target) yon_char_unite(_("Are you sure want to stop "),target,"?\n",_("The system may become unstable."),NULL) -#define SERVICE_SART_WARNING_LABEL(target) yon_char_unite(_("Are you sure want to start "),target,"?\n",_("The system may become unstable."),NULL) +#define SERVICE_START_WARNING_LABEL(target) yon_char_unite(_("Are you sure want to start "),target,"?\n",_("The system may become unstable."),NULL) #define REEXEC_SERVICE_WARMING_LABEL(target) yon_char_unite(_("Are you sure want to restart "),target,"?\n",_("The system may become unstable."),NULL) #define RELOAD_SERVICE_WARMING_LABEL(target) yon_char_unite(_("Are you sure want to reload "),target,"?\n",_("The system may become unstable."),NULL) #define SERVICE_ENABLE_WARNING_LABEL(target) yon_char_unite(_("Are you sure want to enable "),target,"?\n",_("The system may become unstable."),NULL) -- 2.35.1