forked from uwzis/GPU-Passthrough-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GPUPM.cpp
566 lines (554 loc) · 22.8 KB
/
GPUPM.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#include <iostream>
#include <gtk-3.0/gtk/gtk.h>
#include <fstream>
#include <json/json.h>
#include <json/value.h>
using namespace std;
//RUN AS ROOT
void returns(){
exit(0);
}
// Run first time set up scripts
void first(GtkWidget *payload, gpointer data){
system("sh ./tools/fts.sh"); // Run first time setup script
system("touch ./data.json && ./tools/Reboot");
}
//Load VFIO drivers
void vfiod(GtkWidget *vfio, gpointer data) {
system("sh ./tools/vfiomgr.sh && ./tools/Reboot"); // Run VFIO driver script
}
// Load Default drivers
void defaultd(GtkWidget *calculate, gpointer data) {
system("sh ./tools/defaultmgr.sh && ./tools/Reboot"); // Run default GPU driver script
}
// Load CSS for GTK
static void load_css ( void ){
GtkCssProvider *provider;
GdkDisplay *display;
GdkScreen *screen;
const gchar *css_style_file = "./style.css";
GFile *css_fp = g_file_new_for_path ( css_style_file );
GError *error = 0;
provider = gtk_css_provider_new ();
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen ( display );
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER ( provider ), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_css_provider_load_from_file ( provider, css_fp, &error);
g_object_unref ( provider );
}
// toggle button functions,
static void check_state1(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 1;
g_print("button%i, ", i);// list button number then command ran
i = 0;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state2(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 2;
g_print("button%i, ", i);// list button number then command ran
i = 1;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state3(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 3;
g_print("button%i, ", i);// list button number then command ran
i = 2;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state4(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 4;
g_print("button%i, ", i);// list button number then command ran
i = 3;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state5(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 5;
g_print("button%i, ", i);// list button number then command ran
i = 4;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state6(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 6;
g_print("button%i, ", i);// list button number then command ran
i = 5;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state7(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 7;
g_print("button%i, ", i);// list button number then command ran
i = 6;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state8(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 8;
g_print("button%i, ", i);// list button number then command ran
i = 7;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state9(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 9;
g_print("button%i, ", i);// list button number then command ran
i = 8;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state10(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 10;
g_print("button%i, ", i);// list button number then command ran
i = 9;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state11(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 11;
g_print("button%i, ", i);// list button number then command ran
i = 10;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state12(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 12;
g_print("button%i, ", i);// list button number then command ran
i = 11;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state13(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 13;
g_print("button%i, ", i);// list button number then command ran
i = 12;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state14(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 14;
g_print("button%i, ", i);// list button number then command ran
i = 13;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
static void check_state15(GtkWidget* widget, gpointer data, int argc, char **argv){
ifstream file("./data.json");// Get the state Json data
Json::Value son;
Json::Reader reader;
reader.parse(file, son);
file.close();
int i = 15;
g_print("button%i, ", i);// list button number then command ran
i = 14;
string id = son["devices"][i]["id"].asString();
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))){//write to file
char cmd[50];
string str = "python3 ./py/confmgr.py ./vfio.conf add ";
str = str + id;
const char *exe = str.c_str();
system(exe);
}else{//delete from file
char md[50];
string tr = "python3 ./py/confmgr.py ./vfio.conf remove ";
tr = tr + id;
const char *rm = tr.c_str();
system(rm);
}
}
//g++ ./GPUPM.cpp -o "GPUPM" `pkg-config --cflags --libs jsoncpp gtk+-3.0`
int main(int argc, char **argv) {
//if json file does not exist, then run first time startup
int checkIfFileExists(const char *filename);
if (geteuid() == 0) {
if( access("./data.json", F_OK ) != -1){
system("python ./py/load.py");
//initiate gtk widgets
GtkWidget *window, *grid, *para, *default1, *vfio, *vbox, *label, *text;
GdkPixbuf *pixbuf;
gtk_init(&argc, &argv);
load_css();
//create window
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
//icon
pixbuf = gdk_pixbuf_new_from_file("./icons/GPUPM.png", NULL);
gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
//create container
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(window), vbox);
// Title
label = gtk_label_new_with_mnemonic("null");
gtk_label_set_markup (GTK_LABEL (label), "<span font='18'><b>Welcome to GPU Passthrough Manager\n</b></span>");
gtk_container_add(GTK_CONTAINER(vbox), label);
gtk_box_pack_start(GTK_BOX(vbox), label, 0,1,1);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
//info
para = gtk_label_new_with_mnemonic("null");
gtk_label_set_markup (GTK_LABEL (para), "<span font='12'>Select devices to load vfio drivers. Or load default drivers</span>");
gtk_container_add(GTK_CONTAINER(vbox), para);
gtk_box_pack_start(GTK_BOX(vbox), para, 0,1,1);
gtk_label_set_justify(GTK_LABEL(para), GTK_JUSTIFY_CENTER);
//cature json data
ifstream file("./data.json");
Json::Value actualJson;
Json::Reader reader;
reader.parse(file, actualJson);
file.close();
//itterate buttons for the length of the devices in data.json
for (int i = 0; i < actualJson["devices"].size(); i++) {
GtkWidget *toggle[i];
toggle[i] = gtk_toggle_button_new_with_label(actualJson["devices"][i]["name"].asString().c_str());
gtk_box_pack_start(GTK_BOX(vbox), toggle[i], 0,1,1);
//buttons callback to individual functions... I know, this is very unoptimised. I am ashamed.
switch (i) {
case 0: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state1), NULL); break;
case 1: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state2), NULL); break;
case 2: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state3), NULL); break;
case 3: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state4), NULL); break;
case 4: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state5), NULL); break;
case 5: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state6), NULL); break;
case 6: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state7), NULL); break;
case 7: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state8), NULL); break;
case 8: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state9), NULL); break;
case 9: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state10), NULL); break;
case 10: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state11), NULL); break;
case 11: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state12), NULL); break;
case 12: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state13), NULL); break;
case 13: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state14), NULL); break;
case 14: g_signal_connect(toggle[i], "toggled", G_CALLBACK(check_state15), NULL); break;
}
g_print("device %i button created\n", i + 1);
}
//makes grid for buttons Load Default and Load VFIO
grid = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(vbox), grid);
// Load Default
default1 = gtk_button_new_with_label("Load Default");
g_signal_connect(default1, "clicked", G_CALLBACK(defaultd), NULL);
gtk_fixed_put(GTK_FIXED(grid), default1, 0, 400);
gtk_widget_set_size_request(default1, 250, 30);
// Load VFIO
vfio = gtk_button_new_with_label("Load VFIO");
g_signal_connect(vfio, "clicked", G_CALLBACK(vfiod), NULL);
gtk_fixed_put(GTK_FIXED(grid), vfio, 400, 400);
gtk_widget_set_size_request(vfio, 250, 30);
//show all widgets
gtk_widget_show_all(window);
gtk_main();}
else{
//initate widgets
GtkWidget *window, *grid, *payload, *label, *para;
GdkPixbuf *pixbuf;
gtk_init(&argc, &argv);
//create window
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window), 300, 10);
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
//set icon
pixbuf = gdk_pixbuf_new_from_file("./icons/GPUPM.png", NULL);
gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
//create grid for button
grid = gtk_box_new(GTK_ORIENTATION_VERTICAL, 1);
gtk_container_add(GTK_CONTAINER(window), grid);
//create title
label = gtk_label_new("null");
gtk_label_set_markup (GTK_LABEL (label), "<span font='17'>\nWelcome to GPU Passthrough Manager!\n</span>");
gtk_container_add(GTK_CONTAINER(grid), label);
gtk_box_pack_start(GTK_BOX(grid), label, 0,1,1);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
//create text info
para = gtk_label_new("null");
gtk_label_set_markup (GTK_LABEL (para), "<span font='12'>This program is used for assisting in passing through\ngraphics/audio devices to virtual machines.\nTo begin, click the button below to run initial\ncompatibility checks and configuration adjustments.\nBefore continuing, ensure your system supports IOMMU\nand virtualization is enabled in BIOS. Installation will \nfail if these requirements are not met and your\noperating system may become unstable and/or unusable.\n\n</span>");
gtk_container_add(GTK_CONTAINER(grid), para);
gtk_box_pack_start(GTK_BOX(grid), para, 0,1,1);
gtk_label_set_justify(GTK_LABEL(para), GTK_JUSTIFY_CENTER);
//first time startup button
payload = gtk_button_new_with_label("\nStart first time setup\n");
g_signal_connect(payload, "clicked", G_CALLBACK(first), NULL);
gtk_box_pack_start(GTK_BOX(grid), payload, 0,1,1);
//show all widgets
gtk_widget_show_all(window);
gtk_main();
return 0;
}}else{
//initate widgets
GtkWidget *window, *grid, *payload, *label, *para;
GdkPixbuf *pixbuf;
gtk_init(&argc, &argv);
//create window
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window), 250, 10);
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
//set icon
pixbuf = gdk_pixbuf_new_from_file("./icons/GPUPM.png", NULL);
gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
//create grid for button
grid = gtk_box_new(GTK_ORIENTATION_VERTICAL, 1);
gtk_container_add(GTK_CONTAINER(window), grid);
//RUN AS ROOT
label = gtk_label_new("null");
gtk_label_set_markup (GTK_LABEL (label), "<span font='17'>\nRUN AS ROOT!\n</span>");
gtk_container_add(GTK_CONTAINER(grid), label);
gtk_box_pack_start(GTK_BOX(grid), label, 0,1,1);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
//spaces
para = gtk_label_new("null");
gtk_label_set_markup (GTK_LABEL (para), "<span font='12'>\n</span>");
gtk_container_add(GTK_CONTAINER(grid), para);
gtk_box_pack_start(GTK_BOX(grid), para, 0,1,1);
gtk_label_set_justify(GTK_LABEL(para), GTK_JUSTIFY_CENTER);
//returns button
payload = gtk_button_new_with_label("\nOK\n");
g_signal_connect(payload, "clicked", G_CALLBACK(returns), NULL);
gtk_box_pack_start(GTK_BOX(grid), payload, 0,1,1);
//show all widgets
gtk_widget_show_all(window);
gtk_main();
return 0;
}
}