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