1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| void on_button_b_transcode_clicked(GtkButton *button, gpointer user_data)
{
if(annulertranscode == 0) {
annulertranscode = 1;
stoptranscode = 0;
gtk_widget_set_sensitive(button_b_transcode,FALSE);
gtk_widget_set_sensitive(button_EA_compile,FALSE);
gtk_widget_set_sensitive(button_backtest,FALSE);
gchar * filename = (gchar*)gtk_entry_get_text(GTK_ENTRY(entry_backtest_file));
int len = strlen(filename);
if(len < 5) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new(GTK_WINDOW(window1),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
"Incorrect file name.");
gtk_window_set_title(GTK_WINDOW(dialog), "Warning");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
gtk_widget_set_sensitive(button_b_transcode,TRUE);
gtk_widget_set_sensitive(button_backtest,TRUE);
gtk_widget_set_sensitive(button_EA_compile,TRUE);
gtk_button_set_label(GTK_BUTTON(button_b_transcode),"Transcode");
annulertranscode = 0;
input_format = -1;
return;
}
input_format = -1;
if(filename[len-1] == 'v' && filename[len-2] == 's' && filename[len-3] == 'c' && filename[len-4] == '.') input_format = 0;
else if(filename[len-1] == '1' && filename[len-2] == 'f' && filename[len-3] == 'b' && filename[len-4] == '.') input_format = 1;
else if(filename[len-1] == '2' && filename[len-2] == 'f' && filename[len-3] == 'b' && filename[len-4] == '.') input_format = 2;
else if(filename[len-1] == '3' && filename[len-2] == 'f' && filename[len-3] == 'b' && filename[len-4] == '.') input_format = 3;
else if(filename[len-1] == '4' && filename[len-2] == 'f' && filename[len-3] == 'b' && filename[len-4] == '.') input_format = 4;
if(input_format == 4) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new(GTK_WINDOW(window1),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
"Format .bf4 is not Transcodable.");
gtk_window_set_title(GTK_WINDOW(dialog), "Warning");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
gtk_widget_set_sensitive(button_b_transcode,TRUE);
gtk_widget_set_sensitive(button_backtest,TRUE);
gtk_widget_set_sensitive(button_EA_compile,TRUE);
gtk_button_set_label(GTK_BUTTON(button_b_transcode),"Transcode");
annulertranscode = 0;
input_format = -1;
return;
} else if(input_format >= 0 && input_format <= 3) {
transcode = 0;
create_window2();
if(input_format == 0) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_dialog_transcode_bf1),TRUE);
if(input_format == 1) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_dialog_transcode_bf2),TRUE);
if(input_format == 2) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_dialog_transcode_bf3),TRUE);
if(input_format == 3) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_dialog_transcode_bf4),TRUE);
transcode = gtk_dialog_run(GTK_DIALOG(window2));
if(transcode == 0) {
gtk_widget_set_sensitive(button_b_transcode,TRUE);
gtk_widget_set_sensitive(button_backtest,TRUE);
gtk_widget_set_sensitive(button_EA_compile,TRUE);
annulertranscode = 0;
gtk_widget_destroy(window2);
return;
}
gtk_widget_set_sensitive(button_b_transcode,TRUE);
gtk_button_set_label(GTK_BUTTON(button_b_transcode),"Stop Transcode");
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_dialog_transcode_bf1))) g_thread_create(csv_to_bf1_thread,progressbar_backtest,TRUE,NULL);
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_dialog_transcode_bf2))) {
if(input_format == 0) g_thread_create(csv_to_bf2_thread,progressbar_backtest,TRUE,NULL);
else if(input_format == 1) g_thread_create(bf1_to_bf2_thread,progressbar_backtest,TRUE,NULL);
}
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_dialog_transcode_bf3))) {
if(input_format == 0) g_thread_create(csv_to_bf3_thread,progressbar_backtest,TRUE,NULL);
else if(input_format == 1) g_thread_create(bf1_to_bf3_thread,progressbar_backtest,TRUE,NULL);
else if(input_format == 2) g_thread_create(bf2_to_bf3_thread,progressbar_backtest,TRUE,NULL);
}
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_dialog_transcode_bf4))) {
if(input_format == 0) g_thread_create(csv_to_bf4_thread,progressbar_backtest,TRUE,NULL);
else if(input_format == 1) g_thread_create(bf1_to_bf4_thread,progressbar_backtest,TRUE,NULL);
else if(input_format == 2) g_thread_create(bf2_to_bf4_thread,progressbar_backtest,TRUE,NULL);
else if(input_format == 3) g_thread_create(bf3_to_bf4_thread,progressbar_backtest,TRUE,NULL);
}
gtk_widget_destroy(window2);
input_format = -1;
} else if(input_format == -1) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new(GTK_WINDOW(window1),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
"Unknown file format.");
gtk_window_set_title(GTK_WINDOW(dialog), "Warning");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
gtk_widget_set_sensitive(button_b_transcode,TRUE);
gtk_widget_set_sensitive(button_backtest,TRUE);
gtk_widget_set_sensitive(button_EA_compile,TRUE);
gtk_button_set_label(GTK_BUTTON(button_b_transcode),"Transcode");
annulertranscode = 0;
input_format = -1;
return;
}
} else {
stoptranscode = 1;
}
} |
Partager