Source window changes

pull/113/head
parent 58755b9fda
commit 497e810bd9
No known key found for this signature in database
GPG Key ID: FF1D842BF4DDE92B

@ -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);
}

@ -927,9 +927,10 @@ typedef struct {
GtkWidget *PathButton;
GtkWidget *AddButton;
GtkWidget *AddBox;
GHashTable *sources;
dictionary *sources;
} source_window;
typedef struct {
GtkWidget *MainBox;
GtkWidget *TypeCombo;

@ -223,6 +223,8 @@ NULL)
#define COUNT_INVALID_LABEL(target) yon_char_unite(_("Cues"),target,NULL)
#define ABOUT_TITLE_LABEL _("About UBLinux installation")
#define VALUE_REPEAT_LABEL _("Repeating values")
#define SOURCE_CREATE_ONGOING_ERROR_LABEL _("Source creation were not done")
// #define _LABEL _("New section at")
// #define _LABEL _("\"/ublinux-data/\" user data section")
// #define _LABEL _("\"/ublinux/\" system section")

@ -49,33 +49,20 @@
<property name="margin-end">5</property>
<property name="margin-top">15</property>
<property name="margin-bottom">15</property>
<property name="spacing">15</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="icon-name">com.ublinux.ubinstall-gtk</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<property name="spacing">15</property>
<child>
<object class="GtkLabel">
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Choose a path for configuration file</property>
<property name="xalign">0</property>
<property name="valign">start</property>
<property name="icon-name">com.ublinux.ubinstall-gtk</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
@ -87,12 +74,14 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkSwitch" id="AutoSwitch">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="active">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Choose a path for configuration file</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@ -101,10 +90,34 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Automatically</property>
<property name="spacing">5</property>
<child>
<object class="GtkSwitch" id="AutoSwitch">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Automatically</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -114,24 +127,42 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hscrollbar-policy">never</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkScrolledWindow">
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hscrollbar-policy">never</property>
<property name="can-focus">False</property>
<child>
<object class="GtkViewport">
<object class="GtkBox">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
@ -214,6 +245,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">0</property>
</packing>
</child>
@ -230,25 +262,25 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>

Loading…
Cancel
Save