|
|
1 | /** |
|
|
2 | * ZANavi, Zoff Android Navigation system. |
|
|
3 | * Copyright (C) 2011-2012 Zoff <zoff@zoff.cc> |
|
|
4 | * |
|
|
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. |
|
|
8 | * |
|
|
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. |
|
|
13 | * |
|
|
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. |
|
|
18 | */ |
|
|
19 | |
1 | /** |
20 | /** |
2 | * Navit, a modular navigation system. |
21 | * Navit, a modular navigation system. |
3 | * Copyright (C) 2005-2008 Navit Team |
22 | * Copyright (C) 2005-2008 Navit Team |
4 | * |
23 | * |
5 | * This program is free software; you can redistribute it and/or |
24 | * This program is free software; you can redistribute it and/or |
… | |
… | |
38 | struct gui * |
57 | struct gui * |
39 | gui_new(struct attr *parent, struct attr **attrs) |
58 | gui_new(struct attr *parent, struct attr **attrs) |
40 | { |
59 | { |
41 | struct gui *this_; |
60 | struct gui *this_; |
42 | struct attr *type_attr; |
61 | struct attr *type_attr; |
43 | struct gui_priv *(*guitype_new)(struct navit *nav, |
62 | struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui); |
44 | struct gui_methods *meth, struct attr **attrs, struct gui *gui); |
|
|
45 | struct attr cbl; |
63 | struct attr cbl; |
46 | if (!(type_attr = attr_search(attrs, NULL, attr_type))) |
64 | if (!(type_attr = attr_search(attrs, NULL, attr_type))) |
47 | { |
65 | { |
48 | return NULL; |
66 | return NULL; |
49 | } |
67 | } |
… | |
… | |
55 | this_=g_new0(struct gui, 1); |
73 | this_=g_new0(struct gui, 1); |
56 | this_->attrs = attr_list_dup(attrs); |
74 | this_->attrs = attr_list_dup(attrs); |
57 | cbl.type = attr_callback_list; |
75 | cbl.type = attr_callback_list; |
58 | cbl.u.callback_list = callback_list_new(); |
76 | cbl.u.callback_list = callback_list_new(); |
59 | this_->attrs = attr_generic_add_attr(this_->attrs, &cbl); |
77 | this_->attrs = attr_generic_add_attr(this_->attrs, &cbl); |
60 | this_->priv = guitype_new(parent->u.navit, &this_->meth, this_->attrs, |
78 | this_->priv = guitype_new(parent->u.navit, &this_->meth, this_->attrs, this_); |
61 | this_); |
|
|
62 | this_->parent = *parent; |
79 | this_->parent = *parent; |
63 | return this_; |
80 | return this_; |
64 | } |
81 | } |
65 | |
82 | |
66 | int gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, |
83 | int gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) |
67 | struct attr_iter *iter) |
|
|
68 | { |
84 | { |
69 | int ret; |
85 | int ret; |
70 | if (this_->meth.get_attr) |
86 | if (this_->meth.get_attr) |
71 | { |
87 | { |
72 | ret = this_->meth.get_attr(this_->priv, type, attr); |
88 | ret = this_->meth.get_attr(this_->priv, type, attr); |
… | |
… | |
102 | struct menu * |
118 | struct menu * |
103 | gui_menubar_new(struct gui *gui) |
119 | gui_menubar_new(struct gui *gui) |
104 | { |
120 | { |
105 | struct menu *this_; |
121 | struct menu *this_; |
106 | if (!gui->meth.menubar_new) |
122 | if (!gui->meth.menubar_new) |
107 | return NULL; this_=g_new0(struct menu, 1); |
123 | return NULL;this_=g_new0(struct menu, 1); |
108 | this_->priv = gui->meth.menubar_new(gui->priv, &this_->meth); |
124 | this_->priv = gui->meth.menubar_new(gui->priv, &this_->meth); |
109 | if (!this_->priv) |
125 | if (!this_->priv) |
110 | { |
126 | { |
111 | g_free(this_); |
127 | g_free(this_); |
112 | return NULL; |
128 | return NULL; |
… | |
… | |
117 | struct menu * |
133 | struct menu * |
118 | gui_popup_new(struct gui *gui) |
134 | gui_popup_new(struct gui *gui) |
119 | { |
135 | { |
120 | struct menu *this_; |
136 | struct menu *this_; |
121 | if (!gui->meth.popup_new) |
137 | if (!gui->meth.popup_new) |
122 | return NULL; this_=g_new0(struct menu, 1); |
138 | return NULL;this_=g_new0(struct menu, 1); |
123 | this_->priv = gui->meth.popup_new(gui->priv, &this_->meth); |
139 | this_->priv = gui->meth.popup_new(gui->priv, &this_->meth); |
124 | if (!this_->priv) |
140 | if (!this_->priv) |
125 | { |
141 | { |
126 | g_free(this_); |
142 | g_free(this_); |
127 | return NULL; |
143 | return NULL; |
128 | } |
144 | } |
129 | return this_; |
145 | return this_; |
130 | } |
146 | } |
131 | |
147 | |
132 | struct datawindow * |
148 | struct datawindow * |
133 | gui_datawindow_new(struct gui *gui, char *name, struct callback *click, |
149 | gui_datawindow_new(struct gui *gui, char *name, struct callback *click, struct callback *close) |
134 | struct callback *close) |
|
|
135 | { |
150 | { |
136 | struct datawindow *this_; |
151 | struct datawindow *this_; |
137 | if (!gui->meth.datawindow_new) |
152 | if (!gui->meth.datawindow_new) |
138 | return NULL; this_=g_new0(struct datawindow, 1); |
153 | return NULL;this_=g_new0(struct datawindow, 1); |
139 | this_->priv = gui->meth.datawindow_new(gui->priv, name, click, close, |
154 | this_->priv = gui->meth.datawindow_new(gui->priv, name, click, close, &this_->meth); |
140 | &this_->meth); |
|
|
141 | if (!this_->priv) |
155 | if (!this_->priv) |
142 | { |
156 | { |
143 | g_free(this_); |
157 | g_free(this_); |
144 | return NULL; |
158 | return NULL; |
145 | } |
159 | } |