|
|
|
|
@ -31,10 +31,16 @@ source_element *yon_source_element_new(){
|
|
|
|
|
g_signal_connect(G_OBJECT(element->PathButton),"clicked",G_CALLBACK(on_source_choose),element);
|
|
|
|
|
g_signal_connect(G_OBJECT(element->TypeCombo),"changed",G_CALLBACK(on_source_changed),element);
|
|
|
|
|
g_object_set_data(G_OBJECT(element->PathButton),"combo",element->TypeCombo);
|
|
|
|
|
g_object_set_data(G_OBJECT(element->MainBox),"source_element",element);
|
|
|
|
|
g_object_set_data(G_OBJECT(element->PathButton),"target_combo",element->TypeCombo);
|
|
|
|
|
g_object_set_data(G_OBJECT(element->TypeCombo),"target",element->DeviceCombo);
|
|
|
|
|
g_object_set_data(G_OBJECT(element->TypeCombo),"button",element->PathButton);
|
|
|
|
|
g_object_set_data(G_OBJECT(element->TypeCombo),"combo",element->PathEntry);
|
|
|
|
|
gtk_widget_set_sensitive(element->DeviceCombo,0);
|
|
|
|
|
gtk_widget_set_sensitive(element->TypeCombo,0);
|
|
|
|
|
gtk_widget_set_sensitive(element->PathEntry,0);
|
|
|
|
|
gtk_widget_set_sensitive(element->PathButton,0);
|
|
|
|
|
gtk_widget_hide(element->PathButton);
|
|
|
|
|
int size;
|
|
|
|
|
config_str parts = yon_config_load(get_parts_and_devices_command, &size);
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
@ -144,6 +150,53 @@ void on_source_accept(GtkWidget *,source_window *window){
|
|
|
|
|
if (!yon_char_is_empty(creation_path)){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),SOURCE_CREATE_ONGOING_ERROR_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
char *sources_list = NULL;
|
|
|
|
|
GList *list = gtk_container_get_children(GTK_CONTAINER(window->AddBox));
|
|
|
|
|
GList *iter;
|
|
|
|
|
for (iter=list;iter;iter=iter->next){
|
|
|
|
|
source_element *element = NULL;
|
|
|
|
|
element = g_object_get_data(G_OBJECT(iter->data),"source_element");
|
|
|
|
|
switch(gtk_combo_box_get_active(GTK_COMBO_BOX(element->TypeCombo))){
|
|
|
|
|
case 0:{
|
|
|
|
|
char *cur = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(element->DeviceCombo));
|
|
|
|
|
if (yon_char_check_element(sources_list,cur,",")){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),VALUE_REPEAT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
yon_ubl_status_highlight_incorrect(element->DeviceCombo);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
char *temp = yon_char_append_element(sources_list,cur,",");
|
|
|
|
|
if (!yon_char_is_empty(sources_list)) free(sources_list);
|
|
|
|
|
sources_list = temp;
|
|
|
|
|
} break;
|
|
|
|
|
case 1:{
|
|
|
|
|
char *cur = (char*)gtk_entry_get_text(GTK_ENTRY(element->PathEntry));
|
|
|
|
|
if (yon_char_check_element(sources_list,cur,",")){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),VALUE_REPEAT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
yon_ubl_status_highlight_incorrect(element->DeviceCombo);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
char *temp = yon_char_append_element(sources_list,cur,",");
|
|
|
|
|
if (!yon_char_is_empty(sources_list)) free(sources_list);
|
|
|
|
|
sources_list = temp;
|
|
|
|
|
} break;
|
|
|
|
|
case 2:{
|
|
|
|
|
char *cur = (char*)gtk_entry_get_text(GTK_ENTRY(element->PathEntry));
|
|
|
|
|
if (yon_char_check_element(sources_list,cur,",")){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),VALUE_REPEAT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
yon_ubl_status_highlight_incorrect(element->DeviceCombo);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
char *temp = yon_char_append_element(sources_list,cur,",");
|
|
|
|
|
if (!yon_char_is_empty(sources_list)) free(sources_list);
|
|
|
|
|
sources_list = temp;
|
|
|
|
|
} break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(sources_list)){
|
|
|
|
|
yon_config_register(source_parameter,source_parameter_command,sources_list);
|
|
|
|
|
} else {
|
|
|
|
|
yon_config_remove_by_key(source_parameter);
|
|
|
|
|
}
|
|
|
|
|
int size;
|
|
|
|
|
config_str paths = NULL;
|
|
|
|
|
dictionary *dict;
|
|
|
|
|
@ -161,7 +214,6 @@ void on_source_accept(GtkWidget *,source_window *window){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
char *parameter_string = yon_char_parsed_to_string(paths,(int)size,",");
|
|
|
|
|
yon_config_register(source_parameter,source_parameter_command,parameter_string);
|
|
|
|
|
free(parameter_string);
|
|
|
|
|
on_subwindow_close(window->Window);
|
|
|
|
|
|
|
|
|
|
@ -208,7 +260,19 @@ source_window *yon_source_window_new(){
|
|
|
|
|
g_object_set_data(G_OBJECT(window->TypeCombo),"target",window->DeviceCombo);
|
|
|
|
|
g_object_set_data(G_OBJECT(window->TypeCombo),"button",window->PathButton);
|
|
|
|
|
g_object_set_data(G_OBJECT(window->TypeCombo),"combo",window->PathEntry);
|
|
|
|
|
int size;
|
|
|
|
|
{
|
|
|
|
|
char *config_parameter = config(source_parameter);
|
|
|
|
|
if (window->sources){
|
|
|
|
|
yon_dictionary_free_all(window->sources,NULL);
|
|
|
|
|
}
|
|
|
|
|
int size;
|
|
|
|
|
config_str parsed = yon_char_parse(config_parameter,&size,",");
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(window->sources,parsed[i],NULL);
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
int size;
|
|
|
|
|
config_str parts = yon_config_load(get_parts_and_devices_command, &size);
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
int parsed_size;
|
|
|
|
|
@ -225,16 +289,6 @@ source_window *yon_source_window_new(){
|
|
|
|
|
|
|
|
|
|
void on_source_clicked(GtkWidget *,main_window *widgets){
|
|
|
|
|
source_window *window = yon_source_window_new();
|
|
|
|
|
char *sources = config(source_parameter);
|
|
|
|
|
if (!yon_char_is_empty(sources)&&strcmp(sources,"auto")){
|
|
|
|
|
gtk_switch_set_active(GTK_SWITCH(window->AutoSwitch),0);
|
|
|
|
|
int size;
|
|
|
|
|
config_str parsed = yon_char_parse(sources,&size,",");
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(window->sources,parsed[i],NULL);
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
}
|
|
|
|
|
g_object_set_data(G_OBJECT(window->Window),"widgets",widgets);
|
|
|
|
|
yon_source_update(window);
|
|
|
|
|
gtk_widget_show(window->Window);
|
|
|
|
|
|