summaryrefslogtreecommitdiff
path: root/gui.c
blob: 63a68d6597bc621535a50e5640451fcb352be76f (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
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
#include <glib.h>
#include "debug.h"
#include "gui.h"
#include "statusbar.h"
#include "menu.h"
#include "data_window.h"
#include "plugin.h"

struct gui *
gui_new(struct navit *nav, const char *type, int w, int h)
{
	struct gui *this_;
	struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, int w, int h);

        guitype_new=plugin_get_gui_type(type);
        if (! guitype_new)
                return NULL;

	this_=g_new0(struct gui, 1);
	this_->priv=guitype_new(nav, &this_->meth, w, h);
	return this_;
}

struct statusbar *
gui_statusbar_new(struct gui *gui)
{
	struct statusbar *this_;
	if (! gui->meth.statusbar_new)
		return NULL;
	this_=g_new0(struct statusbar, 1);
	this_->priv=gui->meth.statusbar_new(gui->priv, &this_->meth);
	if (! this_->priv) {
		g_free(this_);
		return NULL;
	}
	return this_;
}

struct menu *
gui_menubar_new(struct gui *gui)
{
	struct menu *this_;
	if (! gui->meth.menubar_new)
		return NULL;
	this_=g_new0(struct menu, 1);
	this_->priv=gui->meth.menubar_new(gui->priv, &this_->meth);
	if (! this_->priv) {
		g_free(this_);
		return NULL;
	}
	return this_;
}


struct menu *
gui_toolbar_new(struct gui *gui)
{
	struct menu *this_;
	if (! gui->meth.toolbar_new)
		return NULL;
	this_=g_new0(struct menu, 1);
	this_->priv=gui->meth.toolbar_new(gui->priv, &this_->meth);
	if (! this_->priv) {
		g_free(this_);
		return NULL;
	}
	return this_;
}

struct menu *
gui_popup_new(struct gui *gui)
{
	struct menu *this_;
	if (! gui->meth.popup_new)
		return NULL;
	this_=g_new0(struct menu, 1);
	this_->priv=gui->meth.popup_new(gui->priv, &this_->meth);
	if (! this_->priv) {
		g_free(this_);
		return NULL;
	}
	return this_;
}

struct datawindow *
gui_datawindow_new(struct gui *gui, char *name, struct callback *click, struct callback *close)
{
	struct datawindow *this_;
	if (! gui->meth.datawindow_new)
		return NULL;
	this_=g_new0(struct datawindow, 1);
	this_->priv=gui->meth.datawindow_new(gui->priv, name, click, close, &this_->meth);
	if (! this_->priv) {
		g_free(this_);
		return NULL;
	}
	return this_;
}

int
gui_add_bookmark(struct gui *gui, struct coord *c, char *description)
{
	int ret;
	dbg(2,"enter\n");
	if (! gui->meth.add_bookmark)
		return 0;
	ret=gui->meth.add_bookmark(gui->priv, c, description);
	
	dbg(2,"ret=%d\n", ret);
	return ret;
}

int
gui_set_graphics(struct gui *this_, struct graphics *gra)
{
	if (! this_->meth.set_graphics)
		return 1;
	return this_->meth.set_graphics(this_->priv, gra);
}

int
gui_has_main_loop(struct gui *this_)
{
	if (! this_->meth.run_main_loop)
		return 0;
	return 1;
}

int
gui_run_main_loop(struct gui *this_)
{
	if (! gui_has_main_loop(this_))
		return 1;
	return this_->meth.run_main_loop(this_->priv);
}