commit db97b26566af8604f4c74b8f2f4648ee2f7dac10 Author: kevin Date: Wed Mar 26 12:37:55 2025 +0100 Upload files to "/" diff --git a/advanced.c b/advanced.c new file mode 100644 index 0000000..ae3f8e2 --- /dev/null +++ b/advanced.c @@ -0,0 +1,45 @@ +#include +#include + +static void +print_hello (GtkWidget *widget, + gpointer data) +{ + g_print ("Hello World\n"); +} + +static void +activate (GtkApplication *app, + gpointer user_data) +{ + GtkBuilder *builder = gtk_builder_new (); + gtk_builder_add_from_file (builder, "builder.ui", NULL); + + GObject *window = gtk_builder_get_object (builder, "window"); + gtk_window_set_application (GTK_WINDOW (window), app); + + GObject *button = gtk_builder_get_object (builder, "button1"); + g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL); + + button = gtk_builder_get_object (builder, "button2"); + g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL); + + gtk_window_present (GTK_WINDOW (window)); + g_object_unref (builder); +} + +int +main (int argc, + char *argv[]) +{ + GtkApplication *app = gtk_application_new ("dev.kevink.example2", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + + int status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + + return status; +} + + +// gcc $(pkg-config --cflags libadwaita-1) -o advanced-gtk advanced.c $(pkg-config --libs libadwaita-1) && ./advanced-gtk diff --git a/builder.ui b/builder.ui new file mode 100644 index 0000000..3152e6b --- /dev/null +++ b/builder.ui @@ -0,0 +1,53 @@ + + + + Advanced Example + 300 + 200 + + + + + + Advanced ✨ + True + end + 5 + + + + + + + + + TRUE + TRUE + + + First Button + TRUE + TRUE + + 0 + 0 + + + + + + Second Button + TRUE + TRUE + + 1 + 0 + + + + + + + diff --git a/hello-world.c b/hello-world.c new file mode 100644 index 0000000..9110b8d --- /dev/null +++ b/hello-world.c @@ -0,0 +1,46 @@ +#include + +static void +print_hello (GtkWidget *widget, + gpointer data) +{ + g_print ("Hello World\n"); +} + +static void +activate (GtkApplication *app, + gpointer user_data) +{ + GtkWidget *window; + GtkWidget *button; + + gtk_application_set + + window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello World"); + gtk_window_set_default_size (GTK_WINDOW (window), 250, 200); + + button = gtk_button_new_with_label ("Hello World"); + g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL); + gtk_window_set_child (GTK_WINDOW (window), button); + + gtk_window_present (GTK_WINDOW (window)); +} + +int +main (int argc, + char **argv) +{ + GtkApplication *app; + int status; + + app = gtk_application_new ("dev.kevink.example", G_APPLICATION_DEFAULT_FLAGS); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + + return status; +} + + +// gcc $(pkg-config --cflags gtk4) -o hello-world-gtk hello-world.c $(pkg-config --libs gtk4) && ./hello-world-gtk