]> git.street.me.uk Git - andy/viking.git/blob - src/acquire.h
Replace g_thread by g_thread_pool
[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
31 typedef struct _VikDataSourceInterface VikDataSourceInterface;
32
33 /* global data structure used to expose the progress dialog to the worker thread */
34 typedef struct {
35   GtkWidget *status;
36   VikWindow *vw;
37   VikLayersPanel *vlp;
38   VikViewport *vvp;
39   GtkWidget *dialog;
40   gboolean ok; /* if OK is false when we exit, we MUST free w */
41   VikDataSourceInterface *source_interface;
42   gpointer user_data;
43 } acq_dialog_widgets_t;
44
45 typedef enum {
46   VIK_DATASOURCE_GPSBABEL_DIRECT,
47   VIK_DATASOURCE_URL,
48   VIK_DATASOURCE_SHELL_CMD
49 } vik_datasource_type_t;
50
51 typedef enum {
52   VIK_DATASOURCE_CREATENEWLAYER,
53   VIK_DATASOURCE_ADDTOLAYER
54 } vik_datasource_mode_t;
55 /* TODO: replace track/layer? */
56
57 typedef enum {
58   VIK_DATASOURCE_INPUTTYPE_NONE = 0,
59   VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
60   VIK_DATASOURCE_INPUTTYPE_TRACK,
61   VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK
62 } vik_datasource_inputtype_t;
63
64
65 /* returns pointer to state if OK, otherwise NULL */
66 typedef gpointer (*VikDataSourceInitFunc) ();
67
68 /* returns NULL if OK, otherwise returns an error message. */
69 typedef gchar *(*VikDataSourceCheckExistenceFunc) ();
70
71 /* Create widgets to show in a setup dialog, set up state via user_data */
72 typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
73
74 /* if VIK_DATASOURCE_GPSBABEL_DIRECT, babelargs and inputfile.
75    if VIK_DATASOURCE_SHELL_CMD, shellcmd and inputtype.
76    if VIK_DATASOURCE_URL, url and inputtype.
77    set both to NULL to signal refusal (ie already downloading) */
78 typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype );
79
80 typedef void (*VikDataSourceGetCmdStringFuncWithInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name );
81 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 );
82
83 /* */
84 typedef void  (*VikDataSourceProgressFunc)  (gpointer c, gpointer data, acq_dialog_widgets_t *w);
85
86 /* Creates widgets to show in a progress dialog, may set up state via user_data */
87 typedef void  (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data );
88
89 /* Frees any widgets created for the setup or progress dialogs, any allocated state, etc. */
90 typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data );
91
92
93 struct _VikDataSourceInterface {
94   const gchar *window_title;
95   const gchar *layer_title;
96   vik_datasource_type_t type;
97   vik_datasource_mode_t mode;
98   vik_datasource_inputtype_t inputtype;
99   gboolean keep_dialog_open; /* when done */
100
101
102   /*** Manual UI Building ***/
103   VikDataSourceInitFunc init_func;
104   VikDataSourceCheckExistenceFunc check_existence_func;
105   VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func;      
106   /***                    ***/
107
108   /* or VikDataSourceGetCmdStringFuncWithInput, if inputtype is not NONE */
109   VikDataSourceGetCmdStringFunc get_cmd_string_func; 
110
111   VikDataSourceProgressFunc progress_func;
112   VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func;
113   VikDataSourceCleanupFunc cleanup_func;
114
115
116   /*** UI Building        ***/
117   VikLayerParam *                   params;
118   guint16                           params_count;
119   VikLayerParamData *               params_defaults;
120   gchar **                          params_groups;
121   guint8                            params_groups_count;
122
123 };
124
125 /**********************************/
126 /**********************************/
127 /**********************************/
128
129 /* for sources with no input data */
130 void a_acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *source_interface );
131
132 /* Create a sub menu intended for rightclicking on a TRWLayer. menu called "Filter"
133  * returns NULL if no filters */
134 GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
135
136 /* Create a sub menu intended for rightclicking on a TRWLayer. menu called "Filter with Track "TRACKNAME"..."
137  * returns NULL if no filters or no filter track has been set
138  */
139 GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
140
141 /* Create a sub menu intended for rightclicking on a track. menu called "Filter"
142  * returns NULL if no applicable filters */
143 GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr);
144
145 /* sets aplication-wide track to use with filter. references the track. */
146 void a_acquire_set_filter_track ( VikTrack *tr, const gchar *name );
147
148
149 #endif