diff --git a/20231123/alignment-01.c b/20231123/alignment-01.c new file mode 100644 index 0000000000000000000000000000000000000000..3bfffa4a1ee9ec9f7a3e494f0baa2e3890d4dba7 --- /dev/null +++ b/20231123/alignment-01.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdint.h> +#include <string.h> + +int main (void) +{ + uint8_t a; + uint16_t b; + uint8_t c; + memset (&a, 0xff, 4); + printf ("a = %d\nb = %d\nc = %d\n", a, b, c); + return 0; +} diff --git a/20231123/alignment-02.c b/20231123/alignment-02.c new file mode 100644 index 0000000000000000000000000000000000000000..84ff0b508a9e5addf3f0d4bc829f335f137019b3 --- /dev/null +++ b/20231123/alignment-02.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdint.h> +#include <string.h> + +uint8_t a; +uint16_t b; +uint8_t c; + +int main (void) +{ + memset (&a, 0xff, 4); + printf ("a = %d\nb = %d\nc = %d\n", a, b, c); + return 0; +} diff --git a/20231123/alignment-03.c b/20231123/alignment-03.c new file mode 100644 index 0000000000000000000000000000000000000000..62091dfe3ccaa414972bca5a013087459229240a --- /dev/null +++ b/20231123/alignment-03.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdint.h> +#include <string.h> + +uint8_t a; +uint16_t b; +uint8_t c; + +int main (void) +{ + memset (&a, 0xff, 8); + printf ("a = %d\nb = %d\nc = %d\n", a, b, c); + return 0; +} diff --git a/20231123/alignment-04.c b/20231123/alignment-04.c new file mode 100644 index 0000000000000000000000000000000000000000..f91792d9579e36c4b0625d9d457c67709e47c373 --- /dev/null +++ b/20231123/alignment-04.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdint.h> +#include <string.h> + +uint8_t a; +uint16_t b; +uint8_t c; + +int main (void) +{ + memset (&a, 0xff, 5); + printf ("a = %d\nb = %d\nc = %d\n", a, b, c); + return 0; +} diff --git a/20231123/alignment-05.c b/20231123/alignment-05.c new file mode 100644 index 0000000000000000000000000000000000000000..6f1a971266e2db36304807342b3169be1763de46 --- /dev/null +++ b/20231123/alignment-05.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdint.h> +#include <string.h> + +uint8_t a; +uint64_t b; +uint8_t c; + +int main (void) +{ + memset (&a, 0xff, 5); + printf ("a = %d\nb = %d\nc = %d\n", a, b, c); + return 0; +} diff --git a/20231123/alignment-06.c b/20231123/alignment-06.c new file mode 100644 index 0000000000000000000000000000000000000000..6b05bb13002524847e4fcdf2219e8553a5a3f6f1 --- /dev/null +++ b/20231123/alignment-06.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdint.h> +#include <string.h> + +uint8_t a; +uint64_t b; +uint8_t c; + +int main (void) +{ + memset (&a, 0xff, 9); + printf ("a = %d\nb = %d\nc = %d\n", a, b, c); + return 0; +} diff --git a/20231123/deriv-01.c b/20231123/deriv-01.c new file mode 100644 index 0000000000000000000000000000000000000000..610980cfd1f266cf5af90ec9a9f5e21ff4b618fc --- /dev/null +++ b/20231123/deriv-01.c @@ -0,0 +1,25 @@ +#include <stdio.h> + +float f (float x) +{ + return x * x; +} + +float df_a (float x) +{ + return 2.0 * x; +} + +float df_n (float x) +{ + float dx = 0.0000001; + float df = f (x + 0.5 * dx) - f (x - 0.5 * dx); + return df / dx; +} + +int main (void) +{ + for (float x = -3.0; x <= 3.0; x += 0.1) + printf ("%10f%10f%10f%10f\n", x, f (x), df_a (x), df_n (x)); + return 0; +} diff --git a/20231123/deriv-01.dat b/20231123/deriv-01.dat new file mode 100644 index 0000000000000000000000000000000000000000..94d46f9c5ff8f8c73d005c48ef3323b95aa10de6 --- /dev/null +++ b/20231123/deriv-01.dat @@ -0,0 +1,61 @@ + -3.000000 9.000000 -6.000000 0.000000 + -2.900000 8.410001 -5.800000 0.000000 + -2.800000 7.840001 -5.600000 0.000000 + -2.700000 7.290001 -5.400001 0.000000 + -2.600000 6.760002 -5.200001 0.000000 + -2.500000 6.250002 -5.000001 0.000000 + -2.400001 5.760003 -4.800001 0.000000 + -2.300001 5.290003 -4.600001 0.000000 + -2.200001 4.840003 -4.400002 0.000000 + -2.100001 4.410004 -4.200002 0.000000 + -2.000001 4.000004 -4.000002 0.000000 + -1.900001 3.610003 -3.800002 0.000000 + -1.800001 3.240003 -3.600002 0.000000 + -1.700001 2.890003 -3.400002 0.000000 + -1.600001 2.560003 -3.200002 0.000000 + -1.500001 2.250003 -3.000002 0.000000 + -1.400001 1.960002 -2.800002 0.000000 + -1.300001 1.690002 -2.600002 0.000000 + -1.200001 1.440002 -2.400002 0.000000 + -1.100001 1.210002 -2.200001 0.000000 + -1.000001 1.000001 -2.000001 0.000000 + -0.900001 0.810001 -1.800001 -2.384186 + -0.800001 0.640001 -1.600001 -1.788139 + -0.700001 0.490001 -1.400001 -1.788139 + -0.600001 0.360001 -1.200001 -1.490116 + -0.500001 0.250001 -1.000001 -1.192093 + -0.400001 0.160000 -0.800001 -1.043081 + -0.300001 0.090000 -0.600001 -0.670552 + -0.200001 0.040000 -0.400001 -0.372529 + -0.100001 0.010000 -0.200001 -0.204891 + -0.000001 0.000000 -0.000001 -0.000001 + 0.099999 0.010000 0.199999 0.214204 + 0.199999 0.040000 0.399999 0.372529 + 0.299999 0.090000 0.599999 0.745058 + 0.399999 0.160000 0.799999 0.894070 + 0.499999 0.249999 0.999999 1.192093 + 0.599999 0.359999 1.199999 1.192093 + 0.699999 0.489999 1.399999 1.788139 + 0.799999 0.639999 1.599999 1.788139 + 0.899999 0.809999 1.799999 2.384186 + 0.999999 0.999999 1.999999 2.384186 + 1.099999 1.209999 2.199999 0.000000 + 1.199999 1.439999 2.399999 0.000000 + 1.299999 1.689999 2.599999 0.000000 + 1.399999 1.959999 2.799999 0.000000 + 1.500000 2.249999 2.999999 0.000000 + 1.600000 2.559999 3.199999 0.000000 + 1.700000 2.889998 3.399999 0.000000 + 1.800000 3.239999 3.599999 0.000000 + 1.900000 3.609998 3.799999 0.000000 + 2.000000 3.999999 3.999999 0.000000 + 2.100000 4.409998 4.199999 0.000000 + 2.200000 4.839998 4.399999 0.000000 + 2.299999 5.289998 4.599999 0.000000 + 2.399999 5.759997 4.799999 0.000000 + 2.499999 6.249997 4.999999 0.000000 + 2.599999 6.759996 5.199998 0.000000 + 2.699999 7.289995 5.399998 0.000000 + 2.799999 7.839994 5.599998 0.000000 + 2.899999 8.409993 5.799998 0.000000 + 2.999999 8.999993 5.999998 0.000000 diff --git a/20231123/deriv-01.gp b/20231123/deriv-01.gp new file mode 100644 index 0000000000000000000000000000000000000000..109ff331eedf01e1556ad8421d7362fa1733e83b --- /dev/null +++ b/20231123/deriv-01.gp @@ -0,0 +1,4 @@ +plot "deriv-01.dat" using 1:2 with lines title "f(x)", \ + "deriv-01.dat" using 1:3 with lines title "df_a(x)", \ + "deriv-01.dat" using 1:4 with lines lc "red" dashtype "-" title "df_n(x)" +pause -1 diff --git a/20231123/deriv-02.c b/20231123/deriv-02.c new file mode 100644 index 0000000000000000000000000000000000000000..14235c90aaab4454daba87e9cd75e19dd123edf5 --- /dev/null +++ b/20231123/deriv-02.c @@ -0,0 +1,25 @@ +#include <stdio.h> + +float f (float x) +{ + return x * x * x; +} + +float df_a (float x) +{ + return 3.0 * x * x; +} + +float df_n (float x) +{ + float dx = 0.1; + float df = f (x + 0.5 * dx) - f (x - 0.5 * dx); + return df / dx; +} + +int main (void) +{ + for (float x = -3.0; x <= 3.0; x += 0.1) + printf ("%11f %11f %11f %11f\n", x, f (x), df_a (x), df_n (x)); + return 0; +} diff --git a/20231123/deriv-02.dat b/20231123/deriv-02.dat new file mode 100644 index 0000000000000000000000000000000000000000..49f62404e668974e2c4cba85c593ff8fad978e85 --- /dev/null +++ b/20231123/deriv-02.dat @@ -0,0 +1,61 @@ + -3.000000 -27.000000 27.000000 27.002468 + -2.900000 -24.389004 25.230001 25.232487 + -2.800000 -21.952005 23.520002 23.522472 + -2.700000 -19.683006 21.870005 21.872482 + -2.600000 -17.576008 20.280006 20.282497 + -2.500000 -15.625009 18.750008 18.752489 + -2.400001 -13.824010 17.280008 17.282486 + -2.300001 -12.167011 15.870009 15.872488 + -2.200001 -10.648011 14.520010 14.522505 + -2.100001 -9.261011 13.230011 13.232498 + -2.000001 -8.000011 12.000011 12.002497 + -1.900001 -6.859010 10.830010 10.832500 + -1.800001 -5.832009 9.720010 9.722505 + -1.700001 -4.913008 8.670009 8.672500 + -1.600001 -4.096007 7.680008 7.682502 + -1.500001 -3.375006 6.750008 6.752501 + -1.400001 -2.744005 5.880007 5.882499 + -1.300001 -2.197004 5.070006 5.072502 + -1.200001 -1.728003 4.320005 4.322501 + -1.100001 -1.331003 3.630005 3.632501 + -1.000001 -1.000002 3.000004 3.002503 + -0.900001 -0.729002 2.430004 2.432504 + -0.800001 -0.512001 1.920003 1.922504 + -0.700001 -0.343001 1.470003 1.472503 + -0.600001 -0.216001 1.080002 1.082503 + -0.500001 -0.125000 0.750002 0.752502 + -0.400001 -0.064000 0.480001 0.482502 + -0.300001 -0.027000 0.270001 0.272501 + -0.200001 -0.008000 0.120001 0.122501 + -0.100001 -0.001000 0.030000 0.032500 + -0.000001 -0.000000 0.000000 0.002500 + 0.099999 0.001000 0.030000 0.032500 + 0.199999 0.008000 0.119999 0.122499 + 0.299999 0.027000 0.269999 0.272499 + 0.399999 0.064000 0.479998 0.482499 + 0.499999 0.125000 0.749998 0.752498 + 0.599999 0.215999 1.079998 1.082498 + 0.699999 0.342999 1.469997 1.472498 + 0.799999 0.511999 1.919997 1.922498 + 0.899999 0.728999 2.429997 2.432498 + 0.999999 0.999998 2.999997 3.002497 + 1.099999 1.330998 3.629996 3.632492 + 1.199999 1.727998 4.319996 4.322493 + 1.299999 2.196997 5.069996 5.072492 + 1.399999 2.743997 5.879996 5.882490 + 1.500000 3.374997 6.749996 6.752491 + 1.600000 4.095996 7.679996 7.682493 + 1.700000 4.912996 8.669995 8.672490 + 1.800000 5.831996 9.719995 9.722486 + 1.900000 6.858996 10.829996 10.832486 + 2.000000 7.999996 11.999996 12.002501 + 2.100000 9.260995 13.229996 13.232479 + 2.200000 10.647994 14.519995 14.522486 + 2.299999 12.166991 15.869993 15.872469 + 2.399999 13.823989 17.279991 17.282476 + 2.499999 15.624988 18.749989 18.752470 + 2.599999 17.575983 20.279987 20.282459 + 2.699999 19.682980 21.869986 21.872482 + 2.799999 21.951977 23.519983 23.522453 + 2.899999 24.388971 25.229980 25.232468 + 2.999999 26.999969 26.999979 27.002430 diff --git a/20231123/deriv-02.gp b/20231123/deriv-02.gp new file mode 100644 index 0000000000000000000000000000000000000000..a0a097aa09cc8db86a8ffeba3c54205403b56c8a --- /dev/null +++ b/20231123/deriv-02.gp @@ -0,0 +1,4 @@ +plot "deriv-02.dat" using 1:2 with lines title "f(x)", \ + "deriv-02.dat" using 1:3 with lines title "df_a(x)", \ + "deriv-02.dat" using 1:4 with lines lc "red" dashtype "-" title "df_n(x)" +pause -1 diff --git a/20231123/wurf-01.c b/20231123/wurf-01.c new file mode 100644 index 0000000000000000000000000000000000000000..85ee32ef9d7614f812032cb4d121a5082b137969 --- /dev/null +++ b/20231123/wurf-01.c @@ -0,0 +1,43 @@ +#include <gtk/gtk.h> + +double x = 137; +double y = 255; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x, y, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, 1024, 768); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-02.c b/20231123/wurf-02.c new file mode 100644 index 0000000000000000000000000000000000000000..c4978ecb3a1663a393e465a6566b4b5505461e5e --- /dev/null +++ b/20231123/wurf-02.c @@ -0,0 +1,57 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 137; +double y = 255; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x, y, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += 3; + y += 2; + gtk_widget_queue_draw (widget); + g_timeout_add (50, (GSourceFunc) timer, widget); + return FALSE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-03.c b/20231123/wurf-03.c new file mode 100644 index 0000000000000000000000000000000000000000..b2fea184068d5f4d769fffa19f5a1c0032b4945d --- /dev/null +++ b/20231123/wurf-03.c @@ -0,0 +1,56 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 137; +double y = 255; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x, y, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += 3; + y += 2; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-04.c b/20231123/wurf-04.c new file mode 100644 index 0000000000000000000000000000000000000000..8cfb17dfd27878ec2d0bd66bddf651ec2ee9dacc --- /dev/null +++ b/20231123/wurf-04.c @@ -0,0 +1,59 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 2.0; +double vx = 2.0; +double vy = 1.0; +double dt = 0.05; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-05.c b/20231123/wurf-05.c new file mode 100644 index 0000000000000000000000000000000000000000..1c8dfc33ae5471624ca1f722419275bc22c4ecfe --- /dev/null +++ b/20231123/wurf-05.c @@ -0,0 +1,59 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 2.0; +double vx = 2.0; +double vy = 1.0; +double dt = 0.2; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-06.c b/20231123/wurf-06.c new file mode 100644 index 0000000000000000000000000000000000000000..1f1370f0b2173443ed737a6c01c0c0ccf639ac52 --- /dev/null +++ b/20231123/wurf-06.c @@ -0,0 +1,62 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 2.0; +double vx = 2.0; +double vy = 1.0; +double dt = 0.2; +double g = 9.81; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + vx += 0.0 * dt; + vy += -g * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-07.c b/20231123/wurf-07.c new file mode 100644 index 0000000000000000000000000000000000000000..de7172075b6f7210f649c549cd1ba647d82dd862 --- /dev/null +++ b/20231123/wurf-07.c @@ -0,0 +1,62 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 2.0; +double vx = 2.0; +double vy = 1.0; +double dt = 0.2; +double g = 0.1; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + vx += 0.0 * dt; + vy += -g * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-08.c b/20231123/wurf-08.c new file mode 100644 index 0000000000000000000000000000000000000000..7faeb0db95337ec53c3352d5a4f6caa91a8a822e --- /dev/null +++ b/20231123/wurf-08.c @@ -0,0 +1,62 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 6.0; +double vx = 1.5; +double vy = 4.0; +double dt = 0.5; +double g = 0.2; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + vx += 0.0 * dt; + vy += -g * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-09.c b/20231123/wurf-09.c new file mode 100644 index 0000000000000000000000000000000000000000..51683e733db0079c49387e09211aec93de8ca834 --- /dev/null +++ b/20231123/wurf-09.c @@ -0,0 +1,63 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 6.0; +double vx = 1.5; +double vy = 4.0; +double cw = 0.02; +double dt = 0.5; +double g = 0.2; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + vx += - cw * vx * vx * dt; + vy += -g * dt - cw * vy * vy * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-10.c b/20231123/wurf-10.c new file mode 100644 index 0000000000000000000000000000000000000000..c92dcb410016295fdac786d40e72f3d31a525511 --- /dev/null +++ b/20231123/wurf-10.c @@ -0,0 +1,65 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 6.0; +double vx = 1.5; +double vy = 4.0; +double cw = 0.02; +double dt = 0.5; +double g = 0.2; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + if (y <= 0) + vy = -vy; + vx += - cw * vx * vx * dt; + vy += -g * dt - cw * vy * vy * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-11.c b/20231123/wurf-11.c new file mode 100644 index 0000000000000000000000000000000000000000..8fed86ef4aad03fc6f3712933099c9a769f345a4 --- /dev/null +++ b/20231123/wurf-11.c @@ -0,0 +1,67 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 6.0; +double vx = 1.5; +double vy = 4.0; +double cw = 0.02; +double dt = 0.5; +double g = 0.2; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + if (y <= 0) + vy = -vy; + if (x * 10.0 >= WIDTH) + vx = -vx; + vx += - cw * vx * vx * dt; + vy += -g * dt - cw * vy * vy * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-12.c b/20231123/wurf-12.c new file mode 100644 index 0000000000000000000000000000000000000000..84e97130cc2caa5181082c6544e3330b9c5b2525 --- /dev/null +++ b/20231123/wurf-12.c @@ -0,0 +1,67 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 6.0; +double vx = 3.0; +double vy = 4.0; +double cw = 0.02; +double dt = 0.5; +double g = 0.2; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + if (y <= 0) + vy = -vy; + if (x * 10.0 >= WIDTH) + vx = -vx; + vx += - cw * vx * vx * dt; + vy += -g * dt - cw * vy * vy * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-13.c b/20231123/wurf-13.c new file mode 100644 index 0000000000000000000000000000000000000000..ea10a27f8ff1b275d6b859529593487be5953239 --- /dev/null +++ b/20231123/wurf-13.c @@ -0,0 +1,73 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 6.0; +double vx = 3.0; +double vy = 4.0; +double cw = 0.01; +double dt = 0.5; +double g = 0.2; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + if (y <= 0) + vy = -vy; + if (x * 10.0 >= WIDTH) + vx = -vx; + if (vx > 0) + vx += - cw * vx * vx * dt; + else + vx += cw * vx * vx * dt; + if (vy > 0) + vy += -g * dt - cw * vy * vy * dt; + else + vy += -g * dt + cw * vy * vy * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +} diff --git a/20231123/wurf-14.c b/20231123/wurf-14.c new file mode 100644 index 0000000000000000000000000000000000000000..a6e83845ebfc3b171242973795273cdedb49efeb --- /dev/null +++ b/20231123/wurf-14.c @@ -0,0 +1,84 @@ +#include <gtk/gtk.h> + +#define WIDTH 1024 +#define HEIGHT 768 + +double x = 0.0; +double y = 6.0; +double vx = 3.0; +double vy = 4.0; +double cw = 0.005; +double dt = 0.5; +double g = 0.2; + +static void draw (GtkDrawingArea *drawing_area, cairo_t *c, + int width, int height, gpointer user_data) +{ + GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 }; + + gdk_cairo_set_source_rgba (c, &blue); + cairo_arc (c, x * 10.0, HEIGHT - y * 10, 10, 0, 2 * G_PI); + cairo_fill (c); +} + +gboolean timer (GtkWidget *widget) +{ + x += vx * dt; + y += vy * dt; + if (y <= 0.0) + { + y = 0.0; + vy = -vy; + } + if (x * 10.0 >= WIDTH) + { + x = WIDTH * 0.1; + vx = -vx; + } + if ( x <= 0.0) + { + x = 0.0; + vx = -vx; + } + if (vx > 0) + vx += - cw * vx * vx * dt; + else + vx += cw * vx * vx * dt; + if (vy > 0) + vy += -g * dt - cw * vy * vy * dt; + else + vy += -g * dt + cw * vy * vy * dt; + gtk_widget_queue_draw (widget); + return TRUE; +} + +static void activate (GtkApplication *app, gpointer user_data) +{ + GtkWidget *window = gtk_application_window_new (app); + gtk_window_set_title (GTK_WINDOW (window), "Hello"); + + GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child (GTK_WINDOW (window), vbox); + + GtkWidget *drawing_area = gtk_drawing_area_new (); + gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT); + gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL); + gtk_box_append (GTK_BOX (vbox), drawing_area); + + GtkWidget *quit_button = gtk_button_new_with_label ("Quit"); + g_signal_connect_swapped (quit_button, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_box_append (GTK_BOX (vbox), quit_button); + + g_timeout_add (50, (GSourceFunc) timer, drawing_area); + + gtk_window_present (GTK_WINDOW (window)); +} + +int main (int argc, char **argv) +{ + GtkApplication *app = gtk_application_new ("de.hs-bochum.cvh.hp.hello-gtk", 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; +}