summaryrefslogtreecommitdiff
path: root/desktop/gui_factory.c
blob: 9a4fa396a304f094aee87521c7339634b45afbf3 (plain)
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

#include "desktop/gui.h"
#include "desktop/gui_factory.h"

struct gui_table *guit = NULL;


static void gui_default_quit(void)
{
}

nserror gui_factory_register(struct gui_table *gt)
{
	/* ensure not already initialised */
	if (guit != NULL) {
		return NSERROR_INIT_FAILED;
	}


	/* check the mandantory fields are set */
	if (gt->poll == NULL) {
		return NSERROR_BAD_PARAMETER;
	}
	if (gt->window_create == NULL) {
		return NSERROR_BAD_PARAMETER;
	}
	if (gt->window_destroy == NULL) {
		return NSERROR_BAD_PARAMETER;
	}


	/* fill in the optional entries with defaults */
	if (gt->quit == NULL) {
		gt->quit = &gui_default_quit;
	}

	guit = gt;

	return NSERROR_OK;
}