mkernel 0.0.2
Micro-kernel framework, everything as a module
mkmodgtk.c
Go to the documentation of this file.
1
17#include "mkmod.h"
18#include "gettext.h"
19#define _(String) gettext (String)
20
21#include <stdio.h>
22
23#include "debug/assert.h"
24#include "debug/memory.h"
25
26#include <math.h>
27#pragma GCC diagnostic push /* save the actual diag context */
28#pragma GCC diagnostic ignored "-Wpedantic" /* locally disable maybe warnings */
29#include <gtk/gtk.h>
30#pragma GCC diagnostic pop /* restore previous diag context */
31
32/* List exposed module functions */
33static void mkmod_function();
35 mkmod_function
36};
37
38static moduleinfo_t moduleinfo = {
39 "MyGTKModule",
40 "MyGTKModule description",
41 0,
42 1,
43 0,
44 "First and Lastname",
45 "email@address.tld",
46 "http://www.mygtkmodule.com",
47 "GPLv3"
48};
49
50static void
51print_hello (GtkWidget *widget,
52 gpointer data)
53{
54 (void)widget;
55 (void)data;
56 g_print (_("Hello world from GTK !!!"));
57 g_print ("\n");
58}
59
60static void
61activate (GtkApplication* app,
62 gpointer user_data)
63{
64 GtkWidget *window;
65 GtkWidget *button;
66 GtkWidget *box;
67
68 (void)user_data;
69 window = gtk_application_window_new (app);
70 gtk_window_set_title (GTK_WINDOW (window), "Window");
71 gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
72
73 box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
74 gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
75 gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
76
77 gtk_window_set_child (GTK_WINDOW (window), box);
78
79 button = gtk_button_new_with_label (_("Hello world from GTK !!!"));
80
81 g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
82 g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
83
84 gtk_box_append (GTK_BOX (box), button);
85
86 gtk_window_present (GTK_WINDOW (window));
87
88}
89
91{
92 DBG_MSG("params()");
93 return &moduleinfo;
94}
95
96uint8_t onUnload()
97{
98 DBG_MSG("params()");
99 return 0;
100}
101
102static void mkmod_function()
103{
104 GtkApplication *app;
105 DBG_MSG("params()");
106
107 printf(_("Hello from mkmod_function\n"));
108 app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
109 g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
110 /* g_application_run (G_APPLICATION (app), argc, argv); */
111 g_application_run (G_APPLICATION (app), 0,NULL);
112 g_object_unref (app);
113
114}
115
Debugging macros.
#define DBG_MSG(msg)
Checkpoint on stderr with a static message.
Definition: assert.h:130
Tracks memory allocation and leaks when compiled without NDEBUG.
#define NULL
Definition: mkernel-opt.c:64
ABI interface shared between module class and application.
#define _(String)
Definition: mkmodgtk.c:19
mkmod_api_t module_api
Definition: mkmodgtk.c:34
uint8_t onUnload()
Definition: mkmodgtk.c:96
moduleinfo_t * onLoad()
Definition: mkmodgtk.c:90