summaryrefslogtreecommitdiff
path: root/desktop/gui_factory.c
blob: c760218ec0d88b0771cd165c158442d5000a75d9 (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
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

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

struct gui_table *guit = NULL;


static void gui_default_quit(void)
{
}

static void gui_default_window_set_title(struct gui_window *g, const char *title)
{
}

static void gui_default_window_set_url(struct gui_window *g, const char *url)
{
}

static void gui_default_window_start_throbber(struct gui_window *g)
{
}

static void gui_default_window_stop_throbber(struct gui_window *g)
{
}

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;
	}
	if (gt->window_set_title == NULL) {
		gt->window_set_title = gui_default_window_set_title;
	}
	if (gt->window_set_url == NULL) {
		gt->window_set_url = gui_default_window_set_url;
	}
	if (gt->window_start_throbber == NULL) {
		gt->window_start_throbber = gui_default_window_start_throbber;
	}
	if (gt->window_stop_throbber == NULL) {
		gt->window_stop_throbber = gui_default_window_stop_throbber;
	}

	guit = gt;

	return NSERROR_OK;
}