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