]>
Commit | Line | Data |
---|---|---|
1d1bc3c1 EB |
1 | /* |
2 | * viking -- GPS Data and Topo Analyzer, Explorer, and Manager | |
3 | * | |
4 | * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net> | |
17acdaec | 5 | * Copyright (C) 2015, Rob Norris <rw_norris@hotmail.com> |
1d1bc3c1 EB |
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 | ||
a25c4c50 GB |
26 | #include <gtk/gtk.h> |
27 | ||
28 | #include "vikwindow.h" | |
29 | #include "viklayerspanel.h" | |
30 | #include "vikviewport.h" | |
0944940f | 31 | #include "babel.h" |
a25c4c50 | 32 | |
722b5481 RN |
33 | G_BEGIN_DECLS |
34 | ||
cf697cc2 EB |
35 | typedef struct _VikDataSourceInterface VikDataSourceInterface; |
36 | ||
307abf54 RN |
37 | typedef struct { |
38 | VikWindow *vw; | |
39 | VikLayersPanel *vlp; | |
40 | VikViewport *vvp; | |
2801a19b | 41 | gpointer userdata; |
307abf54 RN |
42 | } acq_vik_t; |
43 | ||
fba47910 GB |
44 | /** |
45 | * acq_dialog_widgets_t: | |
46 | * | |
47 | * global data structure used to expose the progress dialog to the worker thread. | |
48 | */ | |
7b3479e3 EB |
49 | typedef struct { |
50 | GtkWidget *status; | |
51 | VikWindow *vw; | |
52 | VikLayersPanel *vlp; | |
53 | VikViewport *vvp; | |
54 | GtkWidget *dialog; | |
b2aa700f | 55 | gboolean running; |
62ddf770 | 56 | VikDataSourceInterface *source_interface; |
65f0ccab | 57 | gpointer user_data; |
7b3479e3 EB |
58 | } acq_dialog_widgets_t; |
59 | ||
28c82d8b | 60 | typedef enum { |
9cc13848 RN |
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, | |
3cc57413 | 64 | VIK_DATASOURCE_MANUAL_LAYER_MANAGEMENT, |
28c82d8b EB |
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; | |
7b3479e3 | 74 | |
fba47910 GB |
75 | /** |
76 | * VikDataSourceInitFunc: | |
77 | * | |
78 | * Returns: pointer to state if OK, otherwise %NULL | |
79 | */ | |
307abf54 | 80 | typedef gpointer (*VikDataSourceInitFunc) ( acq_vik_t *avt ); |
92255687 | 81 | |
fba47910 GB |
82 | /** |
83 | * VikDataSourceCheckExistenceFunc: | |
84 | * | |
85 | * Returns: %NULL if OK, otherwise returns an error message. | |
86 | */ | |
92255687 EB |
87 | typedef gchar *(*VikDataSourceCheckExistenceFunc) (); |
88 | ||
fba47910 GB |
89 | /** |
90 | * VikDataSourceAddSetupWidgetsFunc: | |
91 | * | |
92 | * Create widgets to show in a setup dialog, set up state via user_data. | |
93 | */ | |
65f0ccab AF |
94 | typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data ); |
95 | ||
fba47910 | 96 | /** |
17acdaec | 97 | * VikDataSourceGetProcessOptionsFunc: |
eb3f9398 | 98 | * @user_data: provided by #VikDataSourceInterface.init_func or dialog with params |
17acdaec RN |
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: | |
fba47910 | 103 | * |
fba47910 GB |
104 | * set both to %NULL to signal refusal (ie already downloading). |
105 | */ | |
17acdaec | 106 | typedef void (*VikDataSourceGetProcessOptionsFunc) ( gpointer user_data, ProcessOptions *process_options, gpointer download_options, const gchar *input_file_name, const gchar *input_track_file_name ); |
28c82d8b | 107 | |
fba47910 GB |
108 | /** |
109 | * VikDataSourceProcessFunc: | |
c12a9108 | 110 | * @vtl: |
17acdaec | 111 | * @process_options: options to control the behaviour of this function (see #ProcessOptions) |
c12a9108 | 112 | * @status_cb: the #VikDataSourceInterface.progress_func |
ed691ed1 | 113 | * @adw: the widgets and data used by #VikDataSourceInterface.progress_func |
17acdaec | 114 | * @download_options: Optional options used if downloads from URLs is used. |
fba47910 GB |
115 | * |
116 | * The actual function to do stuff - must report success/failure. | |
117 | */ | |
17acdaec | 118 | typedef gboolean (*VikDataSourceProcessFunc) ( gpointer vtl, ProcessOptions *process_options, BabelStatusFunc, acq_dialog_widgets_t *adw, gpointer download_options ); |
0944940f | 119 | |
17acdaec | 120 | /* NB Same as BabelStatusFunc */ |
5564dd66 | 121 | typedef void (*VikDataSourceProgressFunc) ( BabelProgressCode c, gpointer data, acq_dialog_widgets_t *w ); |
65f0ccab | 122 | |
fba47910 GB |
123 | /** |
124 | * VikDataSourceAddProgressWidgetsFunc: | |
125 | * | |
126 | * Creates widgets to show in a progress dialog, may set up state via user_data. | |
127 | */ | |
65f0ccab AF |
128 | typedef void (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data ); |
129 | ||
fba47910 GB |
130 | /** |
131 | * VikDataSourceCleanupFunc: | |
132 | * | |
133 | * Frees any widgets created for the setup or progress dialogs, any allocated state, etc. | |
134 | */ | |
65f0ccab AF |
135 | typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data ); |
136 | ||
17acdaec | 137 | typedef void (*VikDataSourceOffFunc) ( gpointer user_data, gchar **babelargs, gchar **file_descriptor ); |
7b3479e3 | 138 | |
c12a9108 GB |
139 | /** |
140 | * VikDataSourceInterface: | |
141 | * | |
142 | * Main interface. | |
143 | */ | |
cf697cc2 | 144 | struct _VikDataSourceInterface { |
a8d46e0b | 145 | const gchar *window_title; |
7b3479e3 | 146 | const gchar *layer_title; |
28c82d8b EB |
147 | vik_datasource_mode_t mode; |
148 | vik_datasource_inputtype_t inputtype; | |
d2525524 | 149 | gboolean autoview; |
28c82d8b EB |
150 | gboolean keep_dialog_open; /* when done */ |
151 | ||
b2aa700f | 152 | gboolean is_thread; |
7b3479e3 | 153 | |
28c82d8b | 154 | /*** Manual UI Building ***/ |
65f0ccab AF |
155 | VikDataSourceInitFunc init_func; |
156 | VikDataSourceCheckExistenceFunc check_existence_func; | |
157 | VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func; | |
28c82d8b EB |
158 | /*** ***/ |
159 | ||
17acdaec | 160 | VikDataSourceGetProcessOptionsFunc get_process_options_func; |
7b3479e3 | 161 | |
0944940f RN |
162 | VikDataSourceProcessFunc process_func; |
163 | ||
7b3479e3 EB |
164 | VikDataSourceProgressFunc progress_func; |
165 | VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func; | |
166 | VikDataSourceCleanupFunc cleanup_func; | |
2b756ea0 | 167 | VikDataSourceOffFunc off_func; |
28c82d8b EB |
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 | ||
cf697cc2 | 176 | }; |
7b3479e3 | 177 | |
28c82d8b | 178 | /**********************************/ |
7b3479e3 | 179 | |
9cc13848 RN |
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 ); | |
1d1bc3c1 | 187 | |
28c82d8b EB |
188 | GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl); |
189 | ||
28c82d8b EB |
190 | GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl); |
191 | ||
28c82d8b EB |
192 | GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr); |
193 | ||
ce4bd1cf | 194 | void a_acquire_set_filter_track ( VikTrack *tr ); |
28c82d8b | 195 | |
722b5481 | 196 | G_END_DECLS |
28c82d8b | 197 | |
1d1bc3c1 | 198 | #endif |