This repository was archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.c
More file actions
56 lines (43 loc) · 1.7 KB
/
demo.c
File metadata and controls
56 lines (43 loc) · 1.7 KB
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
#include "fawn.h"
#include <stdio.h>
void AddNewBtnClicked(GtkWidget *widget, gpointer data) {
printf("Welcome to the Fawm demo application!\n");
}
int main(int argc, char *argv[]) {
// Initialize Fawn.
FawnInit(argc, argv);
// Load CSS.
LoadCss("demo.css");
// Button widget.
GtkWidget *top_btn = NewButton("Add New", "add-new");
Action(top_btn, "clicked", AddNewBtnClicked);
// Window widget.
uint size[2] = {500, 200};
GtkWidget *header = NewHeaderBar("My Application", 1, top_btn);
GtkWidget *window = NewWindow("My Window", size, header, TRUE, "", TRUE);
// Alter widget.
GtkWidget *alter = NewAlert("Welcome!", "This is Fawn demo application", "welcome", TRUE);
Attach(alter, window);
// Box widget.
GtkWidget *box = NewBox(true, 1);
Attach(box, window);
// Input widget.
GtkWidget *input = NewInput("Enter name", "", FALSE, 25, "username", 0, 10);
Attach(input, box);
// Action of the big button.
void WelcomeMessage(GtkWidget *widget, gpointer data) {
char *username = GetEntryText(input, FALSE);
char *welcome_message = malloc(sizeof(char) * strlen(username) + 6);
sprintf(welcome_message, "Hello %s", username);
GtkWidget *welcome_window = NewWindow("Welcome", size, NULL, TRUE, "", FALSE);
GtkWidget *alter = NewAlert("Welcome!", welcome_message, "welcome-username", TRUE);
Attach(alter, welcome_window);
}
// Big button widget.
GtkWidget *big_btn = NewBigButton("Welcome Message", "Click to see the welcome message!", "bigbutton");
Action(big_btn, "clicked", WelcomeMessage);
Attach(big_btn, box);
// Render the design.
FawnRender();
return 0;
}