]> git.street.me.uk Git - andy/viking.git/blob - src/acquire.h
Some spelling fixes in a comment
[andy/viking.git] / src / acquire.h
1 /*
2  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3  *
4  * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5  * Copyright (C) 2015, Rob Norris <rw_norris@hotmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #ifndef _VIKING_ACQUIRE_H
24 #define _VIKING_ACQUIRE_H
25
26 #include <gtk/gtk.h>
27
28 #include "vikwindow.h"
29 #include "viklayerspanel.h"
30 #include "vikviewport.h"
31 #include "babel.h"
32
33 G_BEGIN_DECLS
34
35 typedef struct _VikDataSourceInterface VikDataSourceInterface;
36
37 typedef struct {
38   VikWindow *vw;
39   VikLayersPanel *vlp;
40   VikViewport *vvp;
41   gpointer userdata;
42 } acq_vik_t;
43
44 /**
45  * acq_dialog_widgets_t:
46  *
47  * global data structure used to expose the progress dialog to the worker thread.
48  */
49 typedef struct {
50   GtkWidget *status;
51   VikWindow *vw;
52   VikLayersPanel *vlp;
53   VikViewport *vvp;
54   GtkWidget *dialog;
55   gboolean running;
56   VikDataSourceInterface *source_interface;
57   gpointer user_data;
58 } acq_dialog_widgets_t;
59
60 typedef enum {
61   VIK_DATASOURCE_CREATENEWLAYER, // Generally Datasources shouldn't use these and let the HCI decide
62   VIK_DATASOURCE_ADDTOLAYER,     //    between the create or add to layer options
63   VIK_DATASOURCE_AUTO_LAYER_MANAGEMENT,
64   VIK_DATASOURCE_MANUAL_LAYER_MANAGEMENT,
65 } vik_datasource_mode_t;
66 /* TODO: replace track/layer? */
67
68 typedef enum {
69   VIK_DATASOURCE_INPUTTYPE_NONE = 0,
70   VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
71   VIK_DATASOURCE_INPUTTYPE_TRACK,
72   VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK
73 } vik_datasource_inputtype_t;
74
75 /**
76  * VikDataSourceInitFunc:
77  * 
78  * Returns: pointer to state if OK, otherwise %NULL
79  */
80 typedef gpointer (*VikDataSourceInitFunc) ( acq_vik_t *avt );
81
82 /**
83  * VikDataSourceCheckExistenceFunc:
84  * 
85  * Returns: %NULL if OK, otherwise returns an error message.
86  */
87 typedef gchar *(*VikDataSourceCheckExistenceFunc) ();
88
89 /**
90  * VikDataSourceAddSetupWidgetsFunc:
91  * 
92  * Create widgets to show in a setup dialog, set up state via user_data.
93  */
94 typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
95
96 /**
97  * VikDataSourceGetProcessOptionsFunc:
98  * @user_data: provided by #VikDataSourceInterface.init_func or dialog with params
99  * @process_options: main options controlling the behaviour of #VikDataSourceInterface.process_func
100  * @download_options: optional options for downloads from URLs for #VikDataSourceInterface.process_func
101  * @input_file_name:
102  * @input_track_file_name:
103  * 
104  * set both to %NULL to signal refusal (ie already downloading).
105  */
106 typedef void (*VikDataSourceGetProcessOptionsFunc) ( gpointer user_data, ProcessOptions *process_options, gpointer download_options, const gchar *input_file_name, const gchar *input_track_file_name );
107
108 /**
109  * VikDataSourceProcessFunc:
110  * @vtl:
111  * @process_options: options to control the behaviour of this function (see #ProcessOptions)
112  * @status_cb: the #VikDataSourceInterface.progress_func
113  * @adw: the widgets and data used by #VikDataSourceInterface.progress_func
114  * @download_options: Optional options used if downloads from URLs is used.
115  * 
116  * The actual function to do stuff - must report success/failure.
117  */
118 typedef gboolean (*VikDataSourceProcessFunc) ( gpointer vtl, ProcessOptions *process_options, BabelStatusFunc, acq_dialog_widgets_t *adw, gpointer download_options );
119
120 /* NB Same as BabelStatusFunc */
121 typedef void  (*VikDataSourceProgressFunc)  ( BabelProgressCode c, gpointer data, acq_dialog_widgets_t *w );
122
123 /**
124  * VikDataSourceAddProgressWidgetsFunc:
125  * 
126  * Creates widgets to show in a progress dialog, may set up state via user_data.
127  */
128 typedef void  (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data );
129
130 /**
131  * VikDataSourceCleanupFunc:
132  * 
133  * Frees any widgets created for the setup or progress dialogs, any allocated state, etc.
134  */
135 typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data );
136
137 typedef void (*VikDataSourceOffFunc) ( gpointer user_data, gchar **babelargs, gchar **file_descriptor );
138
139 /**
140  * VikDataSourceInterface:
141  * 
142  * Main interface.
143  */
144 struct _VikDataSourceInterface {
145   const gchar *window_title;
146   const gchar *layer_title;
147   vik_datasource_mode_t mode;
148   vik_datasource_inputtype_t inputtype;
149   gboolean autoview;
150   gboolean keep_dialog_open; /* when done */
151
152   gboolean is_thread;
153
154   /*** Manual UI Building ***/
155   VikDataSourceInitFunc init_func;
156   VikDataSourceCheckExistenceFunc check_existence_func;
157   VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func;      
158   /***                    ***/
159
160   VikDataSourceGetProcessOptionsFunc get_process_options_func;
161
162   VikDataSourceProcessFunc process_func;
163
164   VikDataSourceProgressFunc progress_func;
165   VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func;
166   VikDataSourceCleanupFunc cleanup_func;
167   VikDataSourceOffFunc off_func;
168
169   /*** UI Building        ***/
170   VikLayerParam *                   params;
171   guint16                           params_count;
172   VikLayerParamData *               params_defaults;
173   gchar **                          params_groups;
174   guint8                            params_groups_count;
175
176 };
177
178 /**********************************/
179
180 void a_acquire ( VikWindow *vw,
181                  VikLayersPanel *vlp,
182                  VikViewport *vvp,
183                  vik_datasource_mode_t mode,
184                  VikDataSourceInterface *source_interface,
185                  gpointer userdata,
186                  VikDataSourceCleanupFunc cleanup_function );
187
188 GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
189
190 GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
191
192 GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr);
193
194 void a_acquire_set_filter_track ( VikTrack *tr );
195
196 G_END_DECLS
197
198 #endif