Test sync for log window and progress bar

pull/16/head
parent 6d5524b52c
commit 47c845c70a

@ -78,128 +78,130 @@ void yon_load_proceed(YON_CONFIG_TYPE type){
}
void yon_interface_update(main_window *widgets){
enum YON_PAGES page;
char *type = config(AUTOINSTALL_TYPE_INSTALL);
if (strcmp(type,"fast")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationRadio),1);
page = YON_PAGE_INSTALL_COMMON;
} else if (strcmp(type,"next")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationNearRadio),1);
page = YON_PAGE_INSTALL_SEPARATE;
} else if (strcmp(type,"part")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationLinuxRadio),1);
page = YON_PAGE_INSTALL_SAME_PARTITION;
} else if (!strcmp(type,"grub_install")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->GrubInstallRadio),1);
page = YON_PAGE_OPTIONS_GRUB_INSTALL;
} else if (strcmp(type,"grub_update")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->GrubUpdateRadio),1);
page = YON_PAGE_OPTIONS_GRUB_UPDATE;
} else if (strcmp(type,"system_only")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->OSRadio),1);
page = YON_PAGE_OPTIONS_OS_ONLY;
} else if (strcmp(type,"data_only")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UserDataOnlyRadio),1);
page = YON_PAGE_OPTIONS_USRDATA_ONLY;
} else if (strcmp(type,"custom")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SeparateRadio),1);
page = YON_PAGE_OPTIONS_SEPARATE;
}
char *device = config(AUTOINSTALL_DEVICE);
char *part = NULL;
if (page!=YON_PAGE_INSTALL_COMMON)
part = config(part_parameter);
char *fs_type = config(part_type_parameter);
char *device_label = config(device_label_parameter);
char *format = config(device_format_parameter);
char *part_size = config(part_size_parameter);
GtkListStore *device_list = widgets->DevicesList;
GtkListStore *part_list=widgets->PartitionsList;
GtkWidget *device_tree=NULL;
GtkWidget *part_tree=NULL;
switch (page){
case YON_PAGE_INSTALL_COMMON:{
device_tree = widgets->CommonInstallationDevicesTree;
} break;
case YON_PAGE_INSTALL_SEPARATE:{
device_tree = widgets->InstallationNearSysDevicesTree;
part_tree = widgets->InstallationNearSysSectionTree;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),atof(part_size));
if (part_size[strlen(part_size)-1]=='M') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),0);
if (part_size[strlen(part_size)-1]=='G') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),1);
if (part_size[strlen(part_size)-1]=='T') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),2);
if (!strcmp(format,"no")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),0);
else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),1);
gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->NextInstallationFilesystemTypeCombo),fs_type);
gtk_entry_set_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry),device_label);
} break;
case YON_PAGE_INSTALL_SAME_PARTITION:{
device_tree = widgets->SamePlaceDeviceTree;
part_tree = widgets->SamePlacePartTree;
gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->SameInstallationFilesystemTypeCombo),fs_type);
if (!strcmp(format,"no")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),0);
else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),1);
gtk_entry_set_text(GTK_ENTRY(widgets->SameInstallationSectionNameEntry),device_label);
} break;
case YON_PAGE_OPTIONS_GRUB_INSTALL:{
device_tree = widgets->GrubInstallDevicesTree;
} break;
case YON_PAGE_OPTIONS_GRUB_UPDATE:{
device_tree = widgets->GrubUpdateDevicesTree;
} break;
case YON_PAGE_OPTIONS_SEPARATE:{
GtkTreeIter iter;
device_tree = widgets->SeparateDevicesTree;
part_tree = widgets->SeparateSysSectionTree;
for_iter(GTK_TREE_MODEL(device_list),&iter){
char *cur_device;
gtk_tree_model_get(GTK_TREE_MODEL(device_list),&iter, 0,&cur_device,-1);
if (!strcmp(cur_device,device)){
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(device_tree)),&iter);
break;
}
}
for_iter(GTK_TREE_MODEL(part_list),&iter){
char *cur_part;
gtk_tree_model_get(GTK_TREE_MODEL(device_list),&iter, 0,&cur_part,-1);
if (!strcmp(cur_part,part)){
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(part_tree)),&iter);
}
}
} break;
case YON_PAGE_OPTIONS_OS_ONLY:{
device_tree = widgets->OSDevicesTree;
part_tree = widgets->OSSysSectionTree;
} break;
case YON_PAGE_OPTIONS_USRDATA_ONLY:{
device_tree = widgets->UserdataDevicesTree;
part_tree = widgets->UserdataSysSectionTree;
} break;
}
char *zone = config(zone_parameter);
char *system_locale = config(locale_parameter);
char *language = config(lang_parameter);
char *kbmodel = config (xkbmodel_parameter);
char *optinos = config(xkboptions_parameter);
char *layout = config(xkblayout_parameter);
char *user_name = config(user_name_parameter);
char *user_gecos = config(user_name_parameter);
char *user_password = config(user_name_parameter);
char *root_password = config(user_name_parameter);
char *autologin = config(user_name_parameter);
char *hostname = config(user_name_parameter);
if (widgets){};
// enum YON_PAGES page;
// char *type = config(AUTOINSTALL_TYPE_INSTALL);
// if (strcmp(type,"fast")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationRadio),1);
// page = YON_PAGE_INSTALL_COMMON;
// } else if (strcmp(type,"next")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationNearRadio),1);
// page = YON_PAGE_INSTALL_SEPARATE;
// } else if (strcmp(type,"part")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationLinuxRadio),1);
// page = YON_PAGE_INSTALL_SAME_PARTITION;
// } else if (!strcmp(type,"grub_install")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->GrubInstallRadio),1);
// page = YON_PAGE_OPTIONS_GRUB_INSTALL;
// } else if (strcmp(type,"grub_update")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->GrubUpdateRadio),1);
// page = YON_PAGE_OPTIONS_GRUB_UPDATE;
// } else if (strcmp(type,"system_only")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->OSRadio),1);
// page = YON_PAGE_OPTIONS_OS_ONLY;
// } else if (strcmp(type,"data_only")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UserDataOnlyRadio),1);
// page = YON_PAGE_OPTIONS_USRDATA_ONLY;
// } else if (strcmp(type,"custom")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1);
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SeparateRadio),1);
// page = YON_PAGE_OPTIONS_SEPARATE;
// }
// char *device = config(AUTOINSTALL_DEVICE);
// char *part = NULL;
// if (page!=YON_PAGE_INSTALL_COMMON)
// part = config(part_parameter);
// char *fs_type = config(part_type_parameter);
// char *device_label = config(device_label_parameter);
// char *format = config(device_format_parameter);
// char *part_size = config(part_size_parameter);
// GtkListStore *device_list = widgets->DevicesList;
// GtkListStore *part_list=widgets->PartitionsList;
// GtkWidget *device_tree=NULL;
// GtkWidget *part_tree=NULL;
// switch (page){
// case YON_PAGE_INSTALL_COMMON:{
// device_tree = widgets->CommonInstallationDevicesTree;
// } break;
// case YON_PAGE_INSTALL_SEPARATE:{
// device_tree = widgets->InstallationNearSysDevicesTree;
// part_tree = widgets->InstallationNearSysSectionTree;
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),atof(part_size));
// if (part_size[strlen(part_size)-1]=='M') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),0);
// if (part_size[strlen(part_size)-1]=='G') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),1);
// if (part_size[strlen(part_size)-1]=='T') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),2);
// if (!strcmp(format,"no")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),0);
// else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),1);
// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->NextInstallationFilesystemTypeCombo),fs_type);
// gtk_entry_set_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry),device_label);
// } break;
// case YON_PAGE_INSTALL_SAME_PARTITION:{
// device_tree = widgets->SamePlaceDeviceTree;
// part_tree = widgets->SamePlacePartTree;
// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->SameInstallationFilesystemTypeCombo),fs_type);
// if (!strcmp(format,"no")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),0);
// else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),1);
// gtk_entry_set_text(GTK_ENTRY(widgets->SameInstallationSectionNameEntry),device_label);
// } break;
// case YON_PAGE_OPTIONS_GRUB_INSTALL:{
// device_tree = widgets->GrubInstallDevicesTree;
// } break;
// case YON_PAGE_OPTIONS_GRUB_UPDATE:{
// device_tree = widgets->GrubUpdateDevicesTree;
// } break;
// case YON_PAGE_OPTIONS_SEPARATE:{
// GtkTreeIter iter;
// device_tree = widgets->SeparateDevicesTree;
// part_tree = widgets->SeparateSysSectionTree;
// for_iter(GTK_TREE_MODEL(device_list),&iter){
// char *cur_device;
// gtk_tree_model_get(GTK_TREE_MODEL(device_list),&iter, 0,&cur_device,-1);
// if (!strcmp(cur_device,device)){
// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(device_tree)),&iter);
// break;
// }
// }
// for_iter(GTK_TREE_MODEL(part_list),&iter){
// char *cur_part;
// gtk_tree_model_get(GTK_TREE_MODEL(device_list),&iter, 0,&cur_part,-1);
// if (!strcmp(cur_part,part)){
// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(part_tree)),&iter);
// }
// }
// } break;
// case YON_PAGE_OPTIONS_OS_ONLY:{
// device_tree = widgets->OSDevicesTree;
// part_tree = widgets->OSSysSectionTree;
// } break;
// case YON_PAGE_OPTIONS_USRDATA_ONLY:{
// device_tree = widgets->UserdataDevicesTree;
// part_tree = widgets->UserdataSysSectionTree;
// } break;
// default:{}break;
// }
// char *zone = config(zone_parameter);
// char *system_locale = config(locale_parameter);
// char *language = config(lang_parameter);
// char *kbmodel = config (xkbmodel_parameter);
// char *optinos = config(xkboptions_parameter);
// char *layout = config(xkblayout_parameter);
// char *user_name = config(user_name_parameter);
// char *user_gecos = config(user_name_parameter);
// char *user_password = config(user_name_parameter);
// char *root_password = config(user_name_parameter);
// char *autologin = config(user_name_parameter);
// char *hostname = config(user_name_parameter);
}
@ -497,6 +499,7 @@ void config_init(){
main_config.save_done=0;
main_config.configure_mode=0;
main_config.load_mode=-1;
main_config.log_progress_buzy=-1;
}
void on_configuration_mode_switch(GtkWidget *self);
@ -614,52 +617,38 @@ void *on_config_save(void *data){
gboolean yon_installation_progress_update(void *data);
gboolean yon_installation_progress_update(void *data){
main_window *widgets = (main_window*)data;
FILE *file = NULL;
char *current = g_malloc0(4096);
clock_t last_time = 0;
clock_t current_time;
while (1){
while (gtk_events_pending()) gtk_main_iteration();
current_time = clock();
if ((double)(current_time - last_time) / CLOCKS_PER_SEC >= 0.5){
if (!file)
file = fopen(progress_path,"r");
if (file){
if (fgets(current,4096,file)){
} else {
if (!yon_char_is_empty(current)&&current[0]=='('){
char * current_copy = yon_char_new(current);
char *percentage = yon_char_divide_search(current_copy,")",-1);
free(yon_char_divide(current_copy,0));
free(yon_char_divide(percentage,0));
if (strcmp(percentage,"#pb")){
double fraction = atof(percentage);
gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),current_copy);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),fraction/100);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress),0);
gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel),"");
} else {
gtk_widget_show(gtk_widget_get_parent(widgets->PackageInstallationProgress));
int size;
config_str parsed = yon_char_parse(current_copy,&size," ");
double fraction = atof(parsed[2])/100;
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress),fraction);
gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel),yon_char_parsed_to_string(parsed,size," "));
yon_char_parsed_free(parsed,size);
}
last_time = current_time;
free(current_copy);
free(percentage);
}
break;
}
}
while (gtk_events_pending()) gtk_main_iteration();
int size;
while (main_config.log_progress_buzy){};
main_config.log_progress_buzy=1;
config_str text = yon_file_open(progress_path,&size);
main_config.log_progress_buzy=0;
if (size){
if (!yon_char_is_empty(text[size-1])&&text[size-1][0]=='('){
char * current_copy = yon_char_new(text[size-1]);
char *percentage = yon_char_divide_search(current_copy,")",-1);
free(yon_char_divide(current_copy,0));
free(yon_char_divide(percentage,0));
if (strcmp(percentage,"#pb")){
double fraction = atof(percentage);
gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),current_copy);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),fraction/100);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress),0);
gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel),"");
} else {
gtk_widget_show(gtk_widget_get_parent(widgets->PackageInstallationProgress));
int size;
config_str parsed = yon_char_parse(current_copy,&size," ");
double fraction = atof(parsed[2])/100;
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress),fraction);
gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel),yon_char_parsed_to_string(parsed,size," "));
yon_char_parsed_free(parsed,size);
}
free(current_copy);
free(percentage);
}
fclose(file);
file=NULL;
}
if (main_config.install_thread){
return 1;
@ -836,7 +825,10 @@ gboolean yon_read_log(void *data){
log_window *window = (log_window*)data;
if (window->Window){
int size;
while (!main_config.install_complete&&main_config.log_progress_buzy){};
main_config.log_progress_buzy=1;
config_str parsed = yon_file_open(window->command,&size);
main_config.log_progress_buzy=0;
if (size){
char *final = yon_char_parsed_to_string(parsed,size,"");
gtk_label_set_text(GTK_LABEL(window->LogLabel),final);
@ -1963,7 +1955,8 @@ main_window *yon_main_window_complete(){
models[i+1] = yon_char_divide_search(models[i+1],"\n",-1);
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->KeyboardModelCombo),models[i],_(models[i+1]));
}
yon_load_proceed(YON_CONFIG_DEFAULT);
yon_interface_update(widgets);
return widgets;
}

@ -138,7 +138,7 @@ NULL
#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get [autoinstall] AUTOINSTALL[installer_lang] AUTOINSTALL[install_type] AUTOINSTALL[device] AUTOINSTALL[part] AUTOINSTALL[part_size] AUTOINSTALL[part_label] AUTOINSTALL[part_fs_type] AUTOINSTALL[part_format] UTOINSTALL[locale] AUTOINSTALL[lang] AUTOINSTALL[zone] AUTOINSTALL[user_name] AUTOINSTALL[user_gecos] AUTOINSTALL[user_password] AUTOINSTALL[root_password] AUTOINSTALL[autologin] AUTOINSTALL[xkbmodel] AUTOINSTALL[xkblayout] AUTOINSTALL[xkbvariant] AUTOINSTALL[xkboptions] AUTOINSTALL[hostname] AUTOINSTALL[modules] AUTOINSTALL[modules_extra]",NULL)
#define config_get_local_command "ubconfig --source system get [autoinstall] AUTOINSTALL[installer_lang] AUTOINSTALL[install_type] AUTOINSTALL[device] AUTOINSTALL[part] AUTOINSTALL[part_size] AUTOINSTALL[part_label] AUTOINSTALL[part_fs_type] AUTOINSTALL[part_format] UTOINSTALL[locale] AUTOINSTALL[lang] AUTOINSTALL[zone] AUTOINSTALL[user_name] AUTOINSTALL[user_gecos] AUTOINSTALL[user_password] AUTOINSTALL[root_password] AUTOINSTALL[autologin] AUTOINSTALL[xkbmodel] AUTOINSTALL[xkblayout] AUTOINSTALL[xkbvariant] AUTOINSTALL[xkboptions] AUTOINSTALL[hostname] AUTOINSTALL[modules] AUTOINSTALL[modules_extra]"
#define config_get_global_command yon_char_new("ubconfig --source global get [autoinstall] AUTOINSTALL[installer_lang] AUTOINSTALL[install_type] AUTOINSTALL[device] AUTOINSTALL[part] AUTOINSTALL[part_size] AUTOINSTALL[part_label] AUTOINSTALL[part_fs_type] AUTOINSTALL[part_format] UTOINSTALL[locale] AUTOINSTALL[lang] AUTOINSTALL[zone] AUTOINSTALL[user_name] AUTOINSTALL[user_gecos] AUTOINSTALL[user_password] AUTOINSTALL[root_password] AUTOINSTALL[autologin] AUTOINSTALL[xkbmodel] AUTOINSTALL[xkblayout] AUTOINSTALL[xkbvariant] AUTOINSTALL[xkboptions] AUTOINSTALL[hostname] AUTOINSTALL[modules] AUTOINSTALL[modules_extra]")
#define config_get_default_command ""
#define config_get_default_command "ubconfig --source default get [autoinstall] AUTOINSTALL[installer_lang] AUTOINSTALL[install_type] AUTOINSTALL[device] AUTOINSTALL[part] AUTOINSTALL[part_size] AUTOINSTALL[part_label] AUTOINSTALL[part_fs_type] AUTOINSTALL[part_format] UTOINSTALL[locale] AUTOINSTALL[lang] AUTOINSTALL[zone] AUTOINSTALL[user_name] AUTOINSTALL[user_gecos] AUTOINSTALL[user_password] AUTOINSTALL[root_password] AUTOINSTALL[autologin] AUTOINSTALL[xkbmodel] AUTOINSTALL[xkblayout] AUTOINSTALL[xkbvariant] AUTOINSTALL[xkboptions] AUTOINSTALL[hostname] AUTOINSTALL[modules] AUTOINSTALL[modules_extra]"
#define config_get_global_only_parameters ""
#define config_get_local_only_parameters ""
@ -202,6 +202,7 @@ typedef struct {
GThread *install_thread;
guint progress_thread;
int configure_mode;
int log_progress_buzy;
} config;
typedef struct {

Loading…
Cancel
Save