Update gtk28

This commit is contained in:
daleclack 2020-12-27 11:18:15 +08:00
parent 113c30e599
commit 6f8c221a00
2 changed files with 18 additions and 9 deletions

View File

@ -49,7 +49,7 @@
1608434422 source:/root/gtk28/main.cpp
"gtkwin.h"
1608874831 source:/root/gtk28/test.cpp
1609038937 source:/root/gtk28/test.cpp
"test.h"
<cstdio>
<cstring>

View File

@ -17,9 +17,14 @@ void print(GtkWidget *widget,gpointer data){
filename="config_2";break;
}
char str[57];
freopen(filename,"r",stdin);
fgets(str,57,stdin);
MsgBox("Test",str);
FILE *fp;
fp=fopen(filename,"r");
if(fp==NULL){
MsgBox("Error","The config file not exist!\nUse Change config menu for a config");
}else{
fgets(str,57,fp);
MsgBox("Test",str);
}
fclose(stdin);
}
@ -74,11 +79,15 @@ void InputBox(const gchar *content,const char *filename){
//Check the response and update the file with the "OK" Response
if(response==GTK_RESPONSE_OK){
str=gtk_entry_get_text(GTK_ENTRY(entry));
freopen(filename,"w",stdout);
g_print(str);
fclose(stdout);
gtk_widget_destroy(dialog);
MsgBox("Change config","Config changed!\nPlease Restart the application");
if(strlen(str)!=0){
freopen(filename,"w",stdout);
g_print(str);
fclose(stdout);
gtk_widget_destroy(dialog);
MsgBox("Change config","Config changed!\nPlease Restart the application");
}else{
gtk_widget_destroy(dialog);
}
}else{
gtk_widget_destroy(dialog);
}