]> git.street.me.uk Git - andy/viking.git/blame_incremental - src/acquire.h
The vikgoto should not be calling display updates.
[andy/viking.git] / src / acquire.h
... / ...
CommitLineData
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5 *
6 * This program 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 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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 this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#ifndef _VIKING_ACQUIRE_H
23#define _VIKING_ACQUIRE_H
24
25#include <gtk/gtk.h>
26
27#include "vikwindow.h"
28#include "viklayerspanel.h"
29#include "vikviewport.h"
30#include "babel.h"
31
32G_BEGIN_DECLS
33
34typedef struct _VikDataSourceInterface VikDataSourceInterface;
35
36/* global data structure used to expose the progress dialog to the worker thread */
37typedef struct {
38 GtkWidget *status;
39 VikWindow *vw;
40 VikLayersPanel *vlp;
41 VikViewport *vvp;
42 GtkWidget *dialog;
43 gboolean ok; /* if OK is false when we exit, we MUST free w */
44 VikDataSourceInterface *source_interface;
45 gpointer user_data;
46} acq_dialog_widgets_t;
47
48/* Direct, URL & Shell types process the results with GPSBabel to create tracks/waypoint */
49typedef enum {
50 VIK_DATASOURCE_GPSBABEL_DIRECT,
51 VIK_DATASOURCE_URL,
52 VIK_DATASOURCE_SHELL_CMD,
53 VIK_DATASOURCE_INTERNAL
54} vik_datasource_type_t;
55
56typedef enum {
57 VIK_DATASOURCE_CREATENEWLAYER,
58 VIK_DATASOURCE_ADDTOLAYER
59} vik_datasource_mode_t;
60/* TODO: replace track/layer? */
61
62typedef enum {
63 VIK_DATASOURCE_INPUTTYPE_NONE = 0,
64 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
65 VIK_DATASOURCE_INPUTTYPE_TRACK,
66 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK
67} vik_datasource_inputtype_t;
68
69/* returns pointer to state if OK, otherwise NULL */
70typedef gpointer (*VikDataSourceInitFunc) ();
71
72/* returns NULL if OK, otherwise returns an error message. */
73typedef gchar *(*VikDataSourceCheckExistenceFunc) ();
74
75/* Create widgets to show in a setup dialog, set up state via user_data */
76typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
77
78/* if VIK_DATASOURCE_GPSBABEL_DIRECT, babelargs and inputfile.
79 if VIK_DATASOURCE_SHELL_CMD, shellcmd and inputtype.
80 if VIK_DATASOURCE_URL, url and inputtype.
81 set both to NULL to signal refusal (ie already downloading) */
82typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype );
83
84typedef void (*VikDataSourceGetCmdStringFuncWithInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name );
85typedef void (*VikDataSourceGetCmdStringFuncWithInputInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name, const gchar *input_track_file_name );
86
87/* The actual function to do stuff - must report success/failure */
88typedef gboolean (*VikDataSourceProcessFunc) ( gpointer vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw );
89
90/* */
91typedef void (*VikDataSourceProgressFunc) ( BabelProgressCode c, gpointer data, acq_dialog_widgets_t *w );
92
93/* Creates widgets to show in a progress dialog, may set up state via user_data */
94typedef void (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data );
95
96/* Frees any widgets created for the setup or progress dialogs, any allocated state, etc. */
97typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data );
98
99typedef void (*VikDataSourceOffFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype );;
100
101struct _VikDataSourceInterface {
102 const gchar *window_title;
103 const gchar *layer_title;
104 vik_datasource_type_t type;
105 vik_datasource_mode_t mode;
106 vik_datasource_inputtype_t inputtype;
107 gboolean autoview;
108 gboolean keep_dialog_open; /* when done */
109
110
111 /*** Manual UI Building ***/
112 VikDataSourceInitFunc init_func;
113 VikDataSourceCheckExistenceFunc check_existence_func;
114 VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func;
115 /*** ***/
116
117 /* or VikDataSourceGetCmdStringFuncWithInput, if inputtype is not NONE */
118 VikDataSourceGetCmdStringFunc get_cmd_string_func;
119
120 VikDataSourceProcessFunc process_func;
121
122 VikDataSourceProgressFunc progress_func;
123 VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func;
124 VikDataSourceCleanupFunc cleanup_func;
125 VikDataSourceOffFunc off_func;
126
127 /*** UI Building ***/
128 VikLayerParam * params;
129 guint16 params_count;
130 VikLayerParamData * params_defaults;
131 gchar ** params_groups;
132 guint8 params_groups_count;
133
134};
135
136/**********************************/
137/**********************************/
138/**********************************/
139
140/* for sources with no input data */
141void a_acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *source_interface );
142
143/* Create a sub menu intended for rightclicking on a TRWLayer. menu called "Filter"
144 * returns NULL if no filters */
145GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
146
147/* Create a sub menu intended for rightclicking on a TRWLayer. menu called "Filter with Track "TRACKNAME"..."
148 * returns NULL if no filters or no filter track has been set
149 */
150GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
151
152/* Create a sub menu intended for rightclicking on a track. menu called "Filter"
153 * returns NULL if no applicable filters */
154GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr);
155
156/* sets application-wide track to use with filter. references the track. */
157void a_acquire_set_filter_track ( VikTrack *tr );
158
159G_END_DECLS
160
161#endif