diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 823260d..9c9158b 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -472,24 +472,24 @@ void yon_interface_update(main_window *){ void on_config_global_local_save(GtkWidget *, main_window *){ main_config.save_config=3; - yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL); + yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL); } void on_config_local_save(GtkWidget *, main_window *){ main_config.save_config=1; - yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_local_command,NULL); + yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL); } void on_config_global_save(GtkWidget *, main_window *){ main_config.save_config=0; - yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL); + yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL); } void on_config_custom_save(GtkWidget *, main_window *){ main_config.save_config=1; - template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,yon_config_get_custom_command("system"),NULL); + template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); if (window){}; } @@ -516,38 +516,32 @@ void on_config_custom_load(GtkWidget *,main_window *widgets){ } void yon_load_proceed(YON_CONFIG_TYPE type){ - yon_config_clean(); + 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); - if (type==YON_CONFIG_GLOBAL){ - yon_config_load_config(type,config_get_global_command,NULL); - } else if (type==YON_CONFIG_LOCAL){ - yon_config_load_config(type,config_get_local_command,NULL); - } else if (type==YON_CONFIG_CUSTOM){ - char *path=""; - textdomain(template_ui_LocaleName); - GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); - textdomain(LocaleName); - gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubl-settings-services"); - gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL); - GtkFileFilter *filter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filter,"*.ini"); - gtk_file_filter_set_name(filter, "*.ini"); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter); - gtk_widget_show(dialog); - int response = gtk_dialog_run(GTK_DIALOG(dialog)); - if (response == GTK_RESPONSE_ACCEPT){ - char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - if (!yon_char_is_empty(file)){ - path=file; - } - gtk_widget_destroy(dialog); - } else { - gtk_widget_destroy(dialog); - } - char *command = yon_config_get_custom_command(path); - yon_config_load_config(type,command,NULL); - } + switch (type){ + case YON_CONFIG_GLOBAL: + yon_config_load_config(type,config_get_command("global"),NULL); + yon_ubl_status_box_render(yon_char_get_localised_from_lib(GLOBAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case YON_CONFIG_LOCAL: + yon_config_load_config(type,config_get_command("system"),NULL); + yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case YON_CONFIG_CUSTOM: + char *path = NULL; + path=yon_custom_config_init(GTK_FILE_CHOOSER_ACTION_OPEN); + 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: + break; + } } void on_apply_filters(GtkWidget *self, dictionary *dict){ diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index 6a978c1..b16b6b9 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -45,9 +45,7 @@ #define get_processes_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.service\"" #define get_slices_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.slice\"" -#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get security CGROUP_QUOTA[*]",NULL) -#define config_get_local_command "ubconfig --default --source system get security CGROUP_QUOTA[*]" -#define config_get_global_command "ubconfig --default --source global get security CGROUP_QUOTA[*]" +#define config_get_command(target) yon_char_unite("ubconfig --source ",target," get security CGROUP_QUOTA[*]",NULL) #define config_get_default_command "" #define config_get_global_only_parameters ""