This repository has been 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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,5 +54,3 @@ dkms.conf | |
# Directory | ||
bin/* | ||
|
||
# Sample Codes | ||
demo.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} |