2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5 * Copyright (C) 2015, Rob Norris <rw_norris@hotmail.com>
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.
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.
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
23 #ifndef _VIKING_ACQUIRE_H
24 #define _VIKING_ACQUIRE_H
28 #include "vikwindow.h"
29 #include "viklayerspanel.h"
30 #include "vikviewport.h"
35 typedef struct _VikDataSourceInterface VikDataSourceInterface;
45 * acq_dialog_widgets_t:
47 * global data structure used to expose the progress dialog to the worker thread.
56 VikDataSourceInterface *source_interface;
58 } acq_dialog_widgets_t;
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? */
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;
76 * VikDataSourceInitFunc:
78 * Returns: pointer to state if OK, otherwise %NULL
80 typedef gpointer (*VikDataSourceInitFunc) ( acq_vik_t *avt );
83 * VikDataSourceCheckExistenceFunc:
85 * Returns: %NULL if OK, otherwise returns an error message.
87 typedef gchar *(*VikDataSourceCheckExistenceFunc) ();
90 * VikDataSourceAddSetupWidgetsFunc:
92 * Create widgets to show in a setup dialog, set up state via user_data.
94 typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
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
102 * @input_track_file_name:
104 * set both to %NULL to signal refusal (ie already downloading).
106 typedef void (*VikDataSourceGetProcessOptionsFunc) ( gpointer user_data, ProcessOptions *process_options, gpointer download_options, const gchar *input_file_name, const gchar *input_track_file_name );
109 * VikDataSourceProcessFunc:
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.
116 * The actual function to do stuff - must report success/failure.
118 typedef gboolean (*VikDataSourceProcessFunc) ( gpointer vtl, ProcessOptions *process_options, BabelStatusFunc, acq_dialog_widgets_t *adw, gpointer download_options );
120 /* NB Same as BabelStatusFunc */
121 typedef void (*VikDataSourceProgressFunc) ( BabelProgressCode c, gpointer data, acq_dialog_widgets_t *w );
124 * VikDataSourceAddProgressWidgetsFunc:
126 * Creates widgets to show in a progress dialog, may set up state via user_data.
128 typedef void (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data );
131 * VikDataSourceCleanupFunc:
133 * Frees any widgets created for the setup or progress dialogs, any allocated state, etc.
135 typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data );
137 typedef void (*VikDataSourceOffFunc) ( gpointer user_data, gchar **babelargs, gchar **file_descriptor );
140 * VikDataSourceInterface:
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;
150 gboolean keep_dialog_open; /* when done */
154 /*** Manual UI Building ***/
155 VikDataSourceInitFunc init_func;
156 VikDataSourceCheckExistenceFunc check_existence_func;
157 VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func;
160 VikDataSourceGetProcessOptionsFunc get_process_options_func;
162 VikDataSourceProcessFunc process_func;
164 VikDataSourceProgressFunc progress_func;
165 VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func;
166 VikDataSourceCleanupFunc cleanup_func;
167 VikDataSourceOffFunc off_func;
169 /*** UI Building ***/
170 VikLayerParam * params;
171 guint16 params_count;
172 VikLayerParamData * params_defaults;
173 gchar ** params_groups;
174 guint8 params_groups_count;
178 /**********************************/
180 void a_acquire ( VikWindow *vw,
183 vik_datasource_mode_t mode,
184 VikDataSourceInterface *source_interface,
186 VikDataSourceCleanupFunc cleanup_function );
188 GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
190 GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
192 GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr);
194 void a_acquire_set_filter_track ( VikTrack *tr );