2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
26 #include "data_window.h"
31 struct gui_methods meth;
32 struct gui_priv *priv;
38 gui_new(struct attr *parent, struct attr **attrs)
41 struct attr *type_attr;
42 struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui);
44 if (! (type_attr=attr_search(attrs, NULL, attr_type))) {
48 guitype_new=plugin_get_gui_type(type_attr->u.str);
52 this_=g_new0(struct gui, 1);
53 this_->attrs=attr_list_dup(attrs);
54 cbl.type=attr_callback_list;
55 cbl.u.callback_list=callback_list_new();
56 this_->attrs=attr_generic_add_attr(this_->attrs, &cbl);
57 this_->priv=guitype_new(parent->u.navit, &this_->meth, this_->attrs, this_);
58 this_->parent=*parent;
63 gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
66 if (this_->meth.get_attr) {
67 ret=this_->meth.get_attr(this_->priv, type, attr);
71 if (type == this_->parent.type) {
75 return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
80 gui_set_attr(struct gui *this_, struct attr *attr)
83 if (this_->meth.set_attr)
84 ret=this_->meth.set_attr(this_->priv, attr);
86 this_->attrs=attr_generic_set_attr(this_->attrs, attr);
91 gui_add_attr(struct gui *this_, struct attr *attr)
94 if (this_->meth.add_attr)
95 ret=this_->meth.add_attr(this_->priv, attr);
100 gui_menubar_new(struct gui *gui)
103 if (! gui->meth.menubar_new)
105 this_=g_new0(struct menu, 1);
106 this_->priv=gui->meth.menubar_new(gui->priv, &this_->meth);
115 gui_popup_new(struct gui *gui)
118 if (! gui->meth.popup_new)
120 this_=g_new0(struct menu, 1);
121 this_->priv=gui->meth.popup_new(gui->priv, &this_->meth);
130 gui_datawindow_new(struct gui *gui, char *name, struct callback *click, struct callback *close)
132 struct datawindow *this_;
133 if (! gui->meth.datawindow_new)
135 this_=g_new0(struct datawindow, 1);
136 this_->priv=gui->meth.datawindow_new(gui->priv, name, click, close, &this_->meth);
145 gui_add_bookmark(struct gui *gui, struct pcoord *c, char *description)
149 if (! gui->meth.add_bookmark)
151 ret=gui->meth.add_bookmark(gui->priv, c, description);
153 dbg(2,"ret=%d\n", ret);
158 gui_set_graphics(struct gui *this_, struct graphics *gra)
160 if (! this_->meth.set_graphics)
162 return this_->meth.set_graphics(this_->priv, gra);
166 gui_disable_suspend(struct gui *this_)
168 if (this_->meth.disable_suspend)
169 this_->meth.disable_suspend(this_->priv);
173 gui_has_main_loop(struct gui *this_)
175 if (! this_->meth.run_main_loop)
181 gui_run_main_loop(struct gui *this_)
183 if (! gui_has_main_loop(this_))
185 return this_->meth.run_main_loop(this_->priv);