|
|
|
|
@ -308,7 +308,16 @@ source_element *yon_source_element_new(){
|
|
|
|
|
|
|
|
|
|
void yon_source_element_add(char *key,void*,source_window *window){
|
|
|
|
|
source_element *element = yon_source_element_new();
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(element->PathEntry),key);
|
|
|
|
|
if (yon_char_check_begins_with(key,"/dev/")){
|
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(element->DeviceCombo),key);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(element->TypeCombo),0);
|
|
|
|
|
} else if (g_regex_match_simple(".*\\.iso",key,G_REGEX_DEFAULT,G_REGEX_MATCH_DEFAULT)){
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(element->PathEntry),key);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(element->TypeCombo),2);
|
|
|
|
|
} else {
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(element->PathEntry),key);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(element->TypeCombo),1);
|
|
|
|
|
}
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(window->AddBox),element->MainBox,0,0,0);
|
|
|
|
|
g_object_set_data(G_OBJECT(element->MainBox),"window",window);
|
|
|
|
|
g_object_set_data(G_OBJECT(element->PathButton),"target",window->PathEntry);
|
|
|
|
|
@ -320,22 +329,32 @@ void yon_source_update(source_window *window){
|
|
|
|
|
for (iter=list;iter;iter=iter->next){
|
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(iter->data));
|
|
|
|
|
}
|
|
|
|
|
g_hash_table_foreach(window->sources,(GHFunc)yon_source_element_add,window);
|
|
|
|
|
dictionary *dict;
|
|
|
|
|
if (!window->sources) return;
|
|
|
|
|
for_dictionaries(dict,window->sources){
|
|
|
|
|
yon_source_element_add(dict->key,NULL,window);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_source_add(GtkWidget *,source_window *window){
|
|
|
|
|
const char *path = gtk_widget_get_visible(window->PathEntry)?gtk_entry_get_text(GTK_ENTRY(window->PathEntry)):gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceCombo));
|
|
|
|
|
if (!g_hash_table_contains(window->sources,path)){
|
|
|
|
|
g_hash_table_add(window->sources,yon_char_new(path));
|
|
|
|
|
if (!yon_dictionary_get(&window->sources,(char*)path)){
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(window->sources,yon_char_new(path),NULL);
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(window->PathEntry),"");
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceCombo),0);
|
|
|
|
|
yon_source_update(window);
|
|
|
|
|
} else {
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),VALUE_REPEAT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_source_remove(GtkWidget *,source_element *element){
|
|
|
|
|
source_window *window = g_object_get_data(G_OBJECT(element->MainBox),"window");
|
|
|
|
|
const char *path = gtk_entry_get_text(GTK_ENTRY(window->PathEntry));
|
|
|
|
|
if (g_hash_table_contains(window->sources,path)){
|
|
|
|
|
g_hash_table_remove(window->sources,path);
|
|
|
|
|
const char *path = gtk_widget_get_visible(element->PathEntry)?gtk_entry_get_text(GTK_ENTRY(element->PathEntry)):gtk_combo_box_get_active_id(GTK_COMBO_BOX(element->DeviceCombo));
|
|
|
|
|
dictionary *dict = yon_dictionary_get(&window->sources,(char*)path);
|
|
|
|
|
if (dict){
|
|
|
|
|
window->sources = yon_dictionary_rip(dict);
|
|
|
|
|
yon_source_update(window);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -376,8 +395,21 @@ void on_source_accept(GtkWidget *,source_window *window){
|
|
|
|
|
on_subwindow_close(window->Window);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
guint size;
|
|
|
|
|
config_str paths = (config_str)g_hash_table_get_keys_as_array(window->sources,&size);
|
|
|
|
|
const char *creation_path = gtk_widget_get_visible(window->PathEntry)? gtk_entry_get_text(GTK_ENTRY(window->PathEntry)):NULL;
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
int size;
|
|
|
|
|
config_str paths = NULL;
|
|
|
|
|
dictionary *dict;
|
|
|
|
|
if (!window->sources) return;
|
|
|
|
|
for_dictionaries(dict,window->sources){
|
|
|
|
|
if (yon_char_parsed_check_exist(paths,size,dict->key)>-1){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),VALUE_REPEAT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(paths,&size,dict->key);
|
|
|
|
|
}
|
|
|
|
|
if (!size){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
yon_ubl_status_highlight_incorrect(window->PathEntry);
|
|
|
|
|
@ -399,6 +431,8 @@ void on_source_accept(GtkWidget *,source_window *window){
|
|
|
|
|
yon_char_parsed_free(parameters,size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yon_dictionary_free_all(window->sources,NULL);
|
|
|
|
|
free(window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
source_window *yon_source_window_new(){
|
|
|
|
|
@ -416,14 +450,14 @@ source_window *yon_source_window_new(){
|
|
|
|
|
window->PathButton = yon_gtk_builder_get_widget(builder,"PathButton");
|
|
|
|
|
window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton");
|
|
|
|
|
window->AddBox = yon_gtk_builder_get_widget(builder,"AddBox");
|
|
|
|
|
window->sources = g_hash_table_new(g_str_hash,g_str_equal);
|
|
|
|
|
window->sources = NULL;
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_source_accept),window);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_source_add),window);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->PathButton),"clicked",G_CALLBACK(on_source_choose),window);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->TypeCombo),"changed",G_CALLBACK(on_source_changed),window);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->AutoSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch_inversed),gtk_widget_get_parent(window->AddBox));
|
|
|
|
|
g_signal_connect(G_OBJECT(window->AutoSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch_inversed),gtk_widget_get_parent(gtk_widget_get_parent(window->AddBox)));
|
|
|
|
|
g_object_set_data(G_OBJECT(window->PathButton),"combo",window->TypeCombo);
|
|
|
|
|
g_object_set_data(G_OBJECT(window->PathButton),"target",window->PathEntry);
|
|
|
|
|
g_object_set_data(G_OBJECT(window->TypeCombo),"target",window->DeviceCombo);
|
|
|
|
|
@ -446,7 +480,18 @@ 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|