2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
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.
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.
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
22 #ifndef _VIKING_ACQUIRE_H
23 #define _VIKING_ACQUIRE_H
27 #include "vikwindow.h"
28 #include "viklayerspanel.h"
29 #include "vikviewport.h"
34 typedef struct _VikDataSourceInterface VikDataSourceInterface;
37 * acq_dialog_widgets_t:
39 * global data structure used to expose the progress dialog to the worker thread.
47 gboolean ok; /* if OK is false when we exit, we MUST free w */
48 VikDataSourceInterface *source_interface;
50 } acq_dialog_widgets_t;
53 VIK_DATASOURCE_CREATENEWLAYER,
54 VIK_DATASOURCE_ADDTOLAYER
55 } vik_datasource_mode_t;
56 /* TODO: replace track/layer? */
59 VIK_DATASOURCE_INPUTTYPE_NONE = 0,
60 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
61 VIK_DATASOURCE_INPUTTYPE_TRACK,
62 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK
63 } vik_datasource_inputtype_t;
66 * VikDataSourceInitFunc:
68 * Returns: pointer to state if OK, otherwise %NULL
70 typedef gpointer (*VikDataSourceInitFunc) ();
73 * VikDataSourceCheckExistenceFunc:
75 * Returns: %NULL if OK, otherwise returns an error message.
77 typedef gchar *(*VikDataSourceCheckExistenceFunc) ();
80 * VikDataSourceAddSetupWidgetsFunc:
82 * Create widgets to show in a setup dialog, set up state via user_data.
84 typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
87 * VikDataSourceGetCmdStringFunc:
88 * @user_data: provided by #VikDataSourceInterface.init_func or dialog with params
89 * @args: the arguments computed for #VikDataSourceInterface.process_func
90 * @extra: extra arguments for #VikDataSourceInterface.process_func
92 * set both to %NULL to signal refusal (ie already downloading).
94 typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **args, gchar **extra );
96 typedef void (*VikDataSourceGetCmdStringFuncWithInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name );
97 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 );
100 * VikDataSourceProcessFunc:
102 * The actual function to do stuff - must report success/failure.
104 typedef gboolean (*VikDataSourceProcessFunc) ( gpointer vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw );
107 typedef void (*VikDataSourceProgressFunc) ( BabelProgressCode c, gpointer data, acq_dialog_widgets_t *w );
110 * VikDataSourceAddProgressWidgetsFunc:
112 * Creates widgets to show in a progress dialog, may set up state via user_data.
114 typedef void (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data );
117 * VikDataSourceCleanupFunc:
119 * Frees any widgets created for the setup or progress dialogs, any allocated state, etc.
121 typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data );
123 typedef void (*VikDataSourceOffFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype );;
125 struct _VikDataSourceInterface {
126 const gchar *window_title;
127 const gchar *layer_title;
128 vik_datasource_mode_t mode;
129 vik_datasource_inputtype_t inputtype;
131 gboolean keep_dialog_open; /* when done */
134 /*** Manual UI Building ***/
135 VikDataSourceInitFunc init_func;
136 VikDataSourceCheckExistenceFunc check_existence_func;
137 VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func;
140 /* or VikDataSourceGetCmdStringFuncWithInput, if inputtype is not NONE */
141 VikDataSourceGetCmdStringFunc get_cmd_string_func;
143 VikDataSourceProcessFunc process_func;
145 VikDataSourceProgressFunc progress_func;
146 VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func;
147 VikDataSourceCleanupFunc cleanup_func;
148 VikDataSourceOffFunc off_func;
150 /*** UI Building ***/
151 VikLayerParam * params;
152 guint16 params_count;
153 VikLayerParamData * params_defaults;
154 gchar ** params_groups;
155 guint8 params_groups_count;
159 /**********************************/
160 /**********************************/
161 /**********************************/
163 void a_acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *source_interface );
165 GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
167 GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
169 GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr);
171 void a_acquire_set_filter_track ( VikTrack *tr );