|
|
|
|
@ -166,9 +166,10 @@ void on_config_autostart_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
gboolean status = 0;
|
|
|
|
|
char *name;
|
|
|
|
|
gtk_tree_model_get(model,&iter,0,&status,5,&name,-1);
|
|
|
|
|
char *parsed_name = yon_char_divide(name, yon_char_find_last(name,'.'));
|
|
|
|
|
free(name);
|
|
|
|
|
name=parsed_name;
|
|
|
|
|
char *unit = yon_char_new(name);
|
|
|
|
|
char *parsed_name = yon_char_divide(unit, yon_char_find_last(name,'.'));
|
|
|
|
|
free(unit);
|
|
|
|
|
unit=parsed_name;
|
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,!status,-1);
|
|
|
|
|
char *config_sting = yon_config_get_by_key("SERVICES_ENABLE");
|
|
|
|
|
int size;
|
|
|
|
|
@ -176,9 +177,17 @@ void on_config_autostart_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
int place = yon_char_parsed_check_exist(parsed,size,name);
|
|
|
|
|
if (status==0){
|
|
|
|
|
if (place ==-1){
|
|
|
|
|
if (yon_char_parsed_check_exist(parsed,size,unit)==-1){
|
|
|
|
|
if (!yon_config_append("SERVICES_ENABLE",name,",")){
|
|
|
|
|
yon_config_register("SERVICES_ENABLE",SERVICES_ENABLE_get_command,name);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
parsed = yon_char_parsed_rip(parsed,&size,place);
|
|
|
|
|
if (parsed)
|
|
|
|
|
yon_config_set("SERVICES_ENABLE",yon_char_parsed_to_string(parsed,size,","));
|
|
|
|
|
else yon_config_remove_by_key("SERVICES_ENABLE");
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (place !=-1){
|
|
|
|
|
@ -186,6 +195,7 @@ void on_config_autostart_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (parsed)
|
|
|
|
|
yon_config_set("SERVICES_ENABLE",yon_char_parsed_to_string(parsed,size,","));
|
|
|
|
|
else yon_config_remove_by_key("SERVICES_ENABLE");
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
@ -213,9 +223,10 @@ void on_config_autostop_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
gboolean status = 0;
|
|
|
|
|
char *name;
|
|
|
|
|
gtk_tree_model_get(model,&iter,1,&status,5,&name,-1);
|
|
|
|
|
char *parsed_name = yon_char_divide(name, yon_char_find_last(name,'.'));
|
|
|
|
|
free(name);
|
|
|
|
|
name=parsed_name;
|
|
|
|
|
char *unit = yon_char_new(name);
|
|
|
|
|
char *parsed_name = yon_char_divide(unit, yon_char_find_last(name,'.'));
|
|
|
|
|
free(unit);
|
|
|
|
|
unit=parsed_name;
|
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model),&iter,1,!status,-1);
|
|
|
|
|
char *config_sting = yon_config_get_by_key("SERVICES_DISABLE");
|
|
|
|
|
int size;
|
|
|
|
|
@ -223,9 +234,17 @@ void on_config_autostop_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
int place = yon_char_parsed_check_exist(parsed,size,name);
|
|
|
|
|
if (status==0){
|
|
|
|
|
if (place ==-1){
|
|
|
|
|
if (yon_char_parsed_check_exist(parsed,size,unit)==-1){
|
|
|
|
|
if (!yon_config_append("SERVICES_DISABLE",name,",")){
|
|
|
|
|
yon_config_register("SERVICES_DISABLE",SERVICES_DISABLE_get_command,name);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
parsed = yon_char_parsed_rip(parsed,&size,place);
|
|
|
|
|
if (parsed)
|
|
|
|
|
yon_config_set("SERVICES_DISABLE",yon_char_parsed_to_string(parsed,size,","));
|
|
|
|
|
else yon_config_remove_by_key("SERVICES_DISABLE");
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (place !=-1){
|
|
|
|
|
@ -233,6 +252,7 @@ void on_config_autostop_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (parsed)
|
|
|
|
|
yon_config_set("SERVICES_DISABLE",yon_char_parsed_to_string(parsed,size,","));
|
|
|
|
|
else yon_config_remove_by_key("SERVICES_DISABLE");
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
@ -261,9 +281,10 @@ void on_config_block_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
gboolean status = 0;
|
|
|
|
|
char *name;
|
|
|
|
|
gtk_tree_model_get(model,&iter,2,&status,5,&name,-1);
|
|
|
|
|
char *parsed_name = yon_char_divide(name, yon_char_find_last(name,'.'));
|
|
|
|
|
free(name);
|
|
|
|
|
name=parsed_name;
|
|
|
|
|
char *unit = yon_char_new(name);
|
|
|
|
|
char *parsed_name = yon_char_divide(unit, yon_char_find_last(name,'.'));
|
|
|
|
|
free(unit);
|
|
|
|
|
unit=parsed_name;
|
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model),&iter,2,!status,-1);
|
|
|
|
|
char *config_sting = yon_config_get_by_key("SERVICES_MASK");
|
|
|
|
|
int size;
|
|
|
|
|
@ -271,9 +292,17 @@ void on_config_block_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
int place = yon_char_parsed_check_exist(parsed,size,name);
|
|
|
|
|
if (status==0){
|
|
|
|
|
if (place ==-1){
|
|
|
|
|
if (yon_char_parsed_check_exist(parsed,size,unit)==-1){
|
|
|
|
|
if (!yon_config_append("SERVICES_MASK",name,",")){
|
|
|
|
|
yon_config_register("SERVICES_MASK",SERVICES_MASK_get_command,name);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
parsed = yon_char_parsed_rip(parsed,&size,place);
|
|
|
|
|
if (parsed)
|
|
|
|
|
yon_config_set("SERVICES_MASK",yon_char_parsed_to_string(parsed,size,","));
|
|
|
|
|
else yon_config_remove_by_key("SERVICES_MASK");
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (place !=-1){
|
|
|
|
|
@ -281,6 +310,7 @@ void on_config_block_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (parsed)
|
|
|
|
|
yon_config_set("SERVICES_MASK",yon_char_parsed_to_string(parsed,size,","));
|
|
|
|
|
else yon_config_remove_by_key("SERVICES_MASK");
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
@ -433,16 +463,60 @@ void on_system_restart_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (self&&widgets){};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_session_activate(){
|
|
|
|
|
|
|
|
|
|
void yon_sessions_update(main_window *widgets){
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->SessionMainTree),NULL);
|
|
|
|
|
gtk_list_store_clear(widgets->SessionsList);
|
|
|
|
|
int sessions_size;
|
|
|
|
|
config_str sessions = yon_config_load(list_of_session_command,&sessions_size);
|
|
|
|
|
for (int i=0;i<sessions_size;i++){
|
|
|
|
|
if (sessions[i][strlen(sessions[i])-1]=='\n') sessions[i][strlen(sessions[i])-1] = '\0';
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
int size;
|
|
|
|
|
config_str parsed = yon_char_parse(sessions[i],&size," ");
|
|
|
|
|
if (!strcmp(parsed[1],"\001")) parsed[1]=ACTIVE_LABEL;
|
|
|
|
|
else parsed[1]=INACTIVE_LABEL;
|
|
|
|
|
if (parsed&&size>4){
|
|
|
|
|
gtk_list_store_append(widgets->SessionsList,&iter);
|
|
|
|
|
gtk_list_store_set(widgets->SessionsList,&iter,0,atoi(parsed[0]),1,parsed[1],2,atoi(parsed[2]),3,parsed[3],4,parsed[4],-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->SessionMainTree),GTK_TREE_MODEL(widgets->SessionsList));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_session_end(){
|
|
|
|
|
|
|
|
|
|
void on_session_activate(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (self){};
|
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(widgets->SessionsList);
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SessionMainTree)),&model,&iter)){
|
|
|
|
|
char *id;
|
|
|
|
|
gtk_tree_model_get(model,&iter,0,&id,-1);
|
|
|
|
|
yon_launch(session_activate_session(id));
|
|
|
|
|
yon_sessions_update(widgets);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_session_block(){
|
|
|
|
|
void on_session_end(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (self){};
|
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(widgets->SessionsList);
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SessionMainTree)),&model,&iter)){
|
|
|
|
|
char *id;
|
|
|
|
|
gtk_tree_model_get(model,&iter,0,&id,-1);
|
|
|
|
|
yon_launch(session_terminate_session(id));
|
|
|
|
|
yon_sessions_update(widgets);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_session_block(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (self){};
|
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(widgets->SessionsList);
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SessionMainTree)),&model,&iter)){
|
|
|
|
|
char *id;
|
|
|
|
|
gtk_tree_model_get(model,&iter,0,&id,-1);
|
|
|
|
|
yon_launch(session_lock_session(id));
|
|
|
|
|
yon_sessions_update(widgets);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_window *yon_log_window_new(){
|
|
|
|
|
@ -765,29 +839,6 @@ void on_config_edit_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_session_start_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (self){}
|
|
|
|
|
if (widgets){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_session_stop_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (self){}
|
|
|
|
|
if (widgets){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_session_lock_clicked(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (self){}
|
|
|
|
|
if (widgets){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_system_services_status(GtkWidget *self, main_window *widgets){
|
|
|
|
|
if (self){}
|
|
|
|
|
if (widgets){
|
|
|
|
|
@ -865,12 +916,10 @@ gboolean yon_interface_update(main_window *widgets){
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->SystemUnitsTree),NULL);
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->UserUnitsTree),NULL);
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->ConfigMainTree),NULL);
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->SessionMainTree),NULL);
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->TimersMainTree),NULL);
|
|
|
|
|
gtk_list_store_clear(widgets->SystemList);
|
|
|
|
|
gtk_list_store_clear(widgets->UserList);
|
|
|
|
|
gtk_list_store_clear(widgets->ConfigList);
|
|
|
|
|
gtk_list_store_clear(widgets->SessionsList);
|
|
|
|
|
gtk_list_store_clear(widgets->TimersList);
|
|
|
|
|
int system_size;
|
|
|
|
|
config_str system_services = yon_config_load(load_services_command,&system_size);
|
|
|
|
|
@ -878,8 +927,6 @@ gboolean yon_interface_update(main_window *widgets){
|
|
|
|
|
config_str user_services = yon_config_load(load_user_services_command,&user_size);
|
|
|
|
|
int config_size;
|
|
|
|
|
config_str config_files = yon_config_load(get_config_files_command,&config_size);
|
|
|
|
|
int sessions_size;
|
|
|
|
|
config_str sessions = yon_config_load(list_of_session_command,&sessions_size);
|
|
|
|
|
int timers_size;
|
|
|
|
|
config_str timers = yon_config_load(get_timers_command,&timers_size);
|
|
|
|
|
struct json_object *jsobject = json_tokener_parse(timers[0]);
|
|
|
|
|
@ -922,18 +969,7 @@ gboolean yon_interface_update(main_window *widgets){
|
|
|
|
|
gtk_list_store_set(widgets->ConfigList,&iter,0,parsed[2],1,parsed[1],2,description,-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i=0;i<sessions_size;i++){
|
|
|
|
|
if (sessions[i][strlen(sessions[i])-1]=='\n') sessions[i][strlen(sessions[i])-1] = '\0';
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
int size;
|
|
|
|
|
config_str parsed = yon_char_parse(sessions[i],&size," ");
|
|
|
|
|
if (!strcmp(parsed[1],"\001")) parsed[1]=ACTIVE_LABEL;
|
|
|
|
|
else parsed[1]=INACTIVE_LABEL;
|
|
|
|
|
if (parsed&&size>4){
|
|
|
|
|
gtk_list_store_append(widgets->SessionsList,&iter);
|
|
|
|
|
gtk_list_store_set(widgets->SessionsList,&iter,0,atoi(parsed[0]),1,parsed[1],2,atoi(parsed[2]),3,parsed[3],4,parsed[4],-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yon_sessions_update(widgets);
|
|
|
|
|
for (size_t i=0;i<json_object_array_length(jsobject);i++){
|
|
|
|
|
struct json_object *item_obj = json_object_array_get_idx(jsobject, i);
|
|
|
|
|
const char *unit="",*next="",*left="",*last="",*passed="",*activates="";
|
|
|
|
|
@ -1136,7 +1172,6 @@ gboolean yon_interface_update(main_window *widgets){
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->SystemUnitsTree),GTK_TREE_MODEL(widgets->SystemFilter));
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->UserUnitsTree),GTK_TREE_MODEL(widgets->UserFilter));
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->ConfigMainTree),GTK_TREE_MODEL(widgets->ConfigList));
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->SessionMainTree),GTK_TREE_MODEL(widgets->SessionsList));
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->TimersMainTree),GTK_TREE_MODEL(widgets->TimersList));
|
|
|
|
|
main_config.update_thread_active=0;
|
|
|
|
|
return 0;
|
|
|
|
|
@ -1317,9 +1352,9 @@ void yon_main_window_complete(main_window *widgets){
|
|
|
|
|
widgets->SessionStopButton=yon_gtk_builder_get_widget(builder,"SessionStopButton");
|
|
|
|
|
widgets->SessionBlockButton=yon_gtk_builder_get_widget(builder,"SessionBlockButton");
|
|
|
|
|
widgets->SessionMenu = yon_rmb_menu_setup(widgets->SessionMainTree,NULL,NULL,
|
|
|
|
|
ACTIVATE_SESSION_LABEL,play_icon_path,on_session_activate,NULL,
|
|
|
|
|
END_SESSION_LABEL,stop_icon_path,on_session_end,NULL,
|
|
|
|
|
BLOCK_SESSION_LABEL,block_icon_path,on_session_block,NULL,
|
|
|
|
|
ACTIVATE_SESSION_LABEL,play_icon_path,G_CALLBACK(on_session_activate),widgets,
|
|
|
|
|
END_SESSION_LABEL,stop_icon_path,G_CALLBACK(on_session_end),widgets,
|
|
|
|
|
BLOCK_SESSION_LABEL,block_icon_path,G_CALLBACK(on_session_block),widgets,
|
|
|
|
|
NULL);
|
|
|
|
|
{
|
|
|
|
|
GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->SystemMenu->menu));
|
|
|
|
|
@ -1359,9 +1394,9 @@ void yon_main_window_complete(main_window *widgets){
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->ConfigEditButton),"clicked",G_CALLBACK(on_config_edit_clicked),widgets);
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SessionStartButton),"clicked",G_CALLBACK(on_session_start_clicked),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SessionStopButton),"clicked",G_CALLBACK(on_session_stop_clicked),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SessionBlockButton),"clicked",G_CALLBACK(on_session_lock_clicked),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SessionStartButton),"clicked",G_CALLBACK(on_session_activate),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SessionStopButton),"clicked",G_CALLBACK(on_session_end),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SessionBlockButton),"clicked",G_CALLBACK(on_session_block),widgets);
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SystemServicesStatusMenuItem),"activate",G_CALLBACK(on_system_services_status),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->UserServicesStatusMenuItem),"activate",G_CALLBACK(on_user_services_status),widgets);
|
|
|
|
|
|