]> git.street.me.uk Git - andy/viking.git/blame - src/acquire.h
Fix stability of some 32 bit builds.
[andy/viking.git] / src / acquire.h
CommitLineData
1d1bc3c1
EB
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
a25c4c50
GB
25#include <gtk/gtk.h>
26
27#include "vikwindow.h"
28#include "viklayerspanel.h"
29#include "vikviewport.h"
0944940f 30#include "babel.h"
a25c4c50 31
722b5481
RN
32G_BEGIN_DECLS
33
cf697cc2
EB
34typedef struct _VikDataSourceInterface VikDataSourceInterface;
35
307abf54
RN
36typedef struct {
37 VikWindow *vw;
38 VikLayersPanel *vlp;
39 VikViewport *vvp;
2801a19b 40 gpointer userdata;
307abf54
RN
41} acq_vik_t;
42
fba47910
GB
43/**
44 * acq_dialog_widgets_t:
45 *
46 * global data structure used to expose the progress dialog to the worker thread.
47 */
7b3479e3
EB
48typedef struct {
49 GtkWidget *status;
50 VikWindow *vw;
51 VikLayersPanel *vlp;
52 VikViewport *vvp;
53 GtkWidget *dialog;
b2aa700f 54 gboolean running;
62ddf770 55 VikDataSourceInterface *source_interface;
65f0ccab 56 gpointer user_data;
7b3479e3
EB
57} acq_dialog_widgets_t;
58
28c82d8b 59typedef enum {
9cc13848
RN
60 VIK_DATASOURCE_CREATENEWLAYER, // Generally Datasources shouldn't use these and let the HCI decide
61 VIK_DATASOURCE_ADDTOLAYER, // between the create or add to layer options
62 VIK_DATASOURCE_AUTO_LAYER_MANAGEMENT,
3cc57413 63 VIK_DATASOURCE_MANUAL_LAYER_MANAGEMENT,
28c82d8b
EB
64} vik_datasource_mode_t;
65/* TODO: replace track/layer? */
66
67typedef enum {
68 VIK_DATASOURCE_INPUTTYPE_NONE = 0,
69 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
70 VIK_DATASOURCE_INPUTTYPE_TRACK,
71 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK
72} vik_datasource_inputtype_t;
7b3479e3 73
fba47910
GB
74/**
75 * VikDataSourceInitFunc:
76 *
77 * Returns: pointer to state if OK, otherwise %NULL
78 */
307abf54 79typedef gpointer (*VikDataSourceInitFunc) ( acq_vik_t *avt );
92255687 80
fba47910
GB
81/**
82 * VikDataSourceCheckExistenceFunc:
83 *
84 * Returns: %NULL if OK, otherwise returns an error message.
85 */
92255687
EB
86typedef gchar *(*VikDataSourceCheckExistenceFunc) ();
87
fba47910
GB
88/**
89 * VikDataSourceAddSetupWidgetsFunc:
90 *
91 * Create widgets to show in a setup dialog, set up state via user_data.
92 */
65f0ccab
AF
93typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
94
fba47910
GB
95/**
96 * VikDataSourceGetCmdStringFunc:
eb3f9398
GB
97 * @user_data: provided by #VikDataSourceInterface.init_func or dialog with params
98 * @args: the arguments computed for #VikDataSourceInterface.process_func
99 * @extra: extra arguments for #VikDataSourceInterface.process_func
ed691ed1 100 * @options: even more options for #VikDataSourceInterface.process_func
fba47910 101 *
fba47910
GB
102 * set both to %NULL to signal refusal (ie already downloading).
103 */
ed691ed1 104typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **args, gchar **extra, gpointer options );
65f0ccab 105
28c82d8b
EB
106typedef void (*VikDataSourceGetCmdStringFuncWithInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name );
107typedef void (*VikDataSourceGetCmdStringFuncWithInputInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name, const gchar *input_track_file_name );
108
fba47910
GB
109/**
110 * VikDataSourceProcessFunc:
c12a9108
GB
111 * @vtl:
112 * @cmd: the arguments computed by #VikDataSourceInterface.get_cmd_string_func
113 * @extra: the extra arguments computed by #VikDataSourceInterface.get_cmd_string_func
114 * @status_cb: the #VikDataSourceInterface.progress_func
ed691ed1
RN
115 * @adw: the widgets and data used by #VikDataSourceInterface.progress_func
116 * @options: more options returned by #VikDataSourceInterface.get_cmd_string_func
fba47910
GB
117 *
118 * The actual function to do stuff - must report success/failure.
119 */
ed691ed1 120typedef gboolean (*VikDataSourceProcessFunc) ( gpointer vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, gpointer options );
0944940f 121
65f0ccab 122/* */
5564dd66 123typedef void (*VikDataSourceProgressFunc) ( BabelProgressCode c, gpointer data, acq_dialog_widgets_t *w );
65f0ccab 124
fba47910
GB
125/**
126 * VikDataSourceAddProgressWidgetsFunc:
127 *
128 * Creates widgets to show in a progress dialog, may set up state via user_data.
129 */
65f0ccab
AF
130typedef void (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data );
131
fba47910
GB
132/**
133 * VikDataSourceCleanupFunc:
134 *
135 * Frees any widgets created for the setup or progress dialogs, any allocated state, etc.
136 */
65f0ccab
AF
137typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data );
138
2b756ea0 139typedef void (*VikDataSourceOffFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype );;
7b3479e3 140
c12a9108
GB
141/**
142 * VikDataSourceInterface:
143 *
144 * Main interface.
145 */
cf697cc2 146struct _VikDataSourceInterface {
a8d46e0b 147 const gchar *window_title;
7b3479e3 148 const gchar *layer_title;
28c82d8b
EB
149 vik_datasource_mode_t mode;
150 vik_datasource_inputtype_t inputtype;
d2525524 151 gboolean autoview;
28c82d8b
EB
152 gboolean keep_dialog_open; /* when done */
153
b2aa700f 154 gboolean is_thread;
7b3479e3 155
28c82d8b 156 /*** Manual UI Building ***/
65f0ccab
AF
157 VikDataSourceInitFunc init_func;
158 VikDataSourceCheckExistenceFunc check_existence_func;
159 VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func;
28c82d8b
EB
160 /*** ***/
161
162 /* or VikDataSourceGetCmdStringFuncWithInput, if inputtype is not NONE */
65f0ccab 163 VikDataSourceGetCmdStringFunc get_cmd_string_func;
7b3479e3 164
0944940f
RN
165 VikDataSourceProcessFunc process_func;
166
7b3479e3
EB
167 VikDataSourceProgressFunc progress_func;
168 VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func;
169 VikDataSourceCleanupFunc cleanup_func;
2b756ea0 170 VikDataSourceOffFunc off_func;
28c82d8b
EB
171
172 /*** UI Building ***/
173 VikLayerParam * params;
174 guint16 params_count;
175 VikLayerParamData * params_defaults;
176 gchar ** params_groups;
177 guint8 params_groups_count;
178
cf697cc2 179};
7b3479e3 180
28c82d8b 181/**********************************/
7b3479e3 182
9cc13848
RN
183void a_acquire ( VikWindow *vw,
184 VikLayersPanel *vlp,
185 VikViewport *vvp,
186 vik_datasource_mode_t mode,
187 VikDataSourceInterface *source_interface,
188 gpointer userdata,
189 VikDataSourceCleanupFunc cleanup_function );
1d1bc3c1 190
28c82d8b
EB
191GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
192
28c82d8b
EB
193GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
194
28c82d8b
EB
195GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr);
196
ce4bd1cf 197void a_acquire_set_filter_track ( VikTrack *tr );
28c82d8b 198
722b5481 199G_END_DECLS
28c82d8b 200
1d1bc3c1 201#endif