Contents of /trunk/src/gpxview.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 288 - (show annotations)
Mon Jun 7 19:19:50 2010 UTC (13 years, 11 months ago) by harbaum
File MIME type: text/plain
File size: 8322 byte(s)
GPS focus enable, portrait support and some attribute icon work
1 /*
2 * Copyright (C) 2008 Till Harbaum <till@harbaum.org>.
3 *
4 * This file is part of GPXView.
5 *
6 * GPXView is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GPXView is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GPXView. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef GPXVIEW_H
21 #define GPXVIEW_H
22
23 #ifdef USE_MAEMO
24 #if MAEMO_VERSION_MAJOR < 5
25 #define USE_BREAD_CRUMB_TRAIL
26 #else
27 #define FREMANTLE
28
29 // these are on maemo fremantle
30 #include <hildon/hildon-button.h>
31 #include <hildon/hildon-text-view.h>
32 #include <hildon/hildon-window-stack.h>
33 #define USE_HILDON_TEXT_VIEW
34 #define USE_STACKABLE_WINDOW
35 #define NO_COPY_N_PASTE
36 #define MENU_GPXLIST 0
37 #define MENU_CACHELIST 1
38 #define MENU_CACHE 2
39 #endif
40 #endif
41
42 #ifdef BCT
43 #include "bct.h"
44 #endif
45
46 #include "config.h"
47
48 #include <string.h>
49 #include <stdlib.h>
50
51 #include <locale.h>
52 #include <libintl.h>
53
54 #ifndef _
55 #define _(String) gettext(String)
56 #endif
57 #define N_(String) (String)
58
59 #ifdef USE_MAEMO
60 #include <hildon/hildon-program.h>
61 #include <hildon/hildon-file-chooser-dialog.h>
62 #include <hildon/hildon-file-system-model.h>
63 #include <hildon/hildon-bread-crumb-trail.h>
64 #include <hildon/hildon-number-editor.h>
65 #include <libosso.h> /* required for screen saver timeout */
66 #ifdef HILDON_HELP
67 #include <hildon/hildon-help.h>
68 #endif
69 #if MAEMO_VERSION_MAJOR >= 5
70 #define MAEMO5
71 #define USE_PANNABLE_AREA
72 #include <hildon/hildon-pannable-area.h>
73 /* panning a gtkhtml view currently doesn't work well */
74 #define PANNABLE_HTML
75 #endif
76 #endif
77
78 #include <gtk/gtk.h>
79 #include <gtkhtml/gtkhtml.h>
80
81 /* list of current gpx files is being kept in gconf */
82 #include <gconf/gconf.h>
83 #include <gconf/gconf-client.h>
84
85 #include <libgnomevfs/gnome-vfs.h>
86 #include <libgnomevfs/gnome-vfs-inet-connection.h>
87
88 /* all include appdata_t relies on go here ... */
89 #include "gpx.h"
90 #include "settings.h"
91 #include "gps.h"
92 #include "portrait.h"
93
94 #define GPXLIST_ITEM_VALID (1<<0)
95 #define GPXLIST_ITEM_DATE (1<<1)
96 #define GPXLIST_ITEM_CNUM (1<<2)
97 #define GPXLIST_ITEM_FILENAME (1<<3)
98 #define GPXLIST_ITEM_DEFAULT (GPXLIST_ITEM_VALID | GPXLIST_ITEM_CNUM)
99
100 #define CACHELIST_ITEM_VALID (1<<0)
101 #define CACHELIST_ITEM_ID (1<<1)
102 #define CACHELIST_ITEM_SIZE (1<<2)
103 #define CACHELIST_ITEM_RATING (1<<3)
104 #define CACHELIST_ITEM_DEFAULT (CACHELIST_ITEM_VALID | CACHELIST_ITEM_ID)
105
106 typedef struct {
107 pos_t home; /* current home geo position */
108 gboolean use_gps; /* use GPS if avbailable */
109 char *path; /* current path to select GPX from */
110
111 location_t *location; /* extra home locations */
112 int active_location; /* index of active (extra) home location */
113
114 gboolean imperial; /* display imperial units */
115
116 char *image_path; /* path to cache images in */
117
118 int search; /* "search in" items */
119 char *search_str;
120 int search_days;
121
122 struct proxy_s *proxy; /* proxy settings */
123
124 int gpxlist_items;
125 int cachelist_items;
126 gboolean cachelist_hide_found;
127
128 /* geotext related */
129 char *geotext_text;
130 int geotext_shift;
131
132 gpx_t *gpx;
133 GtkListStore *gpxstore;
134 GtkWidget *gpxview;
135 GConfClient *gconf_client;
136
137 gboolean compass_locked;
138 int compass_damping;
139
140 gboolean disable_gcvote;
141
142 struct gps_state *gps_state;
143
144 /* keep track of all html views so zoom events can be delivered */
145 struct html_view *html_view;
146
147 #ifndef REQUIRES_CLOSE_BUTTON
148 /* this is being activated and de-activated on selection/deselection */
149 GtkWidget *menu_remove, *menu_close;
150 #endif
151
152 #ifndef NO_COPY_N_PASTE
153 /* do enable/disable the edit entries */
154 GtkWidget *menu_cut, *menu_copy, *menu_paste;
155 GtkTextBuffer *active_buffer;
156 #endif
157
158 GtkClipboard *clipboard; /* clipboard for copy/paste */
159
160 #ifdef USE_STACKABLE_WINDOW
161 GtkWidget *export_menu, *tools_menu;
162 #endif
163
164 /* save result here to be able to "goto" it */
165 pos_t geomath;
166
167 int cur_items;
168 GtkWidget *cur_view;
169
170 char *mmpoi_path; /* path to save poi to */
171 float mmpoi_radius;
172 gboolean mmpoi_use_radius;
173 gboolean mmpoi_dont_export_found;
174 gboolean mmpoi_dont_export_disabled;
175
176 char *fieldnotes_path; /* path to save field notes to */
177
178 char *garmin_path; /* path to save garmin data to */
179 gboolean garmin_ign_found;
180
181 #ifdef USE_MAEMO
182 gboolean fullscreen;
183 #ifdef ENABLE_MAEMO_MAPPER
184 pos_t mmpos; /* position received from Maemo Mapper */
185 gboolean mmpos_valid;
186 #endif
187
188 gboolean mmpoi_dontlaunch;
189
190 gboolean cachelist_disable_screensaver;
191 gboolean goto_disable_screensaver;
192
193 HildonProgram *program;
194 HildonWindow *window;
195 osso_context_t *osso_context;
196 #else
197 GtkWidget *window;
198 #endif
199
200 gboolean cachelist_update;
201
202 #if defined(USE_BREAD_CRUMB_TRAIL) || defined(BCT)
203 /* reference to enable/disable these while walking the crumb trail */
204 GtkWidget *menu_import, *menu_export;
205 GtkWidget *menu_search;
206
207 GtkWidget *bct;
208 #endif
209
210 /* keep track of current "path" in the bread crumb trail */
211 gpx_t *cur_gpx;
212 cache_t *cur_cache;
213 struct cache_context_s *cache_context;
214
215 gpx_t *search_results;
216
217 #ifdef ENABLE_OSM_GPS_MAP
218 struct {
219 struct map_context_s *context;
220 int source;
221 int zoom;
222 pos_t pos;
223 gboolean dpix;
224 } map;
225 #endif
226
227 /* username is also used to detect own caches (by log entry) */
228 char *username;
229
230 /* stuff to call geotoad */
231 struct {
232 char *password, *filename;
233 float distance, lat, lon;
234 int flags;
235 gboolean no_owned_found;
236 } gt;
237
238 #ifdef ESPEAK
239 /* espeak handling */
240 struct {
241 gboolean enabled;
242 int sample_rate; // or init error
243 } espeak;
244 #endif
245
246 #ifndef USE_STACKABLE_WINDOW
247 GtkWidget *vbox;
248 #endif
249
250 struct {
251 gps_mask_t set;
252 struct gps_t fix;
253 pos_t saved; /* saved last gps position */
254 } gps;
255
256 } appdata_t;
257
258 /* all includes that rely on appdata_t go here ... */
259 #include "goto.h"
260 #include "gconf.h"
261 #include "html.h"
262 #include "icons.h"
263 #include "gcvote.h"
264 #include "cache.h"
265 #include "geomath.h"
266 #include "geotext.h"
267 #include "notes.h"
268 #include "help.h"
269 #include "mm_poi.h"
270 #include "precpos.h"
271 #include "garmin_export.h"
272 #include "geotoad.h"
273 #include "about.h"
274 #include "astro.h"
275
276 #ifdef ENABLE_OSM_GPS_MAP
277 #include "map-tool.h"
278 #endif
279
280 #ifdef USE_MAEMO
281 #include "dbus.h"
282 #endif
283
284 #define SEARCH_ID (1<<0)
285 #define SEARCH_NAME (1<<1)
286 #define SEARCH_DESC (1<<2)
287 #define SEARCH_OWNER (1<<3)
288 #define SEARCH_FINDS (1<<4)
289
290 #ifdef USE_MAEMO
291 #define DIALOG_WIDTH 800
292 #define DIALOG_HEIGHT 480
293 #define GTK_FM_OK GTK_RESPONSE_OK
294 #else
295 #define DIALOG_WIDTH 560
296 #define DIALOG_HEIGHT 340
297 #define GTK_FM_OK GTK_RESPONSE_ACCEPT
298 #endif
299
300 #include "misc.h"
301
302 #define CHANGE_FLAG_POS (1<<0)
303 #define CHANGE_FLAG_MASK (1<<1)
304
305 extern void main_after_settings_redraw(appdata_t *appdata, int flags);
306
307 #include <stdarg.h>
308 extern void errorf(const char *fmt, ...);
309 extern gboolean on_window_key_press(GtkWidget *widget,
310 GdkEventKey *event, appdata_t *appdata);
311 #ifdef USE_STACKABLE_WINDOW
312 HildonAppMenu *menu_create(appdata_t *appdata, int mode);
313 #endif
314 void cachelist_goto_cache(appdata_t *appdata, cache_t *cache);
315 void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx);
316 gboolean gpxlist_find(appdata_t *appdata, GtkTreeIter *iter, gpx_t *gpx);
317 void gpxlist_set(GtkListStore *store, GtkTreeIter *iter, gpx_t *gpx);
318 void gpxlist_add(appdata_t *appdata, gpx_t *new);
319 void cachelist_redraw(appdata_t *appdata);
320
321 /* interface to main windows gps callback */
322 pos_t *gps_get_pos(appdata_t *appdata);
323 float gps_get_heading(appdata_t *appdata);
324 gint gps_get_satnum(appdata_t *appdata);
325 gps_sat_t *gps_get_sats(appdata_t *appdata);
326 float gps_get_eph(appdata_t *appdata);
327 void gps_change_state(appdata_t *appdata);
328
329 /* change GPS state via main focus handling */
330 gboolean on_main_focus_change(GtkWidget *, GdkEventFocus *, gpointer);
331
332
333 #endif // GPXVIEW_H