To view the lesson code switch to English from the button above
#include<gtk/gtk.h>
#include<string.h>
GtkBuilder *builder;
GtkWidget *window;
GtkWidget *stack;
//about section
GtkWidget *nameEntry;
GtkWidget *titleEntry;
GtkWidget *fileChooser;
GtkWidget *emailEntry;
GtkWidget *phoneEntry;
GtkWidget *locationEntry;
GtkWidget *dobEntry;
GtkWidget *aboutEntry;
//education section
GtkWidget *degreeEntry;
GtkWidget *collegeEntry;
GtkWidget *educationDateEntry;
//experience section
GtkWidget *jobEntry;
GtkWidget *entityEntry;
GtkWidget *dateEntry;
GtkWidget *descriptionEntry;
//skills
GtkWidget *skillsEntry;
//languages section
GtkWidget *languageEntry;
GtkWidget *comboBox;
//options
GtkWidget *addButton;
GtkWidget *deleteButton;
GtkWidget *generateButton;
//datalabels
GtkWidget *dataLabels[4];
FILE *html;
FILE *css;
int eduCounter=0, expCounter=0, lngCounter=0;
char skills[200], itemLabel[400];
struct about {
char name[30];
char title[30];
char email[50];
char phone[20];
char dob[15];
char location[30];
char image[400];
char about[250];
};
struct about user;
struct education {
char degree[100];
char college[100];
char date[15];
};
struct education eduItems[4];
struct experience {
char job[50];
char entity[50];
char date[15];
char description[250];
};
struct experience expItems[4];
struct language {
char name[20];
char prof[30];
};
struct language lngItems[4];
void on_addButton_clicked() {
if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "about")==0) {
strcpy(user.name, gtk_entry_get_text(GTK_ENTRY(nameEntry)));
strcpy(user.title, gtk_entry_get_text(GTK_ENTRY(titleEntry)));
strcpy(user.email, gtk_entry_get_text(GTK_ENTRY(emailEntry)));
strcpy(user.phone, gtk_entry_get_text(GTK_ENTRY(phoneEntry)));
strcpy(user.location, gtk_entry_get_text(GTK_ENTRY(locationEntry)));
strcpy(user.about, gtk_entry_get_text(GTK_ENTRY(aboutEntry)));
strcpy(user.dob, gtk_entry_get_text(GTK_ENTRY(dobEntry)));
strcpy(user.image, gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(fileChooser)));
sprintf(itemLabel, "Name: %s\nTitle: %s\nEmail: %s\nPhone: %s\nLocation: %s\nDate Of Birth: %s\nAbout Me: %s\n",
user.name, user.title, user.email, user.phone, user.location, user.dob, user.about);
gtk_label_set_text(GTK_LABEL(dataLabels[0]), itemLabel);
}
else if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "education")==0) {
if(eduCounter<4) {
strcpy(eduItems[eduCounter].degree, gtk_entry_get_text(GTK_ENTRY(degreeEntry)));
strcpy(eduItems[eduCounter].college, gtk_entry_get_text(GTK_ENTRY(collegeEntry)));
strcpy(eduItems[eduCounter].date, gtk_entry_get_text(GTK_ENTRY(educationDateEntry)));
sprintf(itemLabel, "%d)\nDegree/Course: %s\nCollege/School: %s\nDate: %s\n",
eduCounter+1, eduItems[eduCounter].degree, eduItems[eduCounter].college, eduItems[eduCounter].date);
gtk_label_set_text(GTK_LABEL(dataLabels[eduCounter]), itemLabel);
eduCounter++;
}
}
else if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "experience")==0) {
if(expCounter<4) {
strcpy(expItems[expCounter].job, gtk_entry_get_text(GTK_ENTRY(jobEntry)));
strcpy(expItems[expCounter].entity, gtk_entry_get_text(GTK_ENTRY(entityEntry)));
strcpy(expItems[expCounter].date, gtk_entry_get_text(GTK_ENTRY(dateEntry)));
strcpy(expItems[expCounter].description, gtk_entry_get_text(GTK_ENTRY(descriptionEntry)));
sprintf(itemLabel, "%d)\nJob/Project: %s\nEntity: %s\nDate: %s\nDescription: %s\n",
expCounter+1, expItems[expCounter].job, expItems[expCounter].entity, expItems[expCounter].date, expItems[expCounter].description);
gtk_label_set_text(GTK_LABEL(dataLabels[expCounter]), itemLabel);
expCounter++;
}
}
else if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "skills")==0) {
strcpy(skills, gtk_entry_get_text(GTK_ENTRY(skillsEntry)));
sprintf(itemLabel, "Skills: %s", skills);
gtk_label_set_text(GTK_LABEL(dataLabels[0]), itemLabel);
}
else if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "languages")==0) {
if(lngCounter<4) {
strcpy(lngItems[lngCounter].name, gtk_entry_get_text(GTK_ENTRY(languageEntry)));
strcpy(lngItems[lngCounter].prof, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(comboBox)));
sprintf(itemLabel, "%d)\nLanguage: %s\nProficiency: %s\n", lngCounter+1, lngItems[lngCounter].name, lngItems[lngCounter].prof);
gtk_label_set_text(GTK_LABEL(dataLabels[lngCounter]), itemLabel);
lngCounter++;
}
}
}
void on_deleteButton_clicked() {
int i;
for(i=0; i<4; i++) {
gtk_label_set_text(GTK_LABEL(dataLabels[i]), "");
}
if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "about")==0) {
strcpy(user.name, "");
strcpy(user.title, "");
strcpy(user.email, "");
strcpy(user.phone, "");
strcpy(user.location, "");
strcpy(user.about, "");
strcpy(user.dob, "");
strcpy(user.image, "");
}
else if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "education")==0) {
strcpy(eduItems[eduCounter].degree, "");
strcpy(eduItems[eduCounter].college, "");
strcpy(eduItems[eduCounter].date, "");
eduCounter=0;
}
else if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "experience")==0) {
strcpy(expItems[expCounter].job, "");
strcpy(expItems[expCounter].entity, "");
strcpy(expItems[expCounter].date, "");
strcpy(expItems[expCounter].description, "");
expCounter=0;
}
else if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "skills")==0) {
strcpy(skills, "");
}
else if(strcmp(gtk_stack_get_visible_child_name(GTK_STACK(stack)), "languages")==0) {
strcpy(lngItems[lngCounter].name, "");
strcpy(lngItems[lngCounter].prof, "");
lngCounter=0;
}
}
void on_generateButton_clicked() {
html= fopen("index.html", "w");
css = fopen("style.css", "w");
fprintf(html, "<!DOCTYPE html> <html> <head> <meta charset=\"utf-8\"> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> <title>%s</title> <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" /> <script src=\"https://kit.fontawesome.com/44a288ac8d.js\" crossorigin=\"anonymous\"></script> </head> <body> <div class=\"cv\"> <div class=\"header\"> <div class=\"pic\"> <img src=\"%s\"/> </div> <div class=\"details\"> <h1>%s</h1> <h3>%s</h3> <div class=\"basic-info\"> <div> <i class=\"fa-solid fa-envelope\"></i>%s</div> <div><i class=\"fa-solid fa-phone\"></i>%s</div> <div><i class=\"fa-solid fa-location-dot\"></i>%s</div> <div><i class=\"fa-solid fa-calendar-days\"></i>%s</div> </div> </div> </div> <div class=\"main\"> <div class=\"half\"> <div> <h2>ABOUT</h2> <p>%s</p> </div> <div> <h2>EDUCATION</h2>",
user.name, user.image, user.name, user.title, user.email, user.phone, user.location, user.dob, user.about);
int i;
for(i=0; i<eduCounter; i++) {
fprintf(html, "<div> <h3>%s</h3> <h3 class=\"light\">%s</h3> <p class=\"date\">%s</p> </div>", eduItems[i].degree, eduItems[i].college, eduItems[i].date);
}
fprintf(html, "</div><div><h2>EXPERIENCE</h2>");
for(i=0; i<expCounter; i++) {
fprintf(html, "<div> <h3>%s</h3> <h3 class=\"light\">%s</h3> <p class=\"date\">%s</p> <p class=\"light\">%s</p> </div>",
expItems[i].job, expItems[i].entity, expItems[i].date, expItems[i].description);
}
fprintf(html, "</div> </div> <div class=\"half\"> <div> <h2>SKILLS</h2> <p>%s</p> </div> <div> <h2>LANGUAGES</h2>", skills);
for(i=0; i<lngCounter; i++) {
fprintf(html, "<div> <h3>%s</h3> <p>%s</p> </div>", lngItems[i].name, lngItems[i].prof);
}
fprintf(html, "</div></div></div></div></body></html>");
fprintf(css, "@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap'); :root { --theme-color: teal; } body { font-family: \"Roboto\", sans-serif; line-height: 24px; background-color: gray; } * { margin: 0; padding: 0; } .cv { display: flex; flex-direction: column; width: 100vw; max-width: 900px; margin: 50px auto; } .header{ display: flex; flex-direction: row; height: 15vh; min-height: 150px; background-color: var(--theme-color); color: white; padding: 20px; align-items: center; } h3 { color: black; } img { width: 140px; height: 140px; border-radius: 50%%; object-fit: cover; border-style: solid; border-color: white; border-width: 5px; } .details { display: flex; flex-direction: column; margin-left: 20px; width: 90%%; } .basic-info { display: flex; flex-direction: row; justify-content: space-between; flex-wrap: wrap; } i { margin-right: 5px; } .main { display: flex; flex-direction: row; justify-content: space-between; padding: 20px; background-color: white; text-align: justify; } .half { width: 45%%; } .main h2 { color: var(--theme-color); margin-top: 30px; } .light { font-weight: 400; } .date { color: var(--theme-color); font-style: italic; } @media screen and (max-width: 600px) { .main { flex-direction: column; } .half { width: 100%%; } .cv { margin: auto; } }");
fclose(html);
fclose(css);
}
int main() {
gtk_init(NULL,NULL);
builder = gtk_builder_new_from_file("design.glade");
window = gtk_builder_get_object(builder, "window");
stack = gtk_builder_get_object(builder, "stack");
//about section
nameEntry = gtk_builder_get_object(builder, "nameEntry");
titleEntry = gtk_builder_get_object(builder, "titleEntry");
fileChooser = gtk_builder_get_object(builder, "fileChooser");
emailEntry = gtk_builder_get_object(builder, "emailEntry");
phoneEntry = gtk_builder_get_object(builder, "phoneEntry");
locationEntry = gtk_builder_get_object(builder, "locationEntry");
dobEntry = gtk_builder_get_object(builder, "dobEntry");
aboutEntry = gtk_builder_get_object(builder, "aboutEntry");
//education section
degreeEntry = gtk_builder_get_object(builder, "degreeEntry");
collegeEntry = gtk_builder_get_object(builder, "collegeEntry");
educationDateEntry = gtk_builder_get_object(builder, "educationDateEntry");
//experience section
jobEntry = gtk_builder_get_object(builder, "jobEntry");
entityEntry = gtk_builder_get_object(builder, "entityEntry");
dateEntry = gtk_builder_get_object(builder, "dateEntry");
descriptionEntry = gtk_builder_get_object(builder, "descriptionEntry");
//skills section
skillsEntry = gtk_builder_get_object(builder, "skillsEntry");
//language section
languageEntry = gtk_builder_get_object(builder, "languageEntry");
comboBox = gtk_builder_get_object(builder, "comboBox");
//options
addButton = gtk_builder_get_object(builder, "addButton");
deleteButton = gtk_builder_get_object(builder, "deleteButton");
generateButton = gtk_builder_get_object(builder, "generateButton");
//datalabels
dataLabels[0] = gtk_builder_get_object(builder, "dataLabel1");
dataLabels[1] = gtk_builder_get_object(builder, "dataLabel2");
dataLabels[2] = gtk_builder_get_object(builder, "dataLabel3");
dataLabels[3] = gtk_builder_get_object(builder, "dataLabel4");
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(addButton, "clicked", G_CALLBACK(on_addButton_clicked), NULL);
g_signal_connect(deleteButton, "clicked", G_CALLBACK(on_deleteButton_clicked), NULL);
g_signal_connect(generateButton, "clicked", G_CALLBACK(on_generateButton_clicked), NULL);
gtk_window_maximize(window);
gtk_widget_show(window);
gtk_main();
}