diff --git a/source/ubl-settings-services.c b/source/ubl-settings-services.c index f8ca6c9..a68b337 100644 --- a/source/ubl-settings-services.c +++ b/source/ubl-settings-services.c @@ -1265,18 +1265,25 @@ gboolean yon_interface_update_finish(main_window *widgets){ } } main_config.update_thread_active=0; + char *final = yon_char_unite(yon_char_get_localised_from_lib(SUCCESS_LABEL),". ",main_config.load_mode==0?yon_char_get_localised_from_lib(GLOBAL_LOAD_SUCCESS_LABEL):yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),NULL); + yon_ubl_status_box_render(final,BACKGROUND_IMAGE_SUCCESS_TYPE); + free(final); return G_SOURCE_REMOVE; } void* yon_interface_update(main_window *widgets){ - dictionary *dict = yon_systemd_get_list(); - if (dict){} + // dictionary *dict = yon_systemd_get_list(); + // if (dict){} if (widgets){ g_idle_add((GSourceFunc)yon_interface_list_models_disconnect,widgets); - // int system_size; - // config_str system_services = yon_config_load(load_services_command,&system_size); + int system_size; + config_str system_services = yon_config_load(load_services_command,&system_size); + int system_units_size; + config_str system_units = yon_config_load(load_system_units_command,&system_units_size); int user_size; config_str user_services = yon_config_load(load_user_services_command,&user_size); + int user_units_size; + config_str user_units = yon_config_load(load_user_units_command,&user_units_size); int config_size; config_str config_files = yon_config_load(get_config_files_command,&config_size); int timers_size; @@ -1288,47 +1295,101 @@ void* yon_interface_update(main_window *widgets){ yon_char_remove_last_symbol(launched[i],'\n'); } - dictionary *dact = NULL; - for_dictionaries(dact,dict){ - enum YON_UNIT_TYPE type = yon_get_unit_type(((systemd_struct*)dact->data)->name); - struct system_services_data *data = malloc(sizeof(struct system_services_data)); - { - data->widgets=widgets; - data->SystemAutostart=((systemd_struct*)dact->data)->enable; - data->SystemLaunched=((systemd_struct*)dact->data)->active; - data->Name=((systemd_struct*)dact->data)->name; - data->Descr=((systemd_struct*)dact->data)->description; - data->Type = type; - data->Loaded=((systemd_struct*)dact->data)->load; - data->Active=((systemd_struct*)dact->data)->active; - data->State=((systemd_struct*)dact->data)->state; - } - g_idle_add((GSourceFunc)yon_system_set,data); + // dictionary *dact = NULL; + // for_dictionaries(dact,dict){ + // enum YON_UNIT_TYPE type = yon_get_unit_type(((systemd_struct*)dact->data)->name); + // struct system_services_data *data = malloc(sizeof(struct system_services_data)); + // { + // data->widgets=widgets; + // data->SystemAutostart=((systemd_struct*)dact->data)->enable; + // data->SystemLaunched=((systemd_struct*)dact->data)->active; + // data->Name=((systemd_struct*)dact->data)->name; + // data->Descr=((systemd_struct*)dact->data)->description; + // data->Type = type; + // data->Loaded=((systemd_struct*)dact->data)->load; + // data->Active=((systemd_struct*)dact->data)->active; + // data->State=((systemd_struct*)dact->data)->state; + // } + // g_idle_add((GSourceFunc)yon_system_set,data); + // } + + for (int i=0; iSystemList,&iter); + gtk_list_store_set(widgets->SystemList,&iter,3,1,4,active,5,parsed[0],6,parsed[4],7,type,8,active,9,loaded,11,_(parsed[3]),-1); + } + + } + for (int i=0;iSystemList,&iter); + enum YON_UNIT_TYPE type = yon_get_unit_type(system_units[i]); + gtk_list_store_set(widgets->SystemList,&iter,0,0,1,0,2,0,3,0,4,0,5,system_units[i],6,"",7,type,8,0,9,0,10,0,11,_("disabled"),-1); + + } } + // for (int i=0; iwidgets=widgets; + // data->SystemAutostart=0;//loaded; + // data->SystemLaunched=0;//active; + // data->Name=yon_char_new(parsed[0]); + // data->Descr=yon_char_new(parsed[4]); + // data->Type = type; + // data->Loaded=strcmp(parsed[1],"loaded")?0:1; + // data->Active=strcmp(parsed[2],"active")?0:1; + // data->State=yon_char_new(_(parsed[3])); + // } + // g_idle_add((GSourceFunc)yon_user_set,data); + // } + // yon_char_parsed_free(parsed,size); + // } + for (int i=0; iwidgets=widgets; - data->SystemAutostart=0;//loaded; - data->SystemLaunched=0;//active; - data->Name=yon_char_new(parsed[0]); - data->Descr=yon_char_new(parsed[4]); - data->Type = type; - data->Loaded=strcmp(parsed[1],"loaded")?0:1; - data->Active=strcmp(parsed[2],"active")?0:1; - data->State=yon_char_new(_(parsed[3])); - } - g_idle_add((GSourceFunc)yon_user_set,data); + int loaded = !strcmp(parsed[1],"loaded"); + int active = !strcmp(parsed[2],"active"); + enum YON_UNIT_TYPE type = yon_get_unit_type(parsed[0]); + gtk_list_store_append(widgets->UserList,&iter); + gtk_list_store_set(widgets->UserList,&iter,3,1,4,active,5,parsed[0],6,parsed[4],7,type,8,active,9,loaded,11,_(parsed[3]),-1); + } + + } + for (int i=0;iUserList,&iter); + enum YON_UNIT_TYPE type = yon_get_unit_type(user_units[i]); + gtk_list_store_set(widgets->UserList,&iter,0,0,1,0,2,0,3,0,4,0,5,user_units[i],6,"",7,type,8,0,9,0,10,0,11,_("disabled"),-1); + } - yon_char_parsed_free(parsed,size); } int descr_size; diff --git a/source/ubl-settings-services.h b/source/ubl-settings-services.h index f6083a8..619021e 100644 --- a/source/ubl-settings-services.h +++ b/source/ubl-settings-services.h @@ -39,6 +39,8 @@ #define systemd_config_path "resource:///com/ublinux/csv/systemd_conf.csv" #define load_services_command "systemctl list-units --no-pager --all --plain --no-legend |sed -E 's/(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(.*)/\\1;\\2;\\3;\\4;\\5/'" +#define load_system_units_command "systemctl list-unit-files --no-pager --all --plain --no-legend |sed -E 's/(\\S+)\\s+(\\S+)\\s+(\\S+)(.*)/\\1/'" +#define load_user_units_command yon_char_unite("systemctl --user --machine=",yon_ubl_root_user_get(),"@ list-unit-files --no-pager --all --plain --no-legend |sed -E 's/(\\S+)\\s+(\\S+)\\s+(\\S+)(.*)/\\1;\\2;\\3;/'",NULL) #define load_user_services_command yon_char_unite("systemctl --user --machine=",yon_ubl_root_user_get(),"@ list-units --no-pager --all --plain --no-legend |sed -E 's/(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(.*)/\\1;\\2;\\3;\\4;\\5/'",NULL) #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:"